简体   繁体   中英

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?

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM