本文介绍了纬度和经度错误 - Google Maps API JS 3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
过了一段时间,Google Maps似乎将属性名称(Qa或Pa)更改为Na或其他名称。使用 lat()和 lng ():函数AlertPos(location){
//尝试显示纬度和经度
document.getElementById('lat')。value = location.lat();
document.getElementById('long')。value = location.lng();
alert(location.lat());
alert(location.lng());
}
After a while, Google Maps seems to change the property name (Qa or Pa) to Na or another name.
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) }This affects my application. Can any body help?
解决方案Use lat() and 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()); }
这篇关于纬度和经度错误 - Google Maps API JS 3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!