百度地图获取定位
放在public/index.html页面
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=xwZFVgduNKdzeckYPyvQcA1fcVUUqyBL"></script>
mounted() {
var geolocation = new window.BMap.Geolocation()
geolocation.getCurrentPosition(
function(r) {
console.log(r)
alert(r.point.lng)
alert(r.point.lat)
},
{ enableHighAccuracy: true } //获取精准位置
)
}
百度地图坐标转换文字地址
var myGeo = new window.BMap.Geocoder({ extensions_town: true })
myGeo.getLocation(new window.BMap.Point(val.lng, val.lat), function(result) {
if (result) {
that.temp.area = result.surroundingPois[0].address
}
})
vue-百度地图文档
https://dafrok.github.io/vue-baidu-map/#/zh/start/usage