ClearLayer() not working for polyline Decorators

时间:2015-10-06 08:54:35

标签: javascript leaflet

I am working with leaflet api, where user draw shapes on images.

Clearly i am having problem with polyline decorator because clearlayer method doesn't seem to work for decorators, might be a bug or owner haven't implemented it yet.

When i try to clear layers, it give console error

Console Error

Uncaught TypeError: layer.off is not a function

Script

L.easyButton('<img src="ex.png">', 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('<img src="/assets/img/delete.png">', function () {
                    currentFeatureGroup.clearLayers();
                }).addTo(map);

If someone have any idea how to resolve it,please help...Thanks for your time

0 个答案:

没有答案