@octostar/map-component 0.1.30 → 0.1.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -10,6 +10,7 @@ import { saveAs } from "file-saver";
10
10
  import { MousePointer2, Square, Hexagon, Circle, MoreVertical, ChevronDown, Filter, X, Move, Ruler, Search, Scan, Pencil, Database, MapPin, Minus, Pentagon, Type, MoveRight, Undo2, Redo2, Trash2, Navigation, Loader2, Map as Map$1, Satellite, FolderOpen, Upload, Download, MoreHorizontal, Focus, Box, Layers, Plus, ChevronRight, Eye, EyeOff, Lock, Smile, Package, Copy, FolderInput, Save, Calendar, Palette, Blend, RefreshCw, ExternalLink, Info, SkipBack, Pause, Play, Clock, AlertTriangle, TestTube, Users, GripVertical, Plane, FileJson, Check, Phone, Car, AlertCircle } from "lucide-react";
11
11
  import { clsx } from "clsx";
12
12
  import { twMerge } from "tailwind-merge";
13
+ import { createPortal } from "react-dom";
13
14
  import { format } from "date-fns";
14
15
  import { create } from "zustand";
15
16
  import dayjs from "dayjs";
@@ -2951,7 +2952,7 @@ function RecordFieldsSection({ feature }) {
2951
2952
  );
2952
2953
  }
2953
2954
  let persistedTabPreference = "properties";
2954
- function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometry, onClose, isEditMode = true, isReadOnlyLayer = false, layerName, layerId, autoFocusLabel = false, entityCardProvider, typePickerProvider, featureSaveProvider, featureRefreshProvider, onFeatureSaved, onDeleteFeatures, onOpenInNewTab, onEntityContextMenu, layers, onMoveFeaturesToLayer, onCopyFeaturesToLayer, onCreateLayerAndMoveFeatures, onCreateLayerAndCopyFeatures, getFeatureColor }) {
2955
+ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometry, onClose, isEditMode = true, isReadOnlyLayer = false, layerName, layerId, autoFocusLabel = false, entityCardProvider, typePickerProvider, featureSaveProvider, featureRefreshProvider, onFeatureSaved, onDeleteFeatures, onOpenInNewTab, onEntityContextMenu, layers, onMoveFeaturesToLayer, onCopyFeaturesToLayer, onCreateLayerAndMoveFeatures, onCreateLayerAndCopyFeatures, getFeatureColor, anchorEl }) {
2955
2956
  var _a, _b, _c, _d, _e;
2956
2957
  const feature = selectedFeatures[0];
2957
2958
  const { toast } = useToast();
@@ -2987,6 +2988,28 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
2987
2988
  }
2988
2989
  prevMultiSelection.current = hasMultipleSelection;
2989
2990
  }, [hasMultipleSelection, entityCardProvider]);
2991
+ const [anchorRect, setAnchorRect] = useState(
2992
+ () => anchorEl ? anchorEl.getBoundingClientRect() : null
2993
+ );
2994
+ useEffect(() => {
2995
+ if (!anchorEl) {
2996
+ setAnchorRect(null);
2997
+ return;
2998
+ }
2999
+ const update = () => {
3000
+ setAnchorRect(anchorEl.getBoundingClientRect());
3001
+ };
3002
+ update();
3003
+ window.addEventListener("resize", update, { passive: true });
3004
+ window.addEventListener("scroll", update, { capture: true, passive: true });
3005
+ const observer = typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : null;
3006
+ observer == null ? void 0 : observer.observe(anchorEl);
3007
+ return () => {
3008
+ window.removeEventListener("resize", update);
3009
+ window.removeEventListener("scroll", update, { capture: true });
3010
+ observer == null ? void 0 : observer.disconnect();
3011
+ };
3012
+ }, [anchorEl]);
2990
3013
  const featureIds = selectedFeatures.map((f) => f.id);
2991
3014
  const targetLayers = (layers == null ? void 0 : layers.filter((l) => l.id !== layerId && !l.readOnly)) ?? [];
2992
3015
  const hasLayerActions = targetLayers.length > 0 || onCreateLayerAndMoveFeatures || onCreateLayerAndCopyFeatures;
@@ -4073,12 +4096,43 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
4073
4096
  ] })
4074
4097
  ] });
4075
4098
  const panelContent = isRecord ? recordContent : propertiesContent;
4099
+ const COMMON_PANEL_CLASSES = "bg-background/95 floating-panel rounded-lg shadow-lg border border-border flex flex-col overflow-hidden";
4100
+ const EDGE_MARGIN = 16;
4101
+ const BOTTOM_MARGIN = 32;
4102
+ const computePanelPosition = (panelWidthPx, widthClass) => {
4103
+ if (!anchorEl) {
4104
+ return {
4105
+ className: `absolute top-4 right-4 z-10 ${widthClass} ${COMMON_PANEL_CLASSES}`,
4106
+ style: { maxHeight: "calc(100vh - 6rem)" }
4107
+ };
4108
+ }
4109
+ const anchorHidden = !anchorRect || anchorRect.width === 0 || anchorRect.height === 0 || anchorRect.bottom <= 0 || anchorRect.top >= window.innerHeight || anchorRect.right <= 0 || anchorRect.left >= window.innerWidth;
4110
+ if (anchorHidden) {
4111
+ return {
4112
+ className: `fixed ${widthClass} ${COMMON_PANEL_CLASSES} opacity-0 pointer-events-none`,
4113
+ // `display:none` (not just opacity:0) so the panel truly cannot
4114
+ // intercept clicks while hidden, even with `pointer-events: none`
4115
+ // disabled by a stray CSS rule somewhere upstream.
4116
+ style: { top: 0, left: 0, maxHeight: "calc(100vh - 6rem)", zIndex: 1e3, display: "none" }
4117
+ };
4118
+ }
4119
+ const top = Math.max(EDGE_MARGIN, anchorRect.top + EDGE_MARGIN);
4120
+ const desiredRight = window.innerWidth - anchorRect.right + EDGE_MARGIN;
4121
+ const right = Math.max(EDGE_MARGIN, Math.min(desiredRight, window.innerWidth - panelWidthPx - EDGE_MARGIN));
4122
+ const maxHeight = Math.max(160, window.innerHeight - top - BOTTOM_MARGIN);
4123
+ return {
4124
+ className: `fixed ${widthClass} ${COMMON_PANEL_CLASSES}`,
4125
+ style: { top, right, maxHeight, zIndex: 1e3 }
4126
+ };
4127
+ };
4128
+ const portalIfAnchored = (jsx2) => anchorEl ? createPortal(jsx2, document.body) : jsx2;
4076
4129
  if (entityCardProvider) {
4077
- return /* @__PURE__ */ jsxs(
4130
+ const cardsPositioned = computePanelPosition(320, "w-80");
4131
+ const cardsPanel = /* @__PURE__ */ jsxs(
4078
4132
  "div",
4079
4133
  {
4080
- className: "absolute top-4 right-4 z-10 w-80 bg-background/95 floating-panel rounded-lg shadow-lg border border-border flex flex-col overflow-hidden",
4081
- style: { maxHeight: "calc(100vh - 6rem)" },
4134
+ className: cardsPositioned.className,
4135
+ style: cardsPositioned.style,
4082
4136
  "data-testid": "panel-properties",
4083
4137
  children: [
4084
4138
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 px-3 py-2.5 border-b border-border shrink-0 bg-background/95", children: [
@@ -4206,12 +4260,14 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
4206
4260
  ]
4207
4261
  }
4208
4262
  );
4263
+ return portalIfAnchored(cardsPanel);
4209
4264
  }
4210
- return /* @__PURE__ */ jsxs(
4265
+ const positioned = computePanelPosition(288, "w-72");
4266
+ const panelJsx = /* @__PURE__ */ jsxs(
4211
4267
  "div",
4212
4268
  {
4213
- className: "absolute top-4 right-4 z-10 w-72 bg-background/95 floating-panel rounded-lg shadow-lg border border-border flex flex-col overflow-hidden",
4214
- style: { maxHeight: "calc(100vh - 6rem)" },
4269
+ className: positioned.className,
4270
+ style: positioned.style,
4215
4271
  "data-testid": "panel-properties",
4216
4272
  children: [
4217
4273
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 px-3 py-2.5 border-b border-border shrink-0 bg-background/95", children: [
@@ -4303,6 +4359,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
4303
4359
  ]
4304
4360
  }
4305
4361
  );
4362
+ return portalIfAnchored(panelJsx);
4306
4363
  }
4307
4364
  function StatusIndicator({ featureCount, selectedCount = 0 }) {
4308
4365
  const hasSelection = selectedCount > 0;
@@ -5777,6 +5834,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
5777
5834
  const handleMapStyleChangeRef = useRef(null);
5778
5835
  const flightPath3DLayerId = useRef(null);
5779
5836
  const update3DFlightPathsRef = useRef(null);
5837
+ const moveLabelsBeforeBasemapSymbolsRef = useRef(null);
5780
5838
  const tooltipProviderRef = useRef(tooltipProvider);
5781
5839
  tooltipProviderRef.current = tooltipProvider;
5782
5840
  const restoreEnrichedGeoJSONRef = useRef(null);
@@ -5871,6 +5929,11 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
5871
5929
  window.removeEventListener("error", handleGlobalError, true);
5872
5930
  window.removeEventListener("unhandledrejection", handleUnhandledRejection, true);
5873
5931
  if (tooltipElRef.current) {
5932
+ const cleanup = tooltipElRef.current._cleanup;
5933
+ try {
5934
+ cleanup == null ? void 0 : cleanup();
5935
+ } catch {
5936
+ }
5874
5937
  try {
5875
5938
  (_a = tooltipElRef.current.parentElement) == null ? void 0 : _a.removeChild(tooltipElRef.current);
5876
5939
  } catch {
@@ -6191,7 +6254,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
6191
6254
  const sourceData = {
6192
6255
  type: "FeatureCollection",
6193
6256
  features: allFeatures.map((f) => {
6194
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
6257
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
6195
6258
  const featureId = String(f.id);
6196
6259
  const layer = featureToLayer.get(featureId);
6197
6260
  const visualConfig = layer == null ? void 0 : layer.visualConfig;
@@ -6284,6 +6347,22 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
6284
6347
  });
6285
6348
  }
6286
6349
  const isFeatureSelected = selectedIds.includes(featureId) ? 1 : 0;
6350
+ let labelPriority = 100;
6351
+ if (isFeatureSelected) {
6352
+ labelPriority = 0;
6353
+ } else if (traceLabel) {
6354
+ labelPriority = 5;
6355
+ } else if (((_l = f.properties) == null ? void 0 : _l.kind) === "text") {
6356
+ labelPriority = ((_m = f.properties) == null ? void 0 : _m.fontWeight) === "bold" ? 8 : 10;
6357
+ } else {
6358
+ const idStr = String(featureId);
6359
+ let h = 0;
6360
+ for (let i = 0; i < idStr.length; i++) {
6361
+ h = (h << 5) - h + idStr.charCodeAt(i);
6362
+ h |= 0;
6363
+ }
6364
+ labelPriority = 100 + Math.abs(h) % 1e3;
6365
+ }
6287
6366
  return {
6288
6367
  type: "Feature",
6289
6368
  id: featureId,
@@ -6306,10 +6385,11 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
6306
6385
  "stroke-width": strokeWidth,
6307
6386
  "stroke-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? baseOpacity : 0,
6308
6387
  fill: strokeColor,
6309
- "fill-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? ((_l = f.properties) == null ? void 0 : _l["fill-opacity"]) ?? 0.2 : 0,
6388
+ "fill-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? ((_n = f.properties) == null ? void 0 : _n["fill-opacity"]) ?? 0.2 : 0,
6310
6389
  pointRadius,
6311
6390
  isHiddenFor3DOnly: hideFlatFor3DOnly ? 1 : 0,
6312
- isTimelineHidden: isTimelineVisible ? 0 : 1
6391
+ isTimelineHidden: isTimelineVisible ? 0 : 1,
6392
+ _labelPriority: labelPriority
6313
6393
  }
6314
6394
  };
6315
6395
  })
@@ -6977,36 +7057,36 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
6977
7057
  // Text features: center anchor; others: top anchor
6978
7058
  "text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
6979
7059
  "text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
6980
- // Always allow overlap for every label this layer renders.
6981
- //
6982
- // The earlier `false` branch (for plain entity labels) was an
6983
- // attempt to thin dense clusters via MapLibre's collision
6984
- // detection. In practice it interacts poorly with this layer:
7060
+ // Native collision-based de-overlap.
6985
7061
  //
6986
- // - The `custom-labels` symbol layer has NO `icon-image`, so
6987
- // `text-optional: true` cannot fall back to "show icon, drop
6988
- // text". MapLibre instead drops the entire symbol when the
6989
- // text loses collision.
6990
- // - Vector basemaps (Streets / OSM Bright) place dense
6991
- // city / POI / street labels everywhere, and our entity
6992
- // label loses against ANY of them even at low zoom on an
6993
- // otherwise-empty map. The PR that introduced collision
6994
- // here only anticipated this happening "occasionally at
6995
- // very high zoom", but the empirical behaviour is far more
6996
- // aggressive.
7062
+ // History: a prior PR turned collision off (`text-allow-overlap: true`)
7063
+ // because basemap symbol layers (city / POI / street names from Carto
7064
+ // Voyager etc.) were processed FIRST by MapLibre's collision pipeline
7065
+ // (lower z-order = placed earlier), so our entity labels lost against
7066
+ // every basemap label -- even on near-empty maps. With `false`, freshly
7067
+ // dropped points rendered no label at all.
6997
7068
  //
6998
- // Net effect of the previous setting: a freshly dropped entity
6999
- // point on an editable layer rendered NO label at all on most
7000
- // basemaps, even with a single feature on the map.
7069
+ // The fix has two parts:
7070
+ // 1. (here) Re-enable collision and use `symbol-sort-key` to control
7071
+ // intra-layer priority. Selected/text/trace features win against
7072
+ // ordinary points so they keep their labels when crowded.
7073
+ // 2. (see `moveLabelsBeforeBasemapSymbols` below) After each basemap
7074
+ // load, move `custom-labels` BEFORE basemap symbol layers in the
7075
+ // style stack. MapLibre processes collision in painter order, so
7076
+ // placing our layer earlier makes entity labels claim space
7077
+ // first and basemap labels yield to us.
7001
7078
  //
7002
- // Reverting to unconditional `true` restores the previous
7003
- // (working) behaviour. Stacking in dense clusters should be
7004
- // addressed via a different mechanism (cluster/heatmap modes
7005
- // already exist; per-zoom font-size or a host-supplied
7006
- // collision opt-in are options if revisited).
7007
- "text-allow-overlap": true,
7079
+ // Net effect: dense clusters de-overlap automatically, important
7080
+ // features keep their labels, and basemap labels no longer suppress
7081
+ // entity labels. The auto-label threshold (autoLabelConfig.threshold)
7082
+ // remains as a hard cap for very dense viewports.
7083
+ "text-allow-overlap": false,
7008
7084
  "text-ignore-placement": false,
7009
7085
  "text-optional": true,
7086
+ "text-padding": 2,
7087
+ // Lower value = higher collision priority (placed first).
7088
+ // Computed per-feature in syncFeaturesToCustomLayers.
7089
+ "symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100],
7010
7090
  // Bold font for text features with fontWeight=bold, trace labels, others regular
7011
7091
  "text-font": [
7012
7092
  "case",
@@ -7098,12 +7178,17 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
7098
7178
  }
7099
7179
  });
7100
7180
  if (tooltipElRef.current) {
7181
+ const prevCleanup = tooltipElRef.current._cleanup;
7182
+ try {
7183
+ prevCleanup == null ? void 0 : prevCleanup();
7184
+ } catch {
7185
+ }
7101
7186
  (_a = tooltipElRef.current.parentElement) == null ? void 0 : _a.removeChild(tooltipElRef.current);
7102
7187
  }
7103
7188
  const tooltipEl2 = document.createElement("div");
7104
7189
  tooltipEl2.className = "feature-tooltip-fixed";
7105
- tooltipEl2.style.cssText = "position:absolute;z-index:50;pointer-events:auto;display:none;max-width:320px;";
7106
- mapInstance.getContainer().appendChild(tooltipEl2);
7190
+ tooltipEl2.style.cssText = "position:fixed;z-index:1000;pointer-events:auto;display:none;max-width:480px;";
7191
+ document.body.appendChild(tooltipEl2);
7107
7192
  tooltipElRef.current = tooltipEl2;
7108
7193
  let tooltipLngLat = null;
7109
7194
  let tooltipHideTimeout = null;
@@ -7118,17 +7203,20 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
7118
7203
  if (!tooltipLngLat || tooltipEl2.style.display === "none") return;
7119
7204
  const point = mapInstance.project(tooltipLngLat);
7120
7205
  const container = mapInstance.getContainer();
7121
- const cw = container.clientWidth;
7122
- const ch = container.clientHeight;
7123
- tooltipEl2.style.maxWidth = Math.min(320, cw - 24) + "px";
7206
+ const rect = container.getBoundingClientRect();
7207
+ const ax = rect.left + point.x;
7208
+ const ay = rect.top + point.y;
7209
+ const vw = window.innerWidth;
7210
+ const vh = window.innerHeight;
7211
+ tooltipEl2.style.maxWidth = Math.min(480, vw - 24) + "px";
7124
7212
  const tw = tooltipEl2.offsetWidth || 200;
7125
7213
  const th = tooltipEl2.offsetHeight || 80;
7126
7214
  const gap = 12;
7127
- let left = point.x < cw / 2 ? point.x + gap : point.x - tw - gap;
7128
- let top = point.y - th - gap;
7129
- if (top < 4) top = point.y + gap;
7130
- if (left + tw > cw - 4) left = cw - tw - 4;
7131
- if (top + th > ch - 4) top = ch - th - 4;
7215
+ let left = ax < vw / 2 ? ax + gap : ax - tw - gap;
7216
+ let top = ay - th - gap;
7217
+ if (top < 4) top = ay + gap;
7218
+ if (left + tw > vw - 4) left = vw - tw - 4;
7219
+ if (top + th > vh - 4) top = vh - th - 4;
7132
7220
  left = Math.max(4, left);
7133
7221
  top = Math.max(4, top);
7134
7222
  tooltipEl2.style.left = left + "px";
@@ -7154,6 +7242,13 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
7154
7242
  tooltipLngLatForPagination = null;
7155
7243
  };
7156
7244
  mapInstance.on("move", positionTooltip);
7245
+ const onWindowReposition = () => positionTooltip();
7246
+ window.addEventListener("scroll", onWindowReposition, { capture: true, passive: true });
7247
+ window.addEventListener("resize", onWindowReposition, { passive: true });
7248
+ tooltipEl2._cleanup = () => {
7249
+ window.removeEventListener("scroll", onWindowReposition, { capture: true });
7250
+ window.removeEventListener("resize", onWindowReposition);
7251
+ };
7157
7252
  const scheduleTooltipHide = () => {
7158
7253
  if (tooltipHideTimeout) clearTimeout(tooltipHideTimeout);
7159
7254
  tooltipHideTimeout = setTimeout(() => {
@@ -7482,6 +7577,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
7482
7577
  if (styleUrl) {
7483
7578
  const prefix = BASEMAP_LAYER_PREFIXES[baseMapStyle] || `${baseMapStyle}-`;
7484
7579
  fetch(styleUrl).then((res) => res.json()).then((externalStyle) => {
7580
+ var _a2;
7485
7581
  const addedLayerIds = [];
7486
7582
  const resolveUrl = (url) => {
7487
7583
  if (/^https?:\/\//.test(url)) return url;
@@ -7537,6 +7633,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
7537
7633
  }
7538
7634
  basemapLayerIds.current.set(baseMapStyle, addedLayerIds);
7539
7635
  loadedBasemaps.current.add(baseMapStyle);
7636
+ (_a2 = moveLabelsBeforeBasemapSymbolsRef.current) == null ? void 0 : _a2.call(moveLabelsBeforeBasemapSymbolsRef);
7540
7637
  const triggerResize = () => {
7541
7638
  try {
7542
7639
  mapInstance.resize();
@@ -9591,6 +9688,38 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
9591
9688
  });
9592
9689
  return total;
9593
9690
  }, [layers, getLayerUnsavedCount]);
9691
+ const moveLabelsBeforeBasemapSymbols = useCallback(() => {
9692
+ if (!map.current) return;
9693
+ const m = map.current;
9694
+ if (!m.getLayer("custom-labels")) return;
9695
+ const style = m.getStyle();
9696
+ const allLayers = (style == null ? void 0 : style.layers) || [];
9697
+ const basemapPrefixes = Object.values(BASEMAP_LAYER_PREFIXES);
9698
+ const isVisible = (l) => {
9699
+ var _a;
9700
+ const v = (_a = l.layout) == null ? void 0 : _a.visibility;
9701
+ return v === void 0 || v === "visible";
9702
+ };
9703
+ const firstVisibleBasemapSymbol = allLayers.find(
9704
+ (l) => l.type === "symbol" && basemapPrefixes.some((p) => l.id.startsWith(p)) && isVisible(l)
9705
+ );
9706
+ try {
9707
+ if (firstVisibleBasemapSymbol) {
9708
+ m.moveLayer("custom-labels", firstVisibleBasemapSymbol.id);
9709
+ if (m.getLayer("custom-arrow-labels")) {
9710
+ m.moveLayer("custom-arrow-labels", firstVisibleBasemapSymbol.id);
9711
+ }
9712
+ } else {
9713
+ m.moveLayer("custom-labels");
9714
+ if (m.getLayer("custom-arrow-labels")) {
9715
+ m.moveLayer("custom-arrow-labels");
9716
+ }
9717
+ }
9718
+ } catch (e) {
9719
+ console.warn("[map-component] moveLabelsBeforeBasemapSymbols failed:", (e == null ? void 0 : e.message) ?? e);
9720
+ }
9721
+ }, []);
9722
+ moveLabelsBeforeBasemapSymbolsRef.current = moveLabelsBeforeBasemapSymbols;
9594
9723
  const loadBasemapStyle = useCallback(async (styleName) => {
9595
9724
  if (!map.current) return [];
9596
9725
  const mapInstance = map.current;
@@ -9654,12 +9783,13 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
9654
9783
  }
9655
9784
  }
9656
9785
  }
9786
+ moveLabelsBeforeBasemapSymbols();
9657
9787
  return addedLayerIds;
9658
9788
  } catch (e) {
9659
9789
  console.error(`Failed to load basemap style ${styleName}:`, e);
9660
9790
  return [];
9661
9791
  }
9662
- }, []);
9792
+ }, [moveLabelsBeforeBasemapSymbols]);
9663
9793
  const setBasemapVisibility = useCallback((styleName, visible) => {
9664
9794
  if (!map.current) return;
9665
9795
  const mapInstance = map.current;
@@ -9711,7 +9841,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
9711
9841
  }
9712
9842
  setBasemapVisibility(style, true);
9713
9843
  setCurrentMapStyle(style);
9714
- }, [loadBasemapStyle, setBasemapVisibility]);
9844
+ moveLabelsBeforeBasemapSymbols();
9845
+ }, [loadBasemapStyle, setBasemapVisibility, moveLabelsBeforeBasemapSymbols]);
9715
9846
  handleMapStyleChangeRef.current = handleMapStyleChange;
9716
9847
  const handleUpdateTraceConfig = useCallback((layerId, config) => {
9717
9848
  setLayers((prev) => prev.map(
@@ -12372,7 +12503,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
12372
12503
  }
12373
12504
  ),
12374
12505
  showProperties && selectedFeatures.length > 0 && (() => {
12375
- var _a;
12506
+ var _a, _b;
12376
12507
  const firstFeatureId = (_a = selectedFeatures[0]) == null ? void 0 : _a.id;
12377
12508
  const featureLayer = layers.find((l) => l.featureIds.includes(firstFeatureId));
12378
12509
  const layerName = featureLayer == null ? void 0 : featureLayer.name;
@@ -12408,7 +12539,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
12408
12539
  onCopyFeaturesToLayer: handleCopyFeaturesToLayer,
12409
12540
  onCreateLayerAndMoveFeatures: handleCreateLayerAndMoveFeatures,
12410
12541
  onCreateLayerAndCopyFeatures: handleCreateLayerAndCopyFeatures,
12411
- getFeatureColor: (featureId) => selectedFeatureColors.get(featureId)
12542
+ getFeatureColor: (featureId) => selectedFeatureColors.get(featureId),
12543
+ anchorEl: isMapLoaded ? ((_b = map.current) == null ? void 0 : _b.getContainer()) ?? null : null
12412
12544
  }
12413
12545
  );
12414
12546
  })(),