JS中动态改了polyline.points,因为polyline是数组,所以我设置了第一个个元素[0],从log中可以看到后台数据确实是改变了,但是地图上的polyline始终没有变化,应该是个bug
WXML文件内容:
<map id=“map” longitude="{{x}}" latitude="{{y}}" scale=“14” controls="{{controls}}" bindcontroltap=“controltap” markers="{{markers}}" bindmarkertap=“markertap” polyline="{{polyline}}" bindregionchange=“regionchange” bindcontroltap=“moveToLocation” show-location
style=“width: 100%; height: 60vh;”></map>
<button bindtap=“test” class=“weui-btn mini-btn” type=“primary” size=“mini”>选取坐标</button>
JS文件内容:
test: function () {
var testpoints = [{
longitude: 121.43686999999998,
latitude: 31.18826000000001
}, {
longitude: 113.324520,
latitude: 23.21229
}]
this.data.polyline[0].points = testpoints
},
JS文件中的data内容:
data: {
polyline: [{
points: [{
longitude: 113.3245211,
latitude: 23.10229
}, {
longitude: 113.324520,
latitude: 23.21229
}],
color: “#FF0000DD”,
width: 2,
dottedLine: true
}]
}