这就是我的尝试,但我没有得到任何回应。可能有什么不对?
使用的API:
<script src="http://maps.google.com/maps?file=api&v=2&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);
});
}
答案 0 :(得分: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>