Open jimRsmiley opened 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);
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.
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.
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.
https://developers.google.com/maps/documentation/javascript/places-autocomplete