首先引入百度api的
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=你的ak"></script>
调用下面方法可以获取的位置信息
function geolocation() {
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r) {
if (this.getStatus() == BMAP_STATUS_SUCCESS) {
var mk = new BMap.Marker(r.point);
g_bmapx = r.point.lng;//精度
g_bmapy = r.point.lat;//纬度
} else {
}
}, {
enableHighAccuracy : true
})
}