查找地图上的图层,要素:
window.MapLeaflet.eachLayer(function (layer) {if (layer !== window.MapLeaflet) {console.log("layer instanceof L.Polyline", layer instanceof L.Polyline)// L.Marker,L.Polyline, L.Polygon||L.Rectangle,L.CircleMarker, L.Circleif (layer instanceof L.Polyline) {window.MapLeaflet.removeLayer(layer);}if (layer instanceof L.CircleMarker) {window.MapLeaflet.removeLayer(layer);}}})
判断类型:
L.Marker,L.Polyline, L.Polygon||L.Rectangle,L.CircleMarker, L.Circle
判断方法:
layer instanceof L.Polyline
输出: