从Bing Maps位置API获取ISO 3166-2代码



是否有一种方法可以获取特定邮政编码/countryCode组合使用Bing Maps位置API的ISO 3166-2代码?

每个示例:1210/at => at-9

使用bing Maps REST位置API和GEOCODE您的查询(邮政,乡村...)。作为请求的一部分,添加&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 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/microsoft/bingmapsresttoolkit,它非常容易在.NET中使用REST服务,并且还具有Nuget Package对于您的项目中的轻松包括。

最新更新