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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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 +"®ion=" + 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!