0

I am using the Google Map JavaScript Api. I want to restrict the autocomplete search results to the areas and places of a specific city.

I tried to find this on Google as well as on Stackoverflow but could not get the answer.

How can I achieve this?

The link for fetching the api I am using is as follows

<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY&libraries=places&callback=initAutocomplete"
async defer></script>

any help would be precious!!

Cláudio Alves
  • 767
  • 3
  • 12
Foramkumar Parekh
  • 421
  • 1
  • 6
  • 26
  • Have you seen this posts: http://stackoverflow.com/questions/10637183/how-can-i-restrict-the-google-maps-places-librarys-autocomplete-to-suggestions and http://stackoverflow.com/questions/8282026/how-to-limit-google-autocomplete-results-to-city-and-country-only ? – Cláudio Alves Apr 22 '16 at 10:30
  • Nope, i could not find that question at the time of asking question. Can you just help me, how can i find thew northwest and southeast latlong of a place? – Foramkumar Parekh Apr 25 '16 at 04:26

1 Answers1

0
function initAutocomplete() {
    autocomplete = new google.maps.places.Autocomplete(
            (document.getElementById('cities')),{types: ['establishment']});
    autocomplete.addListener('place_changed', function(){});
}

you could change its type

The types of predictions to be returned. Four types are supported: 'establishment' for businesses, 'geocode' for addresses, '(regions)' for administrative regions and '(cities)' for localities. If nothing is specified, all types are returned.

https://developers.google.com/maps/documentation/javascript/reference#AutocompletionRequest

Ma Yubo
  • 215
  • 1
  • 10