简体   繁体   中英

Bing Maps api Problems geocoding addresses with “#”

With Bing Maps API, is it possible to geocode the addresses with "#"

Example - This geocodes OK with Address:

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.

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,

Like this string url = " https://dev.virtualearth.net/REST/v1/Locations?query= " + System.Web.HttpUtility.UrlEncode(strAddress) + "&key=" + key;

none of them worked for me!

Basically we are do geocoding in Plugin but not 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. As an untested example:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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