0

这就是我正在尝试的方式,但我没有得到任何回应。有什么问题?

使用的 API:

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=***&sensor=false"
            type="text/javascript"></script>



function initialize() {
     var addrLookup = 'San Diego , CA   92101';
     var geoCoder = new google.maps.Geocoder();
     var geoRequest = { address: addrLookup };
     geoCoder.geocode(geoRequest,function(results,status){
        window.alert("response");
        console.log(status);
     });
}
4

1 回答 1

0

稍微修改你的脚本:

<html>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
    <script>
        function initialize() {
              var addrLookup = 'San Diego , CA   92101';
              var geoCoder = new google.maps.Geocoder();
              var geoRequest = { address: addrLookup };
              geoCoder.geocode(geoRequest,function(results,status){

                  console.log('latitude: ',results[0].geometry.location.lat());
                  console.log('longitude: ',results[0].geometry.location.lng());
              });
           }
    </script>

    <body onload="initialize()">


</body></html>
于 2013-03-19T20:33:18.330 回答