开发者

Help with regions in google maps on android phone using Geocoder?

开发者 https://www.devze.com 2023-03-16 03:12 出处:网络
I have a search ba开发者_Go百科r in my application for locations, when a user presses the search button i want to search for the address based on the current region the user is in.

I have a search ba开发者_Go百科r in my application for locations, when a user presses the search button i want to search for the address based on the current region the user is in.

At the moment I just call

Geocoder geoCoder = new Geocoder(StreetAngelActivity.this,Locale.getDefault());
addresses = geoCoder.getFromLocationName(searchBar.getText().toString(),1);

But the result is not based on the region the person is in.

How can I ensure that the search retrieves based on the users current location?

I need to somehow find the region the user is in (how would i do this)?

and then append it to the searchbar.getText() and pass to the geocoder


Take a look at the link below, you can specify a region. There is no way to specify a region using the Android API, only a locale.

http://code.google.com/apis/maps/documentation/geocoding/

P.S. You can make a GeoCoder with a custom locale, which is probably your best bet.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号