【问题标题】:Bing Maps REST Service必应地图 REST 服务
【发布时间】:2014-06-26 01:23:40
【问题描述】:

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

我已阅读 Microsoft 关于 Web 服务的文档,并且我正在遵循正确的结构来构建请求。我在谷歌上搜索了一个解决方案,但没有运气

【问题讨论】:

    标签: rest maps bing-maps


    【解决方案1】:

    您没有正确发出请求。 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={country}&adminDistrict={district}&locality={locality}&key={key}

    此外,您应该使用 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"]
    }]
    

    【讨论】:

    • 大声笑@“你正在混合两者”,我还在学习#hides。谢谢!我现在得到了预期的结果。 #TimeToDev
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多