【问题标题】:Reverse Geocoding issue反向地理编码问题
【发布时间】:2014-04-16 13:30:13
【问题描述】:

我正在使用标记进行反向地理编码。因此,取决于标记位置,它将获得经度和纬度,从而从地理编码器中获取地址。 问题是,在标记的某些位置,它的地址不正确,尽管位置可能正确,但剩余的“街道”等不正确,有时它根本不显示地址,TextView 仍保留其先前的输入。

下面是我的标记拖拽列表:

 public void onMarkerDragEnd(Marker marker) {


                LatLng position = marker.getPosition(); 



                 Geocoder geocoder = new Geocoder(MainActivity.this);
                 TextView textView1 = (TextView)findViewById(R.id.textView1);
                try
                 {
                         List<Address> addresses = geocoder.getFromLocation(position.latitude,position.longitude,0);
                         for(Address address : addresses)
                         {
                                 if(address.getLocality()!=null)
                                 {


                                        SubStreetNumber = address.getSubThoroughfare ();
                                        Street = address.getThoroughfare();
                                        Area = address.getSubLocality ();
                                        City = address.getLocality();
                                        PostCode = address.getPostalCode();
                                        break;
                                      }


                                 textView1.setText(SubStreetNumber + ", " + Street + ", " + City + ", " + PostCode);    

                         }

                         }

                catch(IOException ioException)
                {
                        Log.e("MyApp","Exception",ioException);
                }
            }

【问题讨论】:

    标签: javascript android google-maps geocoding


    【解决方案1】:

    这行代码geocoder.getFromLocation(position.latitude,position.longitude,0);有bug报告

    它与您的代码无关,我也遇到过这种情况。在某些设备上有效,在某些设备上无效,有时有效,有时无效。

    如果您注意到您的 logcat 中会出现一条黄线,说明它无法连接到某些服务...

    【讨论】:

    • 我很欣赏这一点,但我仍然认为它的一些原因是我的代码。因为有时我没有收到无法连接到服务的 logcat 错误。 '0' 是放在 'position.logitude' 之后的正确值吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-31
    相关资源
    最近更新 更多