可能的重复:
用jQuery解析Google Geo API(反向地理编码)
$(window).load(function() {
var purl = "http://maps.googleapis.com/maps/api/geocode/json?latlng=32.759294499999996,-97.32799089999999&sensor=false";
$.getJSON(purl,function(result){
$.each(result, function(i, field){
$("#data").append(field + " ");
});
});
});
如果您访问URL,则会以JSON格式看到结果。当我将其发送为$ .getjson时,请求它不会在firebug上返回任何响应。有什么想法吗 ?
请参阅此处的反向地理编码示例:
在这是他们的示例(减去地图):
var geocoder;
function initialize() {
geocoder = new google.maps.Geocoder();
}
function codeLatLng(lat, lng) {
var latlng = new google.maps.LatLng(lat, lng);
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
alert(results[1].formatted_address);
} else {
alert('No results found');
}
} else {
alert('Geocoder failed due to: ' + status);
}
});
}
$().ready(function () {
initialize();
codeLatLng(32.759294499999996,-97.32799089999999);
});
$.ajax({
type : "GET",
url : URL,
dataType : "jsonp",
jsonp : "jsoncallback",
jsonpCallback : MSS,
cache : true,
success : function(service_data) {
binding(service_data);
},
error : function(msg) {
alert(JSON.stringify(msg));
}
});