Search code examples
javascriptgoogle-maps-api-3google-maps-autocomplete

Google maps api autocomplete - get location in one city (or few cities)


I already Googled that but I didn't find any answer. Is it possible to get in the Google Maps autoComplete results only locations in given cities? For example I want all the addresses in the city of Paris and New York, and exclude every other result. I didn't find this in the docs, I can filter results by country, but I want to filter by city. Is there any callback function that I can pass to the service that will be called for every result and exclude it from the list if my callback function return false?


Solution

  • No, this is not currently possible, but there is long-standing feature request on the Public Issue Tracker to have the Places Autocomplete's componentRestrictions option be more similar to the same option for the Geocoding Service, as Autocomplete only supports countries (up to 5) while the geocoder allows for other component filters, including city/locality. You may want to star the issue to get updates and show increased interest in this being implemented.