简体   繁体   English

Bing Maps api问题使用“#”对地址进行地理编码

[英]Bing Maps api Problems geocoding addresses with “#”

With Bing Maps API, is it possible to geocode the addresses with "#" 使用Bing Maps API,可以使用“#”对地址进行地理编码

Example - This geocodes OK with Address: 示例-此地址的地址解析为“ OK”:

1600 Amphitheatre Pkwy APT 23, Mountain View, CA 94043, USA 1600 Amphitheatre Pkwy APT 23,Mountain View,CA 94043,USA

But if I replace the Apt with #, 1600 Amphitheatre Pkwy #23, Mountain View, CA 94043, USA the result is an error. 但是,如果我将Apt替换为美国加利福尼亚州94043,山景城1600 Amphitheatre Pkwy#23,则结果为错误。

This is my url: 这是我的网址:

var strAddress ;

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

I tried using encodeUriComponent, System.Web.HttpUtility.UrlEncode, Uri.EscapeUriString, 我尝试使用encodeUriComponent,System.Web.HttpUtility.UrlEncode,Uri.EscapeUriString,

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

none of them worked for me! 他们都没有为我工作!

Basically we are do geocoding in Plugin but not javascript. 基本上,我们会在插件中进行地理编码,而不是JavaScript。
Could anyone please help me? 谁能帮我吗? Thanks in Advance. 提前致谢。

You can use encodeURIComponent to escape the # character to %23 , which then prevents it from starting a hash component of the URI. 您可以使用encodeURIComponent#字符转义到%23 ,然后防止它启动URI的哈希组件。 As an untested example: 作为一个未经测试的示例:

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

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

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