![](http://img-cdn-tc.dcloud.net.cn/uploads/questions/20221028/58cf614ee05cc9aa27c7f351a351c89d.png)
主要代码内容为下方
<template>
<view>
<view>
<map class="map" id="map0" :show-location="true" :polyline="polylinePoint" :markers="selfPoint" :longitude="origin.longitude" :latitude="origin.latitude" "></map>
</view>
</view>
</template>
//定位到当前位置
uni.getLocation({
type: 'gcj02',
success: (res) => {;
uni.createMapContext("map0", this).moveToLocation({
longitude: res.latitude,
latitude: res.longitude,
success: () => {
uni.showToast({
title: "移动到当前定位点成功,经度:" + res.longitude + ",纬度:" + res
.latitude,
icon: "none",
duration: 3000
})
},
fail: () => {
uni.showToast({
title: "移动到当前定位点失败",
icon: "none"
})
}
})
},
fail:(err)=>{
console.log(err);
}
})