繁体   English   中英

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

[英]Get ISO 3166-2 Code from Bing Maps Locations API

是否可以通过 Bing Maps Locations API获得针对特定PostalCode / CountryCode组合的ISO 3166-2代码?

例如:1210 / AT => AT-9

使用Bing Maps REST位置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/zh-CN/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包,可以轻松地包括在您的项目中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM