问题
I have a question similar to here:
using jquery.getJson with Google's GeoCoding HTTP Service
with the exception that I'm trying to retrieve the geo-coordinates for an address without using the API key, from a client-side lookup.
Everything seems to work when using this code:
$.getJSON("http://maps.google.com/maps/api/geocode/json?address=202++3991+Henning+Dr+Burnaby+BC+V5C+6N5&sensor=false&callback=?",
function(data, textStatus){
console.log(data);
console.log(textStatus);
});
However, I'm getting an 'invalid label' jQuery error.
回答1:
The V3 geocoding API doesn't support the callback parameter, so the JSONP call you're trying to make won't work. Instead you could use the JavaScript API and use the Geocoding Service or proxy the results through your web server (to get around the cross-site issues).
回答2:
You can't use the web service directly because of same origin policy.
Lucky, there is a solution: The Geocoding Service in the Maps API V3.
来源:https://stackoverflow.com/questions/9216073/google-maps-v3-geocoding-lookup-using-getjson