0

I am doing integration of google maps with my website for mobile. Whenever i pass an address to the url which contains '#', it shows the address before the occurance of '#'

Example: if the address is test1#test2 and i pass it to the google url, in the map it shows test1.

URL i am using is "http://maps.google.com/maps?daddr=" + add" where add is the variable

Newbee
  • 1,320
  • 4
  • 16
  • 21

1 Answers1

1

A hash (#) is a specific token in a URI (a/k/a URL). It means that you're looking for part of a page and not a whole resource. Typically, when you need to include a token that would cause issues in parsing a URL (such as a "$" or a "/"), you should "URI-encode" the token. This results in something like %20 (a space), or %2F ("/"). You probably just need to URI-encode your hash as %23.

Chances are you should be URI-encoding the entire address you want to send, not just hashes. There are many options for doing this. JavaScript even has a built-in function that does the job (encodeURIComponent()).

Pete
  • 2,538
  • 13
  • 15
  • Yes. You can place an encoded URL in an href. (Sorry, I tried to show an example, but the SO link parsing failed me!) – Pete Sep 05 '12 at 20:41