繁体   English   中英

如何在Android中实现位置搜索?

[英]How to implement a search for location in Android?

基本上,在单击按钮时,我希望用户输入关键字或确切的位置名称,并且在列表视图中,我要显示在特定半径或状态/区域内与给定关键字匹配的所有位置。 我已经读过有关Geocoder / Google地图和类似内容的文章,但是是否有任何关于如何做我想做的事情的深入教程? 我对整个主题感到很困惑。 谢谢。

我使用不同的方式:

1)Android Location Geocoder

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

2)对Google Maps Geocode API的HTTP请求

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

希望对您有所帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM