Skip to content

Apply zIndex and opacity consistently on image, video and SVG overlays - #10533

Merged
mourner merged 1 commit into
Leaflet:mainfrom
b84330808:fix-overlay-zindex-opacity
Nov 6, 2026
Merged

mourner merged 1 commit into
Leaflet:mainfrom
b84330808:fix-overlay-zindex-opacity

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

VideoOverlay and SVGOverlay override _initImage, which was the only place that applied options.zIndex when an overlay is added. So they ignore the option, and also a setZIndex call made before adding them, which is what LayersControl's autoZIndex does.

Two more cases of a 0 being ignored:

  • new ImageOverlay(url, bounds, {zIndex: 0}) sets no z-index
  • overlay.setStyle({opacity: 0}) does nothing, so featureGroup.setStyle({opacity: 0}) hides the paths and leaves the overlays visible

zIndex is now applied in onAdd, for all three classes.

One thing to check: the zIndex: 1 default now also reaches video and SVG overlays, so they stack above vector layers in the overlay pane, as image overlays already do.

VideoOverlay and SVGOverlay override _initImage, which was the only place
that applied options.zIndex on add, so they ignored the option as well as
a setZIndex call made before adding them, which is what LayersControl's
autoZIndex does. ImageOverlay skipped a zIndex of 0, and setStyle ignored
an opacity of 0.
@mourner
mourner merged commit e69418f into Leaflet:main Nov 6, 2026
10 checks passed
simon04 pushed a commit to maplair/maplair that referenced this pull request Nov 8, 2026
The zIndex option was applied only to images created by the overlay and
only if not 0, and a z-index set before adding the overlay was lost for
supplied elements. setStyle() now also applies an opacity of 0. The specs
of the video overlay use data URIs instead of fetching videos.

Leaflet: Leaflet/Leaflet#10533
Leaflet commits: Leaflet/Leaflet@e69418f, Leaflet/Leaflet@339c6b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants