-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Leaflet layers being interactive and/or draggable (for example,…
… markers) when ALS layer is not being selected. Added setInteractive(), getInteractive() and isInteractive() methods to L.Layer (thanks to Piero "Jadaw1n" Steinger; comment: Leaflet/Leaflet#5442 (comment); home page: https://github.com/Jadaw1n)
- Loading branch information
Showing
2 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Sets this layer to be interactive or not. | ||
* @param interactive {boolean} If true, this layer will be interactive. Otherwise layer will be static. | ||
* @author Piero "Jadaw1n" Steinger. Home page: https://github.com/Jadaw1n | ||
*/ | ||
L.Layer.prototype.setInteractive = function (interactive) { | ||
if (this.getLayers) { | ||
this.getLayers().forEach(layer => { | ||
layer.setInteractive(interactive); | ||
}); | ||
return; | ||
} | ||
if (!this._path) { | ||
return; | ||
} | ||
|
||
this.options.interactive = interactive; | ||
|
||
if (interactive) { | ||
L.DomUtil.addClass(this._path, 'leaflet-interactive'); | ||
} else { | ||
L.DomUtil.removeClass(this._path, 'leaflet-interactive'); | ||
} | ||
}; | ||
|
||
/** | ||
* @return {boolean} True, if this layer is interactive. False otherwise. | ||
*/ | ||
L.Layer.prototype.getInteractive = function () { | ||
return this.options.interactive; | ||
} | ||
|
||
/** | ||
* Alias for Layer.getInteractive() | ||
* @return {boolean} True, if this layer is interactive. False otherwise. | ||
*/ | ||
L.Layer.prototype.isInteractive = function () { | ||
return this.getInteractive(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters