簡體   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