function loadmap(){
let that = this
this.$vux.loading.show({
text: '獲取定位信息...'
})
//初始化地圖對象,加載地圖
var map = new AMap.Map('containers', {
resizeEnable: true
});
var options = {
'showButton': true,//是否顯示定位按鈕
'buttonPosition': 'LB',//定位按鈕的位置
/* LT LB RT RB */
'buttonOffset': new AMap.Pixel(10, 20),//定位按鈕距離對應角落的距離
'showMarker': true,//是否顯示定位點
'markerOptions':{//自定義定位點樣式,同Marker的Options
'offset': new AMap.Pixel(-18, -36),
'content':'<img src="https://a.amap.com/jsapi_demos/static/resource/img/user.png" style="width:36px;height:36px"/>'
},
'showCircle': true,//是否顯示定位精度圈
'circleOptions': {//定位精度圈的樣式
'strokeColor': '#0093FF',
'noSelect': true,
'strokeOpacity': 0.5,
'strokeWeight': 1,
'fillColor': '#02B0FF',
'fillOpacity': 0.25
}
}
AMap.plugin(["AMap.Geolocation"], function() {
var geolocation = new AMap.Geolocation(options);
map.addControl(geolocation);
geolocation.getCurrentPosition()
AMap.event.addListener(geolocation, 'complete', function (data) {
that.$toast('定位成功')
that.$vux.loading.hide()
});
AMap.event.addListener(geolocation, 'error', function(){
// 定位失敗
that.$vux.loading.hide()
that.$toast('定位失敗')
})
});
高德地圖獲取精確定位信息
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.