george
george

Reputation: 41

Geocoder getFromLocationName() returns just 1 result

Android Geocoder always returns just 1 possible address

val addressesList = Geocoder(this.context).getFromLocationName("Toledo", 5)

Expected : I want to get 5 possible addresses, which has Toledo in their names ( there are Toledo, USA; Toledo, Spain; Toledo, Columbia, etc.)

Actual : Always get 1 address.

Upvotes: 4

Views: 843

Answers (1)

evan
evan

Reputation: 5691

The Geocoding API is not meant to be used for ambiguous queries such as "Toledo". It can be expected that the API won't necessarily return all possible matching results.

I suggest using Autocomplete instead to get multiple results for broad inputs. Google's documentation states:

In general, use the Geocoding API when geocoding complete addresses (for example, “48 Pirrama Rd, Pyrmont, NSW, Australia”). Use the Places API Place Autocomplete service when geocoding ambiguous (incomplete) addresses.

Hope this helps!

Upvotes: 4

Related Questions