0

可能重复:
带有 google geocoding api json 的
json Uncaught SyntaxError: Unexpected token :

$.getJSON('http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true&callback=?', function(data) {
    console.log(data);
});

它给了我这个错误:Uncaught SyntaxError: Unexpected token :

4

1 回答 1

0

您正在尝试从它不支持的 google maps 获取 JSONP 响应。

试试这个,

<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>

<script>  
    $(function(){   
        var geocoder = new google.maps.Geocoder();
        var latlng = new google.maps.LatLng(40.714224,-73.961452);
        geocoder.geocode(
            {latLng  : latlng }, 
            function(dataObject, statusObject) {
                console.log(dataObject);
            }
        );
    });
</script>
于 2012-06-30T10:09:38.057 回答