Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict Google's place autocomplete to Philadelphia #15

Open
jimRsmiley opened this issue Jul 14, 2014 · 3 comments
Open

Restrict Google's place autocomplete to Philadelphia #15

jimRsmiley opened this issue Jul 14, 2014 · 3 comments
Assignees

Comments

@jimRsmiley
Copy link

It looks like you can restrict the search to a defined boundary. Currently, the address search will offer to complete any address in the country.

screenshot

https://developers.google.com/maps/documentation/javascript/places-autocomplete

@leekinney leekinney self-assigned this Jul 16, 2014
@leekinney
Copy link
Member

So I was looking into this and it looks like the autocomplete is bound to the map viewport. When I do searches Philly locations are popping up first for me but there are still those other locations showing up as well. We could either zoom in so it's more centered on Philly or it looks like there is an option to set bounds with a specific lat/lng but I can't figure out what those parameters would be. If I wanted to do that would this be the right direction?

var defaultBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(-33.8902, 151.1759), --- changing this out to philly parameters?
new google.maps.LatLng(-33.8474, 151.2631));

var input = document.getElementById('searchTextField');
var options = {
bounds: defaultBounds
};

autocomplete = new google.maps.places.Autocomplete(input, options);

@kongsally kongsally assigned kongsally and leekinney and unassigned leekinney and kongsally Jul 30, 2014
@kongsally
Copy link

I tried restricting the component by their locality and I got a better result but it still shows New York, I'll try the bounds too.
screen shot 2014-07-30 at 7 58 49 pm

@jimRsmiley
Copy link
Author

Excellent! Now would be a to time push up any code you have, even if it's only half working. Just make sure it's in it's own branch. Commit early and often.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants