如何在Android中实现位置搜索

如何在Android中实现位置搜索

本文介绍了如何在Android中实现位置搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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)Android Location Geocoder

1) Android Location Geocoder

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

2)对Google Maps Geocode API的HTTP请求

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

希望对您有所帮助!

这篇关于如何在Android中实现位置搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 19:52