<map style="width: 100%" :latitude="latitude" :style="{ height: conFigObj.shiftTaskPicture!== 1 ? '660rpx' : '880rpx' }"
:longitude="longitude" :markers="markers" :scale="scale">
具体参数的话就在uniapp官网能看到
//获取定位
initAddress(){
const that = this
uni.showLoading({
title: '定位中...',
mask: true
})
uni.getLocation({
type: 'gcj02',
geocode: true,
isHighAccuracy: true,
success(response) {
uni.hideLoading()
console.log(response, 'response 经纬度')
let address = response.address
if (address) {
let province = address.province || '';
let city = address.city || '';
let district = address.district || '';
let street = address.street || '';
let streetNum = address.streetNum || '';
let poiName = address.poiName || '';
that.stopPosition = city + district + street + streetNum //拼接当前位置
}
that.longitude = response.longitude //当前经度
that.latitude = response.latitude //当前纬度
that.markers[0].longitude= response.longitude //图标的经度
that.markers[0].latitude= response.latitude //图标纬度
},
fail(err) {
console.log(err, '定位失败')
uni.hideLoading()
}
})
},
执行方法然后给地图赋值,地图就能直接切到定位的经纬度
此处高德地图SHA1是本地证书解析出来的值,如果不是本地证书的话就在UNIAPP云端证书里面看这个值,填入高德地图
最后把高德地图的应用KEY填入uniapp