【问题标题】:android problem to get latitude & longitude from a given address从给定地址获取纬度和经度的android问题
【发布时间】:2011-06-25 06:57:47
【问题描述】:

我正在尝试从用户给定的地址中查找经纬度,因为我正在使用以下代码,

GeoPoint pointForEnterAddr;


try {

    List<Address> address = coder.getFromLocationName(enterAddr, 1);

                    if (address == null)

                     pointForEnterAddr = null;

                    else {
                        Address location = address.get(0);
                        System.out.println("Lat in button click :"
                                + location.getLatitude());
                        System.out.println("Long in button click :"
                                + location.getLongitude());


pointForEnterAddr = new GeoPoint((int) (location.getLatitude() * 1E6),
                    (int) (location.getLongitude() * 1E6));


}
 catch (Exception ex) {
                    System.out.println("Error here :" + ex);
                }

但是每次它来捕获部分并显示异常时, java.io.IOException:服务不可用

我怎样才能解决它并获得正确的输出?请告诉我。

谢谢

【问题讨论】:

    标签: android google-maps


    【解决方案1】:

    我为您的问题找到了这个,我认为这是模拟器的错误。看看这个答案

    Android; Geocoder, why do I get "the service is not available"?

    【讨论】:

      【解决方案2】:

      顺便提一下,您可以使用基于 Google 地图的 REST 的 reverse geocoder。您可能可以将其用作后备。由于您也将在您的应用中使用 Google 地图,因此您应该熟悉 API 规则。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-03-26
        • 2013-07-24
        • 2010-12-02
        • 1970-01-01
        • 2017-10-19
        • 1970-01-01
        相关资源
        最近更新 更多