【发布时间】:2020-10-27 10:52:37
【问题描述】:
我又卡住了。 放置标记并连接它们正在工作。感谢“Falke Design”:-) 现在,当我单击“删除最后一个航点”按钮时,我想删除最后一个标记(航点)。 我设法做到了并且工作得很好,但最后一行没有被删除。 完整代码您可以在这里找到: Demo code
这个问题应该在 函数 delteLastWp() 第 218 行
function delteLastWp(id) {
var new_markers = []
marker_new.forEach(function(marker) {
if (marker._id == id) {
map.removeLayer(marker);
}
else new_markers.push(marker)
})
marker_new = new_markers
// remove the last point/line in the polyline as well !
var new_polylines = []
tempLine.forEach(function(polyline) {
if (polyline._id == id) {
map.removeLayer(polyline); //*** This si not working ****
// remove the last point in the polyline as well !
}
else new_polylines.push(polyline)
})
}
请帮帮我!非常感谢你:-)
【问题讨论】:
标签: javascript leaflet drag marker polyline