【问题标题】:Android Google Maps Android V2 Check Entered location is in AhmedabadAndroid Google Maps Android V2 Check Entered location is in Ahmedab​​ad
【发布时间】:2015-03-26 03:56:29
【问题描述】:

我正在使用谷歌地图 v2,我的问题是:

当用户当时输入位置时,我想检查艾哈迈达巴德的位置。

提前谢谢你。

【问题讨论】:

    标签: android google-maps google-maps-api-3 dictionary android-maps


    【解决方案1】:

    Nirmal:第一步需要获取纬度和经度。然后通过以下方法传递坐标。然后将城市的值与艾哈迈达巴德进行比较。

    public void getAddress(double lat, double lng) {
    Geocoder geocoder = new Geocoder(HomeActivity.mContext, Locale.getDefault());
    try {
        List<Address> addresses = geocoder.getFromLocation(lat, lng, 1);
        Address obj = addresses.get(0);
        String add = obj.getAddressLine(0);
        GUIStatics.currentAddress = obj.getSubAdminArea() + ","
                + obj.getAdminArea();
        GUIStatics.latitude = obj.getLatitude();
        GUIStatics.longitude = obj.getLongitude();
        GUIStatics.currentCity= obj.getSubAdminArea();
        GUIStatics.currentState= obj.getAdminArea();
        add = add + "\n" + obj.getCountryName();
        add = add + "\n" + obj.getCountryCode();
        add = add + "\n" + obj.getAdminArea();
        add = add + "\n" + obj.getPostalCode();
        add = add + "\n" + obj.getSubAdminArea();
        add = add + "\n" + obj.getLocality();
        add = add + "\n" + obj.getSubThoroughfare();
    
        Log.v("IGA", "Address" + add);
        // Toast.makeText(this, "Address=>" + add,
        // Toast.LENGTH_SHORT).show();
    
        // TennisAppActivity.showDialog(add);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
    } }
    

    【讨论】:

      猜你喜欢
      • 2017-05-02
      • 2013-03-24
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-19
      • 1970-01-01
      相关资源
      最近更新 更多