Skip to content

Instantly share code, notes, and snippets.

@jonrandahl
Forked from up209d/leaflet.forceZIndex.js
Created September 13, 2023 09:31
Show Gist options
  • Select an option

  • Save jonrandahl/095b2c6c7e742253bfc1c97a6148a55e to your computer and use it in GitHub Desktop.

Select an option

Save jonrandahl/095b2c6c7e742253bfc1c97a6148a55e to your computer and use it in GitHub Desktop.
Force zIndex of Leaflet Marker
// Force zIndex of Leaflet
(function (global) {
const MarkerMixin = {
_updateZIndex: function (offset) { // offset at relative value, or put absolute zIndex value with forceZIndex
this._icon.style.zIndex = isNaN(this.options.forceZIndex) // any no-numeric = unassigned. 0 is ok for the forceZIndex
? (this._zIndex + offset)
: (this.options.forceZIndex + (this.options.zIndexOffset || 0))
},
setForceZIndex: function (forceZIndex) {
this.options.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