Romain
Romain

Reputation: 2348

Location-aware geocoding on Android (just like Google Maps)

It seems that the search in the Google Maps app is location aware. For example, if I search for "Pitt St" while in Sydney, it finds the right street straight away. Clicking "Did you mean..." brings a list of other "Pitt St" close in nearby suburbs.

Is there a way to ge a similar experience in our apps? I tried the standard Geocoder, but a similar search returns "Pitt St, New York" as the first match.

Cheers

Romain

Upvotes: 2

Views: 1571

Answers (1)

EboMike
EboMike

Reputation: 77732

Which function did you use? Geocoder.getFromLocationName() takes a bounding box that allows you to limit the results to a certain region, so you could get the current GPS position first and pass that in.

Alternatively, you could go through the Geocoder API which is more flexible, but also more restrictive in terms of the TOS, not to mention a lot more work to use. (I'm not sure if using it from an Android app is covered in the TOS, I haven't looked at it much).

Upvotes: 3

Related Questions