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.
- Is there a set of options I'm missing?
- Is there a different API we can use for this?
- As a last resort, do you think it's reasonable to implement this manually, for example开发者_如何学编程 by querying the Geocoder with a max radius of 1km, 10km, 100km, and then sorting the results by distance?
Cheers
Romain
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).
精彩评论