0

可能重复:
使用 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 请求发送时,它不会在萤火虫的响应下返回任何内容,它是空白的。有什么想法吗 ?

4

2 回答 2

0

请参阅此处的反向地理编码示例:

https://google-developers.appspot.com/maps/documentation/javascript/examples/geocoding-reverse

这是他们的例子(减去地图):

  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);
});
于 2012-11-08T22:53:20.000 回答
0
$.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));
        }
    });
于 2012-11-09T10:05:35.063 回答