是否可以通过ISO 3166-2获取特定PostalCode / CountryCode组合的Bing Maps Locations API代码?
每个例子:1210 / AT => AT-9
答案 0 :(得分:-1)
使用Bing Maps REST Location API并对您的查询进行地理编码(邮政,国家/地区...)。作为请求的一部分,添加&incl=ciso2
,它将返回国家/地区的ISO2代码值。例如:
https://dev.virtualearth.net/REST/v1/Locations?q=1210%2C%20AT&incl=ciso2&key=YOUR_Bing_Maps_Key
将返回以下内容:
{
"authenticationResultCode": "ValidCredentials",
"brandLogoUri": "http:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png",
"copyright": "Copyright © 2017 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.",
"resourceSets": [{
"estimatedTotal": 1,
"resources": [{
"__type": "Location:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1",
"bbox": [48.237850189209, 16.3536491394043, 48.3225288391113, 16.4731197357178],
"name": "1210, Austria",
"point": {
"type": "Point",
"coordinates": [48.2801895141602, 16.4104042053223]
},
"address": {
"adminDistrict": "Vienna",
"adminDistrict2": "Vienna",
"countryRegion": "Austria",
"formattedAddress": "1210, Austria",
"locality": "Vienna",
"postalCode": "1210",
"countryRegionIso2": "AT"
},
"confidence": "High",
"entityType": "Postcode1",
"geocodePoints": [{
"type": "Point",
"coordinates": [48.2801895141602, 16.4104042053223],
"calculationMethod": "Rooftop",
"usageTypes": ["Display"]
}],
"matchCodes": ["Good"]
}]
}],
"statusCode": 200,
"statusDescription": "OK",
"traceId": "cb93431f2caa4f9fb2fcdbaa0ae80b74|CO30324109|7.7.0.0|"
}
请注意,响应的地址属性中有"countryRegionIso2": "AT"
可以在此处找到Bing Maps REST Locaiton API上的文档:https://msdn.microsoft.com/en-US/library/ff701711.aspx
此处有最佳做法指南:https://msdn.microsoft.com/en-us/library/dn894107.aspx
如果使用.NET,您可能希望使用Bing Maps REST .NET工具包:https://github.com/Microsoft/BingMapsRESTToolkit这使得在.NET中使用REST服务变得非常简单,并且还具有一个NuGet包,可以轻松地包含在您的项目中