百度获取经纬度的例子(各浏览器适用,含IE5):
var x = document.getElementById('position');
function getLocation() {
// 创建百度地理位置实例,代替 navigator.geolocation
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(e) {
if(this.getStatus() == BMAP_STATUS_SUCCESS){
// 百度 geolocation 的经纬度属性不同,此处是 point.lat 而不是 coords.latitude
x.innerHTML = '纬度:' + e.point.lat + '
经度:' + e.point.lng;
} else {
x.innerHTML = 'failed' + this.getStatus();
}
});
}
Kai
Kai
790***286@qq.com11个月前 (07-10)