Home > Mobile >  Get all geolocations by partial name using google maps api
Get all geolocations by partial name using google maps api

Time:04-08

I have signed up with the Google Maps API. I can geolocate locations using the following query

url = f"https://maps.googleapis.com/maps/api/geocode/json?address={city}&key={api_key}"

I need to do a search for towns by partial name.

For example 'MyTown' is a town , but there are also towns with names which include 'MyTown' in the title, such as MyTown-By-Sea, MyTown-SomethingElse and even NiceMyTown

The above query using the API returns just the city MyTown, not the others

Is there some option I have missed to get the Google Maps API to be less specific in the response returned ?

CodePudding user response:

You can use Places Autocomplete API web service. This API will return places suggestions or predictions, based on your given input.

  https://maps.googleapis.com/maps/api/place/autocomplete/json
  ?input=MyTown (based on your example)  
  &location=latitude,longitude
  &key=YOUR_API_KEY
  • Related