Location-aware geocoding on Android (just like Goo

2019-07-21 23:12发布

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

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-07-21 23:46

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).

查看更多
登录 后发表回答