[英]android problem to get latitude & longitude from a given address
我正在嘗試從用戶指定的地址中找到經緯度,因為我正在使用以下代碼,
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:服務不可用
我該如何解決並獲得正確的輸出? 請告訴我。
謝謝
我發現這是您的問題,我認為這是模擬器的錯誤。 看這個答案
只需提及一種替代方法,您就可以使用Google Maps的基於REST的反向地理編碼器 。 您可以將其用作備用。 您也將在應用程序中使用Google Maps,因此您應該熟悉API規則。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.