我想知道是否有人知道如何在使用这种约定添加点后,实际上是否可以删除一层点。
var pointsLayer, someFeatures = [{
//Hard coded for now
"type": "Feature",
"properties": {
"name": "Company A",
"show_on_map": true,
"icon": 'img/violations.png'
},
"geometry": {
"type": "Point",
"coordinates": [43.22519, -107.69348]
}
}, {
"type": "Feature",
.
.
.
}];
for(w=0; w < someFeatures.length; w++){
pointsLayer = L.marker(someFeatures[w].geometry.coordinates, {icon: violations})
.bindPopup("Company: "+someFeatures[w].properties.name);
//add map points
map.addLayer(pointsLayer);
}
类似的 for 循环中典型的 removeLayer(pointsLayer) 对我不起作用。但是,这并不意味着没有遍历的方法。我只是不确定具体如何操作。我正在尝试添加点,这已经成功了,然后在事件上删除它们(不成功)。有什么想法吗?