Bing Maps REST服务

时间:2014-05-08 14:55:36

标签: rest maps bing-maps

我正在向Bing Maps REST服务发送请求以获取位置信息,例如坐标等,我在我的网络浏览器中输入了此请求(http://dev.virtualearth.net/REST/v1/Locations/query=rsa/gauteng/2001/johannesburg/melville?o=xml&key=“mykey”)(作为测试)并返回错误的位置信息。 返回的xml表明我在纽约州的某个州。 谁能帮我理解为什么会这样?

我已经阅读了有关Web服务的Microsoft文档,并且我正在遵循构造请求的正确结构。我用Google搜索了解决方案,但没有运气

1 个答案:

答案 0 :(得分:0)

您未正确发出请求。 Bing提供了两种方法:结构化查询和非结构化查询。你把两者混合在一起。

结构化(" REST"喜欢): http://dev.virtualearth.net/REST/v1/Locations/CA/BC/V6G/Vancouver/Stanley%20Park%20Causeway?key=BingMapsKey

非结构化(使用查询字符串): http://dev.virtualearth.net/REST/v1/Locations?locality=London&postalCode=SW1A&key=BingMapsKey

如参考页面(http://msdn.microsoft.com/en-us/library/ff701714.aspx)所指定的那样,与您的请求类似的请求需要这样做:

http://dev.virtualearth.net/REST/v1/Locations?countryRegion= {国家}&安培; adminDistrict = {区}&安培;局部性= {局部性}&安培;关键= {}键

此外,您应该使用2个字母的ISO代码。因此,南非将是" ZA"。

您的完整请求将是:

http://dev.virtualearth.net/REST/v1/Locations?countryRegion=za&adminDistrict=johannesburg&locality=melville&key=key

它返回如下内容:

address: {
    adminDistrict: "Gauteng",
    adminDistrict2: "Johannesburg",
    countryRegion: "South Africa",
    formattedAddress: "Melville, South Africa",
    locality: "Melville"
},
confidence: "High",
entityType: "Neighborhood",
geocodePoints: [{
    type: "Point",
    coordinates: [
        -26.17535972595215,
        28.008920669555664
    ],
    calculationMethod: "Rooftop",
    usageTypes: ["Display"]
}]