纬度和经度错误 - Google Maps API JS 3.0 [英] Error on Latitude and Longitude - Google Maps API JS 3.0
本文介绍了纬度和经度错误 - Google Maps API JS 3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var map;
函数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);
});
}
函数AlertPos(位置){
//尝试显示经度和纬度
document.getElementById('lat')。value = location.Qa;
document.getElementById('long')。value = location.Pa;
alert(location.Qa)
alert(location.Pa)
}
这会影响我的应用程序。任何身体可以帮助吗?
解决方案使用
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文