用jQuery解析Google Geo API(反向地理编码) [英] Parsing Google Geo API (Reverse Geocoding) with jQuery
问题描述
我确定我不是唯一一个,但当请求的数据是 latitude $ c $时,当jQuery请求查找地址时,我无法解析/返回任何东西c>和
经度
所以Google可以返回数据,但它不能被jQuery读取?
I'm sure I'm not the only one, but I cannot parse/return anything when jQuery takes a request to lookup an address when the data being requested is the latitude
and longitude
so Google can return the data, but it cannot be read by jQuery?
http://maps.googleapis.com/maps/api/geocode/json
带参数:
With parameters:
latlng=51.276914,1.077252
&sensor=false
在Firebug中,它表示 200 OK
,但是响应中没有显示任何内容:
In Firebug it says 200 OK
but nothing is displayed in the response:
我可以在打开它时看到它: http://maps.googleapis.com/maps/api/geocode/json?latlng=51.187296,1.229086&sensor=false&_=1302084865163
I can see it when I open it: http://maps.googleapis.com/maps/api/geocode/json?latlng=51.187296,1.229086&sensor=false&_=1302084865163
我做的是:
What I did was:
$.ajax(
{
url: 'http://maps.googleapis.com/maps/api/geocode/json',
data: 'latlng=' + geolocation + '&sensor=false',
dataType: 'json',
cache: false,
success: function(data){ alert(data); }
});
这不起作用...既不是 $。get $使用
json
dataType
来获取c $ c>, $。getJSON
>。
That doesn't work... neither $.get
, $.getJSON
with the json
dataType
.
为什么jQuery不能解析/读取响应?
Why can't jQuery parse/read the response?
推荐答案
出于安全原因,您需要使用Google地理编码器。请参阅此处。
You need to use googles geocoder for security reasons. See answer here.
这篇关于用jQuery解析Google Geo API(反向地理编码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!