No more jsonp for Google geocoding webservice?

I needed to do some reverse geocoding in a javascript webapp. The Google Maps API worked flawlessly, but it seemed overkill to load all that javascript just to do one lousy reverse geocoding lookup (esp. on a mobile device, my target platform).  I searched some more and found the Google geocoding webservice, which is invoked with a simple HTTP GET request and returns the response in JSON. Version 2 of this service works great, as you can specify a callback-function to do jsonp (a simple method to allow for cross domain ajax requests),
This example request for v2, http://maps.google.com/maps/geo?q=51,4&sensor=false&output=json&callback=parseme, results in a response containing a call to your own “parseme”-function, with the json-object as the payload;

parseme && parseme( {
"name": "51,4",
"Status": {
"code": 200,
"request": "geocode"
},
"Placemark": [ {
"id": "p1",
"address": "Brukkelen 191, 9200 Dendermonde, Belgium",
...
]})

But a month ago Google announced a new version of their geocoding webservice and the documentation for V2 mentioned that it was deprecated in favor of the Geocoding V3 Web Service. so I switched to the new API, only to discover that callbacks aren’t supported any more.
An example request for v3 http://maps.google.com/maps/api/geocode/json?latlng=51,4&sensor=false&callback=parseme results in nothing but the javascript-object:

{
"status": "OK",
"results": [ {
"types": [ "street_address" ],
"formatted_address": "Brukkelen 191, 9200 Dendermonde, Belgium",
...
]})

And that, my dear fellow travellers, sucks big time. JSON without the P means we’re back to useless proxy-scripts on our servers. So until Google lets Jason pee (sorry folks, I just had to write this) in the V3 geocoding webservice, I’ll continue using the deprecated V2 with sweet -but undocumented- callback!

8 thoughts on “No more jsonp for Google geocoding webservice?”

  1. Yes, that sucks indeed. Seems, GOOG wants to limit the geocoding requests in order to force people to go for the premium API. This cut off together with the new limitation to 2.500 requests per day and IP – what else could be the reason?

    Reply
    • thanks, that’s interesting neil!
      just gave it a shot but I can’t seem to get it to work though:

      “Your client does not have permission to get URL /maps/api/js/GeocodeService.Search?latlng=51,4&sensor=false&callback=parseme from this server”

      and supplying an api-key didn’t work either. do you have it working?

      Reply
  2. No, not yet. I was just capturing (Wireshark) what this sample does:
    http://code.google.com/intl/de-DE/apis/maps/documentation/v3/examples/geocoding-simple.html (found here: http://code.google.com/intl/de-DE/apis/maps/documentation/v3/services.html
    The syntax is strange, but this does work for me (at least it returns some results):
    The sample issues this request:
    http://maps.google.com/maps/api/js/GeocodeService.Search?1m2&1sSydney,%20NSW&4sUS&2m1&1sde-DE&callback=_xdc_._x0njhw&token=56957
    which produces JSONP (at least once). A good starting point for further investigations, I think 🙂
    Regards

    Reply
  3. Google Maps V3 does have a way to use the geolocation service with native JS objects, but you have to use their maps library:
    Include http://maps.google.com/maps/api/js?sensor=false
    Then:

    var geocoder = new google.maps.Geocoder();
    geocoder.geocode( {'address': loc }, function(data, status){console.log(data);});

    Reply

Leave a Reply to frank Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.