Skip to content Skip to sidebar Skip to footer

How To Capture And Parse Json Returned From Google Maps V3 Api?

I have written down the following code: var url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='+position.coords.latitude+','+position.coords.longitude+'&sensor=fal

Solution 1:

If you're on V3 you should use the Geocoding API for this: http://code.google.com/apis/maps/documentation/geocoding/

The API no longer returns JSON-P, so that you won't be able to access it with ajax without a proxy on the same domain.

var geocoder = new google.maps.Geocoder();
geocoder.geocode({ <putoptionshere>}, callback);

results and status is sent to the callback function.

Solution 2:

I'd use jQuery's getJSON() method: http://api.jquery.com/jQuery.getJSON/, it automatically creates a json object from the response that you can then use.

Post a Comment for "How To Capture And Parse Json Returned From Google Maps V3 Api?"