0

Basically, on button click, I want the user to input a keyword or an exact location name, and in a listview, I want to show all the locations that match the given keyword within a certain radius or state/region. I've read about Geocoder/Google Maps and stuff like that, but is there like any tutorials that go in depth on how to do what I'm trying to do? I'm pretty confused on the whole subject. Thanks.

assaf
  • 69
  • 2
  • 10

1 Answers1

0

I use to different ways:

1) Android Location Geocoder

Geocoder geocoder = new Geocoder(context);
List<Address> addresses = geocoder.getFromLocationName(locationName, MAX_RESULTS);

2) A HTTP request to the Google Maps Geocode API

HttpGet httpGet = new HttpGet("http://maps.google.com/maps/api/geocode/json?address=" + urlEncodedLocationName +"&region=" + region + "&language=" + userLanguage);
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(httpGet);
HttpEntity entity = response.getEntity();
String result = EntityUtils.toString(entity, UTF8_CHARSET);

I hope this help you!

MartinCR
  • 658
  • 6
  • 7
  • Thank you. I eventually found a tutorial where I can implement the first option. However, if that doesn't pan out I can definitely try out the second! – assaf Aug 27 '14 at 03:02