【问题标题】:How to implement a search for location in Android?如何在Android中实现位置搜索?
【发布时间】:2014-08-26 23:38:07
【问题描述】:

基本上,在单击按钮时,我希望用户输入关键字或确切的位置名称,并且在列表视图中,我想显示在特定半径或州/区域内与给定关键字匹配的所有位置。我已经阅读了有关地理编码器/谷歌地图和类似的东西,但是有没有像任何教程一样深入了解如何做我想做的事情?我对整个主题很困惑。谢谢。

【问题讨论】:

    标签: android parsing location geocode


    【解决方案1】:

    我习惯了不同的方式:

    1) Android 位置地理编码器

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

    希望对你有帮助!

    【讨论】:

    • 谢谢。我最终找到了一个教程,我可以在其中实现第一个选项。但是,如果这不成功,我绝对可以尝试第二个!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-15
    相关资源
    最近更新 更多