<cover-view class="buttom-view-icon-button" @click="moveTolocation">
<cover-image src="/static/map/location.png" class="buttom-view-icon-button-img"></cover-image>
</cover-view>
moveTolocation(){
let mapObjs = uni.createMapContext('mapId', this)
mapObjs.moveToLocation({ latitude: 25.01335131460308,
longitude: 121.53562913165706 },
{
complete: res=>{
console.log('移动完成:', res)
}
})
// this.onRegionChange('',true)
},
如果只是想移动用户当前实际位置,不用传经纬度就可以了
moveTolocation(){
let mapObjs = uni.createMapContext('mapId', this)
mapObjs.moveToLocation(
{
complete: res=>{
console.log('移动完成:', res)
}
})
// this.onRegionChange('',true)
},
官方文档地址:https://uniapp.dcloud.io/api/location/map?id=createmapcontext