Browse Source

Added stacking order for map marker overlays based on their position in the Overlays list (#15967)

* 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
pull/16631/head
Dmytro Khylko 3 weeks ago
committed by GitHub
parent
commit
a458bdd37c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 15
      ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/markers-data-layer.ts
  2. 11
      ui-ngx/src/app/modules/home/components/widget/lib/maps/map.ts
  3. 6
      ui-ngx/src/app/shared/models/widget/maps/map.models.ts

15
ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/markers-data-layer.ts

@ -409,7 +409,8 @@ class TbMarkerDataLayerItem extends TbLatestDataLayerItem<MarkersDataLayerSettin
this.marker = L.marker(location, {
tbMarkerData: data,
snapIgnore: !this.dataLayer.isSnappable(),
bubblingMouseEvents: !this.dataLayer.isEditMode()
bubblingMouseEvents: !this.dataLayer.isEditMode(),
pane: this.dataLayer.getMarkersPane()
});
this.updateMarkerIcon(data, dsData);
return this.marker;
@ -562,10 +563,20 @@ export class TbMarkersDataLayer extends TbLatestMapDataLayer<MarkersDataLayerSet
private markersClusterContainer: L.MarkerClusterGroup;
private clusterMarkerColorFunction: CompiledTbFunction<ClusterMarkerColorFunction>;
private readonly markersPane: string;
constructor(protected map: TbMap<any>,
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 {

11
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<S extends BaseMapSettings> {
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<S extends BaseMapSettings> {
}
}
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] = {

6
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'

Loading…
Cancel
Save