MapContext.eraseLines(Object object) 调用为什么不起作用?
let map = wx.createMapContext('mMap', this)
map.eraseLines({
lines: [{
id: 0,
index: 0,
point: [
{latitude: 23.124624, longitude: 113.362086},
{latitude: 23.124556, longitude: 113.362081},
{latitude: 23.124517, longitude: 113.36208}
]
}],
success: function (res) {
console.log(res)
},
complete: function (res) {
console.log(res)
}
})
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
<!-- WXML -->
<map
id="mMap"
longitude="{{location.longitude}}"
latitude="{{location.latitude}}"
polyline="{{polyline}}"
/>
<text bindtap="clearPolyline">擦除</text>
// js
Page({
data: {
location: {longitude: '113.362086', latitude: '23.124624'},
polyline: [{
color: "#818181",
width: 4,
points: [
{latitude: 23.124624, longitude: 113.362086},
{latitude: 23.124556, longitude: 113.362081},
{latitude: 23.124517, longitude: 113.36208}
]
}]
},
clearPolyline () {
const {polyline} = this.data
let map = wx.createMapContext('mMap', this)
map.eraseLines({
lines: {
id: 0,
index: 0,
point: polyline[0].points
},
success: function (res) {
console.log(res)
},
complete: function (res) {
console.log(res)
}
})
}
})
线路id得设置,,清除的时候得匹配,另外这边报两个eraselines问题:
虽然我也没找到问题,但是可以参考这个https://blog.csdn.net/code_res/article/details/135824452?spm=1001.2014.3001.5501
我也很困惑,map标签的polyline没有线段id属性,eraseLines api 却要求填写id和index,官方文档也没有说明清楚。
我这儿也没有生效
代码片段:https://developers.weixin.qq.com/s/B5hsBym67HIR