【问题标题】:In Android Google Map, how do I search address within specific city?在 Android 谷歌地图中,​​如何在特定城市内搜索地址?
【发布时间】:2016-07-08 11:45:04
【问题描述】:

我正在开发一个应用程序,它有一个用于地址搜索的搜索框。我尝试使用以下链接,但它仅适用于特定国家/地区的结果。

A link for address search

我希望它只搜索特定的城市。

【问题讨论】:

    标签: android google-maps google-geocoding-api city


    【解决方案1】:

    添加此行进行城市搜索

    &components=locality:ahmedabad
    

    在特定城市内搜索地址

    http://maps.googleapis.com/maps/api/geocode/json?address=Singapore%20505468&sensor=true&components=locality:ahmedabad

    【讨论】:

      【解决方案2】:

      给你。

      给它一个地址,它会返回纬度和经度给你。希望这会有所帮助。

      http://code.google.com/apis/maps/documentation/geocoding/

      【讨论】:

        【解决方案3】:

        使用地理编码器

        import android.location.Address;
        import android.location.Geocoder;
        import android.location.Location;
        
         Geocoder geoCoder = new Geocoder(Injector.INSTANCE.getApplicationComponent().applicationContext(), Locale.getDefault());
                    try {
                        List<Address> addresses = geoCoder.getFromLocationName(
                                "City name", 5);
        
                        if (addresses.size() > 0) {
                            Log.d(TAG,"ADRESSE "+ addresses.get(0) +",LAT :" + addresses.get(0).getLatitude() +", LONG :" + addresses.get(0).getLongitude() );
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
        

        【讨论】:

        • 这是简单的搜索,不在特定的城市/国家内
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-06-29
        • 1970-01-01
        • 1970-01-01
        • 2023-03-20
        • 2016-01-17
        • 1970-01-01
        相关资源
        最近更新 更多