2011-01-10 38 views
8

獲取給定郵政編碼的位置的最佳方式是什麼?它將對美國以外的國家工作/加拿大.ThanksiOS從郵政編碼查找位置(經度,緯度)

+0

您可以通過提供位置 – Aditya 2011-01-10 11:17:54

+0

的地址,以供將來參考認罪找到位置參考這裏: - http://stackoverflow.com/questions/9606031/ios-mkmapview-place-annotation-by -using-address-instead-lat-long – StuartM 2014-05-03 12:34:58

回答

6

使用谷歌API大地定位(嘗試一下在google.com/maps):

輸入用於例如瑞士郵政編碼: CH-9014

或法式之一: FR-34000

或德語: 去12101

或美國: 我們-90210

或加拿大: CA-J5Z 1A1

或中國: CN-100000nm

example

產量

{ 
    "status": "OK", 
    "results": [ { 
    "types": [ "postal_code" ], 
    "formatted_address": "9014 St Gallen, Switzerland", 
    "address_components": [ { 
     "long_name": "9014", 
     "short_name": "9014", 
     "types": [ "postal_code" ] 
    }, { 
     "long_name": "St Gallen", 
     "short_name": "St Gallen", 
     "types": [ "locality", "political" ] 
    }, { 
     "long_name": "Sankt Gallen", 
     "short_name": "SG", 
     "types": [ "administrative_area_level_1", "political" ] 
    }, { 
     "long_name": "Switzerland", 
     "short_name": "CH", 
     "types": [ "country", "political" ] 
    } ], 
    "geometry": { 
     "location": { 
     "lat": 47.4082855, 
     "lng": 9.3323890 
     }, 
     "location_type": "APPROXIMATE", 
     "viewport": { 
     "southwest": { 
      "lat": 47.3991076, 
      "lng": 9.3180504 
     }, 
     "northeast": { 
      "lat": 47.4199564, 
      "lng": 9.3543340 
     } 
     }, 
     "bounds": { 
     "southwest": { 
      "lat": 47.3991076, 
      "lng": 9.3180504 
     }, 
     "northeast": { 
      "lat": 47.4199564, 
      "lng": 9.3543340 
     } 
     } 
    } 
    } ] 
} 

所以瑞士郵政編碼9014對應APPX。到此位置:

"lat": 47.4082855, 
"lng": 9.3323890 

見的大地定位API在這裏我的答案:
How to get GLatLng object from address string in advance in google maps?

+0

它是免費的嗎? – 2013-10-07 06:41:47

+0

@Jagdish:我的代碼?是。用於商業Intranet目的的google-api:沒有。 – 2014-03-19 15:10:09

1

谷歌的API中附帶了一些非常討厭的限制。根據@Claus Broch的建議,最好使用像GeoNames這樣的開放源代碼。

我在添加這個答案的同時也注意到MapQuest最近把一個API放到了OpenStreetMap數據中。它沒有(據我所知)郵政編碼搜索,但位置名稱,方向,高度等都可以自由查詢。我最近發現它,我打算儘快用Google地圖API替換我的電話。

http://developer.mapquest.com/web/products/open

相關問題