summer-of-open-source / wheel-chair-accessible-google-maps

A website that tells users whether their planned transit trip in Philly will be successful with a wheelchair
2 stars 1 forks source link

Restrict Google's place autocomplete to Philadelphia #15

Open jimRsmiley opened 10 years ago

jimRsmiley commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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.