diff --git a/src/layer/vector/SVG.js b/src/layer/vector/SVG.js index 3e9bee108..0d089e149 100644 --- a/src/layer/vector/SVG.js +++ b/src/layer/vector/SVG.js @@ -95,12 +95,16 @@ export const SVG = Renderer.extend({ _addPath(layer) { if (!this._rootGroup) { this._initContainer(); } this._rootGroup.appendChild(layer._path); - layer.addInteractiveTarget(layer._path); + if (layer.options.interactive) { + layer.addInteractiveTarget(layer._path); + } }, _removePath(layer) { layer._path.remove(); - layer.removeInteractiveTarget(layer._path); + if (layer.options.interactive) { + layer.removeInteractiveTarget(layer._path); + } delete this._layers[stamp(layer)]; }, @@ -147,8 +151,10 @@ export const SVG = Renderer.extend({ if (options.interactive) { path.classList.add('leaflet-interactive'); + layer.addInteractiveTarget(path); } else { path.classList.remove('leaflet-interactive'); + layer.removeInteractiveTarget(path); } },