From a458bdd37ce8508cc0edef86e08da0c0c0da9bed Mon Sep 17 00:00:00 2001 From: Dmytro Khylko <55889080+DmytroKhylko@users.noreply.github.com> Date: Wed, 11 Nov 2026 18:10:22 +0200 Subject: [PATCH] Added stacking order for map marker overlays based on their position in the Overlays list (#15967) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: assign dedicated Leaflet pane per marker data layer for z-index control Each marker data layer gets its own Leaflet pane (tb-markers-pane-{index}) whose z-index is derived from the layer's position in the Overlays list (first = highest = always on top). Stacking order is controlled by drag-reordering layers in the editor — no new settings field required. Pane z-index formula: 600 + (count - 1 - index), keeping marker layers above overlayPane (400) and below tooltipPane/popupPane (650/700). Both individual markers and cluster icons are assigned to the layer's pane via the `pane` and `clusterPane` Leaflet marker options respectively. Scope: markers data layers only; polygons, circles, polylines and trips retain their default Leaflet panes. * refactor: move marker pane ownership to TbMap and keep panes below markerPane --- .../lib/maps/data-layer/markers-data-layer.ts | 15 +++++++++++++-- .../home/components/widget/lib/maps/map.ts | 11 ++++++++++- .../app/shared/models/widget/maps/map.models.ts | 6 ++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/markers-data-layer.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/markers-data-layer.ts index 43946b1294..0cfc7df437 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/markers-data-layer.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/markers-data-layer.ts @@ -409,7 +409,8 @@ class TbMarkerDataLayerItem extends TbLatestDataLayerItem; + private readonly markersPane: string; constructor(protected map: TbMap, - inputSettings: MarkersDataLayerSettings) { + inputSettings: MarkersDataLayerSettings, + markersLayerIndex: number) { super(map, inputSettings); + this.markersPane = map.getMarkersPane(markersLayerIndex); + if (this.markersClusterContainer) { + L.Util.setOptions(this.markersClusterContainer, {clusterPane: this.markersPane}); + } + } + + public getMarkersPane(): string { + return this.markersPane; } public dataLayerType(): MapDataLayerType { diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map.ts index 3d2a901ecb..68000d04b3 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/map.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/map.ts @@ -9,6 +9,7 @@ import { mapDataLayerTypes, MapScale, MapType, + markersPaneZIndex, mergeMapDatasources, parseCenterPosition, TbCircleData, @@ -264,7 +265,7 @@ export abstract class TbMap { this.latestDataLayers = []; this.tripDataLayers = []; if (this.settings.markers) { - const markersDataLayers = this.settings.markers.map(settings => new TbMarkersDataLayer(this, settings)); + const markersDataLayers = this.settings.markers.map((settings, i) => new TbMarkersDataLayer(this, settings, i)); this.dataLayers.push(...markersDataLayers); this.latestDataLayers.push(...markersDataLayers); } @@ -1220,6 +1221,14 @@ export abstract class TbMap { } } + public getMarkersPane(markersLayerIndex: number): string { + const name = `tb-markers-pane-${markersLayerIndex}`; + if (!this.map.getPane(name)) { + this.map.createPane(name).style.zIndex = String(markersPaneZIndex(markersLayerIndex)); + } + return name; + } + public storeShapePattern(patternId: string, pattern: L.TB.Pattern): void { pattern.addTo(this.map); this.shapePatternStorage[patternId] = { diff --git a/ui-ngx/src/app/shared/models/widget/maps/map.models.ts b/ui-ngx/src/app/shared/models/widget/maps/map.models.ts index 9644d83537..921a2b036d 100644 --- a/ui-ngx/src/app/shared/models/widget/maps/map.models.ts +++ b/ui-ngx/src/app/shared/models/widget/maps/map.models.ts @@ -32,6 +32,12 @@ import { MarkerIconContainer, MarkerShape } from '@shared/models/widget/maps/mar import { ColorRange, DateFormatSettings, simpleDateFormat } from '@shared/models/widget-settings.models'; import _ from 'lodash'; +const LEAFLET_SHADOW_PANE_Z_INDEX = 500; +const LEAFLET_MARKER_PANE_Z_INDEX = 600; + +export const markersPaneZIndex = (markersLayerIndex: number): number => + Math.max(LEAFLET_SHADOW_PANE_Z_INDEX + 1, LEAFLET_MARKER_PANE_Z_INDEX - 1 - markersLayerIndex); + export enum MapType { geoMap = 'geoMap', image = 'image'