簡體   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