使用getJSON的Google Maps V3地理编码查询

问题描述:

我有一个类似这里的问题:

I have a question similar to here:

结合使用jquery.getJson和Google的GeoCoding HTTP服务

除了我试图从客户端查找中不使用API​​密钥来检索地址的地理坐标之外.

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);
});

但是,我收到了标签无效"的jQuery错误.

However, I'm getting an 'invalid label' jQuery error.

V3地理编码API不支持callback参数,因此您尝试进行的JSONP调用将无法正常工作.相反,您可以使用JavaScript API并使用地理编码服务或通过以下方式代理结果您的Web服务器(以解决跨站点问题).

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).