Monta
Monta

Reputation: 1180

Geocoding Google Api returns 1 result for ambiguous address

I'm using java sdk Geocoding Google Api, to fetch Geocoding information using address.

When I use google maps UI, and enter "1 rue de Paris" I get multiple results in different cities and was expecting the sdk to return more than 1 result also but it's only returning 1.

My code:

GeocodingResult[] results = GeocodingApi.geocode(context, "1 rue de Paris").await()

results contains only 1 element.

what did I miss?

Upvotes: 1

Views: 510

Answers (1)

evan
evan

Reputation: 5691

When you say "google maps UI", are you talking about the Place Autocomplete list of place suggestions you get when you type in this address in Google Maps?

If so, note that what you're using is Geocoding API, not Places API. Geocoding is meant to be used for converting addresses into coordinates and vice-versa, and often returns only 1 place.

If you want to get a list of places, use the Autocomplete service:

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=1%20rue%20de%20Paris&key=YOUR_API_KEY

Hope this helps!

Upvotes: 1

Related Questions