【问题标题】:Bing Maps api Problems geocoding addresses with "#"Bing Maps api 使用“#”对地址进行地理编码问题
【发布时间】:2017-10-11 21:02:52
【问题描述】:

使用 Bing Maps API,是否可以使用“#”对地址进行地理编码

示例 - 这可以使用地址进行地理编码:

1600 Amphitheatre Pkwy APT 23,山景城,CA 94043,美国

但是如果我将 Apt 替换为 #, 1600 Amphitheatre Pkwy #23, 山景城, CA 94043, USA 结果是一个错误。

这是我的网址:

var strAddress ;

string url = "https://dev.virtualearth.net/REST/v1/Locations?query=" + 
strAddress + "&key=" + key;

我尝试使用 编码UriComponent, System.Web.HttpUtility.UrlEncode, Uri.EscapeUriString,

像这样 字符串 url = "https://dev.virtualearth.net/REST/v1/Locations?query=" + System.Web.HttpUtility.UrlEncode(strAddress) + "&key=" + key;

它们都不适合我!

基本上,我们在 Plugin 中进行地理编码,而不是在 javascript 中。
有人可以帮我吗? 提前致谢。

【问题讨论】:

  • 您是否担心散列的 URL 编码或 bing 地图无法正确处理其中包含散列的地址?

标签: c# plugins dynamics-crm geocoding bing-api


【解决方案1】:

您可以使用encodeURIComponent# 字符转义为%23,从而阻止它启动URI 的哈希组件。作为一个未经测试的例子:

stringUrl = "https://dev.virtualearth.net/REST/v1/Locations?query=" + 
             encodeURIComponent( strAddress) + "&key=" +
             encodeURIComponent( key);

【讨论】:

    猜你喜欢
    • 2011-05-09
    • 1970-01-01
    • 2017-03-13
    • 1970-01-01
    • 2013-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多