找了一下午也没找到这个方法怎么才能有效过(微信小程序开发)
wxml:
<map id="map" class="map" longitude="{{lng}}" latitude="{{lat}}" markers="{{markers}}" polyline="{{polyline}}" >
<cover-view bindtap="play">擦拭</cover-view>
</map>
js:
polyline: [{
points: pathArr,
color: '#3777FF', //线填充色
width: 8, //折线宽度
borderWidth: 5, //边线宽度
borderColor: '#FFF', //边线颜色
lineCap: 'round', //线端头方式
arrowLine: true,
id: 250, //路线id
}],
/此方法就是轨迹运动
this.setData({mapCtx:wx.createMapContext("map", this) })
// 缩放地图
this.data.mapCtx.includePoints({
points: pathArr, //路线
padding: [50]
})
// 擦拭路线
this.data.mapCtx.eraseLines({
lines: [{
id: 250, //路线id
index: 0, //线段起点 自我理解
point: this.data.polyline[0].points[100], //线段终点 自我理解
clear: false //false 变灰
}],
success: function (res) {
console.log(res,'擦拭成功')
},
fail: function (res) {
console.log(res,'擦拭失败')
},
complete: function (res) {
console.log(res,'擦拭完毕')
}
})
我运行的时候擦拭成功和擦拭完毕打印出来了,但是路线并没有变化,然后我把lines[0].id 换成了1234之后再运行,接口返回结果一样,并没有报错。
注:当前是在真机调试时打印结果,开发工具中不执行这个方法。
以上方法参考下面这个小程序源码执行的,并没有达到我想要的效果
具体参考下列小程序中,出行服务接口----司乘同显-拼车
小程序源码:https://github.com/TencentLBS/TencentMapMiniProgramDemo
最后,有大佬会的,还请赐教!