2010-09-04 69 views

回答

2

你將不得不使用Geocoding Service,就像Google或免費提供Nominatim提供者獲得的經度和緯度。請注意,由於您只是提供郵政編碼,由於地址本身的不準確性,您可能無法獲得您想要的結果。

+2

另外(至少對谷歌來說),請確保您填寫儘可能多的細節,甚至可以設置一些區域選項,以確保在您希望的國家/地區搜索郵政編碼。對於擁有空格的郵政編碼格式,您可能希望先刪除這些空格,否則Google可能只會使用第一部分並向您顯示另一個國家。 – Arjan 2010-09-04 08:05:17

3

你可以使用YQL像這樣:從geo.places其中文本=「ZIPCODE_HERE」

19

這是一個非常簡單的解決方案選擇重心,假設地理編碼服務都存在:

final Geocoder geocoder = new Geocoder(this); 
final String zip = "90210"; 
try { 
    List<Address> addresses = geocoder.getFromLocationName(zipCode, 1); 
    if (addresses != null && !addresses.isEmpty()) { 
    Address address = addresses.get(0); 
    // Use the address as needed 
    String message = String.format("Latitude: %f, Longitude: %f", 
    address.getLatitude(), address.getLongitude()); 
    Toast.makeText(this, message, Toast.LENGTH_LONG).show(); 
    } else { 
    // Display appropriate message when Geocoder services are not available 
    Toast.makeToast(this, "Unable to geocode zipcode", Toast.LENGTH_LONG).show(); 
    } 
} catch (IOException e) { 
    // handle exception 
} 
+0

它不工作。給「服務不可用」例外..你有更好的方法嗎? – YuDroid 2012-06-21 10:41:53

4

有在GeoCoding中沒有Google的競爭對手:)

您只需編寫一個http獲取以下鏈接的請求。 這裏的a link

只是更改郵政編碼元素根據您的要求。享受。

如需進一步參考,請點擊鏈接。 Maps Geocoding Reference

相關問題