使用 getJSON 进行 Google 地图 V3 地理编码查找
我有一个与这里类似的问题:
using jquery.getJson with Google's GeoCoding HTTP服务,
但我尝试在不使用 API 密钥的情况下从客户端查找中检索地址的地理坐标。
使用此代码时似乎一切正常:
$.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 错误。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
V3 地理编码 API 不支持回调参数,因此您尝试进行的 JSONP 调用将不起作用。相反,您可以使用 JavaScript API 并使用地理编码服务或通过代理结果您的网络服务器(以解决跨站点问题)。
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).
由于同源政策,您无法直接使用网络服务。
幸运的是,有一个解决方案:Maps API V3 中的地理编码服务。
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.