0
votes

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.

1
Are you concerned with the URL encoding of the hash or the fact that bing maps doesn't appropriately handle addresses with a hash in them? - Jeffrey

1 Answers

1
votes

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);