点定义自己的地图组件
<map id="map" latitude="{ {latitude}}" longitude="{ {longitude}}" scale="{ {scale}}" markers="{ {markers}}" show-location> </map>
JS:
data:{ latitude: '34.21797710060448', longitude: '108.71795654296875', scale:12, markers:[ { id:'001', iconPath:"https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeel1.png", latitude: '34.21797710060448', longitude: '108.71795654296875', name:'测试地图111', width:30, height:30 }, { id:'002', iconPath:"https://csdnimg.cn/release/blogv2/dist/pc/img/npsFeel2.png", latitude: '34.347971491244955', longitude: '108.94351959228516', width:30, height:30 }, ] }, positioning(){//点击回到自己当前位置的方法 const mapCtx = wx.createMapContext("map",this); mapCtx.moveToLocation({ // latitude:latitude, // longitude:longitude, success(res){ console.log('调用成功',res) }, fail(err){ console.log('调用失败') } }) }