@octostar/map-component 0.2.14 → 0.2.16
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 +929 -296
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +930 -297
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/cluster-pie-chart.d.ts.map +1 -1
- package/dist/types/components/layers-panel.d.ts +30 -4
- package/dist/types/components/layers-panel.d.ts.map +1 -1
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/cluster-count.d.ts +43 -0
- package/dist/types/lib/cluster-count.d.ts.map +1 -0
- package/dist/types/lib/cluster-gradient.d.ts +37 -0
- package/dist/types/lib/cluster-gradient.d.ts.map +1 -0
- package/dist/types/lib/color-utils.d.ts +67 -0
- package/dist/types/lib/color-utils.d.ts.map +1 -1
- package/dist/types/lib/label-pinning.d.ts +31 -0
- package/dist/types/lib/label-pinning.d.ts.map +1 -0
- package/dist/types/lib/layer-features.d.ts +27 -0
- package/dist/types/lib/layer-features.d.ts.map +1 -0
- package/dist/types/lib/property-utils.d.ts +7 -0
- package/dist/types/lib/property-utils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1092,6 +1092,30 @@ function downloadBlob(blob, filename) {
|
|
|
1092
1092
|
anchor.remove();
|
|
1093
1093
|
setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
1094
1094
|
}
|
|
1095
|
+
function collectLayerFeatures(layer, sources) {
|
|
1096
|
+
const features = [];
|
|
1097
|
+
if (layer.visible) {
|
|
1098
|
+
for (const id of layer.featureIds) {
|
|
1099
|
+
const f = sources.getDrawFeature(id);
|
|
1100
|
+
if (f) features.push(f);
|
|
1101
|
+
}
|
|
1102
|
+
} else {
|
|
1103
|
+
pushAll(features, sources.hiddenFeatures.get(layer.id) ?? []);
|
|
1104
|
+
}
|
|
1105
|
+
const readOnly = sources.readOnlyFeatures.get(layer.id);
|
|
1106
|
+
if (readOnly) pushAll(features, readOnly);
|
|
1107
|
+
return features;
|
|
1108
|
+
}
|
|
1109
|
+
function stripInternalProperties(features, keep) {
|
|
1110
|
+
return features.map((f) => ({
|
|
1111
|
+
...f,
|
|
1112
|
+
properties: Object.fromEntries(
|
|
1113
|
+
Object.entries(f.properties ?? {}).filter(
|
|
1114
|
+
([key]) => !key.startsWith("_") || ((keep == null ? void 0 : keep.has(key)) ?? false)
|
|
1115
|
+
)
|
|
1116
|
+
)
|
|
1117
|
+
}));
|
|
1118
|
+
}
|
|
1095
1119
|
const ToastContext = react.createContext(null);
|
|
1096
1120
|
function useToast() {
|
|
1097
1121
|
const externalToast = react.useContext(ToastContext);
|
|
@@ -2337,6 +2361,85 @@ function hashStringToColor(str) {
|
|
|
2337
2361
|
const light = 45 + (hash >>> 16) % 18;
|
|
2338
2362
|
return hslToHex(hue, sat, light);
|
|
2339
2363
|
}
|
|
2364
|
+
const GRADIENT_RAMP = [
|
|
2365
|
+
"#fee5d9",
|
|
2366
|
+
"#fcae91",
|
|
2367
|
+
"#fb6a4a",
|
|
2368
|
+
"#de2d26",
|
|
2369
|
+
"#a50f15"
|
|
2370
|
+
];
|
|
2371
|
+
const GRADIENT_FALLBACK_COLOR = "#9ca3af";
|
|
2372
|
+
const NUMERIC_FIELD_RATIO_THRESHOLD = 0.8;
|
|
2373
|
+
const NUMERIC_FIELD_COVERAGE_FLOOR = 0.3;
|
|
2374
|
+
function coerceFiniteNumber(raw) {
|
|
2375
|
+
if (typeof raw === "number") return Number.isFinite(raw) ? raw : null;
|
|
2376
|
+
if (typeof raw === "string" && raw.trim() !== "") {
|
|
2377
|
+
const n = Number(raw);
|
|
2378
|
+
return Number.isFinite(n) ? n : null;
|
|
2379
|
+
}
|
|
2380
|
+
return null;
|
|
2381
|
+
}
|
|
2382
|
+
function parseHexColor(hex) {
|
|
2383
|
+
return [
|
|
2384
|
+
parseInt(hex.slice(1, 3), 16),
|
|
2385
|
+
parseInt(hex.slice(3, 5), 16),
|
|
2386
|
+
parseInt(hex.slice(5, 7), 16)
|
|
2387
|
+
];
|
|
2388
|
+
}
|
|
2389
|
+
function gradientColor(t, ramp = GRADIENT_RAMP) {
|
|
2390
|
+
const clamped = Math.max(0, Math.min(1, Number.isFinite(t) ? t : 0.5));
|
|
2391
|
+
const scaled = clamped * (ramp.length - 1);
|
|
2392
|
+
const i = Math.min(Math.floor(scaled), ramp.length - 2);
|
|
2393
|
+
const frac = scaled - i;
|
|
2394
|
+
const [r1, g1, b1] = parseHexColor(ramp[i]);
|
|
2395
|
+
const [r2, g2, b2] = parseHexColor(ramp[i + 1]);
|
|
2396
|
+
const channel = (a, b) => Math.round(a + (b - a) * frac).toString(16).padStart(2, "0");
|
|
2397
|
+
return `#${channel(r1, r2)}${channel(g1, g2)}${channel(b1, b2)}`;
|
|
2398
|
+
}
|
|
2399
|
+
function defaultColorScaleForField(field) {
|
|
2400
|
+
if (!field) return "categorical";
|
|
2401
|
+
return (field.numericRatio ?? 0) >= NUMERIC_FIELD_RATIO_THRESHOLD && (field.coverage ?? 0) >= NUMERIC_FIELD_COVERAGE_FLOOR ? "gradient" : "categorical";
|
|
2402
|
+
}
|
|
2403
|
+
function computeNumericRange(featureIds, getProperties, fieldName) {
|
|
2404
|
+
var _a;
|
|
2405
|
+
let min = Infinity;
|
|
2406
|
+
let max = -Infinity;
|
|
2407
|
+
for (const id of featureIds) {
|
|
2408
|
+
const v = coerceFiniteNumber((_a = getProperties(id)) == null ? void 0 : _a[fieldName]);
|
|
2409
|
+
if (v === null) continue;
|
|
2410
|
+
if (v < min) min = v;
|
|
2411
|
+
if (v > max) max = v;
|
|
2412
|
+
}
|
|
2413
|
+
return isFinite(min) ? { min, max } : null;
|
|
2414
|
+
}
|
|
2415
|
+
function resolveFeatureColor(colorConfig, properties, fallback, gradientRange) {
|
|
2416
|
+
if (!colorConfig) return fallback;
|
|
2417
|
+
if (colorConfig.mode === "fixed" && colorConfig.fixedColor) return colorConfig.fixedColor;
|
|
2418
|
+
if (colorConfig.mode === "field" && colorConfig.fieldName) {
|
|
2419
|
+
if (colorConfig.scale === "gradient") {
|
|
2420
|
+
const value = coerceFiniteNumber(properties == null ? void 0 : properties[colorConfig.fieldName]);
|
|
2421
|
+
if (value === null || !gradientRange) return GRADIENT_FALLBACK_COLOR;
|
|
2422
|
+
const t = gradientRange.max > gradientRange.min ? (value - gradientRange.min) / (gradientRange.max - gradientRange.min) : 0.5;
|
|
2423
|
+
return gradientColor(t);
|
|
2424
|
+
}
|
|
2425
|
+
if (properties) {
|
|
2426
|
+
const key = categoricalKey(properties[colorConfig.fieldName]);
|
|
2427
|
+
if (key !== null) return hashStringToColor(key);
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
return fallback;
|
|
2431
|
+
}
|
|
2432
|
+
function formatGradientStop(value) {
|
|
2433
|
+
if (!Number.isFinite(value)) return "";
|
|
2434
|
+
const abs = Math.abs(value);
|
|
2435
|
+
if (abs >= 1e4) {
|
|
2436
|
+
return new Intl.NumberFormat("en-US", { notation: "compact", maximumFractionDigits: 1 }).format(value);
|
|
2437
|
+
}
|
|
2438
|
+
if (abs > 0 && abs < 1) {
|
|
2439
|
+
return new Intl.NumberFormat("en-US", { maximumSignificantDigits: 3 }).format(value);
|
|
2440
|
+
}
|
|
2441
|
+
return new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 }).format(value);
|
|
2442
|
+
}
|
|
2340
2443
|
const MAP_STYLES = [
|
|
2341
2444
|
{ id: "streets", name: "Streets", icon: lucideReact.Map },
|
|
2342
2445
|
{ id: "satellite", name: "Satellite", icon: lucideReact.Satellite },
|
|
@@ -2425,6 +2528,38 @@ function ColorByFieldLegend({
|
|
|
2425
2528
|
}
|
|
2426
2529
|
);
|
|
2427
2530
|
}
|
|
2531
|
+
function ColorGradientLegend({
|
|
2532
|
+
layerId,
|
|
2533
|
+
min,
|
|
2534
|
+
max,
|
|
2535
|
+
sampled
|
|
2536
|
+
}) {
|
|
2537
|
+
const degenerate = min === max;
|
|
2538
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2539
|
+
"div",
|
|
2540
|
+
{
|
|
2541
|
+
className: "mt-1 rounded border border-border/50 bg-background/40 p-1.5",
|
|
2542
|
+
"data-testid": `legend-gradient-${layerId}`,
|
|
2543
|
+
children: [
|
|
2544
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-[10px] uppercase tracking-wide text-muted-foreground mb-1", children: [
|
|
2545
|
+
"Legend",
|
|
2546
|
+
sampled ? " (sampled)" : ""
|
|
2547
|
+
] }),
|
|
2548
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2549
|
+
"div",
|
|
2550
|
+
{
|
|
2551
|
+
className: "h-2.5 rounded-sm border border-black/10",
|
|
2552
|
+
style: { background: degenerate ? gradientColor(0.5) : `linear-gradient(to right, ${GRADIENT_RAMP.join(", ")})` }
|
|
2553
|
+
}
|
|
2554
|
+
),
|
|
2555
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-between text-[11px] text-muted-foreground tabular-nums mt-0.5", children: degenerate ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mx-auto", children: formatGradientStop(min) }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2556
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: formatGradientStop(min) }),
|
|
2557
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: formatGradientStop(max) })
|
|
2558
|
+
] }) })
|
|
2559
|
+
]
|
|
2560
|
+
}
|
|
2561
|
+
);
|
|
2562
|
+
}
|
|
2428
2563
|
function LayersPanel({
|
|
2429
2564
|
layers,
|
|
2430
2565
|
onAddLayer,
|
|
@@ -2563,7 +2698,7 @@ function LayersPanel({
|
|
|
2563
2698
|
});
|
|
2564
2699
|
}, [onRemoveLayer]);
|
|
2565
2700
|
const renderLayerItem = (layer) => {
|
|
2566
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba;
|
|
2701
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da;
|
|
2567
2702
|
const customCount = featureCountProvider == null ? void 0 : featureCountProvider(layer.id);
|
|
2568
2703
|
const featureCount = customCount != null ? customCount : getFeatureCount(layer.id);
|
|
2569
2704
|
const isExpanded = expandedLayers.has(layer.id);
|
|
@@ -2676,6 +2811,41 @@ function LayersPanel({
|
|
|
2676
2811
|
label: "Save GeoJSON to desktop",
|
|
2677
2812
|
onClick: () => onSaveLayerGeoJSON(layer.id)
|
|
2678
2813
|
},
|
|
2814
|
+
...onUpdateVisualConfig ? [
|
|
2815
|
+
{ type: "divider" },
|
|
2816
|
+
{
|
|
2817
|
+
key: "never-hide-labels",
|
|
2818
|
+
label: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-1.5 py-1", onClick: (e) => e.stopPropagation(), children: [
|
|
2819
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
2820
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
2821
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Type, { className: "w-[18px] h-[18px]" }),
|
|
2822
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm", children: "Never hide labels" })
|
|
2823
|
+
] }),
|
|
2824
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2825
|
+
antd.Switch,
|
|
2826
|
+
{
|
|
2827
|
+
size: "small",
|
|
2828
|
+
disabled: (_b = (_a = layer.visualConfig) == null ? void 0 : _a.label) == null ? void 0 : _b.hidden,
|
|
2829
|
+
checked: !!((_d = (_c = layer.visualConfig) == null ? void 0 : _c.label) == null ? void 0 : _d.neverHide),
|
|
2830
|
+
onChange: (checked) => {
|
|
2831
|
+
var _a2, _b2, _c2;
|
|
2832
|
+
return onUpdateVisualConfig(layer.id, {
|
|
2833
|
+
...layer.visualConfig,
|
|
2834
|
+
label: {
|
|
2835
|
+
...(_a2 = layer.visualConfig) == null ? void 0 : _a2.label,
|
|
2836
|
+
mode: ((_c2 = (_b2 = layer.visualConfig) == null ? void 0 : _b2.label) == null ? void 0 : _c2.mode) ?? "standard",
|
|
2837
|
+
neverHide: checked
|
|
2838
|
+
}
|
|
2839
|
+
});
|
|
2840
|
+
},
|
|
2841
|
+
"data-testid": `switch-never-hide-labels-${layer.id}`
|
|
2842
|
+
}
|
|
2843
|
+
)
|
|
2844
|
+
] }),
|
|
2845
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-muted-foreground mt-1", children: ((_f = (_e = layer.visualConfig) == null ? void 0 : _e.label) == null ? void 0 : _f.hidden) ? "Labels are turned off for this layer" : "Show every label even when the map is crowded" })
|
|
2846
|
+
] })
|
|
2847
|
+
}
|
|
2848
|
+
] : [],
|
|
2679
2849
|
...onFitToLayerFeatures && (typeof featureCount === "string" ? featureCount.length > 0 : featureCount > 0) ? [
|
|
2680
2850
|
{ type: "divider" },
|
|
2681
2851
|
{
|
|
@@ -2728,14 +2898,14 @@ function LayersPanel({
|
|
|
2728
2898
|
]
|
|
2729
2899
|
}
|
|
2730
2900
|
),
|
|
2731
|
-
(hasPointFeatures == null ? void 0 : hasPointFeatures(layer.id)) && !((
|
|
2901
|
+
(hasPointFeatures == null ? void 0 : hasPointFeatures(layer.id)) && !((_g = layer.metadata) == null ? void 0 : _g.hidePointFeatures) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 p-1.5 bg-muted/30 rounded-md", children: [
|
|
2732
2902
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-1.5 text-xs font-medium", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Point Features" }) }),
|
|
2733
2903
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
2734
2904
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2735
2905
|
antd.Switch,
|
|
2736
2906
|
{
|
|
2737
2907
|
size: "small",
|
|
2738
|
-
checked: ((
|
|
2908
|
+
checked: ((_h = layer.traceConfig) == null ? void 0 : _h.enabled) ?? false,
|
|
2739
2909
|
onChange: (checked) => {
|
|
2740
2910
|
var _a2;
|
|
2741
2911
|
return onUpdateTraceConfig(layer.id, {
|
|
@@ -2748,7 +2918,7 @@ function LayersPanel({
|
|
|
2748
2918
|
),
|
|
2749
2919
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", children: "Trace Lines" })
|
|
2750
2920
|
] }),
|
|
2751
|
-
((
|
|
2921
|
+
((_i = layer.traceConfig) == null ? void 0 : _i.enabled) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2752
2922
|
antd.Select,
|
|
2753
2923
|
{
|
|
2754
2924
|
size: "small",
|
|
@@ -2774,7 +2944,7 @@ function LayersPanel({
|
|
|
2774
2944
|
antd.Switch,
|
|
2775
2945
|
{
|
|
2776
2946
|
size: "small",
|
|
2777
|
-
checked: ((
|
|
2947
|
+
checked: ((_j = layer.heatmapConfig) == null ? void 0 : _j.enabled) ?? false,
|
|
2778
2948
|
onChange: (checked) => {
|
|
2779
2949
|
var _a2, _b2;
|
|
2780
2950
|
return onUpdateHeatmapConfig(layer.id, {
|
|
@@ -2788,7 +2958,7 @@ function LayersPanel({
|
|
|
2788
2958
|
),
|
|
2789
2959
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", children: "Heatmap" })
|
|
2790
2960
|
] }),
|
|
2791
|
-
((
|
|
2961
|
+
((_k = layer.heatmapConfig) == null ? void 0 : _k.enabled) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 pl-4", children: [
|
|
2792
2962
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
2793
2963
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] w-12", children: "Intensity" }),
|
|
2794
2964
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2832,10 +3002,11 @@ function LayersPanel({
|
|
|
2832
3002
|
antd.Switch,
|
|
2833
3003
|
{
|
|
2834
3004
|
size: "small",
|
|
2835
|
-
checked: ((
|
|
3005
|
+
checked: ((_l = layer.clusterConfig) == null ? void 0 : _l.enabled) ?? false,
|
|
2836
3006
|
onChange: (checked) => {
|
|
2837
3007
|
var _a2, _b2;
|
|
2838
3008
|
return onUpdateClusterConfig(layer.id, {
|
|
3009
|
+
...layer.clusterConfig,
|
|
2839
3010
|
enabled: checked,
|
|
2840
3011
|
groupByField: ((_a2 = layer.clusterConfig) == null ? void 0 : _a2.groupByField) ?? null,
|
|
2841
3012
|
showPointDots: ((_b2 = layer.clusterConfig) == null ? void 0 : _b2.showPointDots) ?? false
|
|
@@ -2846,7 +3017,7 @@ function LayersPanel({
|
|
|
2846
3017
|
),
|
|
2847
3018
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", children: "Clustering" })
|
|
2848
3019
|
] }),
|
|
2849
|
-
((
|
|
3020
|
+
((_m = layer.clusterConfig) == null ? void 0 : _m.enabled) && getLayerFields && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1 pl-4", children: [
|
|
2850
3021
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2851
3022
|
antd.Select,
|
|
2852
3023
|
{
|
|
@@ -2879,6 +3050,53 @@ function LayersPanel({
|
|
|
2879
3050
|
}
|
|
2880
3051
|
),
|
|
2881
3052
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px]", children: "Show point dots" })
|
|
3053
|
+
] }),
|
|
3054
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
3055
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3056
|
+
antd.Switch,
|
|
3057
|
+
{
|
|
3058
|
+
size: "small",
|
|
3059
|
+
checked: layer.clusterConfig.countByFieldEnabled ?? false,
|
|
3060
|
+
onChange: (checked) => onUpdateClusterConfig(layer.id, {
|
|
3061
|
+
...layer.clusterConfig,
|
|
3062
|
+
countByFieldEnabled: checked
|
|
3063
|
+
}),
|
|
3064
|
+
"data-testid": `switch-cluster-count-by-${layer.id}`
|
|
3065
|
+
}
|
|
3066
|
+
),
|
|
3067
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px]", children: "Count by field" })
|
|
3068
|
+
] }),
|
|
3069
|
+
layer.clusterConfig.countByFieldEnabled && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3070
|
+
antd.Select,
|
|
3071
|
+
{
|
|
3072
|
+
size: "small",
|
|
3073
|
+
value: layer.clusterConfig.countByField ?? void 0,
|
|
3074
|
+
onChange: (val) => onUpdateClusterConfig(layer.id, {
|
|
3075
|
+
...layer.clusterConfig,
|
|
3076
|
+
countByField: val
|
|
3077
|
+
}),
|
|
3078
|
+
className: "w-full text-xs",
|
|
3079
|
+
placeholder: "Select numeric field...",
|
|
3080
|
+
showSearch: true,
|
|
3081
|
+
optionFilterProp: "label",
|
|
3082
|
+
options: getLayerFields(layer.id).filter((f) => f.isNumeric).map((f) => ({ value: f.name, label: f.name })),
|
|
3083
|
+
"data-testid": `select-cluster-count-field-${layer.id}`
|
|
3084
|
+
}
|
|
3085
|
+
),
|
|
3086
|
+
!layer.clusterConfig.groupByField && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
3087
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3088
|
+
antd.Switch,
|
|
3089
|
+
{
|
|
3090
|
+
size: "small",
|
|
3091
|
+
checked: layer.clusterConfig.bubbleGradient ?? false,
|
|
3092
|
+
onChange: (checked) => onUpdateClusterConfig(layer.id, {
|
|
3093
|
+
...layer.clusterConfig,
|
|
3094
|
+
bubbleGradient: checked
|
|
3095
|
+
}),
|
|
3096
|
+
"data-testid": `switch-cluster-gradient-${layer.id}`
|
|
3097
|
+
}
|
|
3098
|
+
),
|
|
3099
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px]", children: "Color bubbles by value" })
|
|
2882
3100
|
] })
|
|
2883
3101
|
] })
|
|
2884
3102
|
] })
|
|
@@ -2915,7 +3133,7 @@ function LayersPanel({
|
|
|
2915
3133
|
antd.Switch,
|
|
2916
3134
|
{
|
|
2917
3135
|
size: "small",
|
|
2918
|
-
checked: !((
|
|
3136
|
+
checked: !((_o = (_n = layer.visualConfig) == null ? void 0 : _n.label) == null ? void 0 : _o.hidden),
|
|
2919
3137
|
onChange: (checked) => {
|
|
2920
3138
|
var _a2, _b2, _c2;
|
|
2921
3139
|
return onUpdateVisualConfig(layer.id, {
|
|
@@ -2931,8 +3149,8 @@ function LayersPanel({
|
|
|
2931
3149
|
antd.Select,
|
|
2932
3150
|
{
|
|
2933
3151
|
size: "small",
|
|
2934
|
-
disabled: (
|
|
2935
|
-
value: ((
|
|
3152
|
+
disabled: (_q = (_p = layer.visualConfig) == null ? void 0 : _p.label) == null ? void 0 : _q.hidden,
|
|
3153
|
+
value: ((_s = (_r = layer.visualConfig) == null ? void 0 : _r.label) == null ? void 0 : _s.mode) ?? "standard",
|
|
2936
3154
|
onChange: (val) => {
|
|
2937
3155
|
var _a2;
|
|
2938
3156
|
return onUpdateVisualConfig(layer.id, {
|
|
@@ -2949,15 +3167,18 @@ function LayersPanel({
|
|
|
2949
3167
|
"data-testid": `select-label-mode-${layer.id}`
|
|
2950
3168
|
}
|
|
2951
3169
|
),
|
|
2952
|
-
((
|
|
3170
|
+
((_u = (_t = layer.visualConfig) == null ? void 0 : _t.label) == null ? void 0 : _u.mode) === "field" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2953
3171
|
antd.Select,
|
|
2954
3172
|
{
|
|
2955
3173
|
size: "small",
|
|
2956
|
-
value: ((
|
|
2957
|
-
onChange: (val) =>
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
3174
|
+
value: ((_w = (_v = layer.visualConfig) == null ? void 0 : _v.label) == null ? void 0 : _w.fieldName) ?? "",
|
|
3175
|
+
onChange: (val) => {
|
|
3176
|
+
var _a2;
|
|
3177
|
+
return onUpdateVisualConfig(layer.id, {
|
|
3178
|
+
...layer.visualConfig,
|
|
3179
|
+
label: { ...(_a2 = layer.visualConfig) == null ? void 0 : _a2.label, mode: "field", fieldName: val }
|
|
3180
|
+
});
|
|
3181
|
+
},
|
|
2961
3182
|
className: "w-full text-sm",
|
|
2962
3183
|
placeholder: "Select field...",
|
|
2963
3184
|
showSearch: true,
|
|
@@ -2966,15 +3187,18 @@ function LayersPanel({
|
|
|
2966
3187
|
"data-testid": `select-label-field-${layer.id}`
|
|
2967
3188
|
}
|
|
2968
3189
|
),
|
|
2969
|
-
((
|
|
3190
|
+
((_y = (_x = layer.visualConfig) == null ? void 0 : _x.label) == null ? void 0 : _y.mode) === "fixed" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2970
3191
|
antd.Input,
|
|
2971
3192
|
{
|
|
2972
3193
|
size: "small",
|
|
2973
|
-
value: ((
|
|
2974
|
-
onChange: (e) =>
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
3194
|
+
value: ((_A = (_z = layer.visualConfig) == null ? void 0 : _z.label) == null ? void 0 : _A.fixedText) ?? "",
|
|
3195
|
+
onChange: (e) => {
|
|
3196
|
+
var _a2;
|
|
3197
|
+
return onUpdateVisualConfig(layer.id, {
|
|
3198
|
+
...layer.visualConfig,
|
|
3199
|
+
label: { ...(_a2 = layer.visualConfig) == null ? void 0 : _a2.label, mode: "fixed", fixedText: e.target.value }
|
|
3200
|
+
});
|
|
3201
|
+
},
|
|
2978
3202
|
placeholder: "Enter label text...",
|
|
2979
3203
|
className: "text-sm",
|
|
2980
3204
|
"data-testid": `input-label-text-${layer.id}`
|
|
@@ -2988,7 +3212,7 @@ function LayersPanel({
|
|
|
2988
3212
|
antd.Select,
|
|
2989
3213
|
{
|
|
2990
3214
|
size: "small",
|
|
2991
|
-
value: ((
|
|
3215
|
+
value: ((_C = (_B = layer.visualConfig) == null ? void 0 : _B.size) == null ? void 0 : _C.mode) ?? "standard",
|
|
2992
3216
|
onChange: (val) => onUpdateVisualConfig(layer.id, {
|
|
2993
3217
|
...layer.visualConfig,
|
|
2994
3218
|
size: { mode: val }
|
|
@@ -3002,11 +3226,11 @@ function LayersPanel({
|
|
|
3002
3226
|
"data-testid": `select-size-mode-${layer.id}`
|
|
3003
3227
|
}
|
|
3004
3228
|
),
|
|
3005
|
-
((
|
|
3229
|
+
((_E = (_D = layer.visualConfig) == null ? void 0 : _D.size) == null ? void 0 : _E.mode) === "field" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3006
3230
|
antd.Select,
|
|
3007
3231
|
{
|
|
3008
3232
|
size: "small",
|
|
3009
|
-
value: ((
|
|
3233
|
+
value: ((_G = (_F = layer.visualConfig) == null ? void 0 : _F.size) == null ? void 0 : _G.fieldName) ?? "",
|
|
3010
3234
|
onChange: (val) => onUpdateVisualConfig(layer.id, {
|
|
3011
3235
|
...layer.visualConfig,
|
|
3012
3236
|
size: { mode: "field", fieldName: val }
|
|
@@ -3019,11 +3243,11 @@ function LayersPanel({
|
|
|
3019
3243
|
"data-testid": `select-size-field-${layer.id}`
|
|
3020
3244
|
}
|
|
3021
3245
|
),
|
|
3022
|
-
((
|
|
3246
|
+
((_I = (_H = layer.visualConfig) == null ? void 0 : _H.size) == null ? void 0 : _I.mode) === "override" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
3023
3247
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3024
3248
|
antd.Slider,
|
|
3025
3249
|
{
|
|
3026
|
-
value: ((
|
|
3250
|
+
value: ((_K = (_J = layer.visualConfig) == null ? void 0 : _J.size) == null ? void 0 : _K.overrideValue) ?? 5,
|
|
3027
3251
|
min: 1,
|
|
3028
3252
|
max: 10,
|
|
3029
3253
|
step: 1,
|
|
@@ -3034,7 +3258,7 @@ function LayersPanel({
|
|
|
3034
3258
|
})
|
|
3035
3259
|
}
|
|
3036
3260
|
),
|
|
3037
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm w-4 text-right", children: ((
|
|
3261
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm w-4 text-right", children: ((_M = (_L = layer.visualConfig) == null ? void 0 : _L.size) == null ? void 0 : _M.overrideValue) ?? 5 })
|
|
3038
3262
|
] }),
|
|
3039
3263
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground pt-0.5", children: [
|
|
3040
3264
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-3.5 h-3.5 rounded-full bg-current" }),
|
|
@@ -3044,7 +3268,7 @@ function LayersPanel({
|
|
|
3044
3268
|
antd.Select,
|
|
3045
3269
|
{
|
|
3046
3270
|
size: "small",
|
|
3047
|
-
value: ((
|
|
3271
|
+
value: ((_O = (_N = layer.visualConfig) == null ? void 0 : _N.color) == null ? void 0 : _O.mode) ?? "standard",
|
|
3048
3272
|
onChange: (val) => onUpdateVisualConfig(layer.id, {
|
|
3049
3273
|
...layer.visualConfig,
|
|
3050
3274
|
color: { mode: val }
|
|
@@ -3058,37 +3282,77 @@ function LayersPanel({
|
|
|
3058
3282
|
"data-testid": `select-color-mode-${layer.id}`
|
|
3059
3283
|
}
|
|
3060
3284
|
),
|
|
3061
|
-
((
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3285
|
+
((_Q = (_P = layer.visualConfig) == null ? void 0 : _P.color) == null ? void 0 : _Q.mode) === "field" && (() => {
|
|
3286
|
+
var _a2, _b2, _c2, _d2;
|
|
3287
|
+
const fields = getLayerFields(layer.id);
|
|
3288
|
+
const colorField = (_b2 = (_a2 = layer.visualConfig) == null ? void 0 : _a2.color) == null ? void 0 : _b2.fieldName;
|
|
3289
|
+
const fieldStats = colorField ? fields.find((f) => f.name === colorField) : void 0;
|
|
3290
|
+
const fieldHasNumeric = (fieldStats == null ? void 0 : fieldStats.min) !== void 0;
|
|
3291
|
+
const scale = ((_d2 = (_c2 = layer.visualConfig) == null ? void 0 : _c2.color) == null ? void 0 : _d2.scale) ?? "categorical";
|
|
3292
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3293
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3294
|
+
antd.Select,
|
|
3295
|
+
{
|
|
3296
|
+
size: "small",
|
|
3297
|
+
value: colorField ?? "",
|
|
3298
|
+
onChange: (val) => onUpdateVisualConfig(layer.id, {
|
|
3299
|
+
...layer.visualConfig,
|
|
3300
|
+
// The scale default is decided once, at pick time, and
|
|
3301
|
+
// stored — never re-inferred at render, so data drifting
|
|
3302
|
+
// later can't silently flip a user's choice.
|
|
3303
|
+
color: { mode: "field", fieldName: val, scale: defaultColorScaleForField(fields.find((f) => f.name === val)) }
|
|
3304
|
+
}),
|
|
3305
|
+
className: "w-full text-sm",
|
|
3306
|
+
placeholder: "Select field...",
|
|
3307
|
+
showSearch: true,
|
|
3308
|
+
optionFilterProp: "label",
|
|
3309
|
+
options: fields.map((f) => ({ value: f.name, label: f.name })),
|
|
3310
|
+
"data-testid": `select-color-field-${layer.id}`
|
|
3311
|
+
}
|
|
3312
|
+
),
|
|
3313
|
+
colorField && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3314
|
+
antd.Segmented,
|
|
3315
|
+
{
|
|
3316
|
+
size: "small",
|
|
3317
|
+
block: true,
|
|
3318
|
+
value: scale,
|
|
3319
|
+
onChange: (val) => {
|
|
3320
|
+
var _a3;
|
|
3321
|
+
return onUpdateVisualConfig(layer.id, {
|
|
3322
|
+
...layer.visualConfig,
|
|
3323
|
+
color: { ...(_a3 = layer.visualConfig) == null ? void 0 : _a3.color, mode: "field", scale: val }
|
|
3324
|
+
});
|
|
3325
|
+
},
|
|
3326
|
+
options: [
|
|
3327
|
+
{ label: "Categories", value: "categorical" },
|
|
3328
|
+
{ label: "Gradient", value: "gradient", disabled: !fieldHasNumeric && scale !== "gradient" }
|
|
3329
|
+
],
|
|
3330
|
+
"data-testid": `segmented-color-scale-${layer.id}`
|
|
3331
|
+
}
|
|
3332
|
+
),
|
|
3333
|
+
colorField && scale === "gradient" && fieldStats && fieldStats.min !== void 0 && fieldStats.max !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3334
|
+
ColorGradientLegend,
|
|
3335
|
+
{
|
|
3336
|
+
layerId: layer.id,
|
|
3337
|
+
min: fieldStats.min,
|
|
3338
|
+
max: fieldStats.max,
|
|
3339
|
+
sampled: fieldStats.sampled
|
|
3340
|
+
}
|
|
3341
|
+
),
|
|
3342
|
+
colorField && scale !== "gradient" && getFieldValueDistribution && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3343
|
+
ColorByFieldLegend,
|
|
3344
|
+
{
|
|
3345
|
+
layerId: layer.id,
|
|
3346
|
+
fieldName: colorField,
|
|
3347
|
+
getFieldValueDistribution
|
|
3348
|
+
}
|
|
3349
|
+
)
|
|
3350
|
+
] });
|
|
3351
|
+
})(),
|
|
3352
|
+
((_S = (_R = layer.visualConfig) == null ? void 0 : _R.color) == null ? void 0 : _S.mode) === "fixed" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3089
3353
|
ColorPickerPopover,
|
|
3090
3354
|
{
|
|
3091
|
-
value: ((
|
|
3355
|
+
value: ((_U = (_T = layer.visualConfig) == null ? void 0 : _T.color) == null ? void 0 : _U.fixedColor) ?? "#3b82f6",
|
|
3092
3356
|
onChange: (color) => {
|
|
3093
3357
|
onUpdateVisualConfig == null ? void 0 : onUpdateVisualConfig(layer.id, {
|
|
3094
3358
|
...layer.visualConfig,
|
|
@@ -3101,7 +3365,7 @@ function LayersPanel({
|
|
|
3101
3365
|
testId: `color-fixed-${layer.id}`
|
|
3102
3366
|
}
|
|
3103
3367
|
),
|
|
3104
|
-
(hasPointFeatures == null ? void 0 : hasPointFeatures(layer.id)) && !((
|
|
3368
|
+
(hasPointFeatures == null ? void 0 : hasPointFeatures(layer.id)) && !((_V = layer.metadata) == null ? void 0 : _V.hidePointFeatures) && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3105
3369
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground pt-0.5", children: [
|
|
3106
3370
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Smile, { className: "w-3.5 h-3.5" }),
|
|
3107
3371
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Point Icon" })
|
|
@@ -3111,7 +3375,7 @@ function LayersPanel({
|
|
|
3111
3375
|
antd.Switch,
|
|
3112
3376
|
{
|
|
3113
3377
|
size: "small",
|
|
3114
|
-
checked: ((
|
|
3378
|
+
checked: ((_X = (_W = layer.visualConfig) == null ? void 0 : _W.icon) == null ? void 0 : _X.enabled) ?? false,
|
|
3115
3379
|
onChange: (checked) => {
|
|
3116
3380
|
var _a2, _b2, _c2, _d2;
|
|
3117
3381
|
onUpdateVisualConfig == null ? void 0 : onUpdateVisualConfig(layer.id, {
|
|
@@ -3126,11 +3390,11 @@ function LayersPanel({
|
|
|
3126
3390
|
"data-testid": `switch-icon-${layer.id}`
|
|
3127
3391
|
}
|
|
3128
3392
|
),
|
|
3129
|
-
((
|
|
3393
|
+
((_Z = (_Y = layer.visualConfig) == null ? void 0 : _Y.icon) == null ? void 0 : _Z.enabled) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 flex-1", children: [
|
|
3130
3394
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3131
3395
|
IconPicker,
|
|
3132
3396
|
{
|
|
3133
|
-
value: ((
|
|
3397
|
+
value: ((_$ = (__ = layer.visualConfig) == null ? void 0 : __.icon) == null ? void 0 : _$.icon) ?? "📍",
|
|
3134
3398
|
onChange: (icon) => {
|
|
3135
3399
|
var _a2, _b2;
|
|
3136
3400
|
onUpdateVisualConfig == null ? void 0 : onUpdateVisualConfig(layer.id, {
|
|
@@ -3147,7 +3411,7 @@ function LayersPanel({
|
|
|
3147
3411
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3148
3412
|
antd.Slider,
|
|
3149
3413
|
{
|
|
3150
|
-
value: ((
|
|
3414
|
+
value: ((_ba = (_aa = layer.visualConfig) == null ? void 0 : _aa.icon) == null ? void 0 : _ba.size) ?? 24,
|
|
3151
3415
|
min: 12,
|
|
3152
3416
|
max: 48,
|
|
3153
3417
|
step: 2,
|
|
@@ -3165,7 +3429,7 @@ function LayersPanel({
|
|
|
3165
3429
|
}
|
|
3166
3430
|
}
|
|
3167
3431
|
),
|
|
3168
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm w-6 text-right", children: ((
|
|
3432
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm w-6 text-right", children: ((_da = (_ca = layer.visualConfig) == null ? void 0 : _ca.icon) == null ? void 0 : _da.size) ?? 24 })
|
|
3169
3433
|
] })
|
|
3170
3434
|
] })
|
|
3171
3435
|
] })
|
|
@@ -6498,13 +6762,282 @@ function hitTestSelection(featureGroups, selectionPolygon, options) {
|
|
|
6498
6762
|
mapPerfLog("hit-test", "selection gesture", { visited, total, selected: selectedIds.length });
|
|
6499
6763
|
return selectedIds;
|
|
6500
6764
|
}
|
|
6765
|
+
const CLUSTER_COUNT_VALUE_PROP = "__cluster_count_value";
|
|
6766
|
+
const CLUSTER_SUM_PROP = "value_sum";
|
|
6767
|
+
const CLUSTER_MEMBER_ID_PROP = "__cluster_fid";
|
|
6768
|
+
function clusterCountValue(raw) {
|
|
6769
|
+
if (typeof raw === "number") return Number.isFinite(raw) ? raw : 1;
|
|
6770
|
+
if (typeof raw === "string" && raw.trim() !== "") {
|
|
6771
|
+
const n = Number(raw);
|
|
6772
|
+
if (Number.isFinite(n)) return n;
|
|
6773
|
+
}
|
|
6774
|
+
return 1;
|
|
6775
|
+
}
|
|
6776
|
+
function injectClusterCountValues(features, fieldName) {
|
|
6777
|
+
return features.map((f) => {
|
|
6778
|
+
var _a;
|
|
6779
|
+
return {
|
|
6780
|
+
...f,
|
|
6781
|
+
properties: {
|
|
6782
|
+
...f.properties,
|
|
6783
|
+
[CLUSTER_COUNT_VALUE_PROP]: clusterCountValue((_a = f.properties) == null ? void 0 : _a[fieldName]),
|
|
6784
|
+
...f.id != null ? { [CLUSTER_MEMBER_ID_PROP]: String(f.id) } : {}
|
|
6785
|
+
}
|
|
6786
|
+
};
|
|
6787
|
+
});
|
|
6788
|
+
}
|
|
6789
|
+
function roundHalfAwayFromZero1(n) {
|
|
6790
|
+
return Math.sign(n) * Math.round(Math.abs(n) * 10) / 10;
|
|
6791
|
+
}
|
|
6792
|
+
function formatClusterBadge(value) {
|
|
6793
|
+
if (value >= 1e6) return `${roundHalfAwayFromZero1(value / 1e6)}M`;
|
|
6794
|
+
if (value >= 1e3) return `${roundHalfAwayFromZero1(value / 1e3)}k`;
|
|
6795
|
+
return String(roundHalfAwayFromZero1(value));
|
|
6796
|
+
}
|
|
6797
|
+
function clusterBadgeTextField(prop) {
|
|
6798
|
+
const value = ["get", prop];
|
|
6799
|
+
const round1 = (expr) => ["/", ["round", ["*", expr, 10]], 10];
|
|
6800
|
+
return [
|
|
6801
|
+
"step",
|
|
6802
|
+
value,
|
|
6803
|
+
["to-string", round1(value)],
|
|
6804
|
+
1e3,
|
|
6805
|
+
["concat", ["to-string", round1(["/", value, 1e3])], "k"],
|
|
6806
|
+
1e6,
|
|
6807
|
+
["concat", ["to-string", round1(["/", value, 1e6])], "M"]
|
|
6808
|
+
];
|
|
6809
|
+
}
|
|
6810
|
+
const INTERNAL_PROPERTY_KEYS = /* @__PURE__ */ new Set([
|
|
6811
|
+
"fill",
|
|
6812
|
+
"fill-opacity",
|
|
6813
|
+
"pointRadius",
|
|
6814
|
+
"pointIcon",
|
|
6815
|
+
"pointIconSize",
|
|
6816
|
+
"circleCenter",
|
|
6817
|
+
"circleRadius",
|
|
6818
|
+
"icon",
|
|
6819
|
+
"iconSize",
|
|
6820
|
+
"fontSize",
|
|
6821
|
+
"fontColor",
|
|
6822
|
+
"fontWeight",
|
|
6823
|
+
"arrowSize",
|
|
6824
|
+
"label",
|
|
6825
|
+
"entityType",
|
|
6826
|
+
"kind",
|
|
6827
|
+
"meta:type",
|
|
6828
|
+
"stroke",
|
|
6829
|
+
"stroke-width",
|
|
6830
|
+
"stroke-opacity",
|
|
6831
|
+
CLUSTER_COUNT_VALUE_PROP,
|
|
6832
|
+
CLUSTER_MEMBER_ID_PROP
|
|
6833
|
+
]);
|
|
6834
|
+
const STYLING_PROPERTY_KEYS = [
|
|
6835
|
+
"stroke",
|
|
6836
|
+
"stroke-width",
|
|
6837
|
+
"stroke-opacity",
|
|
6838
|
+
"fill",
|
|
6839
|
+
"fill-opacity",
|
|
6840
|
+
"pointRadius",
|
|
6841
|
+
"pointIcon",
|
|
6842
|
+
"pointIconSize",
|
|
6843
|
+
"icon",
|
|
6844
|
+
"iconSize",
|
|
6845
|
+
"circleCenter",
|
|
6846
|
+
"circleRadius",
|
|
6847
|
+
"fontSize",
|
|
6848
|
+
"fontColor",
|
|
6849
|
+
"fontWeight",
|
|
6850
|
+
"arrowSize"
|
|
6851
|
+
];
|
|
6852
|
+
const INTERNAL_PROPERTY_PREFIXES = [
|
|
6853
|
+
"IsHiddenBy",
|
|
6854
|
+
"isHidden",
|
|
6855
|
+
"isSelected",
|
|
6856
|
+
"isTrace",
|
|
6857
|
+
"isTimeline",
|
|
6858
|
+
"trace"
|
|
6859
|
+
];
|
|
6860
|
+
function isInternalProperty(key) {
|
|
6861
|
+
if (INTERNAL_PROPERTY_KEYS.has(key)) return true;
|
|
6862
|
+
return INTERNAL_PROPERTY_PREFIXES.some((prefix) => key.startsWith(prefix));
|
|
6863
|
+
}
|
|
6864
|
+
function computeBubbleDomain(values) {
|
|
6865
|
+
let min = Infinity;
|
|
6866
|
+
let max = -Infinity;
|
|
6867
|
+
for (const v of values) {
|
|
6868
|
+
if (!Number.isFinite(v)) continue;
|
|
6869
|
+
if (v < min) min = v;
|
|
6870
|
+
if (v > max) max = v;
|
|
6871
|
+
}
|
|
6872
|
+
return isFinite(min) ? { min, max } : null;
|
|
6873
|
+
}
|
|
6874
|
+
function bubbleGradientColorExpression(prop, min, max) {
|
|
6875
|
+
if (!(max > min)) return gradientColor(0.5);
|
|
6876
|
+
const expr = ["interpolate", ["linear"], ["get", prop]];
|
|
6877
|
+
const span = max - min;
|
|
6878
|
+
GRADIENT_RAMP.forEach((color, i) => {
|
|
6879
|
+
expr.push(min + span * i / (GRADIENT_RAMP.length - 1), color);
|
|
6880
|
+
});
|
|
6881
|
+
return expr;
|
|
6882
|
+
}
|
|
6883
|
+
function createClusterGradientManager(map, sourceId, options) {
|
|
6884
|
+
const clusterProp = options.valueProp ?? "point_count";
|
|
6885
|
+
let scheduled = false;
|
|
6886
|
+
let lastDomainKey = "";
|
|
6887
|
+
let reportedFailure = false;
|
|
6888
|
+
function reportFailure(stage, error) {
|
|
6889
|
+
if (reportedFailure) return;
|
|
6890
|
+
reportedFailure = true;
|
|
6891
|
+
console.error(`[map-component] cluster gradient ${stage} failed; bubbles keep their current colors:`, error);
|
|
6892
|
+
}
|
|
6893
|
+
function apply() {
|
|
6894
|
+
scheduled = false;
|
|
6895
|
+
let values;
|
|
6896
|
+
try {
|
|
6897
|
+
if (!map.getSource(sourceId)) return;
|
|
6898
|
+
values = map.querySourceFeatures(sourceId, { filter: ["has", "point_count"] }).map((f) => {
|
|
6899
|
+
var _a;
|
|
6900
|
+
return Number((_a = f.properties) == null ? void 0 : _a[clusterProp]);
|
|
6901
|
+
});
|
|
6902
|
+
if (options.singleLayerId) {
|
|
6903
|
+
const singles = map.querySourceFeatures(sourceId, {
|
|
6904
|
+
filter: ["all", ["!", ["has", "point_count"]], [">", ["get", CLUSTER_COUNT_VALUE_PROP], 1]]
|
|
6905
|
+
});
|
|
6906
|
+
values.push(...singles.map((f) => {
|
|
6907
|
+
var _a;
|
|
6908
|
+
return Number((_a = f.properties) == null ? void 0 : _a[CLUSTER_COUNT_VALUE_PROP]);
|
|
6909
|
+
}));
|
|
6910
|
+
}
|
|
6911
|
+
} catch (error) {
|
|
6912
|
+
reportFailure("domain query", error);
|
|
6913
|
+
return;
|
|
6914
|
+
}
|
|
6915
|
+
const domain = computeBubbleDomain(values);
|
|
6916
|
+
if (!domain) return;
|
|
6917
|
+
const key = `${domain.min}|${domain.max}`;
|
|
6918
|
+
if (key === lastDomainKey) return;
|
|
6919
|
+
lastDomainKey = key;
|
|
6920
|
+
try {
|
|
6921
|
+
if (map.getLayer(options.clustersLayerId)) {
|
|
6922
|
+
map.setPaintProperty(
|
|
6923
|
+
options.clustersLayerId,
|
|
6924
|
+
"circle-color",
|
|
6925
|
+
bubbleGradientColorExpression(clusterProp, domain.min, domain.max)
|
|
6926
|
+
);
|
|
6927
|
+
}
|
|
6928
|
+
if (options.singleLayerId && map.getLayer(options.singleLayerId)) {
|
|
6929
|
+
map.setPaintProperty(
|
|
6930
|
+
options.singleLayerId,
|
|
6931
|
+
"circle-color",
|
|
6932
|
+
bubbleGradientColorExpression(CLUSTER_COUNT_VALUE_PROP, domain.min, domain.max)
|
|
6933
|
+
);
|
|
6934
|
+
}
|
|
6935
|
+
} catch (error) {
|
|
6936
|
+
reportFailure("paint update", error);
|
|
6937
|
+
lastDomainKey = "";
|
|
6938
|
+
}
|
|
6939
|
+
}
|
|
6940
|
+
function schedule() {
|
|
6941
|
+
if (scheduled) return;
|
|
6942
|
+
scheduled = true;
|
|
6943
|
+
requestAnimationFrame(apply);
|
|
6944
|
+
}
|
|
6945
|
+
function onData(e) {
|
|
6946
|
+
if (e.sourceId === sourceId) schedule();
|
|
6947
|
+
}
|
|
6948
|
+
map.on("moveend", schedule);
|
|
6949
|
+
map.on("data", onData);
|
|
6950
|
+
schedule();
|
|
6951
|
+
return {
|
|
6952
|
+
destroy: () => {
|
|
6953
|
+
map.off("moveend", schedule);
|
|
6954
|
+
map.off("data", onData);
|
|
6955
|
+
}
|
|
6956
|
+
};
|
|
6957
|
+
}
|
|
6958
|
+
const LABEL_NEVER_HIDE_PROP = "_labelNeverHide";
|
|
6959
|
+
const PINNED_LABEL_FILTER = ["==", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
6960
|
+
const UNPINNED_LABEL_FILTER = ["!=", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
6961
|
+
function computeLabelNeverHide(label) {
|
|
6962
|
+
return (label == null ? void 0 : label.neverHide) && !label.hidden ? 1 : 0;
|
|
6963
|
+
}
|
|
6964
|
+
function buildCustomLabelLayout() {
|
|
6965
|
+
return {
|
|
6966
|
+
// Hide labels for trace points (except last point which has isTraceLabel),
|
|
6967
|
+
// arrows handled by the custom-arrow-labels layer. Features blanked by
|
|
6968
|
+
// heatmap/cluster/trace modes stay blank in BOTH layers: "never hide"
|
|
6969
|
+
// exempts labels from collision and density culling, it does not resurrect
|
|
6970
|
+
// labels other mode choices explicitly blank.
|
|
6971
|
+
"text-field": [
|
|
6972
|
+
"case",
|
|
6973
|
+
["==", ["get", "isHiddenByTrace"], true],
|
|
6974
|
+
"",
|
|
6975
|
+
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
6976
|
+
"",
|
|
6977
|
+
["==", ["get", "isHiddenByCluster"], 1],
|
|
6978
|
+
"",
|
|
6979
|
+
["==", ["get", "kind"], "arrow"],
|
|
6980
|
+
"",
|
|
6981
|
+
// Trace points: only show label if isTraceLabel is true (last point in group)
|
|
6982
|
+
["all", ["==", ["get", "isTracePoint"], true], ["!=", ["get", "isTraceLabel"], true]],
|
|
6983
|
+
"",
|
|
6984
|
+
["==", ["get", "kind"], "text"],
|
|
6985
|
+
["coalesce", ["get", "label"], ["get", "text"], "New Label"],
|
|
6986
|
+
["coalesce", ["get", "name"], ""]
|
|
6987
|
+
],
|
|
6988
|
+
// Text features use their fontSize property; trace labels 14px; others 12px
|
|
6989
|
+
"text-size": [
|
|
6990
|
+
"case",
|
|
6991
|
+
["==", ["get", "kind"], "text"],
|
|
6992
|
+
["coalesce", ["get", "fontSize"], 14],
|
|
6993
|
+
["==", ["get", "isTraceLabel"], true],
|
|
6994
|
+
14,
|
|
6995
|
+
12
|
|
6996
|
+
],
|
|
6997
|
+
// Text features: center anchor; others: top anchor
|
|
6998
|
+
"text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
|
|
6999
|
+
"text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
|
|
7000
|
+
"text-padding": 2,
|
|
7001
|
+
// Bold font for text features with fontWeight=bold, trace labels, others regular
|
|
7002
|
+
"text-font": [
|
|
7003
|
+
"case",
|
|
7004
|
+
["all", ["==", ["get", "kind"], "text"], ["==", ["get", "fontWeight"], "bold"]],
|
|
7005
|
+
["literal", ["Montserrat SemiBold", "Noto Sans Regular"]],
|
|
7006
|
+
["==", ["get", "isTraceLabel"], true],
|
|
7007
|
+
["literal", ["Montserrat Medium", "Noto Sans Regular"]],
|
|
7008
|
+
["literal", ["Montserrat Regular", "Noto Sans Regular"]]
|
|
7009
|
+
]
|
|
7010
|
+
};
|
|
7011
|
+
}
|
|
7012
|
+
function buildCustomLabelPaint() {
|
|
7013
|
+
return {
|
|
7014
|
+
// Text features use fontColor; others use default
|
|
7015
|
+
"text-color": [
|
|
7016
|
+
"case",
|
|
7017
|
+
["==", ["get", "kind"], "text"],
|
|
7018
|
+
["coalesce", ["get", "fontColor"], "#000000"],
|
|
7019
|
+
"#1f2937"
|
|
7020
|
+
],
|
|
7021
|
+
"text-halo-color": "#ffffff",
|
|
7022
|
+
// Thicker halo for trace labels and text features
|
|
7023
|
+
"text-halo-width": [
|
|
7024
|
+
"case",
|
|
7025
|
+
["==", ["get", "kind"], "text"],
|
|
7026
|
+
2,
|
|
7027
|
+
["==", ["get", "isTraceLabel"], true],
|
|
7028
|
+
2,
|
|
7029
|
+
1.5
|
|
7030
|
+
],
|
|
7031
|
+
"text-opacity": ["*", 0.9, ["get", "stroke-opacity"]]
|
|
7032
|
+
};
|
|
7033
|
+
}
|
|
6501
7034
|
const OTHER_BUCKET_KEY = "__other__";
|
|
6502
7035
|
const OTHER_BUCKET_LABEL = "Other";
|
|
6503
7036
|
const OTHER_BUCKET_COLOR = "#9ca3af";
|
|
6504
7037
|
function toDisplayName(name) {
|
|
6505
7038
|
return name === OTHER_BUCKET_KEY ? OTHER_BUCKET_LABEL : name;
|
|
6506
7039
|
}
|
|
6507
|
-
function createPieSVG(categories, total, size = 44, onSliceHover) {
|
|
7040
|
+
function createPieSVG(categories, total, size = 44, onSliceHover, badgeValue) {
|
|
6508
7041
|
const container = document.createElement("div");
|
|
6509
7042
|
container.style.width = `${size}px`;
|
|
6510
7043
|
container.style.height = `${size}px`;
|
|
@@ -6602,16 +7135,17 @@ function createPieSVG(categories, total, size = 44, onSliceHover) {
|
|
|
6602
7135
|
centerCircle.setAttribute("r", String(innerRadius - 2));
|
|
6603
7136
|
centerCircle.setAttribute("fill", "#1f2937");
|
|
6604
7137
|
svg.appendChild(centerCircle);
|
|
7138
|
+
const badgeText = formatClusterBadge(badgeValue ?? total);
|
|
6605
7139
|
const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
6606
7140
|
text.setAttribute("x", String(radius));
|
|
6607
7141
|
text.setAttribute("y", String(radius));
|
|
6608
7142
|
text.setAttribute("text-anchor", "middle");
|
|
6609
7143
|
text.setAttribute("dominant-baseline", "central");
|
|
6610
7144
|
text.setAttribute("fill", "white");
|
|
6611
|
-
text.setAttribute("font-size",
|
|
7145
|
+
text.setAttribute("font-size", badgeText.length >= 6 ? "8" : badgeText.length >= 4 ? "9" : badgeText.length >= 3 ? "10" : "11");
|
|
6612
7146
|
text.setAttribute("font-weight", "bold");
|
|
6613
7147
|
text.setAttribute("font-family", "system-ui, sans-serif");
|
|
6614
|
-
text.textContent =
|
|
7148
|
+
text.textContent = badgeText;
|
|
6615
7149
|
svg.appendChild(text);
|
|
6616
7150
|
container.appendChild(svg);
|
|
6617
7151
|
return container;
|
|
@@ -6658,17 +7192,17 @@ function hideTooltip() {
|
|
|
6658
7192
|
tooltipEl.style.display = "none";
|
|
6659
7193
|
}
|
|
6660
7194
|
}
|
|
6661
|
-
function fingerprintCluster(pointCount, counts, size) {
|
|
6662
|
-
return `${size}|${pointCount}|${counts.join(",")}`;
|
|
7195
|
+
function fingerprintCluster(pointCount, counts, size, badgeValue) {
|
|
7196
|
+
return `${size}|${pointCount}|${badgeValue ?? ""}|${counts.join(",")}`;
|
|
6663
7197
|
}
|
|
6664
|
-
function buildPieElement(categories, pointCount, size, source, clusterId, map, coords) {
|
|
7198
|
+
function buildPieElement(categories, pointCount, size, source, clusterId, map, coords, badgeValue) {
|
|
6665
7199
|
const el = createPieSVG(categories, pointCount, size, (cat, event) => {
|
|
6666
7200
|
if (cat) {
|
|
6667
7201
|
showTooltip(cat, event.clientX, event.clientY);
|
|
6668
7202
|
} else {
|
|
6669
7203
|
hideTooltip();
|
|
6670
7204
|
}
|
|
6671
|
-
});
|
|
7205
|
+
}, badgeValue);
|
|
6672
7206
|
el.addEventListener("click", () => {
|
|
6673
7207
|
source.getClusterExpansionZoom(clusterId).then((zoom) => {
|
|
6674
7208
|
if (typeof zoom === "number") {
|
|
@@ -6687,13 +7221,16 @@ function renderClusterPies(map, sourceId, categoryValues, categoryColorMap, mark
|
|
|
6687
7221
|
});
|
|
6688
7222
|
const visibleClusterIds = /* @__PURE__ */ new Set();
|
|
6689
7223
|
clusters.forEach((feature) => {
|
|
6690
|
-
var _a, _b;
|
|
7224
|
+
var _a, _b, _c;
|
|
6691
7225
|
const clusterId = (_a = feature.properties) == null ? void 0 : _a.cluster_id;
|
|
6692
7226
|
if (clusterId === void 0) return;
|
|
6693
7227
|
const clusterKey = `${clusterId}`;
|
|
6694
7228
|
visibleClusterIds.add(clusterKey);
|
|
6695
7229
|
const coords = feature.geometry.coordinates;
|
|
6696
7230
|
const pointCount = ((_b = feature.properties) == null ? void 0 : _b.point_count) || 0;
|
|
7231
|
+
const sumRaw = (_c = feature.properties) == null ? void 0 : _c[CLUSTER_SUM_PROP];
|
|
7232
|
+
const sumNum = typeof sumRaw === "number" ? sumRaw : sumRaw != null ? Number(sumRaw) : NaN;
|
|
7233
|
+
const badgeValue = Number.isFinite(sumNum) ? sumNum : void 0;
|
|
6697
7234
|
const allCounts = categoryValues.map((_, i) => {
|
|
6698
7235
|
var _a2;
|
|
6699
7236
|
return Number(((_a2 = feature.properties) == null ? void 0 : _a2[`cat_${i}`]) || 0);
|
|
@@ -6705,13 +7242,13 @@ function renderClusterPies(map, sourceId, categoryValues, categoryColorMap, mark
|
|
|
6705
7242
|
color: categoryColorMap[cat] || "#3b82f6"
|
|
6706
7243
|
})).filter((c) => c.count > 0);
|
|
6707
7244
|
const size = pointCount < 100 ? 40 : pointCount < 750 ? 50 : 60;
|
|
6708
|
-
const fingerprint = fingerprintCluster(pointCount, allCounts, size);
|
|
7245
|
+
const fingerprint = fingerprintCluster(pointCount, allCounts, size, badgeValue);
|
|
6709
7246
|
const existing = markers.get(clusterKey);
|
|
6710
7247
|
if (existing && existing.fingerprint === fingerprint) {
|
|
6711
7248
|
existing.marker.setLngLat(coords);
|
|
6712
7249
|
return;
|
|
6713
7250
|
}
|
|
6714
|
-
const el = buildPieElement(categories, pointCount, size, source, clusterId, map, coords);
|
|
7251
|
+
const el = buildPieElement(categories, pointCount, size, source, clusterId, map, coords, badgeValue);
|
|
6715
7252
|
if (existing) {
|
|
6716
7253
|
existing.marker.remove();
|
|
6717
7254
|
}
|
|
@@ -6863,6 +7400,7 @@ const CustomSimpleSelect = {
|
|
|
6863
7400
|
startBoxSelect() {
|
|
6864
7401
|
}
|
|
6865
7402
|
};
|
|
7403
|
+
const ENRICHED_EXPORT_KEEP_KEYS = /* @__PURE__ */ new Set(["_layerIndex"]);
|
|
6866
7404
|
function createFlightPath3DLayer(layerId, mapInstance, flightPaths) {
|
|
6867
7405
|
let camera;
|
|
6868
7406
|
let scene;
|
|
@@ -7152,6 +7690,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7152
7690
|
const loadingBasemaps = react.useRef(/* @__PURE__ */ new Set());
|
|
7153
7691
|
const customBasemapRegistry = react.useRef(/* @__PURE__ */ new Map());
|
|
7154
7692
|
const clusterPieManagers = react.useRef(/* @__PURE__ */ new Map());
|
|
7693
|
+
const clusterGradientManagers = react.useRef(/* @__PURE__ */ new Map());
|
|
7694
|
+
const clusterLayerHandlers = react.useRef(/* @__PURE__ */ new Map());
|
|
7155
7695
|
const handleMapStyleChangeRef = react.useRef(null);
|
|
7156
7696
|
const flightPath3DLayerId = react.useRef(null);
|
|
7157
7697
|
const update3DFlightPathsRef = react.useRef(null);
|
|
@@ -7166,6 +7706,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7166
7706
|
const [selectedFeatureIds, setSelectedFeatureIds] = react.useState([]);
|
|
7167
7707
|
const [featureCount, setFeatureCount] = react.useState(0);
|
|
7168
7708
|
const [featureUpdateCounter, setFeatureUpdateCounter] = react.useState(0);
|
|
7709
|
+
const [clusterDataVersion, setClusterDataVersion] = react.useState(0);
|
|
7169
7710
|
const [showProperties, setShowProperties] = react.useState(false);
|
|
7170
7711
|
const [autoFocusLabel, setAutoFocusLabel] = react.useState(false);
|
|
7171
7712
|
const [showLayers, setShowLayers] = react.useState(false);
|
|
@@ -7497,6 +8038,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7497
8038
|
});
|
|
7498
8039
|
});
|
|
7499
8040
|
});
|
|
8041
|
+
const layerGradientRanges = /* @__PURE__ */ new Map();
|
|
7500
8042
|
selectedFeatureIds.forEach((fid) => {
|
|
7501
8043
|
var _a;
|
|
7502
8044
|
const feature = featById.get(fid);
|
|
@@ -7506,22 +8048,29 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7506
8048
|
colorMap.set(fid, tracePointColors.get(fid));
|
|
7507
8049
|
return;
|
|
7508
8050
|
}
|
|
7509
|
-
|
|
8051
|
+
const fallback = ((_a = feature == null ? void 0 : feature.properties) == null ? void 0 : _a.stroke) || "#3b82f6";
|
|
8052
|
+
let color = fallback;
|
|
7510
8053
|
const colorConfig = visualConfig == null ? void 0 : visualConfig.color;
|
|
7511
8054
|
if (colorConfig && feature) {
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
8055
|
+
let range;
|
|
8056
|
+
if (layer && colorConfig.mode === "field" && colorConfig.scale === "gradient" && colorConfig.fieldName) {
|
|
8057
|
+
const cached = layerGradientRanges.get(layer.id);
|
|
8058
|
+
if (cached === void 0) {
|
|
8059
|
+
range = computeNumericRange(layer.featureIds, (id) => {
|
|
8060
|
+
var _a2;
|
|
8061
|
+
return (_a2 = featById.get(id)) == null ? void 0 : _a2.properties;
|
|
8062
|
+
}, colorConfig.fieldName);
|
|
8063
|
+
layerGradientRanges.set(layer.id, range);
|
|
8064
|
+
} else {
|
|
8065
|
+
range = cached;
|
|
7518
8066
|
}
|
|
7519
8067
|
}
|
|
8068
|
+
color = resolveFeatureColor(colorConfig, feature.properties, fallback, range);
|
|
7520
8069
|
}
|
|
7521
8070
|
colorMap.set(fid, color);
|
|
7522
8071
|
});
|
|
7523
8072
|
return colorMap;
|
|
7524
|
-
}, [selectedFeatureIds, layers, getAllFeatures
|
|
8073
|
+
}, [selectedFeatureIds, layers, getAllFeatures]);
|
|
7525
8074
|
const countVisibleFeatures = react.useCallback((threshold) => {
|
|
7526
8075
|
const m = map.current;
|
|
7527
8076
|
if (!m) return 0;
|
|
@@ -7672,27 +8221,38 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7672
8221
|
layer.featureIds.forEach((fid) => featureToLayer.set(fid, layer));
|
|
7673
8222
|
});
|
|
7674
8223
|
const sizeFieldRanges = /* @__PURE__ */ new Map();
|
|
8224
|
+
const colorFieldRanges = /* @__PURE__ */ new Map();
|
|
7675
8225
|
currentLayers.forEach((layer) => {
|
|
7676
|
-
var _a;
|
|
8226
|
+
var _a, _b;
|
|
7677
8227
|
if (!layer.visible) return;
|
|
7678
8228
|
const sizeConfig = (_a = layer.visualConfig) == null ? void 0 : _a.size;
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
8229
|
+
const colorConfig = (_b = layer.visualConfig) == null ? void 0 : _b.color;
|
|
8230
|
+
const sizeField = (sizeConfig == null ? void 0 : sizeConfig.mode) === "field" && sizeConfig.fieldName ? sizeConfig.fieldName : null;
|
|
8231
|
+
const colorField = (colorConfig == null ? void 0 : colorConfig.mode) === "field" && colorConfig.scale === "gradient" && colorConfig.fieldName ? colorConfig.fieldName : null;
|
|
8232
|
+
if (!sizeField && !colorField) return;
|
|
8233
|
+
let sMin = Infinity, sMax = -Infinity;
|
|
8234
|
+
let cMin = Infinity, cMax = -Infinity;
|
|
8235
|
+
layer.featureIds.forEach((fid) => {
|
|
8236
|
+
var _a2;
|
|
8237
|
+
const props = (_a2 = featureById.get(fid)) == null ? void 0 : _a2.properties;
|
|
8238
|
+
if (!props) return;
|
|
8239
|
+
if (sizeField) {
|
|
8240
|
+
const v = coerceFiniteNumber(props[sizeField]);
|
|
8241
|
+
if (v !== null) {
|
|
8242
|
+
if (v < sMin) sMin = v;
|
|
8243
|
+
if (v > sMax) sMax = v;
|
|
7690
8244
|
}
|
|
7691
|
-
});
|
|
7692
|
-
if (isFinite(min) && isFinite(max)) {
|
|
7693
|
-
sizeFieldRanges.set(layer.id, { min, max });
|
|
7694
8245
|
}
|
|
7695
|
-
|
|
8246
|
+
if (colorField) {
|
|
8247
|
+
const v = coerceFiniteNumber(props[colorField]);
|
|
8248
|
+
if (v !== null) {
|
|
8249
|
+
if (v < cMin) cMin = v;
|
|
8250
|
+
if (v > cMax) cMax = v;
|
|
8251
|
+
}
|
|
8252
|
+
}
|
|
8253
|
+
});
|
|
8254
|
+
if (sizeField && isFinite(sMin)) sizeFieldRanges.set(layer.id, { min: sMin, max: sMax });
|
|
8255
|
+
if (colorField && isFinite(cMin)) colorFieldRanges.set(layer.id, { min: cMin, max: cMax });
|
|
7696
8256
|
});
|
|
7697
8257
|
const lastTracePointIds = /* @__PURE__ */ new Set();
|
|
7698
8258
|
const tracePointColors = /* @__PURE__ */ new Map();
|
|
@@ -7757,7 +8317,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7757
8317
|
const sourceData = {
|
|
7758
8318
|
type: "FeatureCollection",
|
|
7759
8319
|
features: allFeatures.map((f) => {
|
|
7760
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
8320
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
7761
8321
|
const featureId = String(f.id);
|
|
7762
8322
|
const layer = featureToLayer.get(featureId);
|
|
7763
8323
|
const visualConfig = layer == null ? void 0 : layer.visualConfig;
|
|
@@ -7766,14 +8326,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7766
8326
|
let strokeColor = ((_b = f.properties) == null ? void 0 : _b.stroke) || "#3b82f6";
|
|
7767
8327
|
const colorConfig = visualConfig == null ? void 0 : visualConfig.color;
|
|
7768
8328
|
if (colorConfig) {
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
}
|
|
7776
|
-
}
|
|
8329
|
+
strokeColor = resolveFeatureColor(
|
|
8330
|
+
colorConfig,
|
|
8331
|
+
f.properties,
|
|
8332
|
+
strokeColor,
|
|
8333
|
+
layer ? colorFieldRanges.get(layer.id) : void 0
|
|
8334
|
+
);
|
|
7777
8335
|
}
|
|
7778
8336
|
let strokeWidth = ((_c = f.properties) == null ? void 0 : _c["stroke-width"]) || 2;
|
|
7779
8337
|
let pointRadius = Math.round(3 + strokeWidth);
|
|
@@ -7901,7 +8459,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7901
8459
|
pointRadius,
|
|
7902
8460
|
isHiddenFor3DOnly: hideFlatFor3DOnly ? 1 : 0,
|
|
7903
8461
|
isTimelineHidden: isTimelineVisible ? 0 : 1,
|
|
7904
|
-
_labelPriority: labelPriority
|
|
8462
|
+
_labelPriority: labelPriority,
|
|
8463
|
+
[LABEL_NEVER_HIDE_PROP]: computeLabelNeverHide((_o = layer == null ? void 0 : layer.visualConfig) == null ? void 0 : _o.label)
|
|
7905
8464
|
}
|
|
7906
8465
|
};
|
|
7907
8466
|
})
|
|
@@ -8215,6 +8774,15 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8215
8774
|
clusterPieManagers.current.delete(layerId);
|
|
8216
8775
|
}
|
|
8217
8776
|
});
|
|
8777
|
+
clusterGradientManagers.current.forEach((mgr, layerId) => {
|
|
8778
|
+
if (!liveLayerIds.has(layerId)) {
|
|
8779
|
+
try {
|
|
8780
|
+
mgr.destroy();
|
|
8781
|
+
} catch {
|
|
8782
|
+
}
|
|
8783
|
+
clusterGradientManagers.current.delete(layerId);
|
|
8784
|
+
}
|
|
8785
|
+
});
|
|
8218
8786
|
const m = map.current;
|
|
8219
8787
|
if (!m) return;
|
|
8220
8788
|
let style;
|
|
@@ -8223,7 +8791,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8223
8791
|
} catch {
|
|
8224
8792
|
return;
|
|
8225
8793
|
}
|
|
8226
|
-
const layerPrefixes = ["heatmap-layer-", "cluster-count-", "clusters-", "unclustered-point-"];
|
|
8794
|
+
const layerPrefixes = ["heatmap-layer-", "cluster-count-", "cluster-single-count-", "cluster-single-", "clusters-", "unclustered-point-"];
|
|
8227
8795
|
const sourcePrefixes = ["heatmap-source-", "cluster-source-"];
|
|
8228
8796
|
((style == null ? void 0 : style.layers) ?? []).forEach((sl) => {
|
|
8229
8797
|
const prefix = layerPrefixes.find((p) => sl.id.startsWith(p));
|
|
@@ -8673,39 +9241,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8673
9241
|
id: "custom-labels",
|
|
8674
9242
|
type: "symbol",
|
|
8675
9243
|
source: "custom-features",
|
|
9244
|
+
filter: UNPINNED_LABEL_FILTER,
|
|
8676
9245
|
layout: {
|
|
9246
|
+
...buildCustomLabelLayout(),
|
|
8677
9247
|
"visibility": "none",
|
|
8678
|
-
// Hide labels for trace points (except last point which has isTraceLabel), arrows handled separately
|
|
8679
|
-
"text-field": [
|
|
8680
|
-
"case",
|
|
8681
|
-
["==", ["get", "isHiddenByTrace"], true],
|
|
8682
|
-
"",
|
|
8683
|
-
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
8684
|
-
"",
|
|
8685
|
-
["==", ["get", "isHiddenByCluster"], 1],
|
|
8686
|
-
"",
|
|
8687
|
-
["==", ["get", "kind"], "arrow"],
|
|
8688
|
-
"",
|
|
8689
|
-
// Arrows use custom-arrow-labels layer
|
|
8690
|
-
// Trace points: only show label if isTraceLabel is true (last point in group)
|
|
8691
|
-
["all", ["==", ["get", "isTracePoint"], true], ["!=", ["get", "isTraceLabel"], true]],
|
|
8692
|
-
"",
|
|
8693
|
-
["==", ["get", "kind"], "text"],
|
|
8694
|
-
["coalesce", ["get", "label"], ["get", "text"], "New Label"],
|
|
8695
|
-
["coalesce", ["get", "name"], ""]
|
|
8696
|
-
],
|
|
8697
|
-
// Text features use their fontSize property; trace labels 14px; others 12px
|
|
8698
|
-
"text-size": [
|
|
8699
|
-
"case",
|
|
8700
|
-
["==", ["get", "kind"], "text"],
|
|
8701
|
-
["coalesce", ["get", "fontSize"], 14],
|
|
8702
|
-
["==", ["get", "isTraceLabel"], true],
|
|
8703
|
-
14,
|
|
8704
|
-
12
|
|
8705
|
-
],
|
|
8706
|
-
// Text features: center anchor; others: top anchor
|
|
8707
|
-
"text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
|
|
8708
|
-
"text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
|
|
8709
9248
|
// Native collision-based de-overlap.
|
|
8710
9249
|
//
|
|
8711
9250
|
// History: a prior PR turned collision off (`text-allow-overlap: true`)
|
|
@@ -8732,40 +9271,28 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8732
9271
|
"text-allow-overlap": false,
|
|
8733
9272
|
"text-ignore-placement": false,
|
|
8734
9273
|
"text-optional": true,
|
|
8735
|
-
"text-padding": 2,
|
|
8736
9274
|
// Lower value = higher collision priority (placed first).
|
|
8737
9275
|
// Computed per-feature in syncFeaturesToCustomLayers.
|
|
8738
|
-
"symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
|
|
8739
|
-
// Bold font for text features with fontWeight=bold, trace labels, others regular
|
|
8740
|
-
"text-font": [
|
|
8741
|
-
"case",
|
|
8742
|
-
["all", ["==", ["get", "kind"], "text"], ["==", ["get", "fontWeight"], "bold"]],
|
|
8743
|
-
["literal", ["Montserrat SemiBold", "Noto Sans Regular"]],
|
|
8744
|
-
["==", ["get", "isTraceLabel"], true],
|
|
8745
|
-
["literal", ["Montserrat Medium", "Noto Sans Regular"]],
|
|
8746
|
-
["literal", ["Montserrat Regular", "Noto Sans Regular"]]
|
|
8747
|
-
]
|
|
9276
|
+
"symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
|
|
8748
9277
|
},
|
|
8749
|
-
paint:
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
"text-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
"text-opacity": ["*", 0.9, ["get", "stroke-opacity"]]
|
|
8768
|
-
}
|
|
9278
|
+
paint: buildCustomLabelPaint()
|
|
9279
|
+
});
|
|
9280
|
+
mapInstance.addLayer({
|
|
9281
|
+
id: "custom-labels-pinned",
|
|
9282
|
+
type: "symbol",
|
|
9283
|
+
source: "custom-features",
|
|
9284
|
+
filter: PINNED_LABEL_FILTER,
|
|
9285
|
+
layout: {
|
|
9286
|
+
...buildCustomLabelLayout(),
|
|
9287
|
+
"visibility": "visible",
|
|
9288
|
+
"text-allow-overlap": true,
|
|
9289
|
+
"text-ignore-placement": true,
|
|
9290
|
+
// With allow-overlap the collision pass is gone and the key only
|
|
9291
|
+
// orders painting, where HIGHER paints on top — negate so important
|
|
9292
|
+
// (low-priority-value) labels draw over their neighbours' halos.
|
|
9293
|
+
"symbol-sort-key": ["*", -1, ["coalesce", ["get", "_labelPriority"], 100]]
|
|
9294
|
+
},
|
|
9295
|
+
paint: buildCustomLabelPaint()
|
|
8769
9296
|
});
|
|
8770
9297
|
mapInstance.addSource("arrow-heads", {
|
|
8771
9298
|
type: "geojson",
|
|
@@ -9591,7 +10118,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9591
10118
|
scheduleSync();
|
|
9592
10119
|
});
|
|
9593
10120
|
mapInstance.on("click", (e) => {
|
|
9594
|
-
var _a;
|
|
10121
|
+
var _a, _b;
|
|
9595
10122
|
if (!enableSelectionRef.current) return;
|
|
9596
10123
|
if (e.originalEvent.button !== 0) return;
|
|
9597
10124
|
if (contextMenuFiredRef.current) return;
|
|
@@ -9600,14 +10127,24 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9600
10127
|
const features = mapInstance.queryRenderedFeatures(e.point, {
|
|
9601
10128
|
layers: ["custom-polygon-fill", "custom-line", "custom-point"]
|
|
9602
10129
|
});
|
|
10130
|
+
let clusteredFeatureId = null;
|
|
9603
10131
|
if (features.length === 0) {
|
|
9604
|
-
|
|
9605
|
-
|
|
10132
|
+
const clusterOverlayIds = layersRef.current.filter((l) => {
|
|
10133
|
+
var _a2;
|
|
10134
|
+
return (_a2 = l.clusterConfig) == null ? void 0 : _a2.enabled;
|
|
10135
|
+
}).flatMap((l) => [`clusters-${l.id}`, `cluster-single-${l.id}`, `cluster-single-count-${l.id}`, `unclustered-point-${l.id}`]).filter((id) => mapInstance.getLayer(id));
|
|
10136
|
+
const clusterHit = clusterOverlayIds.length > 0 ? mapInstance.queryRenderedFeatures(e.point, { layers: clusterOverlayIds })[0] : void 0;
|
|
10137
|
+
if (!clusterHit) {
|
|
10138
|
+
if (selectedFeatureIdsRef.current.length > 0 && !isModifierKey) {
|
|
10139
|
+
applySelectionState([]);
|
|
10140
|
+
}
|
|
10141
|
+
return;
|
|
9606
10142
|
}
|
|
9607
|
-
|
|
10143
|
+
const memberId = (_a = clusterHit.properties) == null ? void 0 : _a[CLUSTER_MEMBER_ID_PROP];
|
|
10144
|
+
if (memberId == null || memberId === "") return;
|
|
10145
|
+
clusteredFeatureId = String(memberId);
|
|
9608
10146
|
}
|
|
9609
|
-
const
|
|
9610
|
-
const featureId = (_a = hitFeature.properties) == null ? void 0 : _a.id;
|
|
10147
|
+
const featureId = clusteredFeatureId ?? ((_b = features[0].properties) == null ? void 0 : _b.id);
|
|
9611
10148
|
if (!featureId) return;
|
|
9612
10149
|
let isReadOnly = false;
|
|
9613
10150
|
readOnlyFeatures.current.forEach((layerFeatures) => {
|
|
@@ -10908,10 +11445,17 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10908
11445
|
scheduleSync();
|
|
10909
11446
|
scheduleTimelineUpdate();
|
|
10910
11447
|
setFeatureUpdateCounter((c) => c + 1);
|
|
11448
|
+
if (hasRealChange && !(options == null ? void 0 : options.fromRefresh) && layersRef.current.some((l) => {
|
|
11449
|
+
var _a2;
|
|
11450
|
+
return (_a2 = l.clusterConfig) == null ? void 0 : _a2.enabled;
|
|
11451
|
+
})) {
|
|
11452
|
+
setClusterDataVersion((c) => c + 1);
|
|
11453
|
+
}
|
|
10911
11454
|
const updated = draw.current.get(featureId);
|
|
10912
11455
|
if (updated) onFeatureUpdate == null ? void 0 : onFeatureUpdate(updated);
|
|
10913
11456
|
} else {
|
|
10914
11457
|
let updatedFeature;
|
|
11458
|
+
let anyRealChange = false;
|
|
10915
11459
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
10916
11460
|
var _a2;
|
|
10917
11461
|
const idx = features.findIndex((f) => String(f.id) === featureId);
|
|
@@ -10923,6 +11467,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10923
11467
|
const oldVal = (_a3 = f.properties) == null ? void 0 : _a3[key];
|
|
10924
11468
|
if (JSON.stringify(oldVal) !== JSON.stringify(value)) hasRealChange = true;
|
|
10925
11469
|
});
|
|
11470
|
+
if (hasRealChange) anyRealChange = true;
|
|
10926
11471
|
const currentUnsaved = (_a2 = f.properties) == null ? void 0 : _a2._unsaved;
|
|
10927
11472
|
const nextProperties = { ...f.properties, ...normalizedProperties };
|
|
10928
11473
|
if (!externalPersistence && hasRealChange && currentUnsaved !== false && !(options == null ? void 0 : options.fromRefresh)) {
|
|
@@ -10943,6 +11488,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10943
11488
|
scheduleSync();
|
|
10944
11489
|
scheduleTimelineUpdate();
|
|
10945
11490
|
setFeatureUpdateCounter((c) => c + 1);
|
|
11491
|
+
if (anyRealChange && !(options == null ? void 0 : options.fromRefresh) && layersRef.current.some((l) => {
|
|
11492
|
+
var _a2;
|
|
11493
|
+
return (_a2 = l.clusterConfig) == null ? void 0 : _a2.enabled;
|
|
11494
|
+
})) {
|
|
11495
|
+
setClusterDataVersion((c) => c + 1);
|
|
11496
|
+
}
|
|
10946
11497
|
onFeatureUpdate == null ? void 0 : onFeatureUpdate(updatedFeature);
|
|
10947
11498
|
}
|
|
10948
11499
|
}
|
|
@@ -10970,6 +11521,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10970
11521
|
draw.current.changeMode("simple_select", { featureIds: [featureId] });
|
|
10971
11522
|
scheduleSync();
|
|
10972
11523
|
setFeatureUpdateCounter((c) => c + 1);
|
|
11524
|
+
if (layersRef.current.some((l) => {
|
|
11525
|
+
var _a;
|
|
11526
|
+
return (_a = l.clusterConfig) == null ? void 0 : _a.enabled;
|
|
11527
|
+
})) {
|
|
11528
|
+
setClusterDataVersion((c) => c + 1);
|
|
11529
|
+
}
|
|
10973
11530
|
const updated = draw.current.get(featureId);
|
|
10974
11531
|
if (updated) {
|
|
10975
11532
|
onFeatureUpdate == null ? void 0 : onFeatureUpdate(updated);
|
|
@@ -11324,11 +11881,17 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11324
11881
|
try {
|
|
11325
11882
|
if (firstVisibleBasemapSymbol) {
|
|
11326
11883
|
m.moveLayer("custom-labels", firstVisibleBasemapSymbol.id);
|
|
11884
|
+
if (m.getLayer("custom-labels-pinned")) {
|
|
11885
|
+
m.moveLayer("custom-labels-pinned", firstVisibleBasemapSymbol.id);
|
|
11886
|
+
}
|
|
11327
11887
|
if (m.getLayer("custom-arrow-labels")) {
|
|
11328
11888
|
m.moveLayer("custom-arrow-labels", firstVisibleBasemapSymbol.id);
|
|
11329
11889
|
}
|
|
11330
11890
|
} else {
|
|
11331
11891
|
m.moveLayer("custom-labels");
|
|
11892
|
+
if (m.getLayer("custom-labels-pinned")) {
|
|
11893
|
+
m.moveLayer("custom-labels-pinned");
|
|
11894
|
+
}
|
|
11332
11895
|
if (m.getLayer("custom-arrow-labels")) {
|
|
11333
11896
|
m.moveLayer("custom-arrow-labels");
|
|
11334
11897
|
}
|
|
@@ -11633,7 +12196,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11633
12196
|
const layer = layers.find((l) => l.id === layerId);
|
|
11634
12197
|
if (!layer) return [];
|
|
11635
12198
|
const fieldsMap = /* @__PURE__ */ new Map();
|
|
11636
|
-
const excludedFields = /* @__PURE__ */ new Set(["name", "startDate", "endDate", "opacity"]);
|
|
12199
|
+
const excludedFields = /* @__PURE__ */ new Set(["name", "startDate", "endDate", "opacity", ...STYLING_PROPERTY_KEYS]);
|
|
11637
12200
|
const MAX_SAMPLES = 1e4;
|
|
11638
12201
|
let features = [];
|
|
11639
12202
|
if (layer.readOnly) {
|
|
@@ -11643,22 +12206,41 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11643
12206
|
} else {
|
|
11644
12207
|
features = hiddenFeatures.current.get(layerId) || [];
|
|
11645
12208
|
}
|
|
11646
|
-
const
|
|
12209
|
+
const sampled = !layer.readOnly && features.length > MAX_SAMPLES;
|
|
12210
|
+
const sampleFeatures = layer.readOnly ? features : features.slice(0, MAX_SAMPLES);
|
|
11647
12211
|
sampleFeatures.forEach((f) => {
|
|
11648
12212
|
if (f && f.properties) {
|
|
11649
12213
|
Object.entries(f.properties).forEach(([key, value]) => {
|
|
11650
|
-
if (
|
|
11651
|
-
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
|
|
11655
|
-
|
|
11656
|
-
|
|
12214
|
+
if (excludedFields.has(key)) return;
|
|
12215
|
+
let acc = fieldsMap.get(key);
|
|
12216
|
+
if (!acc) {
|
|
12217
|
+
acc = { isNumeric: false, numericCount: 0, nonEmptyCount: 0, min: Infinity, max: -Infinity };
|
|
12218
|
+
fieldsMap.set(key, acc);
|
|
12219
|
+
}
|
|
12220
|
+
if (typeof value === "number" || typeof value === "string" && value.trim() !== "" && !isNaN(Number(value))) {
|
|
12221
|
+
acc.isNumeric = true;
|
|
12222
|
+
}
|
|
12223
|
+
if (!(value == null || typeof value === "string" && value.trim() === "")) {
|
|
12224
|
+
acc.nonEmptyCount++;
|
|
12225
|
+
}
|
|
12226
|
+
const num = coerceFiniteNumber(value);
|
|
12227
|
+
if (num !== null) {
|
|
12228
|
+
acc.numericCount++;
|
|
12229
|
+
if (num < acc.min) acc.min = num;
|
|
12230
|
+
if (num > acc.max) acc.max = num;
|
|
11657
12231
|
}
|
|
11658
12232
|
});
|
|
11659
12233
|
}
|
|
11660
12234
|
});
|
|
11661
|
-
|
|
12235
|
+
const sampledFeatureCount = sampleFeatures.length;
|
|
12236
|
+
return Array.from(fieldsMap.entries()).map(([name, acc]) => ({
|
|
12237
|
+
name,
|
|
12238
|
+
isNumeric: acc.isNumeric,
|
|
12239
|
+
numericRatio: acc.nonEmptyCount > 0 ? acc.numericCount / acc.nonEmptyCount : 0,
|
|
12240
|
+
coverage: sampledFeatureCount > 0 ? acc.nonEmptyCount / sampledFeatureCount : 0,
|
|
12241
|
+
sampled,
|
|
12242
|
+
...acc.numericCount > 0 ? { min: acc.min, max: acc.max } : {}
|
|
12243
|
+
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
11662
12244
|
}, [layers]);
|
|
11663
12245
|
const getFieldValueDistribution = react.useCallback(
|
|
11664
12246
|
(layerId, fieldName, maxValues = 50) => {
|
|
@@ -12613,29 +13195,22 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12613
13195
|
}, [measurePoints, measureMode, isMapLoaded]);
|
|
12614
13196
|
const handleSaveLayerGeoJSON = react.useCallback((layerId) => {
|
|
12615
13197
|
const layer = layers.find((l) => l.id === layerId);
|
|
12616
|
-
if (!layer
|
|
12617
|
-
const features =
|
|
12618
|
-
|
|
12619
|
-
|
|
12620
|
-
|
|
12621
|
-
|
|
12622
|
-
|
|
12623
|
-
|
|
12624
|
-
|
|
12625
|
-
pushAll(features, hidden);
|
|
12626
|
-
}
|
|
13198
|
+
if (!layer) return;
|
|
13199
|
+
const features = collectLayerFeatures(layer, {
|
|
13200
|
+
getDrawFeature: (id) => {
|
|
13201
|
+
var _a;
|
|
13202
|
+
return (_a = draw.current) == null ? void 0 : _a.get(id);
|
|
13203
|
+
},
|
|
13204
|
+
hiddenFeatures: hiddenFeatures.current,
|
|
13205
|
+
readOnlyFeatures: readOnlyFeatures.current
|
|
13206
|
+
});
|
|
12627
13207
|
const layerMetadata = {
|
|
12628
13208
|
name: layer.name
|
|
12629
13209
|
};
|
|
12630
13210
|
if (layer.traceConfig) layerMetadata.traceConfig = layer.traceConfig;
|
|
12631
13211
|
if (layer.heatmapConfig) layerMetadata.heatmapConfig = layer.heatmapConfig;
|
|
12632
13212
|
if (layer.visualConfig) layerMetadata.visualConfig = layer.visualConfig;
|
|
12633
|
-
const cleanedFeatures = features
|
|
12634
|
-
...f,
|
|
12635
|
-
properties: Object.fromEntries(
|
|
12636
|
-
Object.entries(f.properties || {}).filter(([key]) => !key.startsWith("_"))
|
|
12637
|
-
)
|
|
12638
|
-
}));
|
|
13213
|
+
const cleanedFeatures = stripInternalProperties(features);
|
|
12639
13214
|
const geojson = {
|
|
12640
13215
|
type: "FeatureCollection",
|
|
12641
13216
|
features: cleanedFeatures,
|
|
@@ -12667,18 +13242,14 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12667
13242
|
var _a;
|
|
12668
13243
|
const isDataViewing = ((_a = layer.metadata) == null ? void 0 : _a.dataViewing) === true;
|
|
12669
13244
|
if (!isDataViewing) {
|
|
12670
|
-
const layerFeatures =
|
|
12671
|
-
|
|
12672
|
-
|
|
12673
|
-
|
|
12674
|
-
|
|
12675
|
-
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
pushAll(layerFeatures, hidden);
|
|
12679
|
-
}
|
|
12680
|
-
const roFeatures = readOnlyFeatures.current.get(layer.id);
|
|
12681
|
-
if (roFeatures) pushAll(layerFeatures, roFeatures);
|
|
13245
|
+
const layerFeatures = collectLayerFeatures(layer, {
|
|
13246
|
+
getDrawFeature: (id) => {
|
|
13247
|
+
var _a2;
|
|
13248
|
+
return (_a2 = draw.current) == null ? void 0 : _a2.get(id);
|
|
13249
|
+
},
|
|
13250
|
+
hiddenFeatures: hiddenFeatures.current,
|
|
13251
|
+
readOnlyFeatures: readOnlyFeatures.current
|
|
13252
|
+
});
|
|
12682
13253
|
layerFeatures.forEach((f) => {
|
|
12683
13254
|
allFeatures.push({
|
|
12684
13255
|
...f,
|
|
@@ -12689,14 +13260,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12689
13260
|
const { id: _id, featureIds: _fids, hasAltitudeData: _alt, ...persistable } = layer;
|
|
12690
13261
|
layerStates.push({ index: idx, ...persistable });
|
|
12691
13262
|
});
|
|
12692
|
-
const cleanedFeatures = allFeatures
|
|
12693
|
-
...f,
|
|
12694
|
-
properties: Object.fromEntries(
|
|
12695
|
-
Object.entries(f.properties || {}).filter(
|
|
12696
|
-
([key]) => !key.startsWith("_") || key === "_layerIndex"
|
|
12697
|
-
)
|
|
12698
|
-
)
|
|
12699
|
-
}));
|
|
13263
|
+
const cleanedFeatures = stripInternalProperties(allFeatures, ENRICHED_EXPORT_KEEP_KEYS);
|
|
12700
13264
|
let viewport;
|
|
12701
13265
|
if (map.current && isMapLoaded) {
|
|
12702
13266
|
const c = map.current.getCenter();
|
|
@@ -13027,6 +13591,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13027
13591
|
}
|
|
13028
13592
|
}, [ingestProgressStore]);
|
|
13029
13593
|
const loadGeoJSONFile = react.useCallback(async (file, requestedTargetLayerId, createNewLayer) => {
|
|
13594
|
+
var _a;
|
|
13030
13595
|
let result;
|
|
13031
13596
|
try {
|
|
13032
13597
|
result = await ingestWithProgress(file.name, file, {
|
|
@@ -13115,14 +13680,49 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13115
13680
|
return;
|
|
13116
13681
|
}
|
|
13117
13682
|
const currentLayers = layersRef.current;
|
|
13118
|
-
let targetLayer = currentLayers.find((l) => l.id === requestedTargetLayerId
|
|
13683
|
+
let targetLayer = currentLayers.find((l) => l.id === requestedTargetLayerId);
|
|
13684
|
+
if (((_a = targetLayer == null ? void 0 : targetLayer.metadata) == null ? void 0 : _a.dataViewing) === true) {
|
|
13685
|
+
toast({
|
|
13686
|
+
title: "Can't load into a data-viewing layer",
|
|
13687
|
+
description: "Its features are fetched from data and aren't saved with the map. Load the file into another layer.",
|
|
13688
|
+
variant: "destructive"
|
|
13689
|
+
});
|
|
13690
|
+
return;
|
|
13691
|
+
}
|
|
13119
13692
|
if (!targetLayer) {
|
|
13120
13693
|
targetLayer = currentLayers.find((l) => l.visible && !l.readOnly);
|
|
13121
13694
|
}
|
|
13122
13695
|
if (!targetLayer) {
|
|
13123
13696
|
targetLayer = currentLayers.find((l) => !l.readOnly);
|
|
13124
13697
|
}
|
|
13125
|
-
if (targetLayer
|
|
13698
|
+
if (!targetLayer) {
|
|
13699
|
+
toast({
|
|
13700
|
+
title: "No layer to load into",
|
|
13701
|
+
description: "Create a layer first, then load the file again.",
|
|
13702
|
+
variant: "destructive"
|
|
13703
|
+
});
|
|
13704
|
+
return;
|
|
13705
|
+
}
|
|
13706
|
+
const targetId = targetLayer.id;
|
|
13707
|
+
const withLayerMetadata = (l, addedIds) => ({
|
|
13708
|
+
...l,
|
|
13709
|
+
featureIds: [...l.featureIds, ...addedIds],
|
|
13710
|
+
...(layerMetadata == null ? void 0 : layerMetadata.traceConfig) && { traceConfig: layerMetadata.traceConfig },
|
|
13711
|
+
...(layerMetadata == null ? void 0 : layerMetadata.heatmapConfig) && { heatmapConfig: layerMetadata.heatmapConfig },
|
|
13712
|
+
...(layerMetadata == null ? void 0 : layerMetadata.visualConfig) && { visualConfig: layerMetadata.visualConfig }
|
|
13713
|
+
});
|
|
13714
|
+
if (targetLayer.readOnly) {
|
|
13715
|
+
const addedFeatures = normalizedFeatures.map((f) => ({ ...f, id: crypto.randomUUID() }));
|
|
13716
|
+
const addedIds = addedFeatures.map((f) => String(f.id));
|
|
13717
|
+
const existing = readOnlyFeatures.current.get(targetId) || [];
|
|
13718
|
+
readOnlyFeatures.current.set(targetId, [...existing, ...addedFeatures]);
|
|
13719
|
+
const cached = layerTemporalCacheRef.current.get(targetId);
|
|
13720
|
+
layerTemporalCacheRef.current.set(targetId, {
|
|
13721
|
+
featureCount: ((cached == null ? void 0 : cached.featureCount) ?? existing.length) + addedFeatures.length,
|
|
13722
|
+
hasTemporal: ((cached == null ? void 0 : cached.hasTemporal) ?? false) || fileHasTemporal
|
|
13723
|
+
});
|
|
13724
|
+
setLayers((prev) => prev.map((l) => l.id === targetId ? withLayerMetadata(l, addedIds) : l));
|
|
13725
|
+
} else if (targetLayer.visible) {
|
|
13126
13726
|
const addedIds = [];
|
|
13127
13727
|
isApiAddingRef.current = true;
|
|
13128
13728
|
try {
|
|
@@ -13133,32 +13733,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13133
13733
|
} finally {
|
|
13134
13734
|
isApiAddingRef.current = false;
|
|
13135
13735
|
}
|
|
13136
|
-
|
|
13137
|
-
|
|
13138
|
-
if (l.id !== targetId) return l;
|
|
13139
|
-
return {
|
|
13140
|
-
...l,
|
|
13141
|
-
featureIds: [...l.featureIds, ...addedIds],
|
|
13142
|
-
...(layerMetadata == null ? void 0 : layerMetadata.traceConfig) && { traceConfig: layerMetadata.traceConfig },
|
|
13143
|
-
...(layerMetadata == null ? void 0 : layerMetadata.heatmapConfig) && { heatmapConfig: layerMetadata.heatmapConfig },
|
|
13144
|
-
...(layerMetadata == null ? void 0 : layerMetadata.visualConfig) && { visualConfig: layerMetadata.visualConfig }
|
|
13145
|
-
};
|
|
13146
|
-
}));
|
|
13147
|
-
} else if (targetLayer) {
|
|
13148
|
-
const targetId = targetLayer.id;
|
|
13736
|
+
setLayers((prev) => prev.map((l) => l.id === targetId ? withLayerMetadata(l, addedIds) : l));
|
|
13737
|
+
} else {
|
|
13149
13738
|
const addedIds = normalizedFeatures.map((f) => String(f.id));
|
|
13150
13739
|
const existing = hiddenFeatures.current.get(targetId) || [];
|
|
13151
13740
|
hiddenFeatures.current.set(targetId, [...existing, ...normalizedFeatures]);
|
|
13152
|
-
setLayers((prev) => prev.map((l) =>
|
|
13153
|
-
if (l.id !== targetId) return l;
|
|
13154
|
-
return {
|
|
13155
|
-
...l,
|
|
13156
|
-
featureIds: [...l.featureIds, ...addedIds],
|
|
13157
|
-
...(layerMetadata == null ? void 0 : layerMetadata.traceConfig) && { traceConfig: layerMetadata.traceConfig },
|
|
13158
|
-
...(layerMetadata == null ? void 0 : layerMetadata.heatmapConfig) && { heatmapConfig: layerMetadata.heatmapConfig },
|
|
13159
|
-
...(layerMetadata == null ? void 0 : layerMetadata.visualConfig) && { visualConfig: layerMetadata.visualConfig }
|
|
13160
|
-
};
|
|
13161
|
-
}));
|
|
13741
|
+
setLayers((prev) => prev.map((l) => l.id === targetId ? withLayerMetadata(l, addedIds) : l));
|
|
13162
13742
|
}
|
|
13163
13743
|
updateFeatureCount();
|
|
13164
13744
|
scheduleTimelineUpdate();
|
|
@@ -13406,16 +13986,33 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13406
13986
|
mapInstance.once("idle", rebuildClusters);
|
|
13407
13987
|
return;
|
|
13408
13988
|
}
|
|
13989
|
+
clusterLayerHandlers.current.forEach((handlers, layerId) => {
|
|
13990
|
+
const clustersLayerId = `clusters-${layerId}`;
|
|
13991
|
+
try {
|
|
13992
|
+
mapInstance.off("click", clustersLayerId, handlers.click);
|
|
13993
|
+
mapInstance.off("mouseenter", clustersLayerId, handlers.enter);
|
|
13994
|
+
mapInstance.off("mouseleave", clustersLayerId, handlers.leave);
|
|
13995
|
+
} catch {
|
|
13996
|
+
}
|
|
13997
|
+
});
|
|
13998
|
+
clusterLayerHandlers.current.clear();
|
|
13409
13999
|
layers.forEach((layer) => {
|
|
13410
14000
|
const sourceId = `cluster-source-${layer.id}`;
|
|
13411
14001
|
const clustersLayerId = `clusters-${layer.id}`;
|
|
13412
14002
|
const clusterCountLayerId = `cluster-count-${layer.id}`;
|
|
13413
14003
|
const unclusteredLayerId = `unclustered-point-${layer.id}`;
|
|
14004
|
+
const singleValueLayerId = `cluster-single-${layer.id}`;
|
|
14005
|
+
const singleValueCountLayerId = `cluster-single-count-${layer.id}`;
|
|
13414
14006
|
const existingPieManager = clusterPieManagers.current.get(layer.id);
|
|
13415
14007
|
if (existingPieManager) {
|
|
13416
14008
|
existingPieManager.destroy();
|
|
13417
14009
|
clusterPieManagers.current.delete(layer.id);
|
|
13418
14010
|
}
|
|
14011
|
+
const existingGradientManager = clusterGradientManagers.current.get(layer.id);
|
|
14012
|
+
if (existingGradientManager) {
|
|
14013
|
+
existingGradientManager.destroy();
|
|
14014
|
+
clusterGradientManagers.current.delete(layer.id);
|
|
14015
|
+
}
|
|
13419
14016
|
try {
|
|
13420
14017
|
if (mapInstance.getLayer(clusterCountLayerId)) {
|
|
13421
14018
|
mapInstance.removeLayer(clusterCountLayerId);
|
|
@@ -13423,6 +14020,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13423
14020
|
if (mapInstance.getLayer(clustersLayerId)) {
|
|
13424
14021
|
mapInstance.removeLayer(clustersLayerId);
|
|
13425
14022
|
}
|
|
14023
|
+
if (mapInstance.getLayer(singleValueCountLayerId)) {
|
|
14024
|
+
mapInstance.removeLayer(singleValueCountLayerId);
|
|
14025
|
+
}
|
|
14026
|
+
if (mapInstance.getLayer(singleValueLayerId)) {
|
|
14027
|
+
mapInstance.removeLayer(singleValueLayerId);
|
|
14028
|
+
}
|
|
13426
14029
|
if (mapInstance.getLayer(unclusteredLayerId)) {
|
|
13427
14030
|
mapInstance.removeLayer(unclusteredLayerId);
|
|
13428
14031
|
}
|
|
@@ -13433,12 +14036,14 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13433
14036
|
}
|
|
13434
14037
|
});
|
|
13435
14038
|
layers.forEach((layer) => {
|
|
13436
|
-
var _a, _b, _c, _d;
|
|
14039
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
13437
14040
|
if (!((_a = layer.clusterConfig) == null ? void 0 : _a.enabled) || !layer.visible) return;
|
|
13438
14041
|
const sourceId = `cluster-source-${layer.id}`;
|
|
13439
14042
|
const clustersLayerId = `clusters-${layer.id}`;
|
|
13440
14043
|
const clusterCountLayerId = `cluster-count-${layer.id}`;
|
|
13441
14044
|
const unclusteredLayerId = `unclustered-point-${layer.id}`;
|
|
14045
|
+
const singleValueLayerId = `cluster-single-${layer.id}`;
|
|
14046
|
+
const singleValueCountLayerId = `cluster-single-count-${layer.id}`;
|
|
13442
14047
|
let pointFeatures = [];
|
|
13443
14048
|
if (layer.visible) {
|
|
13444
14049
|
if (layer.readOnly) {
|
|
@@ -13465,10 +14070,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13465
14070
|
}
|
|
13466
14071
|
if (pointFeatures.length === 0) return;
|
|
13467
14072
|
const groupByField = (_b = layer.clusterConfig) == null ? void 0 : _b.groupByField;
|
|
14073
|
+
const countByField = ((_c = layer.clusterConfig) == null ? void 0 : _c.countByFieldEnabled) && ((_d = layer.clusterConfig) == null ? void 0 : _d.countByField) || null;
|
|
14074
|
+
const bubbleGradient = !!((_e = layer.clusterConfig) == null ? void 0 : _e.bubbleGradient) && !groupByField;
|
|
13468
14075
|
const OTHER_COLOR = OTHER_BUCKET_COLOR;
|
|
13469
14076
|
const MAX_CATEGORIES = 15;
|
|
13470
14077
|
try {
|
|
13471
|
-
const layerColor = ((
|
|
14078
|
+
const layerColor = ((_g = (_f = layer.visualConfig) == null ? void 0 : _f.color) == null ? void 0 : _g.fixedColor) || "#3b82f6";
|
|
13472
14079
|
let clusterProperties = {};
|
|
13473
14080
|
let categoryValues = [];
|
|
13474
14081
|
let categoryColorMap = {};
|
|
@@ -13498,12 +14105,16 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13498
14105
|
const otherExpr = topKeys.length === 0 ? 1 : ["match", fieldAsString, topKeys, 0, 1];
|
|
13499
14106
|
clusterProperties[`cat_${categoryValues.length - 1}`] = ["+", otherExpr];
|
|
13500
14107
|
}
|
|
14108
|
+
if (countByField) {
|
|
14109
|
+
clusterProperties[CLUSTER_SUM_PROP] = ["+", ["get", CLUSTER_COUNT_VALUE_PROP]];
|
|
14110
|
+
}
|
|
14111
|
+
const sourceFeatures = countByField ? injectClusterCountValues(pointFeatures, countByField) : pointFeatures;
|
|
13501
14112
|
const mapStyleMaxZoom = typeof mapInstance.getMaxZoom === "function" ? mapInstance.getMaxZoom() : 24;
|
|
13502
14113
|
const clusterMaxZoom = Math.min(24, Math.max(1, mapStyleMaxZoom - 1));
|
|
13503
14114
|
const geojsonSourceMaxZoom = Math.min(24, Math.max(clusterMaxZoom + 1, mapStyleMaxZoom));
|
|
13504
14115
|
mapInstance.addSource(sourceId, {
|
|
13505
14116
|
type: "geojson",
|
|
13506
|
-
data: { type: "FeatureCollection", features:
|
|
14117
|
+
data: { type: "FeatureCollection", features: sourceFeatures },
|
|
13507
14118
|
maxzoom: geojsonSourceMaxZoom,
|
|
13508
14119
|
cluster: true,
|
|
13509
14120
|
clusterMaxZoom,
|
|
@@ -13561,12 +14172,15 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13561
14172
|
source: sourceId,
|
|
13562
14173
|
filter: ["has", "point_count"],
|
|
13563
14174
|
layout: {
|
|
13564
|
-
"text-field": ["get", "point_count_abbreviated"],
|
|
14175
|
+
"text-field": countByField ? clusterBadgeTextField(CLUSTER_SUM_PROP) : ["get", "point_count_abbreviated"],
|
|
13565
14176
|
"text-font": ["Open Sans Bold", "Arial Unicode MS Bold"],
|
|
13566
14177
|
"text-size": 12
|
|
13567
14178
|
},
|
|
13568
14179
|
paint: {
|
|
13569
|
-
"text-color": "#ffffff"
|
|
14180
|
+
"text-color": "#ffffff",
|
|
14181
|
+
// The gradient's pale end needs a dark halo for the white
|
|
14182
|
+
// badge text to stay readable at every ramp stop.
|
|
14183
|
+
...bubbleGradient ? { "text-halo-color": "#111827", "text-halo-width": 1.1 } : {}
|
|
13570
14184
|
}
|
|
13571
14185
|
});
|
|
13572
14186
|
}
|
|
@@ -13581,7 +14195,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13581
14195
|
id: unclusteredLayerId,
|
|
13582
14196
|
type: "circle",
|
|
13583
14197
|
source: sourceId,
|
|
13584
|
-
|
|
14198
|
+
// With count-by-field on, points whose value exceeds 1 render as
|
|
14199
|
+
// value bubbles below instead of plain dots.
|
|
14200
|
+
filter: countByField ? ["all", ["!", ["has", "point_count"]], ["<=", ["get", CLUSTER_COUNT_VALUE_PROP], 1]] : ["!", ["has", "point_count"]],
|
|
13585
14201
|
paint: {
|
|
13586
14202
|
"circle-color": unclusteredColor,
|
|
13587
14203
|
"circle-radius": 6,
|
|
@@ -13589,7 +14205,50 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13589
14205
|
"circle-stroke-color": "#ffffff"
|
|
13590
14206
|
}
|
|
13591
14207
|
});
|
|
13592
|
-
|
|
14208
|
+
if (countByField) {
|
|
14209
|
+
const singleValueFilter = ["all", ["!", ["has", "point_count"]], [">", ["get", CLUSTER_COUNT_VALUE_PROP], 1]];
|
|
14210
|
+
mapInstance.addLayer({
|
|
14211
|
+
id: singleValueLayerId,
|
|
14212
|
+
type: "circle",
|
|
14213
|
+
source: sourceId,
|
|
14214
|
+
filter: singleValueFilter,
|
|
14215
|
+
paint: {
|
|
14216
|
+
"circle-color": unclusteredColor,
|
|
14217
|
+
"circle-radius": 14,
|
|
14218
|
+
"circle-stroke-width": 2,
|
|
14219
|
+
"circle-stroke-color": "#ffffff"
|
|
14220
|
+
}
|
|
14221
|
+
});
|
|
14222
|
+
mapInstance.addLayer({
|
|
14223
|
+
id: singleValueCountLayerId,
|
|
14224
|
+
type: "symbol",
|
|
14225
|
+
source: sourceId,
|
|
14226
|
+
filter: singleValueFilter,
|
|
14227
|
+
layout: {
|
|
14228
|
+
"text-field": clusterBadgeTextField(CLUSTER_COUNT_VALUE_PROP),
|
|
14229
|
+
"text-font": ["Open Sans Bold", "Arial Unicode MS Bold"],
|
|
14230
|
+
"text-size": 11,
|
|
14231
|
+
// A bubble without its number reads as broken - never cull.
|
|
14232
|
+
"text-allow-overlap": true,
|
|
14233
|
+
"text-ignore-placement": true
|
|
14234
|
+
},
|
|
14235
|
+
paint: {
|
|
14236
|
+
"text-color": "#ffffff",
|
|
14237
|
+
...bubbleGradient ? { "text-halo-color": "#111827", "text-halo-width": 1.1 } : {}
|
|
14238
|
+
}
|
|
14239
|
+
});
|
|
14240
|
+
}
|
|
14241
|
+
if (bubbleGradient) {
|
|
14242
|
+
clusterGradientManagers.current.set(
|
|
14243
|
+
layer.id,
|
|
14244
|
+
createClusterGradientManager(mapInstance, sourceId, {
|
|
14245
|
+
clustersLayerId,
|
|
14246
|
+
valueProp: countByField ? CLUSTER_SUM_PROP : null,
|
|
14247
|
+
...countByField ? { singleLayerId: singleValueLayerId } : {}
|
|
14248
|
+
})
|
|
14249
|
+
);
|
|
14250
|
+
}
|
|
14251
|
+
const handleClusterClick = async (e) => {
|
|
13593
14252
|
var _a2;
|
|
13594
14253
|
const features = mapInstance.queryRenderedFeatures(e.point, {
|
|
13595
14254
|
layers: [clustersLayerId]
|
|
@@ -13608,12 +14267,20 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13608
14267
|
}
|
|
13609
14268
|
} catch {
|
|
13610
14269
|
}
|
|
13611
|
-
}
|
|
13612
|
-
|
|
14270
|
+
};
|
|
14271
|
+
const handleClusterMouseEnter = () => {
|
|
13613
14272
|
mapInstance.getCanvas().style.cursor = "pointer";
|
|
13614
|
-
}
|
|
13615
|
-
|
|
14273
|
+
};
|
|
14274
|
+
const handleClusterMouseLeave = () => {
|
|
13616
14275
|
mapInstance.getCanvas().style.cursor = "";
|
|
14276
|
+
};
|
|
14277
|
+
mapInstance.on("click", clustersLayerId, handleClusterClick);
|
|
14278
|
+
mapInstance.on("mouseenter", clustersLayerId, handleClusterMouseEnter);
|
|
14279
|
+
mapInstance.on("mouseleave", clustersLayerId, handleClusterMouseLeave);
|
|
14280
|
+
clusterLayerHandlers.current.set(layer.id, {
|
|
14281
|
+
click: handleClusterClick,
|
|
14282
|
+
enter: handleClusterMouseEnter,
|
|
14283
|
+
leave: handleClusterMouseLeave
|
|
13617
14284
|
});
|
|
13618
14285
|
} catch (e) {
|
|
13619
14286
|
console.warn("Error creating cluster layer:", e);
|
|
@@ -13631,7 +14298,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13631
14298
|
} catch {
|
|
13632
14299
|
}
|
|
13633
14300
|
};
|
|
13634
|
-
}, [isMapLoaded, layers, currentMapStyle, hashStringToColor$1]);
|
|
14301
|
+
}, [isMapLoaded, layers, currentMapStyle, hashStringToColor$1, clusterDataVersion]);
|
|
13635
14302
|
if (mapError) {
|
|
13636
14303
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex items-center justify-center h-full bg-muted/30 ${className || ""}`, "data-testid": "map-error", children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Card, { className: "max-w-md", children: [
|
|
13637
14304
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 border-b border-border", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
@@ -15151,40 +15818,6 @@ function DebugSidebar({ onAddRandomPoints, onImportKML, onAddDomMarkers, onRemov
|
|
|
15151
15818
|
}
|
|
15152
15819
|
);
|
|
15153
15820
|
}
|
|
15154
|
-
const INTERNAL_PROPERTY_KEYS = /* @__PURE__ */ new Set([
|
|
15155
|
-
"fill",
|
|
15156
|
-
"fill-opacity",
|
|
15157
|
-
"pointRadius",
|
|
15158
|
-
"pointIcon",
|
|
15159
|
-
"pointIconSize",
|
|
15160
|
-
"circleCenter",
|
|
15161
|
-
"circleRadius",
|
|
15162
|
-
"icon",
|
|
15163
|
-
"iconSize",
|
|
15164
|
-
"fontSize",
|
|
15165
|
-
"fontColor",
|
|
15166
|
-
"fontWeight",
|
|
15167
|
-
"arrowSize",
|
|
15168
|
-
"label",
|
|
15169
|
-
"entityType",
|
|
15170
|
-
"kind",
|
|
15171
|
-
"meta:type",
|
|
15172
|
-
"stroke",
|
|
15173
|
-
"stroke-width",
|
|
15174
|
-
"stroke-opacity"
|
|
15175
|
-
]);
|
|
15176
|
-
const INTERNAL_PROPERTY_PREFIXES = [
|
|
15177
|
-
"IsHiddenBy",
|
|
15178
|
-
"isHidden",
|
|
15179
|
-
"isSelected",
|
|
15180
|
-
"isTrace",
|
|
15181
|
-
"isTimeline",
|
|
15182
|
-
"trace"
|
|
15183
|
-
];
|
|
15184
|
-
function isInternalProperty(key) {
|
|
15185
|
-
if (INTERNAL_PROPERTY_KEYS.has(key)) return true;
|
|
15186
|
-
return INTERNAL_PROPERTY_PREFIXES.some((prefix) => key.startsWith(prefix));
|
|
15187
|
-
}
|
|
15188
15821
|
exports.ActionPanel = ActionPanel;
|
|
15189
15822
|
exports.ClusterPieManager = ClusterPieManager;
|
|
15190
15823
|
exports.ColorPickerPopover = ColorPickerPopover;
|