2011-09-01 77 views
6

过了一段时间,Google Maps似乎将属性名称(Qa或Pa)更改为Na或其他名称。纬度和经度错误 - Google Maps API JS 3.0

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) 
} 

这会影响我的应用程序。任何身体可以帮助吗?

回答

9

使用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()); 
} 
+0

非常感谢您......工作;) – fmlvaz

+0

真棒,不能在文档中找到这个! –

+0

被这个难住了。我的地图应用程序自发地停止了工作,因为我像fmlvaz一样依靠'Qa'和'Pa'值(尽管它们早先是'Qa'和'Ra') –