Sco*_*ott 8 jquery geocoding getjson
Google提供了一个出色的REST界面,用于地址编码和地址反向地理编码.我的API密钥有效,如果我直接在浏览器地址中输入请求,它的效果很好.然而,以下jquery失败可怕,我没有理解为什么.希望你能在这里帮助我.
$.getJSON("http://maps.google.com/maps/geo?q="+ address+"&key="+apiKey+"&sensor=false&output=json",
function(data, textStatus){
console.log(data);
});
Run Code Online (Sandbox Code Playgroud)
Google针对此服务的REST界面文档:http://code.google.com/apis/maps/documentation/geocoding/index.html
Sco*_*ott 18
这里的问题是我没有指定JSONP回调.正确的代码如下
$.getJSON("http://maps.google.com/maps/geo?q="+ address+"&key="+apiKey+"&sensor=false&output=json&callback=?",
function(data, textStatus){
console.log(data);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17439 次 |
| 最近记录: |