Last active
September 13, 2023 09:31
-
-
Save up209d/4c68f2391f2302e510eb81aa8bcd4514 to your computer and use it in GitHub Desktop.
Force zIndex of Leaflet Marker
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
// Force zIndex of Leaflet | |
(function(global){ | |
var MarkerMixin = { | |
_updateZIndex: function (offset) { | |
this._icon.style.zIndex = this.options.forceZIndex ? (this.options.forceZIndex + (this.options.zIndexOffset || 0)) : (this._zIndex + offset); | |
}, | |
setForceZIndex: function(forceZIndex) { | |
this.options.forceZIndex = forceZIndex ? forceZIndex : null; | |
} | |
}; | |
if (global) global.include(MarkerMixin); | |
})(L.Marker); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Let me add little fix, to allow
forceZIndex = 0
. Check whether forceZIndex is assigned with isNaN(). Any numeric should be considered as good value.