@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.cjs CHANGED
@@ -12,6 +12,7 @@ const fileSaver = require("file-saver");
12
12
  const lucideReact = require("lucide-react");
13
13
  const clsx = require("clsx");
14
14
  const tailwindMerge = require("tailwind-merge");
15
+ const reactDom = require("react-dom");
15
16
  const dateFns = require("date-fns");
16
17
  const zustand = require("zustand");
17
18
  const dayjs = require("dayjs");
@@ -2972,7 +2973,7 @@ function RecordFieldsSection({ feature }) {
2972
2973
  );
2973
2974
  }
2974
2975
  let persistedTabPreference = "properties";
2975
- 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 }) {
2976
+ 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 }) {
2976
2977
  var _a, _b, _c, _d, _e;
2977
2978
  const feature = selectedFeatures[0];
2978
2979
  const { toast } = useToast();
@@ -3008,6 +3009,28 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
3008
3009
  }
3009
3010
  prevMultiSelection.current = hasMultipleSelection;
3010
3011
  }, [hasMultipleSelection, entityCardProvider]);
3012
+ const [anchorRect, setAnchorRect] = react.useState(
3013
+ () => anchorEl ? anchorEl.getBoundingClientRect() : null
3014
+ );
3015
+ react.useEffect(() => {
3016
+ if (!anchorEl) {
3017
+ setAnchorRect(null);
3018
+ return;
3019
+ }
3020
+ const update = () => {
3021
+ setAnchorRect(anchorEl.getBoundingClientRect());
3022
+ };
3023
+ update();
3024
+ window.addEventListener("resize", update, { passive: true });
3025
+ window.addEventListener("scroll", update, { capture: true, passive: true });
3026
+ const observer = typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : null;
3027
+ observer == null ? void 0 : observer.observe(anchorEl);
3028
+ return () => {
3029
+ window.removeEventListener("resize", update);
3030
+ window.removeEventListener("scroll", update, { capture: true });
3031
+ observer == null ? void 0 : observer.disconnect();
3032
+ };
3033
+ }, [anchorEl]);
3011
3034
  const featureIds = selectedFeatures.map((f) => f.id);
3012
3035
  const targetLayers = (layers == null ? void 0 : layers.filter((l) => l.id !== layerId && !l.readOnly)) ?? [];
3013
3036
  const hasLayerActions = targetLayers.length > 0 || onCreateLayerAndMoveFeatures || onCreateLayerAndCopyFeatures;
@@ -4094,12 +4117,43 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
4094
4117
  ] })
4095
4118
  ] });
4096
4119
  const panelContent = isRecord ? recordContent : propertiesContent;
4120
+ const COMMON_PANEL_CLASSES = "bg-background/95 floating-panel rounded-lg shadow-lg border border-border flex flex-col overflow-hidden";
4121
+ const EDGE_MARGIN = 16;
4122
+ const BOTTOM_MARGIN = 32;
4123
+ const computePanelPosition = (panelWidthPx, widthClass) => {
4124
+ if (!anchorEl) {
4125
+ return {
4126
+ className: `absolute top-4 right-4 z-10 ${widthClass} ${COMMON_PANEL_CLASSES}`,
4127
+ style: { maxHeight: "calc(100vh - 6rem)" }
4128
+ };
4129
+ }
4130
+ const anchorHidden = !anchorRect || anchorRect.width === 0 || anchorRect.height === 0 || anchorRect.bottom <= 0 || anchorRect.top >= window.innerHeight || anchorRect.right <= 0 || anchorRect.left >= window.innerWidth;
4131
+ if (anchorHidden) {
4132
+ return {
4133
+ className: `fixed ${widthClass} ${COMMON_PANEL_CLASSES} opacity-0 pointer-events-none`,
4134
+ // `display:none` (not just opacity:0) so the panel truly cannot
4135
+ // intercept clicks while hidden, even with `pointer-events: none`
4136
+ // disabled by a stray CSS rule somewhere upstream.
4137
+ style: { top: 0, left: 0, maxHeight: "calc(100vh - 6rem)", zIndex: 1e3, display: "none" }
4138
+ };
4139
+ }
4140
+ const top = Math.max(EDGE_MARGIN, anchorRect.top + EDGE_MARGIN);
4141
+ const desiredRight = window.innerWidth - anchorRect.right + EDGE_MARGIN;
4142
+ const right = Math.max(EDGE_MARGIN, Math.min(desiredRight, window.innerWidth - panelWidthPx - EDGE_MARGIN));
4143
+ const maxHeight = Math.max(160, window.innerHeight - top - BOTTOM_MARGIN);
4144
+ return {
4145
+ className: `fixed ${widthClass} ${COMMON_PANEL_CLASSES}`,
4146
+ style: { top, right, maxHeight, zIndex: 1e3 }
4147
+ };
4148
+ };
4149
+ const portalIfAnchored = (jsx2) => anchorEl ? reactDom.createPortal(jsx2, document.body) : jsx2;
4097
4150
  if (entityCardProvider) {
4098
- return /* @__PURE__ */ jsxRuntime.jsxs(
4151
+ const cardsPositioned = computePanelPosition(320, "w-80");
4152
+ const cardsPanel = /* @__PURE__ */ jsxRuntime.jsxs(
4099
4153
  "div",
4100
4154
  {
4101
- 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",
4102
- style: { maxHeight: "calc(100vh - 6rem)" },
4155
+ className: cardsPositioned.className,
4156
+ style: cardsPositioned.style,
4103
4157
  "data-testid": "panel-properties",
4104
4158
  children: [
4105
4159
  /* @__PURE__ */ jsxRuntime.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: [
@@ -4227,12 +4281,14 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
4227
4281
  ]
4228
4282
  }
4229
4283
  );
4284
+ return portalIfAnchored(cardsPanel);
4230
4285
  }
4231
- return /* @__PURE__ */ jsxRuntime.jsxs(
4286
+ const positioned = computePanelPosition(288, "w-72");
4287
+ const panelJsx = /* @__PURE__ */ jsxRuntime.jsxs(
4232
4288
  "div",
4233
4289
  {
4234
- 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",
4235
- style: { maxHeight: "calc(100vh - 6rem)" },
4290
+ className: positioned.className,
4291
+ style: positioned.style,
4236
4292
  "data-testid": "panel-properties",
4237
4293
  children: [
4238
4294
  /* @__PURE__ */ jsxRuntime.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: [
@@ -4324,6 +4380,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
4324
4380
  ]
4325
4381
  }
4326
4382
  );
4383
+ return portalIfAnchored(panelJsx);
4327
4384
  }
4328
4385
  function StatusIndicator({ featureCount, selectedCount = 0 }) {
4329
4386
  const hasSelection = selectedCount > 0;
@@ -5798,6 +5855,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
5798
5855
  const handleMapStyleChangeRef = react.useRef(null);
5799
5856
  const flightPath3DLayerId = react.useRef(null);
5800
5857
  const update3DFlightPathsRef = react.useRef(null);
5858
+ const moveLabelsBeforeBasemapSymbolsRef = react.useRef(null);
5801
5859
  const tooltipProviderRef = react.useRef(tooltipProvider);
5802
5860
  tooltipProviderRef.current = tooltipProvider;
5803
5861
  const restoreEnrichedGeoJSONRef = react.useRef(null);
@@ -5892,6 +5950,11 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
5892
5950
  window.removeEventListener("error", handleGlobalError, true);
5893
5951
  window.removeEventListener("unhandledrejection", handleUnhandledRejection, true);
5894
5952
  if (tooltipElRef.current) {
5953
+ const cleanup = tooltipElRef.current._cleanup;
5954
+ try {
5955
+ cleanup == null ? void 0 : cleanup();
5956
+ } catch {
5957
+ }
5895
5958
  try {
5896
5959
  (_a = tooltipElRef.current.parentElement) == null ? void 0 : _a.removeChild(tooltipElRef.current);
5897
5960
  } catch {
@@ -6212,7 +6275,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
6212
6275
  const sourceData = {
6213
6276
  type: "FeatureCollection",
6214
6277
  features: allFeatures.map((f) => {
6215
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
6278
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
6216
6279
  const featureId = String(f.id);
6217
6280
  const layer = featureToLayer.get(featureId);
6218
6281
  const visualConfig = layer == null ? void 0 : layer.visualConfig;
@@ -6305,6 +6368,22 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
6305
6368
  });
6306
6369
  }
6307
6370
  const isFeatureSelected = selectedIds.includes(featureId) ? 1 : 0;
6371
+ let labelPriority = 100;
6372
+ if (isFeatureSelected) {
6373
+ labelPriority = 0;
6374
+ } else if (traceLabel) {
6375
+ labelPriority = 5;
6376
+ } else if (((_l = f.properties) == null ? void 0 : _l.kind) === "text") {
6377
+ labelPriority = ((_m = f.properties) == null ? void 0 : _m.fontWeight) === "bold" ? 8 : 10;
6378
+ } else {
6379
+ const idStr = String(featureId);
6380
+ let h = 0;
6381
+ for (let i = 0; i < idStr.length; i++) {
6382
+ h = (h << 5) - h + idStr.charCodeAt(i);
6383
+ h |= 0;
6384
+ }
6385
+ labelPriority = 100 + Math.abs(h) % 1e3;
6386
+ }
6308
6387
  return {
6309
6388
  type: "Feature",
6310
6389
  id: featureId,
@@ -6327,10 +6406,11 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
6327
6406
  "stroke-width": strokeWidth,
6328
6407
  "stroke-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? baseOpacity : 0,
6329
6408
  fill: strokeColor,
6330
- "fill-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? ((_l = f.properties) == null ? void 0 : _l["fill-opacity"]) ?? 0.2 : 0,
6409
+ "fill-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? ((_n = f.properties) == null ? void 0 : _n["fill-opacity"]) ?? 0.2 : 0,
6331
6410
  pointRadius,
6332
6411
  isHiddenFor3DOnly: hideFlatFor3DOnly ? 1 : 0,
6333
- isTimelineHidden: isTimelineVisible ? 0 : 1
6412
+ isTimelineHidden: isTimelineVisible ? 0 : 1,
6413
+ _labelPriority: labelPriority
6334
6414
  }
6335
6415
  };
6336
6416
  })
@@ -6998,36 +7078,36 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
6998
7078
  // Text features: center anchor; others: top anchor
6999
7079
  "text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
7000
7080
  "text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
7001
- // Always allow overlap for every label this layer renders.
7002
- //
7003
- // The earlier `false` branch (for plain entity labels) was an
7004
- // attempt to thin dense clusters via MapLibre's collision
7005
- // detection. In practice it interacts poorly with this layer:
7081
+ // Native collision-based de-overlap.
7006
7082
  //
7007
- // - The `custom-labels` symbol layer has NO `icon-image`, so
7008
- // `text-optional: true` cannot fall back to "show icon, drop
7009
- // text". MapLibre instead drops the entire symbol when the
7010
- // text loses collision.
7011
- // - Vector basemaps (Streets / OSM Bright) place dense
7012
- // city / POI / street labels everywhere, and our entity
7013
- // label loses against ANY of them even at low zoom on an
7014
- // otherwise-empty map. The PR that introduced collision
7015
- // here only anticipated this happening "occasionally at
7016
- // very high zoom", but the empirical behaviour is far more
7017
- // aggressive.
7083
+ // History: a prior PR turned collision off (`text-allow-overlap: true`)
7084
+ // because basemap symbol layers (city / POI / street names from Carto
7085
+ // Voyager etc.) were processed FIRST by MapLibre's collision pipeline
7086
+ // (lower z-order = placed earlier), so our entity labels lost against
7087
+ // every basemap label -- even on near-empty maps. With `false`, freshly
7088
+ // dropped points rendered no label at all.
7018
7089
  //
7019
- // Net effect of the previous setting: a freshly dropped entity
7020
- // point on an editable layer rendered NO label at all on most
7021
- // basemaps, even with a single feature on the map.
7090
+ // The fix has two parts:
7091
+ // 1. (here) Re-enable collision and use `symbol-sort-key` to control
7092
+ // intra-layer priority. Selected/text/trace features win against
7093
+ // ordinary points so they keep their labels when crowded.
7094
+ // 2. (see `moveLabelsBeforeBasemapSymbols` below) After each basemap
7095
+ // load, move `custom-labels` BEFORE basemap symbol layers in the
7096
+ // style stack. MapLibre processes collision in painter order, so
7097
+ // placing our layer earlier makes entity labels claim space
7098
+ // first and basemap labels yield to us.
7022
7099
  //
7023
- // Reverting to unconditional `true` restores the previous
7024
- // (working) behaviour. Stacking in dense clusters should be
7025
- // addressed via a different mechanism (cluster/heatmap modes
7026
- // already exist; per-zoom font-size or a host-supplied
7027
- // collision opt-in are options if revisited).
7028
- "text-allow-overlap": true,
7100
+ // Net effect: dense clusters de-overlap automatically, important
7101
+ // features keep their labels, and basemap labels no longer suppress
7102
+ // entity labels. The auto-label threshold (autoLabelConfig.threshold)
7103
+ // remains as a hard cap for very dense viewports.
7104
+ "text-allow-overlap": false,
7029
7105
  "text-ignore-placement": false,
7030
7106
  "text-optional": true,
7107
+ "text-padding": 2,
7108
+ // Lower value = higher collision priority (placed first).
7109
+ // Computed per-feature in syncFeaturesToCustomLayers.
7110
+ "symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100],
7031
7111
  // Bold font for text features with fontWeight=bold, trace labels, others regular
7032
7112
  "text-font": [
7033
7113
  "case",
@@ -7119,12 +7199,17 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
7119
7199
  }
7120
7200
  });
7121
7201
  if (tooltipElRef.current) {
7202
+ const prevCleanup = tooltipElRef.current._cleanup;
7203
+ try {
7204
+ prevCleanup == null ? void 0 : prevCleanup();
7205
+ } catch {
7206
+ }
7122
7207
  (_a = tooltipElRef.current.parentElement) == null ? void 0 : _a.removeChild(tooltipElRef.current);
7123
7208
  }
7124
7209
  const tooltipEl2 = document.createElement("div");
7125
7210
  tooltipEl2.className = "feature-tooltip-fixed";
7126
- tooltipEl2.style.cssText = "position:absolute;z-index:50;pointer-events:auto;display:none;max-width:320px;";
7127
- mapInstance.getContainer().appendChild(tooltipEl2);
7211
+ tooltipEl2.style.cssText = "position:fixed;z-index:1000;pointer-events:auto;display:none;max-width:480px;";
7212
+ document.body.appendChild(tooltipEl2);
7128
7213
  tooltipElRef.current = tooltipEl2;
7129
7214
  let tooltipLngLat = null;
7130
7215
  let tooltipHideTimeout = null;
@@ -7139,17 +7224,20 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
7139
7224
  if (!tooltipLngLat || tooltipEl2.style.display === "none") return;
7140
7225
  const point = mapInstance.project(tooltipLngLat);
7141
7226
  const container = mapInstance.getContainer();
7142
- const cw = container.clientWidth;
7143
- const ch = container.clientHeight;
7144
- tooltipEl2.style.maxWidth = Math.min(320, cw - 24) + "px";
7227
+ const rect = container.getBoundingClientRect();
7228
+ const ax = rect.left + point.x;
7229
+ const ay = rect.top + point.y;
7230
+ const vw = window.innerWidth;
7231
+ const vh = window.innerHeight;
7232
+ tooltipEl2.style.maxWidth = Math.min(480, vw - 24) + "px";
7145
7233
  const tw = tooltipEl2.offsetWidth || 200;
7146
7234
  const th = tooltipEl2.offsetHeight || 80;
7147
7235
  const gap = 12;
7148
- let left = point.x < cw / 2 ? point.x + gap : point.x - tw - gap;
7149
- let top = point.y - th - gap;
7150
- if (top < 4) top = point.y + gap;
7151
- if (left + tw > cw - 4) left = cw - tw - 4;
7152
- if (top + th > ch - 4) top = ch - th - 4;
7236
+ let left = ax < vw / 2 ? ax + gap : ax - tw - gap;
7237
+ let top = ay - th - gap;
7238
+ if (top < 4) top = ay + gap;
7239
+ if (left + tw > vw - 4) left = vw - tw - 4;
7240
+ if (top + th > vh - 4) top = vh - th - 4;
7153
7241
  left = Math.max(4, left);
7154
7242
  top = Math.max(4, top);
7155
7243
  tooltipEl2.style.left = left + "px";
@@ -7175,6 +7263,13 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
7175
7263
  tooltipLngLatForPagination = null;
7176
7264
  };
7177
7265
  mapInstance.on("move", positionTooltip);
7266
+ const onWindowReposition = () => positionTooltip();
7267
+ window.addEventListener("scroll", onWindowReposition, { capture: true, passive: true });
7268
+ window.addEventListener("resize", onWindowReposition, { passive: true });
7269
+ tooltipEl2._cleanup = () => {
7270
+ window.removeEventListener("scroll", onWindowReposition, { capture: true });
7271
+ window.removeEventListener("resize", onWindowReposition);
7272
+ };
7178
7273
  const scheduleTooltipHide = () => {
7179
7274
  if (tooltipHideTimeout) clearTimeout(tooltipHideTimeout);
7180
7275
  tooltipHideTimeout = setTimeout(() => {
@@ -7503,6 +7598,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
7503
7598
  if (styleUrl) {
7504
7599
  const prefix = BASEMAP_LAYER_PREFIXES[baseMapStyle] || `${baseMapStyle}-`;
7505
7600
  fetch(styleUrl).then((res) => res.json()).then((externalStyle) => {
7601
+ var _a2;
7506
7602
  const addedLayerIds = [];
7507
7603
  const resolveUrl = (url) => {
7508
7604
  if (/^https?:\/\//.test(url)) return url;
@@ -7558,6 +7654,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
7558
7654
  }
7559
7655
  basemapLayerIds.current.set(baseMapStyle, addedLayerIds);
7560
7656
  loadedBasemaps.current.add(baseMapStyle);
7657
+ (_a2 = moveLabelsBeforeBasemapSymbolsRef.current) == null ? void 0 : _a2.call(moveLabelsBeforeBasemapSymbolsRef);
7561
7658
  const triggerResize = () => {
7562
7659
  try {
7563
7660
  mapInstance.resize();
@@ -9612,6 +9709,38 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9612
9709
  });
9613
9710
  return total;
9614
9711
  }, [layers, getLayerUnsavedCount]);
9712
+ const moveLabelsBeforeBasemapSymbols = react.useCallback(() => {
9713
+ if (!map.current) return;
9714
+ const m = map.current;
9715
+ if (!m.getLayer("custom-labels")) return;
9716
+ const style = m.getStyle();
9717
+ const allLayers = (style == null ? void 0 : style.layers) || [];
9718
+ const basemapPrefixes = Object.values(BASEMAP_LAYER_PREFIXES);
9719
+ const isVisible = (l) => {
9720
+ var _a;
9721
+ const v = (_a = l.layout) == null ? void 0 : _a.visibility;
9722
+ return v === void 0 || v === "visible";
9723
+ };
9724
+ const firstVisibleBasemapSymbol = allLayers.find(
9725
+ (l) => l.type === "symbol" && basemapPrefixes.some((p) => l.id.startsWith(p)) && isVisible(l)
9726
+ );
9727
+ try {
9728
+ if (firstVisibleBasemapSymbol) {
9729
+ m.moveLayer("custom-labels", firstVisibleBasemapSymbol.id);
9730
+ if (m.getLayer("custom-arrow-labels")) {
9731
+ m.moveLayer("custom-arrow-labels", firstVisibleBasemapSymbol.id);
9732
+ }
9733
+ } else {
9734
+ m.moveLayer("custom-labels");
9735
+ if (m.getLayer("custom-arrow-labels")) {
9736
+ m.moveLayer("custom-arrow-labels");
9737
+ }
9738
+ }
9739
+ } catch (e) {
9740
+ console.warn("[map-component] moveLabelsBeforeBasemapSymbols failed:", (e == null ? void 0 : e.message) ?? e);
9741
+ }
9742
+ }, []);
9743
+ moveLabelsBeforeBasemapSymbolsRef.current = moveLabelsBeforeBasemapSymbols;
9615
9744
  const loadBasemapStyle = react.useCallback(async (styleName) => {
9616
9745
  if (!map.current) return [];
9617
9746
  const mapInstance = map.current;
@@ -9675,12 +9804,13 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9675
9804
  }
9676
9805
  }
9677
9806
  }
9807
+ moveLabelsBeforeBasemapSymbols();
9678
9808
  return addedLayerIds;
9679
9809
  } catch (e) {
9680
9810
  console.error(`Failed to load basemap style ${styleName}:`, e);
9681
9811
  return [];
9682
9812
  }
9683
- }, []);
9813
+ }, [moveLabelsBeforeBasemapSymbols]);
9684
9814
  const setBasemapVisibility = react.useCallback((styleName, visible) => {
9685
9815
  if (!map.current) return;
9686
9816
  const mapInstance = map.current;
@@ -9732,7 +9862,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9732
9862
  }
9733
9863
  setBasemapVisibility(style, true);
9734
9864
  setCurrentMapStyle(style);
9735
- }, [loadBasemapStyle, setBasemapVisibility]);
9865
+ moveLabelsBeforeBasemapSymbols();
9866
+ }, [loadBasemapStyle, setBasemapVisibility, moveLabelsBeforeBasemapSymbols]);
9736
9867
  handleMapStyleChangeRef.current = handleMapStyleChange;
9737
9868
  const handleUpdateTraceConfig = react.useCallback((layerId, config) => {
9738
9869
  setLayers((prev) => prev.map(
@@ -12393,7 +12524,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
12393
12524
  }
12394
12525
  ),
12395
12526
  showProperties && selectedFeatures.length > 0 && (() => {
12396
- var _a;
12527
+ var _a, _b;
12397
12528
  const firstFeatureId = (_a = selectedFeatures[0]) == null ? void 0 : _a.id;
12398
12529
  const featureLayer = layers.find((l) => l.featureIds.includes(firstFeatureId));
12399
12530
  const layerName = featureLayer == null ? void 0 : featureLayer.name;
@@ -12429,7 +12560,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
12429
12560
  onCopyFeaturesToLayer: handleCopyFeaturesToLayer,
12430
12561
  onCreateLayerAndMoveFeatures: handleCreateLayerAndMoveFeatures,
12431
12562
  onCreateLayerAndCopyFeatures: handleCreateLayerAndCopyFeatures,
12432
- getFeatureColor: (featureId) => selectedFeatureColors.get(featureId)
12563
+ getFeatureColor: (featureId) => selectedFeatureColors.get(featureId),
12564
+ anchorEl: isMapLoaded ? ((_b = map.current) == null ? void 0 : _b.getContainer()) ?? null : null
12433
12565
  }
12434
12566
  );
12435
12567
  })(),