本文介绍了iOS从Zipcode中查找位置(经度,纬度)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获得给定邮政编码地址的最佳方式是什么?它会在美国/加拿大以外的国家/地区运作。感谢

解决方案

使用Google地理定位API(在google.com/上试用它例如:
CH-9014



或者

法国人:
FR-34000

或德语:
de-12101


或美国:
us-90210

或加拿大:
ca-J5Z 1A1



cn-100000



地址= ch-9014& sensor = falserel =nofollow noreferrer>例子:

产生

  {
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,
视口:{
:{
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的回答:

>


What could be the best way to get location for a given zipcode. Would it work for countries outside US/Canada .Thanks

解决方案

Use the Google geolocating API (try it out on google.com/maps):

Input for a Swiss ZIP code for example:CH-9014

or a french one:FR-34000

or german:de-12101

or US:us-90210

or canada:ca-J5Z 1A1

or china:cn-100000

for example:

yields

{
  "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
        }
      }
    }
  } ]
}

So the swiss ZIP code 9014 corresponds appx. to this location:

"lat": 47.4082855,
"lng": 9.3323890

See my answer on the geolocating API here:
How to get GLatLng object from address string in advance in google maps?

这篇关于iOS从Zipcode中查找位置(经度,纬度)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 05:57