Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android问题,获取纬度&;指定地址的经度_Android_Google Maps - Fatal编程技术网

android问题,获取纬度&;指定地址的经度

android问题,获取纬度&;指定地址的经度,android,google-maps,Android,Google Maps,我正在尝试从用户给定的地址查找lat&long,因为我使用以下代码 GeoPoint pointForEnterAddr; try { List<Address> address = coder.getFromLocationName(enterAddr, 1); if (address == null) pointForEnterAddr = null;

我正在尝试从用户给定的地址查找lat&long,因为我使用以下代码

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);
                }
插入点的地质点;
试一试{
列表地址=coder.getFromLocationName(enterAddr,1);
如果(地址==null)
pointForEnterAddr=null;
否则{
地址位置=地址。获取(0);
System.out.println(“Lat in”按钮点击:
+location.getLatitude());
System.out.println(“长入按钮单击:”
+location.getLongitude());
PointForInterAddr=新的地质点((int)(location.getLatitude()*1E6),
(int)(location.getLongitude()*1E6));
}
捕获(例外情况除外){
System.out.println(“此处错误:“+ex”);
}
但每次它来捕捉部分并显示例外, java.io.IOException:服务不可用

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


谢谢你

我为你的问题找到了这个,我想这是emulator的错误。看看这个答案


提到另一种选择,你可以使用谷歌地图的REST。你可能可以使用它作为备用。因为你也会在你的应用程序中使用谷歌地图,你应该熟悉API规则。

这并不完全正确。如果你不使用给定的方法,它与你从某个随机服务器调用API一样,这意味着u受每日通话次数的限制。