@octostar/map-component 0.1.30 → 0.1.32
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 +228 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +228 -53
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -0
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/dist/types/components/properties-panel.d.ts +33 -1
- package/dist/types/components/properties-panel.d.ts.map +1 -1
- package/dist/types/lib/map-editor-api.d.ts +13 -0
- package/dist/types/lib/map-editor-api.d.ts.map +1 -1
- package/package.json +1 -1
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, entityCardPlacement = "tab", inlineEntityCardLabel = "Point Detail", 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;
|
|
@@ -4082,6 +4105,35 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
4082
4105
|
] }, key)) })
|
|
4083
4106
|
] })
|
|
4084
4107
|
] }),
|
|
4108
|
+
entityCardPlacement === "inline-above" && entityCardProvider && !hasMultipleSelection && (() => {
|
|
4109
|
+
const inlineCard = entityCardProvider({
|
|
4110
|
+
type: "Feature",
|
|
4111
|
+
id: feature.id,
|
|
4112
|
+
geometry: feature.geometry,
|
|
4113
|
+
properties: feature.properties
|
|
4114
|
+
});
|
|
4115
|
+
if (!inlineCard) return null;
|
|
4116
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4117
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { className: "!my-1.5" }),
|
|
4118
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4119
|
+
antd.Collapse,
|
|
4120
|
+
{
|
|
4121
|
+
size: "small",
|
|
4122
|
+
defaultActiveKey: ["inline-entity-card"],
|
|
4123
|
+
ghost: true,
|
|
4124
|
+
className: "[&_.ant-collapse-header]:!px-0 [&_.ant-collapse-header]:!py-1 [&_.ant-collapse-content-box]:!px-0 [&_.ant-collapse-content-box]:!py-1",
|
|
4125
|
+
items: [{
|
|
4126
|
+
key: "inline-entity-card",
|
|
4127
|
+
label: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
4128
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { className: "w-3 h-3 text-foreground" }),
|
|
4129
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] font-bold uppercase tracking-wide text-foreground", children: inlineEntityCardLabel })
|
|
4130
|
+
] }),
|
|
4131
|
+
children: inlineCard
|
|
4132
|
+
}]
|
|
4133
|
+
}
|
|
4134
|
+
)
|
|
4135
|
+
] });
|
|
4136
|
+
})(),
|
|
4085
4137
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { className: "!my-1.5" }),
|
|
4086
4138
|
/* @__PURE__ */ jsxRuntime.jsx(RecordFieldsSection, { feature }),
|
|
4087
4139
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { className: "!my-1.5" }),
|
|
@@ -4094,12 +4146,43 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
4094
4146
|
] })
|
|
4095
4147
|
] });
|
|
4096
4148
|
const panelContent = isRecord ? recordContent : propertiesContent;
|
|
4097
|
-
|
|
4098
|
-
|
|
4149
|
+
const COMMON_PANEL_CLASSES = "bg-background/95 floating-panel rounded-lg shadow-lg border border-border flex flex-col overflow-hidden";
|
|
4150
|
+
const EDGE_MARGIN = 16;
|
|
4151
|
+
const BOTTOM_MARGIN = 32;
|
|
4152
|
+
const computePanelPosition = (panelWidthPx, widthClass) => {
|
|
4153
|
+
if (!anchorEl) {
|
|
4154
|
+
return {
|
|
4155
|
+
className: `absolute top-4 right-4 z-10 ${widthClass} ${COMMON_PANEL_CLASSES}`,
|
|
4156
|
+
style: { maxHeight: "calc(100vh - 6rem)" }
|
|
4157
|
+
};
|
|
4158
|
+
}
|
|
4159
|
+
const anchorHidden = !anchorRect || anchorRect.width === 0 || anchorRect.height === 0 || anchorRect.bottom <= 0 || anchorRect.top >= window.innerHeight || anchorRect.right <= 0 || anchorRect.left >= window.innerWidth;
|
|
4160
|
+
if (anchorHidden) {
|
|
4161
|
+
return {
|
|
4162
|
+
className: `fixed ${widthClass} ${COMMON_PANEL_CLASSES} opacity-0 pointer-events-none`,
|
|
4163
|
+
// `display:none` (not just opacity:0) so the panel truly cannot
|
|
4164
|
+
// intercept clicks while hidden, even with `pointer-events: none`
|
|
4165
|
+
// disabled by a stray CSS rule somewhere upstream.
|
|
4166
|
+
style: { top: 0, left: 0, maxHeight: "calc(100vh - 6rem)", zIndex: 1e3, display: "none" }
|
|
4167
|
+
};
|
|
4168
|
+
}
|
|
4169
|
+
const top = Math.max(EDGE_MARGIN, anchorRect.top + EDGE_MARGIN);
|
|
4170
|
+
const desiredRight = window.innerWidth - anchorRect.right + EDGE_MARGIN;
|
|
4171
|
+
const right = Math.max(EDGE_MARGIN, Math.min(desiredRight, window.innerWidth - panelWidthPx - EDGE_MARGIN));
|
|
4172
|
+
const maxHeight = Math.max(160, window.innerHeight - top - BOTTOM_MARGIN);
|
|
4173
|
+
return {
|
|
4174
|
+
className: `fixed ${widthClass} ${COMMON_PANEL_CLASSES}`,
|
|
4175
|
+
style: { top, right, maxHeight, zIndex: 1e3 }
|
|
4176
|
+
};
|
|
4177
|
+
};
|
|
4178
|
+
const portalIfAnchored = (jsx2) => anchorEl ? reactDom.createPortal(jsx2, document.body) : jsx2;
|
|
4179
|
+
if (entityCardProvider && (entityCardPlacement !== "inline-above" || hasMultipleSelection)) {
|
|
4180
|
+
const cardsPositioned = computePanelPosition(320, "w-80");
|
|
4181
|
+
const cardsPanel = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4099
4182
|
"div",
|
|
4100
4183
|
{
|
|
4101
|
-
className:
|
|
4102
|
-
style:
|
|
4184
|
+
className: cardsPositioned.className,
|
|
4185
|
+
style: cardsPositioned.style,
|
|
4103
4186
|
"data-testid": "panel-properties",
|
|
4104
4187
|
children: [
|
|
4105
4188
|
/* @__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 +4310,14 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
4227
4310
|
]
|
|
4228
4311
|
}
|
|
4229
4312
|
);
|
|
4313
|
+
return portalIfAnchored(cardsPanel);
|
|
4230
4314
|
}
|
|
4231
|
-
|
|
4315
|
+
const positioned = computePanelPosition(288, "w-72");
|
|
4316
|
+
const panelJsx = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4232
4317
|
"div",
|
|
4233
4318
|
{
|
|
4234
|
-
className:
|
|
4235
|
-
style:
|
|
4319
|
+
className: positioned.className,
|
|
4320
|
+
style: positioned.style,
|
|
4236
4321
|
"data-testid": "panel-properties",
|
|
4237
4322
|
children: [
|
|
4238
4323
|
/* @__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 +4409,7 @@ function PropertiesPanel({ selectedFeatures, onUpdateProperties, onUpdateGeometr
|
|
|
4324
4409
|
]
|
|
4325
4410
|
}
|
|
4326
4411
|
);
|
|
4412
|
+
return portalIfAnchored(panelJsx);
|
|
4327
4413
|
}
|
|
4328
4414
|
function StatusIndicator({ featureCount, selectedCount = 0 }) {
|
|
4329
4415
|
const hasSelection = selectedCount > 0;
|
|
@@ -5748,6 +5834,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
5748
5834
|
onMapStateLoaded,
|
|
5749
5835
|
interceptGeoJSONFileLoad,
|
|
5750
5836
|
entityCardProvider,
|
|
5837
|
+
entityCardPlacement,
|
|
5838
|
+
inlineEntityCardLabel,
|
|
5751
5839
|
typePickerProvider,
|
|
5752
5840
|
contextMenuProvider,
|
|
5753
5841
|
featureSaveProvider,
|
|
@@ -5798,6 +5886,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
5798
5886
|
const handleMapStyleChangeRef = react.useRef(null);
|
|
5799
5887
|
const flightPath3DLayerId = react.useRef(null);
|
|
5800
5888
|
const update3DFlightPathsRef = react.useRef(null);
|
|
5889
|
+
const moveLabelsBeforeBasemapSymbolsRef = react.useRef(null);
|
|
5801
5890
|
const tooltipProviderRef = react.useRef(tooltipProvider);
|
|
5802
5891
|
tooltipProviderRef.current = tooltipProvider;
|
|
5803
5892
|
const restoreEnrichedGeoJSONRef = react.useRef(null);
|
|
@@ -5892,6 +5981,11 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
5892
5981
|
window.removeEventListener("error", handleGlobalError, true);
|
|
5893
5982
|
window.removeEventListener("unhandledrejection", handleUnhandledRejection, true);
|
|
5894
5983
|
if (tooltipElRef.current) {
|
|
5984
|
+
const cleanup = tooltipElRef.current._cleanup;
|
|
5985
|
+
try {
|
|
5986
|
+
cleanup == null ? void 0 : cleanup();
|
|
5987
|
+
} catch {
|
|
5988
|
+
}
|
|
5895
5989
|
try {
|
|
5896
5990
|
(_a = tooltipElRef.current.parentElement) == null ? void 0 : _a.removeChild(tooltipElRef.current);
|
|
5897
5991
|
} catch {
|
|
@@ -6212,7 +6306,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6212
6306
|
const sourceData = {
|
|
6213
6307
|
type: "FeatureCollection",
|
|
6214
6308
|
features: allFeatures.map((f) => {
|
|
6215
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
6309
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
6216
6310
|
const featureId = String(f.id);
|
|
6217
6311
|
const layer = featureToLayer.get(featureId);
|
|
6218
6312
|
const visualConfig = layer == null ? void 0 : layer.visualConfig;
|
|
@@ -6305,6 +6399,22 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6305
6399
|
});
|
|
6306
6400
|
}
|
|
6307
6401
|
const isFeatureSelected = selectedIds.includes(featureId) ? 1 : 0;
|
|
6402
|
+
let labelPriority = 100;
|
|
6403
|
+
if (isFeatureSelected) {
|
|
6404
|
+
labelPriority = 0;
|
|
6405
|
+
} else if (traceLabel) {
|
|
6406
|
+
labelPriority = 5;
|
|
6407
|
+
} else if (((_l = f.properties) == null ? void 0 : _l.kind) === "text") {
|
|
6408
|
+
labelPriority = ((_m = f.properties) == null ? void 0 : _m.fontWeight) === "bold" ? 8 : 10;
|
|
6409
|
+
} else {
|
|
6410
|
+
const idStr = String(featureId);
|
|
6411
|
+
let h = 0;
|
|
6412
|
+
for (let i = 0; i < idStr.length; i++) {
|
|
6413
|
+
h = (h << 5) - h + idStr.charCodeAt(i);
|
|
6414
|
+
h |= 0;
|
|
6415
|
+
}
|
|
6416
|
+
labelPriority = 100 + Math.abs(h) % 1e3;
|
|
6417
|
+
}
|
|
6308
6418
|
return {
|
|
6309
6419
|
type: "Feature",
|
|
6310
6420
|
id: featureId,
|
|
@@ -6327,10 +6437,11 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6327
6437
|
"stroke-width": strokeWidth,
|
|
6328
6438
|
"stroke-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? baseOpacity : 0,
|
|
6329
6439
|
fill: strokeColor,
|
|
6330
|
-
"fill-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? ((
|
|
6440
|
+
"fill-opacity": hideFlatFor3DOnly ? 0 : isTimelineVisible ? ((_n = f.properties) == null ? void 0 : _n["fill-opacity"]) ?? 0.2 : 0,
|
|
6331
6441
|
pointRadius,
|
|
6332
6442
|
isHiddenFor3DOnly: hideFlatFor3DOnly ? 1 : 0,
|
|
6333
|
-
isTimelineHidden: isTimelineVisible ? 0 : 1
|
|
6443
|
+
isTimelineHidden: isTimelineVisible ? 0 : 1,
|
|
6444
|
+
_labelPriority: labelPriority
|
|
6334
6445
|
}
|
|
6335
6446
|
};
|
|
6336
6447
|
})
|
|
@@ -6998,36 +7109,36 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6998
7109
|
// Text features: center anchor; others: top anchor
|
|
6999
7110
|
"text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
|
|
7000
7111
|
"text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
|
|
7001
|
-
//
|
|
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:
|
|
7112
|
+
// Native collision-based de-overlap.
|
|
7006
7113
|
//
|
|
7007
|
-
//
|
|
7008
|
-
//
|
|
7009
|
-
//
|
|
7010
|
-
//
|
|
7011
|
-
//
|
|
7012
|
-
//
|
|
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.
|
|
7114
|
+
// History: a prior PR turned collision off (`text-allow-overlap: true`)
|
|
7115
|
+
// because basemap symbol layers (city / POI / street names from Carto
|
|
7116
|
+
// Voyager etc.) were processed FIRST by MapLibre's collision pipeline
|
|
7117
|
+
// (lower z-order = placed earlier), so our entity labels lost against
|
|
7118
|
+
// every basemap label -- even on near-empty maps. With `false`, freshly
|
|
7119
|
+
// dropped points rendered no label at all.
|
|
7018
7120
|
//
|
|
7019
|
-
//
|
|
7020
|
-
//
|
|
7021
|
-
//
|
|
7121
|
+
// The fix has two parts:
|
|
7122
|
+
// 1. (here) Re-enable collision and use `symbol-sort-key` to control
|
|
7123
|
+
// intra-layer priority. Selected/text/trace features win against
|
|
7124
|
+
// ordinary points so they keep their labels when crowded.
|
|
7125
|
+
// 2. (see `moveLabelsBeforeBasemapSymbols` below) After each basemap
|
|
7126
|
+
// load, move `custom-labels` BEFORE basemap symbol layers in the
|
|
7127
|
+
// style stack. MapLibre processes collision in painter order, so
|
|
7128
|
+
// placing our layer earlier makes entity labels claim space
|
|
7129
|
+
// first and basemap labels yield to us.
|
|
7022
7130
|
//
|
|
7023
|
-
//
|
|
7024
|
-
//
|
|
7025
|
-
//
|
|
7026
|
-
//
|
|
7027
|
-
|
|
7028
|
-
"text-allow-overlap": true,
|
|
7131
|
+
// Net effect: dense clusters de-overlap automatically, important
|
|
7132
|
+
// features keep their labels, and basemap labels no longer suppress
|
|
7133
|
+
// entity labels. The auto-label threshold (autoLabelConfig.threshold)
|
|
7134
|
+
// remains as a hard cap for very dense viewports.
|
|
7135
|
+
"text-allow-overlap": false,
|
|
7029
7136
|
"text-ignore-placement": false,
|
|
7030
7137
|
"text-optional": true,
|
|
7138
|
+
"text-padding": 2,
|
|
7139
|
+
// Lower value = higher collision priority (placed first).
|
|
7140
|
+
// Computed per-feature in syncFeaturesToCustomLayers.
|
|
7141
|
+
"symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100],
|
|
7031
7142
|
// Bold font for text features with fontWeight=bold, trace labels, others regular
|
|
7032
7143
|
"text-font": [
|
|
7033
7144
|
"case",
|
|
@@ -7119,12 +7230,17 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7119
7230
|
}
|
|
7120
7231
|
});
|
|
7121
7232
|
if (tooltipElRef.current) {
|
|
7233
|
+
const prevCleanup = tooltipElRef.current._cleanup;
|
|
7234
|
+
try {
|
|
7235
|
+
prevCleanup == null ? void 0 : prevCleanup();
|
|
7236
|
+
} catch {
|
|
7237
|
+
}
|
|
7122
7238
|
(_a = tooltipElRef.current.parentElement) == null ? void 0 : _a.removeChild(tooltipElRef.current);
|
|
7123
7239
|
}
|
|
7124
7240
|
const tooltipEl2 = document.createElement("div");
|
|
7125
7241
|
tooltipEl2.className = "feature-tooltip-fixed";
|
|
7126
|
-
tooltipEl2.style.cssText = "position:
|
|
7127
|
-
|
|
7242
|
+
tooltipEl2.style.cssText = "position:fixed;z-index:1000;pointer-events:auto;display:none;max-width:480px;";
|
|
7243
|
+
document.body.appendChild(tooltipEl2);
|
|
7128
7244
|
tooltipElRef.current = tooltipEl2;
|
|
7129
7245
|
let tooltipLngLat = null;
|
|
7130
7246
|
let tooltipHideTimeout = null;
|
|
@@ -7139,17 +7255,20 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7139
7255
|
if (!tooltipLngLat || tooltipEl2.style.display === "none") return;
|
|
7140
7256
|
const point = mapInstance.project(tooltipLngLat);
|
|
7141
7257
|
const container = mapInstance.getContainer();
|
|
7142
|
-
const
|
|
7143
|
-
const
|
|
7144
|
-
|
|
7258
|
+
const rect = container.getBoundingClientRect();
|
|
7259
|
+
const ax = rect.left + point.x;
|
|
7260
|
+
const ay = rect.top + point.y;
|
|
7261
|
+
const vw = window.innerWidth;
|
|
7262
|
+
const vh = window.innerHeight;
|
|
7263
|
+
tooltipEl2.style.maxWidth = Math.min(480, vw - 24) + "px";
|
|
7145
7264
|
const tw = tooltipEl2.offsetWidth || 200;
|
|
7146
7265
|
const th = tooltipEl2.offsetHeight || 80;
|
|
7147
7266
|
const gap = 12;
|
|
7148
|
-
let left =
|
|
7149
|
-
let top =
|
|
7150
|
-
if (top < 4) top =
|
|
7151
|
-
if (left + tw >
|
|
7152
|
-
if (top + th >
|
|
7267
|
+
let left = ax < vw / 2 ? ax + gap : ax - tw - gap;
|
|
7268
|
+
let top = ay - th - gap;
|
|
7269
|
+
if (top < 4) top = ay + gap;
|
|
7270
|
+
if (left + tw > vw - 4) left = vw - tw - 4;
|
|
7271
|
+
if (top + th > vh - 4) top = vh - th - 4;
|
|
7153
7272
|
left = Math.max(4, left);
|
|
7154
7273
|
top = Math.max(4, top);
|
|
7155
7274
|
tooltipEl2.style.left = left + "px";
|
|
@@ -7175,6 +7294,13 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7175
7294
|
tooltipLngLatForPagination = null;
|
|
7176
7295
|
};
|
|
7177
7296
|
mapInstance.on("move", positionTooltip);
|
|
7297
|
+
const onWindowReposition = () => positionTooltip();
|
|
7298
|
+
window.addEventListener("scroll", onWindowReposition, { capture: true, passive: true });
|
|
7299
|
+
window.addEventListener("resize", onWindowReposition, { passive: true });
|
|
7300
|
+
tooltipEl2._cleanup = () => {
|
|
7301
|
+
window.removeEventListener("scroll", onWindowReposition, { capture: true });
|
|
7302
|
+
window.removeEventListener("resize", onWindowReposition);
|
|
7303
|
+
};
|
|
7178
7304
|
const scheduleTooltipHide = () => {
|
|
7179
7305
|
if (tooltipHideTimeout) clearTimeout(tooltipHideTimeout);
|
|
7180
7306
|
tooltipHideTimeout = setTimeout(() => {
|
|
@@ -7503,6 +7629,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7503
7629
|
if (styleUrl) {
|
|
7504
7630
|
const prefix = BASEMAP_LAYER_PREFIXES[baseMapStyle] || `${baseMapStyle}-`;
|
|
7505
7631
|
fetch(styleUrl).then((res) => res.json()).then((externalStyle) => {
|
|
7632
|
+
var _a2;
|
|
7506
7633
|
const addedLayerIds = [];
|
|
7507
7634
|
const resolveUrl = (url) => {
|
|
7508
7635
|
if (/^https?:\/\//.test(url)) return url;
|
|
@@ -7558,6 +7685,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7558
7685
|
}
|
|
7559
7686
|
basemapLayerIds.current.set(baseMapStyle, addedLayerIds);
|
|
7560
7687
|
loadedBasemaps.current.add(baseMapStyle);
|
|
7688
|
+
(_a2 = moveLabelsBeforeBasemapSymbolsRef.current) == null ? void 0 : _a2.call(moveLabelsBeforeBasemapSymbolsRef);
|
|
7561
7689
|
const triggerResize = () => {
|
|
7562
7690
|
try {
|
|
7563
7691
|
mapInstance.resize();
|
|
@@ -7788,6 +7916,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7788
7916
|
}
|
|
7789
7917
|
});
|
|
7790
7918
|
setSelectedFeatureIds(ids);
|
|
7919
|
+
selectedFeatureIdsRef.current = ids;
|
|
7791
7920
|
setShowProperties(ids.length > 0);
|
|
7792
7921
|
syncRef.current();
|
|
7793
7922
|
onFeatureSelect == null ? void 0 : onFeatureSelect(e.features);
|
|
@@ -9231,13 +9360,22 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9231
9360
|
} else {
|
|
9232
9361
|
let updatedFeature;
|
|
9233
9362
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
9234
|
-
var _a2;
|
|
9363
|
+
var _a2, _b2;
|
|
9235
9364
|
const idx = features.findIndex((f) => String(f.id) === featureId);
|
|
9236
9365
|
if (idx !== -1) {
|
|
9237
9366
|
const f = features[idx];
|
|
9367
|
+
let hasRealChange = false;
|
|
9368
|
+
Object.entries(normalizedProperties).forEach(([key, value]) => {
|
|
9369
|
+
var _a3;
|
|
9370
|
+
const oldVal = (_a3 = f.properties) == null ? void 0 : _a3[key];
|
|
9371
|
+
if (JSON.stringify(oldVal) !== JSON.stringify(value)) hasRealChange = true;
|
|
9372
|
+
});
|
|
9373
|
+
const currentUnsaved = (_a2 = f.properties) == null ? void 0 : _a2._unsaved;
|
|
9238
9374
|
f.properties = { ...f.properties, ...normalizedProperties };
|
|
9239
|
-
if (!externalPersistence
|
|
9240
|
-
|
|
9375
|
+
if (!externalPersistence && hasRealChange && currentUnsaved !== false) {
|
|
9376
|
+
f.properties._unsaved = true;
|
|
9377
|
+
}
|
|
9378
|
+
if (properties.kind === "text" || ((_b2 = f.properties) == null ? void 0 : _b2.kind) === "text") {
|
|
9241
9379
|
delete f.properties.text;
|
|
9242
9380
|
}
|
|
9243
9381
|
layerTemporalCacheRef.current.delete(layerId);
|
|
@@ -9612,6 +9750,38 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9612
9750
|
});
|
|
9613
9751
|
return total;
|
|
9614
9752
|
}, [layers, getLayerUnsavedCount]);
|
|
9753
|
+
const moveLabelsBeforeBasemapSymbols = react.useCallback(() => {
|
|
9754
|
+
if (!map.current) return;
|
|
9755
|
+
const m = map.current;
|
|
9756
|
+
if (!m.getLayer("custom-labels")) return;
|
|
9757
|
+
const style = m.getStyle();
|
|
9758
|
+
const allLayers = (style == null ? void 0 : style.layers) || [];
|
|
9759
|
+
const basemapPrefixes = Object.values(BASEMAP_LAYER_PREFIXES);
|
|
9760
|
+
const isVisible = (l) => {
|
|
9761
|
+
var _a;
|
|
9762
|
+
const v = (_a = l.layout) == null ? void 0 : _a.visibility;
|
|
9763
|
+
return v === void 0 || v === "visible";
|
|
9764
|
+
};
|
|
9765
|
+
const firstVisibleBasemapSymbol = allLayers.find(
|
|
9766
|
+
(l) => l.type === "symbol" && basemapPrefixes.some((p) => l.id.startsWith(p)) && isVisible(l)
|
|
9767
|
+
);
|
|
9768
|
+
try {
|
|
9769
|
+
if (firstVisibleBasemapSymbol) {
|
|
9770
|
+
m.moveLayer("custom-labels", firstVisibleBasemapSymbol.id);
|
|
9771
|
+
if (m.getLayer("custom-arrow-labels")) {
|
|
9772
|
+
m.moveLayer("custom-arrow-labels", firstVisibleBasemapSymbol.id);
|
|
9773
|
+
}
|
|
9774
|
+
} else {
|
|
9775
|
+
m.moveLayer("custom-labels");
|
|
9776
|
+
if (m.getLayer("custom-arrow-labels")) {
|
|
9777
|
+
m.moveLayer("custom-arrow-labels");
|
|
9778
|
+
}
|
|
9779
|
+
}
|
|
9780
|
+
} catch (e) {
|
|
9781
|
+
console.warn("[map-component] moveLabelsBeforeBasemapSymbols failed:", (e == null ? void 0 : e.message) ?? e);
|
|
9782
|
+
}
|
|
9783
|
+
}, []);
|
|
9784
|
+
moveLabelsBeforeBasemapSymbolsRef.current = moveLabelsBeforeBasemapSymbols;
|
|
9615
9785
|
const loadBasemapStyle = react.useCallback(async (styleName) => {
|
|
9616
9786
|
if (!map.current) return [];
|
|
9617
9787
|
const mapInstance = map.current;
|
|
@@ -9675,12 +9845,13 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9675
9845
|
}
|
|
9676
9846
|
}
|
|
9677
9847
|
}
|
|
9848
|
+
moveLabelsBeforeBasemapSymbols();
|
|
9678
9849
|
return addedLayerIds;
|
|
9679
9850
|
} catch (e) {
|
|
9680
9851
|
console.error(`Failed to load basemap style ${styleName}:`, e);
|
|
9681
9852
|
return [];
|
|
9682
9853
|
}
|
|
9683
|
-
}, []);
|
|
9854
|
+
}, [moveLabelsBeforeBasemapSymbols]);
|
|
9684
9855
|
const setBasemapVisibility = react.useCallback((styleName, visible) => {
|
|
9685
9856
|
if (!map.current) return;
|
|
9686
9857
|
const mapInstance = map.current;
|
|
@@ -9732,7 +9903,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9732
9903
|
}
|
|
9733
9904
|
setBasemapVisibility(style, true);
|
|
9734
9905
|
setCurrentMapStyle(style);
|
|
9735
|
-
|
|
9906
|
+
moveLabelsBeforeBasemapSymbols();
|
|
9907
|
+
}, [loadBasemapStyle, setBasemapVisibility, moveLabelsBeforeBasemapSymbols]);
|
|
9736
9908
|
handleMapStyleChangeRef.current = handleMapStyleChange;
|
|
9737
9909
|
const handleUpdateTraceConfig = react.useCallback((layerId, config) => {
|
|
9738
9910
|
setLayers((prev) => prev.map(
|
|
@@ -12393,7 +12565,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12393
12565
|
}
|
|
12394
12566
|
),
|
|
12395
12567
|
showProperties && selectedFeatures.length > 0 && (() => {
|
|
12396
|
-
var _a;
|
|
12568
|
+
var _a, _b;
|
|
12397
12569
|
const firstFeatureId = (_a = selectedFeatures[0]) == null ? void 0 : _a.id;
|
|
12398
12570
|
const featureLayer = layers.find((l) => l.featureIds.includes(firstFeatureId));
|
|
12399
12571
|
const layerName = featureLayer == null ? void 0 : featureLayer.name;
|
|
@@ -12417,6 +12589,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12417
12589
|
layerId,
|
|
12418
12590
|
autoFocusLabel,
|
|
12419
12591
|
entityCardProvider,
|
|
12592
|
+
entityCardPlacement,
|
|
12593
|
+
inlineEntityCardLabel,
|
|
12420
12594
|
typePickerProvider,
|
|
12421
12595
|
featureSaveProvider,
|
|
12422
12596
|
featureRefreshProvider,
|
|
@@ -12429,7 +12603,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12429
12603
|
onCopyFeaturesToLayer: handleCopyFeaturesToLayer,
|
|
12430
12604
|
onCreateLayerAndMoveFeatures: handleCreateLayerAndMoveFeatures,
|
|
12431
12605
|
onCreateLayerAndCopyFeatures: handleCreateLayerAndCopyFeatures,
|
|
12432
|
-
getFeatureColor: (featureId) => selectedFeatureColors.get(featureId)
|
|
12606
|
+
getFeatureColor: (featureId) => selectedFeatureColors.get(featureId),
|
|
12607
|
+
anchorEl: isMapLoaded ? ((_b = map.current) == null ? void 0 : _b.getContainer()) ?? null : null
|
|
12433
12608
|
}
|
|
12434
12609
|
);
|
|
12435
12610
|
})(),
|