Search code examples
javaandroidgoogle-mapsgeolocationgoogle-geocoder

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


I have a search bar 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


Solution

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