iOS从Zipcode查找位置(纬度,经度)

Qam*_*man 6 iphone geolocation

什么是获取给定邮政编码的最佳位置.它适用于美国/加拿大以外的国家.谢谢

Ste*_*ger 6

使用Google地理定位API(在google.com/maps上试用):

输入瑞士邮政编码,例如:CH-9014

或法国人:FR-34000

或德语:de-12101

或美国:us-90210

或加拿大:ca-J5Z 1A1

或中国:cn-100000

对于例如:

产量

{
  "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
        }
      }
    }
  } ]
}
Run Code Online (Sandbox Code Playgroud)

所以瑞士邮政编码9014对应appx.到这个位置:

"lat": 47.4082855,
"lng": 9.3323890
Run Code Online (Sandbox Code Playgroud)

请参阅我在地理定位API上的答案:
如何在谷歌地图中提前从地址字符串中获取GLatLng对象?