目前我這邊測試發現的問題
UNIAPP 獲取定位的代碼
在這里插入代碼片
data的參數
data() {return {id: 0, // 使用 marker點擊事件 需要填寫idtitle: 'map',latitude: 39.909,longitude: 116.39742,covers: [{latitude: 39.909,longitude: 116.39742,width: 50,height: 50,iconPath: '../../static/drdingwei.png'}]}},
methods: 里面的方法
適用于百度地圖精準定位
getLocation() {const that = this;uni.getLocation({type: 'gcj02', // 返回可以用于uni.openLocation的經緯度,默認為wgs84的gps坐標altitude: true, success: (res) => {console.log('當前位置的經度:' + res.longitude);console.log('當前位置的緯度:' + res.latitude);that.latitude = res.latitudethat.longitude = res.longitudethat.covers[0].latitude = res.latitudethat.covers[0].longitude = res.longitude},fail: (err) => {console.error('獲取位置失敗?