The # character has special meaning in a URL. Anything after the # is never
sent to the server at all!

You need to run your address through encodeURIComponent() before putting it
into the URL. For example:

var address = '1600 Amphitheatre Parkway #23, Mountain View, CA';
var url = '
http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=' +
encodeURIComponent(address);

The resulting URL is now:

http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=1600%20Amphitheatre%20Parkway%20%2323%2C%20Mountain%20View%2C%20CA

and that should work fine.

-Mike
On Sat, Jan 22, 2011 at 12:48 PM, <[email protected]> wrote:

> Sorry if I missed this somewhere in the documentation.
>
> Using the online geocoding example, I added "Apt 23" to the address:
>
> http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway+Apt+23,+Mountain+View,+CA&sensor=false
>
> This geocodes OK, but replaces "Apt" with # in the formatted address:
> "formatted_address": "1600 Amphitheatre Pkwy #23, Mountain View, CA 94043,
> USA"
>
> But if I attempt to geocode the address with the # for Apt.
>
> http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway+#23,+Mountain+View,+CA&sensor=false
>
> that results in an error:
>
> {
>   "status": "REQUEST_DENIED",
>   "results": [ ]
> }
>
> Is there some rule I don't understand about "#" here?  Are there other
> special characters that should be avoided?
>
> Thanks for any insight about this.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-maps-js-api-v3%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to