Google Maps V3 Geocoding Lookup using getJSON

本小妞迷上赌 提交于 2019-12-25 05:37:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!