Getting status of 405 (Method Not Allowed)

1,223 views
Skip to first unread message

Bruno Ronchetti

unread,
Jan 28, 2011, 1:15:31 PM1/28/11
to Google Maps JavaScript API v3
Hi there,

I am pretty new to google maps and am probably doing something
horribly wrong. Hope that someone can help me out.

When I use the following URL in the browser:
http://maps.googleapis.com/maps/api/geocode/json?address=Milano&sensor=false
I am getting the expected response.

But when I try to use the same URL from inside my javascript framework
i am getting a 405 response.

The URL is embedded in an URLRequest object which looks like this:
urlrequest.isa=CPURLRequest
urlrequest._UID=10851
urlrequest._URL=http://maps.googleapis.com/maps/api/geocode/json?
address=Milano&sensor=false
urlrequest._HTTPBody=
urlrequest._HTTPMethod=GET
urlrequest._HTTPHeaderFields={
If-Modified-Since = "Thu, 1 Jan 1970 00:00:00 GMT"
Cache-Control = "no-cache"
X-Requested-With = "XMLHttpRequest"
Content-Type = "text/plain;charset=UTF-8"
}

The URL itself seems identical to me, so it could be something with
the headers... or something else that I do not understand.

Thanks in advance for any clues.

Regards. Bruno.
Message has been deleted

Rossko

unread,
Jan 28, 2011, 5:20:42 PM1/28/11
to Google Maps JavaScript API v3
> But when I try to use the same URL from inside my javascript framework
> i am getting a 405 response.

Sounds like a cross-domain problem.

Don't use the HTTP API from within javascript, use the metthod
provided within the Maps API.
http://code.google.com/apis/maps/documentation/javascript/services.html#Geocoding
You do after all, have to display the results on a map to comply with
the terms of use.

Bruno Ronchetti

unread,
Jan 29, 2011, 12:30:04 PM1/29/11
to Google Maps JavaScript API v3
Thanks Rossko.

It was a cross-domain issue indeed and has gone away when I switched
the URLRequest object with its cross-domain equivalent (I am using
Cappucino - I am now using CPJSONPConnection instead of
CPURLConnection).

But, I am now struggling with another issue: the JSON comes back from
the server and is well-formed as expected (I see it in the firefox
console) but I am getting an error in Chrome and a similar error in
Firefox and Safari.

The following comes from the Chrome javascrpit console...
{
"status": "OK",
===> Uncaught SyntaxError: unexpected token:
"results": [ {
"types": [ "street_address" ],
"formatted_address": "Via Cernaia, 9, 20121 Milan, Italy",
"address_components": [ {
"long_name": "9",
"short_name": "9",
"types": [ "street_number" ]
...


Again I suspect there must be something wrong with the request
headers, but I have not been able to find a solution so far.

Anyway, thanks again for your help.

Regards. Bruno.

Rossko

unread,
Jan 29, 2011, 2:18:13 PM1/29/11
to Google Maps JavaScript API v3
Same advice :
Don't use the HTTP API from within javascript, use the metthod
provided within the Maps API.
http://code.google.com/apis/maps/documentation/javascript/services.ht...

Bruno Ronchetti

unread,
Jan 30, 2011, 11:57:25 AM1/30/11
to Google Maps JavaScript API v3
Thanks Rossko,

after reading here:
http://blog.mikecouturier.com/2009/11/jsonp-and-google-maps-api-geocoder-not.html
and here:
http://blog.futtta.be/2010/04/09/no-more-jsonp-for-google-geocoding-webservice/

I have now given up. I have switched to Cappuccino MapKit which uses
the standard API, as you advise. It works of course, but I continue to
be a bit puzzled why one should need to load a ton of interfaces when
just one is needed.

Rossko

unread,
Jan 30, 2011, 2:41:32 PM1/30/11
to Google Maps JavaScript API v3
> but I continue to
> be a bit puzzled why one should need to load a ton of interfaces when
> just one is needed.

Don't forget you are required by the terms of use to display the
results on a map. The assumption might be that you will be wanting
the rest of the Maps API to do just that.
Reply all
Reply to author
Forward
0 new messages