ClearLayer() not clearing all markers and shapes

المشرف العام

Administrator
طاقم الإدارة
I am working with leaflet api, where user draw shapes on images.There are multiple layers controlled by currentFeatureGroup(), when i draw triangle or circle, the clearlayer control works fine, but when i draw from my custom control which uses polyline decorator and marker as symbol then after pressing clearlayer control it only clear polyline, no decorator clear or no marker clear.

In Short

Clearlayer function works on leaflet draw controls but not on custom controls and markers, what could be the cause.

Script

L.easyButton('
', function () { map.on('click', polylineFence1); }).addTo(map);// Add coordinate to the polyline var polylineFence1 = new L.Polyline([], { color: 'red' }); function fencePlace1(e) { myCheck = "wire"; // Add coordinate to the polyline polylineFence1.addLatLng(e.latlng).addTo(currentFeatureGroup); var decorator = L.polylineDecorator(polylineFence1, { patterns: [ // define a pattern of 10px-wide dashes, repeated every 20px on the line { offset: 5, repeat: '10px', symbol: new L.Symbol.marker() } ] }).addTo(currentFeatureGroup); } //clear layer L.easyButton('
', function () { currentFeatureGroup.clearLayers(); }).addTo(map);Console Error

Uncaught TypeError: layer.off is not a function

I know i am doing something wrong but can't figure out.If someone can help, any kind of help or reference will be appreciated...Thanks for your time



أكثر...
 
أعلى