过了一会儿,Google Maps似乎将属性名称(Qa或Pa)更改为Na或其他名称。
var map;
function initialize() {
var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var myOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
google.maps.event.addListener(map, 'click', function(event) {
AlertPos(event.latLng);
});
}
function AlertPos (location) {
// try to show the latitude and longitude
document.getElementById('lat').value = location.Qa;
document.getElementById('long').value = location.Pa;
alert(location.Qa)
alert(location.Pa)
}
这会影响我的应用程序。有人能帮忙吗?
使用lat()
和lng()
:
function AlertPos (location) {
// try to show the latitude and longitude
document.getElementById('lat').value = location.lat();
document.getElementById('long').value = location.lng();
alert(location.lat());
alert(location.lng());
}