相关疑难解决方法(0)

去除小叶层和L.marker方法

我想知道是否有人知道在使用此约定添加它们之后如何或是否可以实际删除一层点:

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);
            }
Run Code Online (Sandbox Code Playgroud)

典型的removeLayer(pointsLayer); 在类似的for循环中对我不起作用.但是,这并不意味着没有办法循环.我只是不确定如何.我正在尝试添加有效的点,然后在事件中删除它们(不工作).有任何想法吗?

谢谢大家.

PS如果您认为这个问题相关或有帮助,那么请不要忘了竖起大拇指,欢呼.

javascript leaflet

16
推荐指数
2
解决办法
5万
查看次数

标签 统计

javascript ×1

leaflet ×1