百度获取经纬度的例子(各浏览器适用,含IE5):
charset="utf-8"/>
type="text/javascript"src="https://api.map.baidu.com/api?v=2.0&ak=7a6QKaIilZftIMmKGAFLG7QT1GLfIncg">
type="button"onclick="getLocation()"value="确认"/>
id="position">
type="text/javascript">
var x = document.getElementById('position');
function getLocation(){
// 创建百度地理位置实例,代替 navigator.geolocation
var geolocation =newBMap.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();
}
});
}