@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.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import MapboxDraw from "@mapbox/mapbox-gl-draw";
|
|
|
5
5
|
import * as turf from "@turf/turf";
|
|
6
6
|
import * as THREE from "three";
|
|
7
7
|
import proj4 from "proj4";
|
|
8
|
-
import { Button, Modal, Input, App, message, Tooltip, Dropdown, Divider, Popover, Switch, Slider, Tag, Select, Collapse, ColorPicker, Tabs, Card, Table, DatePicker } from "antd";
|
|
8
|
+
import { Button, Modal, Input, App, message, Tooltip, Dropdown, Divider, Popover, Switch, Slider, Tag, Select, Segmented, Collapse, ColorPicker, Tabs, Card, Table, DatePicker } from "antd";
|
|
9
9
|
import { clsx } from "clsx";
|
|
10
10
|
import { twMerge } from "tailwind-merge";
|
|
11
11
|
import { MousePointer2, Square, Hexagon, Circle, MoreVertical, ChevronDown, Filter, X, Move, Ruler, Search, Scan, Pencil, Database, MapPin, Minus, Pentagon, Type, MoveRight, Undo2, Redo2, Trash2, Navigation, Loader2, Map as Map$1, Satellite, FolderOpen, Upload, Download, MoreHorizontal, Focus, Box, Layers, Plus, ChevronRight, Eye, EyeOff, Lock, Smile, Package, Copy, FolderInput, Save, Calendar, Palette, Blend, RefreshCw, ExternalLink, Info, SkipBack, Pause, Play, Clock, AlertTriangle, TestTube, Users, GripVertical, Plane, FileJson, Check, Phone, Car, AlertCircle } from "lucide-react";
|
|
@@ -1071,6 +1071,30 @@ function downloadBlob(blob, filename) {
|
|
|
1071
1071
|
anchor.remove();
|
|
1072
1072
|
setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
1073
1073
|
}
|
|
1074
|
+
function collectLayerFeatures(layer, sources) {
|
|
1075
|
+
const features = [];
|
|
1076
|
+
if (layer.visible) {
|
|
1077
|
+
for (const id of layer.featureIds) {
|
|
1078
|
+
const f = sources.getDrawFeature(id);
|
|
1079
|
+
if (f) features.push(f);
|
|
1080
|
+
}
|
|
1081
|
+
} else {
|
|
1082
|
+
pushAll(features, sources.hiddenFeatures.get(layer.id) ?? []);
|
|
1083
|
+
}
|
|
1084
|
+
const readOnly = sources.readOnlyFeatures.get(layer.id);
|
|
1085
|
+
if (readOnly) pushAll(features, readOnly);
|
|
1086
|
+
return features;
|
|
1087
|
+
}
|
|
1088
|
+
function stripInternalProperties(features, keep) {
|
|
1089
|
+
return features.map((f) => ({
|
|
1090
|
+
...f,
|
|
1091
|
+
properties: Object.fromEntries(
|
|
1092
|
+
Object.entries(f.properties ?? {}).filter(
|
|
1093
|
+
([key]) => !key.startsWith("_") || ((keep == null ? void 0 : keep.has(key)) ?? false)
|
|
1094
|
+
)
|
|
1095
|
+
)
|
|
1096
|
+
}));
|
|
1097
|
+
}
|
|
1074
1098
|
const ToastContext = createContext(null);
|
|
1075
1099
|
function useToast() {
|
|
1076
1100
|
const externalToast = useContext(ToastContext);
|
|
@@ -2316,6 +2340,85 @@ function hashStringToColor(str) {
|
|
|
2316
2340
|
const light = 45 + (hash >>> 16) % 18;
|
|
2317
2341
|
return hslToHex(hue, sat, light);
|
|
2318
2342
|
}
|
|
2343
|
+
const GRADIENT_RAMP = [
|
|
2344
|
+
"#fee5d9",
|
|
2345
|
+
"#fcae91",
|
|
2346
|
+
"#fb6a4a",
|
|
2347
|
+
"#de2d26",
|
|
2348
|
+
"#a50f15"
|
|
2349
|
+
];
|
|
2350
|
+
const GRADIENT_FALLBACK_COLOR = "#9ca3af";
|
|
2351
|
+
const NUMERIC_FIELD_RATIO_THRESHOLD = 0.8;
|
|
2352
|
+
const NUMERIC_FIELD_COVERAGE_FLOOR = 0.3;
|
|
2353
|
+
function coerceFiniteNumber(raw) {
|
|
2354
|
+
if (typeof raw === "number") return Number.isFinite(raw) ? raw : null;
|
|
2355
|
+
if (typeof raw === "string" && raw.trim() !== "") {
|
|
2356
|
+
const n = Number(raw);
|
|
2357
|
+
return Number.isFinite(n) ? n : null;
|
|
2358
|
+
}
|
|
2359
|
+
return null;
|
|
2360
|
+
}
|
|
2361
|
+
function parseHexColor(hex) {
|
|
2362
|
+
return [
|
|
2363
|
+
parseInt(hex.slice(1, 3), 16),
|
|
2364
|
+
parseInt(hex.slice(3, 5), 16),
|
|
2365
|
+
parseInt(hex.slice(5, 7), 16)
|
|
2366
|
+
];
|
|
2367
|
+
}
|
|
2368
|
+
function gradientColor(t, ramp = GRADIENT_RAMP) {
|
|
2369
|
+
const clamped = Math.max(0, Math.min(1, Number.isFinite(t) ? t : 0.5));
|
|
2370
|
+
const scaled = clamped * (ramp.length - 1);
|
|
2371
|
+
const i = Math.min(Math.floor(scaled), ramp.length - 2);
|
|
2372
|
+
const frac = scaled - i;
|
|
2373
|
+
const [r1, g1, b1] = parseHexColor(ramp[i]);
|
|
2374
|
+
const [r2, g2, b2] = parseHexColor(ramp[i + 1]);
|
|
2375
|
+
const channel = (a, b) => Math.round(a + (b - a) * frac).toString(16).padStart(2, "0");
|
|
2376
|
+
return `#${channel(r1, r2)}${channel(g1, g2)}${channel(b1, b2)}`;
|
|
2377
|
+
}
|
|
2378
|
+
function defaultColorScaleForField(field) {
|
|
2379
|
+
if (!field) return "categorical";
|
|
2380
|
+
return (field.numericRatio ?? 0) >= NUMERIC_FIELD_RATIO_THRESHOLD && (field.coverage ?? 0) >= NUMERIC_FIELD_COVERAGE_FLOOR ? "gradient" : "categorical";
|
|
2381
|
+
}
|
|
2382
|
+
function computeNumericRange(featureIds, getProperties, fieldName) {
|
|
2383
|
+
var _a;
|
|
2384
|
+
let min = Infinity;
|
|
2385
|
+
let max = -Infinity;
|
|
2386
|
+
for (const id of featureIds) {
|
|
2387
|
+
const v = coerceFiniteNumber((_a = getProperties(id)) == null ? void 0 : _a[fieldName]);
|
|
2388
|
+
if (v === null) continue;
|
|
2389
|
+
if (v < min) min = v;
|
|
2390
|
+
if (v > max) max = v;
|
|
2391
|
+
}
|
|
2392
|
+
return isFinite(min) ? { min, max } : null;
|
|
2393
|
+
}
|
|
2394
|
+
function resolveFeatureColor(colorConfig, properties, fallback, gradientRange) {
|
|
2395
|
+
if (!colorConfig) return fallback;
|
|
2396
|
+
if (colorConfig.mode === "fixed" && colorConfig.fixedColor) return colorConfig.fixedColor;
|
|
2397
|
+
if (colorConfig.mode === "field" && colorConfig.fieldName) {
|
|
2398
|
+
if (colorConfig.scale === "gradient") {
|
|
2399
|
+
const value = coerceFiniteNumber(properties == null ? void 0 : properties[colorConfig.fieldName]);
|
|
2400
|
+
if (value === null || !gradientRange) return GRADIENT_FALLBACK_COLOR;
|
|
2401
|
+
const t = gradientRange.max > gradientRange.min ? (value - gradientRange.min) / (gradientRange.max - gradientRange.min) : 0.5;
|
|
2402
|
+
return gradientColor(t);
|
|
2403
|
+
}
|
|
2404
|
+
if (properties) {
|
|
2405
|
+
const key = categoricalKey(properties[colorConfig.fieldName]);
|
|
2406
|
+
if (key !== null) return hashStringToColor(key);
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
return fallback;
|
|
2410
|
+
}
|
|
2411
|
+
function formatGradientStop(value) {
|
|
2412
|
+
if (!Number.isFinite(value)) return "";
|
|
2413
|
+
const abs = Math.abs(value);
|
|
2414
|
+
if (abs >= 1e4) {
|
|
2415
|
+
return new Intl.NumberFormat("en-US", { notation: "compact", maximumFractionDigits: 1 }).format(value);
|
|
2416
|
+
}
|
|
2417
|
+
if (abs > 0 && abs < 1) {
|
|
2418
|
+
return new Intl.NumberFormat("en-US", { maximumSignificantDigits: 3 }).format(value);
|
|
2419
|
+
}
|
|
2420
|
+
return new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 }).format(value);
|
|
2421
|
+
}
|
|
2319
2422
|
const MAP_STYLES = [
|
|
2320
2423
|
{ id: "streets", name: "Streets", icon: Map$1 },
|
|
2321
2424
|
{ id: "satellite", name: "Satellite", icon: Satellite },
|
|
@@ -2404,6 +2507,38 @@ function ColorByFieldLegend({
|
|
|
2404
2507
|
}
|
|
2405
2508
|
);
|
|
2406
2509
|
}
|
|
2510
|
+
function ColorGradientLegend({
|
|
2511
|
+
layerId,
|
|
2512
|
+
min,
|
|
2513
|
+
max,
|
|
2514
|
+
sampled
|
|
2515
|
+
}) {
|
|
2516
|
+
const degenerate = min === max;
|
|
2517
|
+
return /* @__PURE__ */ jsxs(
|
|
2518
|
+
"div",
|
|
2519
|
+
{
|
|
2520
|
+
className: "mt-1 rounded border border-border/50 bg-background/40 p-1.5",
|
|
2521
|
+
"data-testid": `legend-gradient-${layerId}`,
|
|
2522
|
+
children: [
|
|
2523
|
+
/* @__PURE__ */ jsxs("div", { className: "text-[10px] uppercase tracking-wide text-muted-foreground mb-1", children: [
|
|
2524
|
+
"Legend",
|
|
2525
|
+
sampled ? " (sampled)" : ""
|
|
2526
|
+
] }),
|
|
2527
|
+
/* @__PURE__ */ jsx(
|
|
2528
|
+
"div",
|
|
2529
|
+
{
|
|
2530
|
+
className: "h-2.5 rounded-sm border border-black/10",
|
|
2531
|
+
style: { background: degenerate ? gradientColor(0.5) : `linear-gradient(to right, ${GRADIENT_RAMP.join(", ")})` }
|
|
2532
|
+
}
|
|
2533
|
+
),
|
|
2534
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-between text-[11px] text-muted-foreground tabular-nums mt-0.5", children: degenerate ? /* @__PURE__ */ jsx("span", { className: "mx-auto", children: formatGradientStop(min) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2535
|
+
/* @__PURE__ */ jsx("span", { children: formatGradientStop(min) }),
|
|
2536
|
+
/* @__PURE__ */ jsx("span", { children: formatGradientStop(max) })
|
|
2537
|
+
] }) })
|
|
2538
|
+
]
|
|
2539
|
+
}
|
|
2540
|
+
);
|
|
2541
|
+
}
|
|
2407
2542
|
function LayersPanel({
|
|
2408
2543
|
layers,
|
|
2409
2544
|
onAddLayer,
|
|
@@ -2542,7 +2677,7 @@ function LayersPanel({
|
|
|
2542
2677
|
});
|
|
2543
2678
|
}, [onRemoveLayer]);
|
|
2544
2679
|
const renderLayerItem = (layer) => {
|
|
2545
|
-
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;
|
|
2680
|
+
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;
|
|
2546
2681
|
const customCount = featureCountProvider == null ? void 0 : featureCountProvider(layer.id);
|
|
2547
2682
|
const featureCount = customCount != null ? customCount : getFeatureCount(layer.id);
|
|
2548
2683
|
const isExpanded = expandedLayers.has(layer.id);
|
|
@@ -2655,6 +2790,41 @@ function LayersPanel({
|
|
|
2655
2790
|
label: "Save GeoJSON to desktop",
|
|
2656
2791
|
onClick: () => onSaveLayerGeoJSON(layer.id)
|
|
2657
2792
|
},
|
|
2793
|
+
...onUpdateVisualConfig ? [
|
|
2794
|
+
{ type: "divider" },
|
|
2795
|
+
{
|
|
2796
|
+
key: "never-hide-labels",
|
|
2797
|
+
label: /* @__PURE__ */ jsxs("div", { className: "px-1.5 py-1", onClick: (e) => e.stopPropagation(), children: [
|
|
2798
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
2799
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
2800
|
+
/* @__PURE__ */ jsx(Type, { className: "w-[18px] h-[18px]" }),
|
|
2801
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm", children: "Never hide labels" })
|
|
2802
|
+
] }),
|
|
2803
|
+
/* @__PURE__ */ jsx(
|
|
2804
|
+
Switch,
|
|
2805
|
+
{
|
|
2806
|
+
size: "small",
|
|
2807
|
+
disabled: (_b = (_a = layer.visualConfig) == null ? void 0 : _a.label) == null ? void 0 : _b.hidden,
|
|
2808
|
+
checked: !!((_d = (_c = layer.visualConfig) == null ? void 0 : _c.label) == null ? void 0 : _d.neverHide),
|
|
2809
|
+
onChange: (checked) => {
|
|
2810
|
+
var _a2, _b2, _c2;
|
|
2811
|
+
return onUpdateVisualConfig(layer.id, {
|
|
2812
|
+
...layer.visualConfig,
|
|
2813
|
+
label: {
|
|
2814
|
+
...(_a2 = layer.visualConfig) == null ? void 0 : _a2.label,
|
|
2815
|
+
mode: ((_c2 = (_b2 = layer.visualConfig) == null ? void 0 : _b2.label) == null ? void 0 : _c2.mode) ?? "standard",
|
|
2816
|
+
neverHide: checked
|
|
2817
|
+
}
|
|
2818
|
+
});
|
|
2819
|
+
},
|
|
2820
|
+
"data-testid": `switch-never-hide-labels-${layer.id}`
|
|
2821
|
+
}
|
|
2822
|
+
)
|
|
2823
|
+
] }),
|
|
2824
|
+
/* @__PURE__ */ 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" })
|
|
2825
|
+
] })
|
|
2826
|
+
}
|
|
2827
|
+
] : [],
|
|
2658
2828
|
...onFitToLayerFeatures && (typeof featureCount === "string" ? featureCount.length > 0 : featureCount > 0) ? [
|
|
2659
2829
|
{ type: "divider" },
|
|
2660
2830
|
{
|
|
@@ -2707,14 +2877,14 @@ function LayersPanel({
|
|
|
2707
2877
|
]
|
|
2708
2878
|
}
|
|
2709
2879
|
),
|
|
2710
|
-
(hasPointFeatures == null ? void 0 : hasPointFeatures(layer.id)) && !((
|
|
2880
|
+
(hasPointFeatures == null ? void 0 : hasPointFeatures(layer.id)) && !((_g = layer.metadata) == null ? void 0 : _g.hidePointFeatures) && /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-1.5 bg-muted/30 rounded-md", children: [
|
|
2711
2881
|
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-1.5 text-xs font-medium", children: /* @__PURE__ */ jsx("span", { children: "Point Features" }) }),
|
|
2712
2882
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
2713
2883
|
/* @__PURE__ */ jsx(
|
|
2714
2884
|
Switch,
|
|
2715
2885
|
{
|
|
2716
2886
|
size: "small",
|
|
2717
|
-
checked: ((
|
|
2887
|
+
checked: ((_h = layer.traceConfig) == null ? void 0 : _h.enabled) ?? false,
|
|
2718
2888
|
onChange: (checked) => {
|
|
2719
2889
|
var _a2;
|
|
2720
2890
|
return onUpdateTraceConfig(layer.id, {
|
|
@@ -2727,7 +2897,7 @@ function LayersPanel({
|
|
|
2727
2897
|
),
|
|
2728
2898
|
/* @__PURE__ */ jsx("span", { className: "text-xs", children: "Trace Lines" })
|
|
2729
2899
|
] }),
|
|
2730
|
-
((
|
|
2900
|
+
((_i = layer.traceConfig) == null ? void 0 : _i.enabled) && /* @__PURE__ */ jsx(
|
|
2731
2901
|
Select,
|
|
2732
2902
|
{
|
|
2733
2903
|
size: "small",
|
|
@@ -2753,7 +2923,7 @@ function LayersPanel({
|
|
|
2753
2923
|
Switch,
|
|
2754
2924
|
{
|
|
2755
2925
|
size: "small",
|
|
2756
|
-
checked: ((
|
|
2926
|
+
checked: ((_j = layer.heatmapConfig) == null ? void 0 : _j.enabled) ?? false,
|
|
2757
2927
|
onChange: (checked) => {
|
|
2758
2928
|
var _a2, _b2;
|
|
2759
2929
|
return onUpdateHeatmapConfig(layer.id, {
|
|
@@ -2767,7 +2937,7 @@ function LayersPanel({
|
|
|
2767
2937
|
),
|
|
2768
2938
|
/* @__PURE__ */ jsx("span", { className: "text-xs", children: "Heatmap" })
|
|
2769
2939
|
] }),
|
|
2770
|
-
((
|
|
2940
|
+
((_k = layer.heatmapConfig) == null ? void 0 : _k.enabled) && /* @__PURE__ */ jsxs("div", { className: "space-y-1 pl-4", children: [
|
|
2771
2941
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
2772
2942
|
/* @__PURE__ */ jsx("span", { className: "text-[10px] w-12", children: "Intensity" }),
|
|
2773
2943
|
/* @__PURE__ */ jsx(
|
|
@@ -2811,10 +2981,11 @@ function LayersPanel({
|
|
|
2811
2981
|
Switch,
|
|
2812
2982
|
{
|
|
2813
2983
|
size: "small",
|
|
2814
|
-
checked: ((
|
|
2984
|
+
checked: ((_l = layer.clusterConfig) == null ? void 0 : _l.enabled) ?? false,
|
|
2815
2985
|
onChange: (checked) => {
|
|
2816
2986
|
var _a2, _b2;
|
|
2817
2987
|
return onUpdateClusterConfig(layer.id, {
|
|
2988
|
+
...layer.clusterConfig,
|
|
2818
2989
|
enabled: checked,
|
|
2819
2990
|
groupByField: ((_a2 = layer.clusterConfig) == null ? void 0 : _a2.groupByField) ?? null,
|
|
2820
2991
|
showPointDots: ((_b2 = layer.clusterConfig) == null ? void 0 : _b2.showPointDots) ?? false
|
|
@@ -2825,7 +2996,7 @@ function LayersPanel({
|
|
|
2825
2996
|
),
|
|
2826
2997
|
/* @__PURE__ */ jsx("span", { className: "text-xs", children: "Clustering" })
|
|
2827
2998
|
] }),
|
|
2828
|
-
((
|
|
2999
|
+
((_m = layer.clusterConfig) == null ? void 0 : _m.enabled) && getLayerFields && /* @__PURE__ */ jsxs("div", { className: "space-y-1 pl-4", children: [
|
|
2829
3000
|
/* @__PURE__ */ jsx(
|
|
2830
3001
|
Select,
|
|
2831
3002
|
{
|
|
@@ -2858,6 +3029,53 @@ function LayersPanel({
|
|
|
2858
3029
|
}
|
|
2859
3030
|
),
|
|
2860
3031
|
/* @__PURE__ */ jsx("span", { className: "text-[10px]", children: "Show point dots" })
|
|
3032
|
+
] }),
|
|
3033
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
3034
|
+
/* @__PURE__ */ jsx(
|
|
3035
|
+
Switch,
|
|
3036
|
+
{
|
|
3037
|
+
size: "small",
|
|
3038
|
+
checked: layer.clusterConfig.countByFieldEnabled ?? false,
|
|
3039
|
+
onChange: (checked) => onUpdateClusterConfig(layer.id, {
|
|
3040
|
+
...layer.clusterConfig,
|
|
3041
|
+
countByFieldEnabled: checked
|
|
3042
|
+
}),
|
|
3043
|
+
"data-testid": `switch-cluster-count-by-${layer.id}`
|
|
3044
|
+
}
|
|
3045
|
+
),
|
|
3046
|
+
/* @__PURE__ */ jsx("span", { className: "text-[10px]", children: "Count by field" })
|
|
3047
|
+
] }),
|
|
3048
|
+
layer.clusterConfig.countByFieldEnabled && /* @__PURE__ */ jsx(
|
|
3049
|
+
Select,
|
|
3050
|
+
{
|
|
3051
|
+
size: "small",
|
|
3052
|
+
value: layer.clusterConfig.countByField ?? void 0,
|
|
3053
|
+
onChange: (val) => onUpdateClusterConfig(layer.id, {
|
|
3054
|
+
...layer.clusterConfig,
|
|
3055
|
+
countByField: val
|
|
3056
|
+
}),
|
|
3057
|
+
className: "w-full text-xs",
|
|
3058
|
+
placeholder: "Select numeric field...",
|
|
3059
|
+
showSearch: true,
|
|
3060
|
+
optionFilterProp: "label",
|
|
3061
|
+
options: getLayerFields(layer.id).filter((f) => f.isNumeric).map((f) => ({ value: f.name, label: f.name })),
|
|
3062
|
+
"data-testid": `select-cluster-count-field-${layer.id}`
|
|
3063
|
+
}
|
|
3064
|
+
),
|
|
3065
|
+
!layer.clusterConfig.groupByField && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
3066
|
+
/* @__PURE__ */ jsx(
|
|
3067
|
+
Switch,
|
|
3068
|
+
{
|
|
3069
|
+
size: "small",
|
|
3070
|
+
checked: layer.clusterConfig.bubbleGradient ?? false,
|
|
3071
|
+
onChange: (checked) => onUpdateClusterConfig(layer.id, {
|
|
3072
|
+
...layer.clusterConfig,
|
|
3073
|
+
bubbleGradient: checked
|
|
3074
|
+
}),
|
|
3075
|
+
"data-testid": `switch-cluster-gradient-${layer.id}`
|
|
3076
|
+
}
|
|
3077
|
+
),
|
|
3078
|
+
/* @__PURE__ */ jsx("span", { className: "text-[10px]", children: "Color bubbles by value" })
|
|
2861
3079
|
] })
|
|
2862
3080
|
] })
|
|
2863
3081
|
] })
|
|
@@ -2894,7 +3112,7 @@ function LayersPanel({
|
|
|
2894
3112
|
Switch,
|
|
2895
3113
|
{
|
|
2896
3114
|
size: "small",
|
|
2897
|
-
checked: !((
|
|
3115
|
+
checked: !((_o = (_n = layer.visualConfig) == null ? void 0 : _n.label) == null ? void 0 : _o.hidden),
|
|
2898
3116
|
onChange: (checked) => {
|
|
2899
3117
|
var _a2, _b2, _c2;
|
|
2900
3118
|
return onUpdateVisualConfig(layer.id, {
|
|
@@ -2910,8 +3128,8 @@ function LayersPanel({
|
|
|
2910
3128
|
Select,
|
|
2911
3129
|
{
|
|
2912
3130
|
size: "small",
|
|
2913
|
-
disabled: (
|
|
2914
|
-
value: ((
|
|
3131
|
+
disabled: (_q = (_p = layer.visualConfig) == null ? void 0 : _p.label) == null ? void 0 : _q.hidden,
|
|
3132
|
+
value: ((_s = (_r = layer.visualConfig) == null ? void 0 : _r.label) == null ? void 0 : _s.mode) ?? "standard",
|
|
2915
3133
|
onChange: (val) => {
|
|
2916
3134
|
var _a2;
|
|
2917
3135
|
return onUpdateVisualConfig(layer.id, {
|
|
@@ -2928,15 +3146,18 @@ function LayersPanel({
|
|
|
2928
3146
|
"data-testid": `select-label-mode-${layer.id}`
|
|
2929
3147
|
}
|
|
2930
3148
|
),
|
|
2931
|
-
((
|
|
3149
|
+
((_u = (_t = layer.visualConfig) == null ? void 0 : _t.label) == null ? void 0 : _u.mode) === "field" && /* @__PURE__ */ jsx(
|
|
2932
3150
|
Select,
|
|
2933
3151
|
{
|
|
2934
3152
|
size: "small",
|
|
2935
|
-
value: ((
|
|
2936
|
-
onChange: (val) =>
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
3153
|
+
value: ((_w = (_v = layer.visualConfig) == null ? void 0 : _v.label) == null ? void 0 : _w.fieldName) ?? "",
|
|
3154
|
+
onChange: (val) => {
|
|
3155
|
+
var _a2;
|
|
3156
|
+
return onUpdateVisualConfig(layer.id, {
|
|
3157
|
+
...layer.visualConfig,
|
|
3158
|
+
label: { ...(_a2 = layer.visualConfig) == null ? void 0 : _a2.label, mode: "field", fieldName: val }
|
|
3159
|
+
});
|
|
3160
|
+
},
|
|
2940
3161
|
className: "w-full text-sm",
|
|
2941
3162
|
placeholder: "Select field...",
|
|
2942
3163
|
showSearch: true,
|
|
@@ -2945,15 +3166,18 @@ function LayersPanel({
|
|
|
2945
3166
|
"data-testid": `select-label-field-${layer.id}`
|
|
2946
3167
|
}
|
|
2947
3168
|
),
|
|
2948
|
-
((
|
|
3169
|
+
((_y = (_x = layer.visualConfig) == null ? void 0 : _x.label) == null ? void 0 : _y.mode) === "fixed" && /* @__PURE__ */ jsx(
|
|
2949
3170
|
Input,
|
|
2950
3171
|
{
|
|
2951
3172
|
size: "small",
|
|
2952
|
-
value: ((
|
|
2953
|
-
onChange: (e) =>
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
3173
|
+
value: ((_A = (_z = layer.visualConfig) == null ? void 0 : _z.label) == null ? void 0 : _A.fixedText) ?? "",
|
|
3174
|
+
onChange: (e) => {
|
|
3175
|
+
var _a2;
|
|
3176
|
+
return onUpdateVisualConfig(layer.id, {
|
|
3177
|
+
...layer.visualConfig,
|
|
3178
|
+
label: { ...(_a2 = layer.visualConfig) == null ? void 0 : _a2.label, mode: "fixed", fixedText: e.target.value }
|
|
3179
|
+
});
|
|
3180
|
+
},
|
|
2957
3181
|
placeholder: "Enter label text...",
|
|
2958
3182
|
className: "text-sm",
|
|
2959
3183
|
"data-testid": `input-label-text-${layer.id}`
|
|
@@ -2967,7 +3191,7 @@ function LayersPanel({
|
|
|
2967
3191
|
Select,
|
|
2968
3192
|
{
|
|
2969
3193
|
size: "small",
|
|
2970
|
-
value: ((
|
|
3194
|
+
value: ((_C = (_B = layer.visualConfig) == null ? void 0 : _B.size) == null ? void 0 : _C.mode) ?? "standard",
|
|
2971
3195
|
onChange: (val) => onUpdateVisualConfig(layer.id, {
|
|
2972
3196
|
...layer.visualConfig,
|
|
2973
3197
|
size: { mode: val }
|
|
@@ -2981,11 +3205,11 @@ function LayersPanel({
|
|
|
2981
3205
|
"data-testid": `select-size-mode-${layer.id}`
|
|
2982
3206
|
}
|
|
2983
3207
|
),
|
|
2984
|
-
((
|
|
3208
|
+
((_E = (_D = layer.visualConfig) == null ? void 0 : _D.size) == null ? void 0 : _E.mode) === "field" && /* @__PURE__ */ jsx(
|
|
2985
3209
|
Select,
|
|
2986
3210
|
{
|
|
2987
3211
|
size: "small",
|
|
2988
|
-
value: ((
|
|
3212
|
+
value: ((_G = (_F = layer.visualConfig) == null ? void 0 : _F.size) == null ? void 0 : _G.fieldName) ?? "",
|
|
2989
3213
|
onChange: (val) => onUpdateVisualConfig(layer.id, {
|
|
2990
3214
|
...layer.visualConfig,
|
|
2991
3215
|
size: { mode: "field", fieldName: val }
|
|
@@ -2998,11 +3222,11 @@ function LayersPanel({
|
|
|
2998
3222
|
"data-testid": `select-size-field-${layer.id}`
|
|
2999
3223
|
}
|
|
3000
3224
|
),
|
|
3001
|
-
((
|
|
3225
|
+
((_I = (_H = layer.visualConfig) == null ? void 0 : _H.size) == null ? void 0 : _I.mode) === "override" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
3002
3226
|
/* @__PURE__ */ jsx(
|
|
3003
3227
|
Slider,
|
|
3004
3228
|
{
|
|
3005
|
-
value: ((
|
|
3229
|
+
value: ((_K = (_J = layer.visualConfig) == null ? void 0 : _J.size) == null ? void 0 : _K.overrideValue) ?? 5,
|
|
3006
3230
|
min: 1,
|
|
3007
3231
|
max: 10,
|
|
3008
3232
|
step: 1,
|
|
@@ -3013,7 +3237,7 @@ function LayersPanel({
|
|
|
3013
3237
|
})
|
|
3014
3238
|
}
|
|
3015
3239
|
),
|
|
3016
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm w-4 text-right", children: ((
|
|
3240
|
+
/* @__PURE__ */ 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 })
|
|
3017
3241
|
] }),
|
|
3018
3242
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground pt-0.5", children: [
|
|
3019
3243
|
/* @__PURE__ */ jsx("span", { className: "w-3.5 h-3.5 rounded-full bg-current" }),
|
|
@@ -3023,7 +3247,7 @@ function LayersPanel({
|
|
|
3023
3247
|
Select,
|
|
3024
3248
|
{
|
|
3025
3249
|
size: "small",
|
|
3026
|
-
value: ((
|
|
3250
|
+
value: ((_O = (_N = layer.visualConfig) == null ? void 0 : _N.color) == null ? void 0 : _O.mode) ?? "standard",
|
|
3027
3251
|
onChange: (val) => onUpdateVisualConfig(layer.id, {
|
|
3028
3252
|
...layer.visualConfig,
|
|
3029
3253
|
color: { mode: val }
|
|
@@ -3037,37 +3261,77 @@ function LayersPanel({
|
|
|
3037
3261
|
"data-testid": `select-color-mode-${layer.id}`
|
|
3038
3262
|
}
|
|
3039
3263
|
),
|
|
3040
|
-
((
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3264
|
+
((_Q = (_P = layer.visualConfig) == null ? void 0 : _P.color) == null ? void 0 : _Q.mode) === "field" && (() => {
|
|
3265
|
+
var _a2, _b2, _c2, _d2;
|
|
3266
|
+
const fields = getLayerFields(layer.id);
|
|
3267
|
+
const colorField = (_b2 = (_a2 = layer.visualConfig) == null ? void 0 : _a2.color) == null ? void 0 : _b2.fieldName;
|
|
3268
|
+
const fieldStats = colorField ? fields.find((f) => f.name === colorField) : void 0;
|
|
3269
|
+
const fieldHasNumeric = (fieldStats == null ? void 0 : fieldStats.min) !== void 0;
|
|
3270
|
+
const scale = ((_d2 = (_c2 = layer.visualConfig) == null ? void 0 : _c2.color) == null ? void 0 : _d2.scale) ?? "categorical";
|
|
3271
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3272
|
+
/* @__PURE__ */ jsx(
|
|
3273
|
+
Select,
|
|
3274
|
+
{
|
|
3275
|
+
size: "small",
|
|
3276
|
+
value: colorField ?? "",
|
|
3277
|
+
onChange: (val) => onUpdateVisualConfig(layer.id, {
|
|
3278
|
+
...layer.visualConfig,
|
|
3279
|
+
// The scale default is decided once, at pick time, and
|
|
3280
|
+
// stored — never re-inferred at render, so data drifting
|
|
3281
|
+
// later can't silently flip a user's choice.
|
|
3282
|
+
color: { mode: "field", fieldName: val, scale: defaultColorScaleForField(fields.find((f) => f.name === val)) }
|
|
3283
|
+
}),
|
|
3284
|
+
className: "w-full text-sm",
|
|
3285
|
+
placeholder: "Select field...",
|
|
3286
|
+
showSearch: true,
|
|
3287
|
+
optionFilterProp: "label",
|
|
3288
|
+
options: fields.map((f) => ({ value: f.name, label: f.name })),
|
|
3289
|
+
"data-testid": `select-color-field-${layer.id}`
|
|
3290
|
+
}
|
|
3291
|
+
),
|
|
3292
|
+
colorField && /* @__PURE__ */ jsx(
|
|
3293
|
+
Segmented,
|
|
3294
|
+
{
|
|
3295
|
+
size: "small",
|
|
3296
|
+
block: true,
|
|
3297
|
+
value: scale,
|
|
3298
|
+
onChange: (val) => {
|
|
3299
|
+
var _a3;
|
|
3300
|
+
return onUpdateVisualConfig(layer.id, {
|
|
3301
|
+
...layer.visualConfig,
|
|
3302
|
+
color: { ...(_a3 = layer.visualConfig) == null ? void 0 : _a3.color, mode: "field", scale: val }
|
|
3303
|
+
});
|
|
3304
|
+
},
|
|
3305
|
+
options: [
|
|
3306
|
+
{ label: "Categories", value: "categorical" },
|
|
3307
|
+
{ label: "Gradient", value: "gradient", disabled: !fieldHasNumeric && scale !== "gradient" }
|
|
3308
|
+
],
|
|
3309
|
+
"data-testid": `segmented-color-scale-${layer.id}`
|
|
3310
|
+
}
|
|
3311
|
+
),
|
|
3312
|
+
colorField && scale === "gradient" && fieldStats && fieldStats.min !== void 0 && fieldStats.max !== void 0 && /* @__PURE__ */ jsx(
|
|
3313
|
+
ColorGradientLegend,
|
|
3314
|
+
{
|
|
3315
|
+
layerId: layer.id,
|
|
3316
|
+
min: fieldStats.min,
|
|
3317
|
+
max: fieldStats.max,
|
|
3318
|
+
sampled: fieldStats.sampled
|
|
3319
|
+
}
|
|
3320
|
+
),
|
|
3321
|
+
colorField && scale !== "gradient" && getFieldValueDistribution && /* @__PURE__ */ jsx(
|
|
3322
|
+
ColorByFieldLegend,
|
|
3323
|
+
{
|
|
3324
|
+
layerId: layer.id,
|
|
3325
|
+
fieldName: colorField,
|
|
3326
|
+
getFieldValueDistribution
|
|
3327
|
+
}
|
|
3328
|
+
)
|
|
3329
|
+
] });
|
|
3330
|
+
})(),
|
|
3331
|
+
((_S = (_R = layer.visualConfig) == null ? void 0 : _R.color) == null ? void 0 : _S.mode) === "fixed" && /* @__PURE__ */ jsx(
|
|
3068
3332
|
ColorPickerPopover,
|
|
3069
3333
|
{
|
|
3070
|
-
value: ((
|
|
3334
|
+
value: ((_U = (_T = layer.visualConfig) == null ? void 0 : _T.color) == null ? void 0 : _U.fixedColor) ?? "#3b82f6",
|
|
3071
3335
|
onChange: (color) => {
|
|
3072
3336
|
onUpdateVisualConfig == null ? void 0 : onUpdateVisualConfig(layer.id, {
|
|
3073
3337
|
...layer.visualConfig,
|
|
@@ -3080,7 +3344,7 @@ function LayersPanel({
|
|
|
3080
3344
|
testId: `color-fixed-${layer.id}`
|
|
3081
3345
|
}
|
|
3082
3346
|
),
|
|
3083
|
-
(hasPointFeatures == null ? void 0 : hasPointFeatures(layer.id)) && !((
|
|
3347
|
+
(hasPointFeatures == null ? void 0 : hasPointFeatures(layer.id)) && !((_V = layer.metadata) == null ? void 0 : _V.hidePointFeatures) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3084
3348
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground pt-0.5", children: [
|
|
3085
3349
|
/* @__PURE__ */ jsx(Smile, { className: "w-3.5 h-3.5" }),
|
|
3086
3350
|
/* @__PURE__ */ jsx("span", { children: "Point Icon" })
|
|
@@ -3090,7 +3354,7 @@ function LayersPanel({
|
|
|
3090
3354
|
Switch,
|
|
3091
3355
|
{
|
|
3092
3356
|
size: "small",
|
|
3093
|
-
checked: ((
|
|
3357
|
+
checked: ((_X = (_W = layer.visualConfig) == null ? void 0 : _W.icon) == null ? void 0 : _X.enabled) ?? false,
|
|
3094
3358
|
onChange: (checked) => {
|
|
3095
3359
|
var _a2, _b2, _c2, _d2;
|
|
3096
3360
|
onUpdateVisualConfig == null ? void 0 : onUpdateVisualConfig(layer.id, {
|
|
@@ -3105,11 +3369,11 @@ function LayersPanel({
|
|
|
3105
3369
|
"data-testid": `switch-icon-${layer.id}`
|
|
3106
3370
|
}
|
|
3107
3371
|
),
|
|
3108
|
-
((
|
|
3372
|
+
((_Z = (_Y = layer.visualConfig) == null ? void 0 : _Y.icon) == null ? void 0 : _Z.enabled) && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 flex-1", children: [
|
|
3109
3373
|
/* @__PURE__ */ jsx(
|
|
3110
3374
|
IconPicker,
|
|
3111
3375
|
{
|
|
3112
|
-
value: ((
|
|
3376
|
+
value: ((_$ = (__ = layer.visualConfig) == null ? void 0 : __.icon) == null ? void 0 : _$.icon) ?? "📍",
|
|
3113
3377
|
onChange: (icon) => {
|
|
3114
3378
|
var _a2, _b2;
|
|
3115
3379
|
onUpdateVisualConfig == null ? void 0 : onUpdateVisualConfig(layer.id, {
|
|
@@ -3126,7 +3390,7 @@ function LayersPanel({
|
|
|
3126
3390
|
/* @__PURE__ */ jsx(
|
|
3127
3391
|
Slider,
|
|
3128
3392
|
{
|
|
3129
|
-
value: ((
|
|
3393
|
+
value: ((_ba = (_aa = layer.visualConfig) == null ? void 0 : _aa.icon) == null ? void 0 : _ba.size) ?? 24,
|
|
3130
3394
|
min: 12,
|
|
3131
3395
|
max: 48,
|
|
3132
3396
|
step: 2,
|
|
@@ -3144,7 +3408,7 @@ function LayersPanel({
|
|
|
3144
3408
|
}
|
|
3145
3409
|
}
|
|
3146
3410
|
),
|
|
3147
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm w-6 text-right", children: ((
|
|
3411
|
+
/* @__PURE__ */ 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 })
|
|
3148
3412
|
] })
|
|
3149
3413
|
] })
|
|
3150
3414
|
] })
|
|
@@ -6477,13 +6741,282 @@ function hitTestSelection(featureGroups, selectionPolygon, options) {
|
|
|
6477
6741
|
mapPerfLog("hit-test", "selection gesture", { visited, total, selected: selectedIds.length });
|
|
6478
6742
|
return selectedIds;
|
|
6479
6743
|
}
|
|
6744
|
+
const CLUSTER_COUNT_VALUE_PROP = "__cluster_count_value";
|
|
6745
|
+
const CLUSTER_SUM_PROP = "value_sum";
|
|
6746
|
+
const CLUSTER_MEMBER_ID_PROP = "__cluster_fid";
|
|
6747
|
+
function clusterCountValue(raw) {
|
|
6748
|
+
if (typeof raw === "number") return Number.isFinite(raw) ? raw : 1;
|
|
6749
|
+
if (typeof raw === "string" && raw.trim() !== "") {
|
|
6750
|
+
const n = Number(raw);
|
|
6751
|
+
if (Number.isFinite(n)) return n;
|
|
6752
|
+
}
|
|
6753
|
+
return 1;
|
|
6754
|
+
}
|
|
6755
|
+
function injectClusterCountValues(features, fieldName) {
|
|
6756
|
+
return features.map((f) => {
|
|
6757
|
+
var _a;
|
|
6758
|
+
return {
|
|
6759
|
+
...f,
|
|
6760
|
+
properties: {
|
|
6761
|
+
...f.properties,
|
|
6762
|
+
[CLUSTER_COUNT_VALUE_PROP]: clusterCountValue((_a = f.properties) == null ? void 0 : _a[fieldName]),
|
|
6763
|
+
...f.id != null ? { [CLUSTER_MEMBER_ID_PROP]: String(f.id) } : {}
|
|
6764
|
+
}
|
|
6765
|
+
};
|
|
6766
|
+
});
|
|
6767
|
+
}
|
|
6768
|
+
function roundHalfAwayFromZero1(n) {
|
|
6769
|
+
return Math.sign(n) * Math.round(Math.abs(n) * 10) / 10;
|
|
6770
|
+
}
|
|
6771
|
+
function formatClusterBadge(value) {
|
|
6772
|
+
if (value >= 1e6) return `${roundHalfAwayFromZero1(value / 1e6)}M`;
|
|
6773
|
+
if (value >= 1e3) return `${roundHalfAwayFromZero1(value / 1e3)}k`;
|
|
6774
|
+
return String(roundHalfAwayFromZero1(value));
|
|
6775
|
+
}
|
|
6776
|
+
function clusterBadgeTextField(prop) {
|
|
6777
|
+
const value = ["get", prop];
|
|
6778
|
+
const round1 = (expr) => ["/", ["round", ["*", expr, 10]], 10];
|
|
6779
|
+
return [
|
|
6780
|
+
"step",
|
|
6781
|
+
value,
|
|
6782
|
+
["to-string", round1(value)],
|
|
6783
|
+
1e3,
|
|
6784
|
+
["concat", ["to-string", round1(["/", value, 1e3])], "k"],
|
|
6785
|
+
1e6,
|
|
6786
|
+
["concat", ["to-string", round1(["/", value, 1e6])], "M"]
|
|
6787
|
+
];
|
|
6788
|
+
}
|
|
6789
|
+
const INTERNAL_PROPERTY_KEYS = /* @__PURE__ */ new Set([
|
|
6790
|
+
"fill",
|
|
6791
|
+
"fill-opacity",
|
|
6792
|
+
"pointRadius",
|
|
6793
|
+
"pointIcon",
|
|
6794
|
+
"pointIconSize",
|
|
6795
|
+
"circleCenter",
|
|
6796
|
+
"circleRadius",
|
|
6797
|
+
"icon",
|
|
6798
|
+
"iconSize",
|
|
6799
|
+
"fontSize",
|
|
6800
|
+
"fontColor",
|
|
6801
|
+
"fontWeight",
|
|
6802
|
+
"arrowSize",
|
|
6803
|
+
"label",
|
|
6804
|
+
"entityType",
|
|
6805
|
+
"kind",
|
|
6806
|
+
"meta:type",
|
|
6807
|
+
"stroke",
|
|
6808
|
+
"stroke-width",
|
|
6809
|
+
"stroke-opacity",
|
|
6810
|
+
CLUSTER_COUNT_VALUE_PROP,
|
|
6811
|
+
CLUSTER_MEMBER_ID_PROP
|
|
6812
|
+
]);
|
|
6813
|
+
const STYLING_PROPERTY_KEYS = [
|
|
6814
|
+
"stroke",
|
|
6815
|
+
"stroke-width",
|
|
6816
|
+
"stroke-opacity",
|
|
6817
|
+
"fill",
|
|
6818
|
+
"fill-opacity",
|
|
6819
|
+
"pointRadius",
|
|
6820
|
+
"pointIcon",
|
|
6821
|
+
"pointIconSize",
|
|
6822
|
+
"icon",
|
|
6823
|
+
"iconSize",
|
|
6824
|
+
"circleCenter",
|
|
6825
|
+
"circleRadius",
|
|
6826
|
+
"fontSize",
|
|
6827
|
+
"fontColor",
|
|
6828
|
+
"fontWeight",
|
|
6829
|
+
"arrowSize"
|
|
6830
|
+
];
|
|
6831
|
+
const INTERNAL_PROPERTY_PREFIXES = [
|
|
6832
|
+
"IsHiddenBy",
|
|
6833
|
+
"isHidden",
|
|
6834
|
+
"isSelected",
|
|
6835
|
+
"isTrace",
|
|
6836
|
+
"isTimeline",
|
|
6837
|
+
"trace"
|
|
6838
|
+
];
|
|
6839
|
+
function isInternalProperty(key) {
|
|
6840
|
+
if (INTERNAL_PROPERTY_KEYS.has(key)) return true;
|
|
6841
|
+
return INTERNAL_PROPERTY_PREFIXES.some((prefix) => key.startsWith(prefix));
|
|
6842
|
+
}
|
|
6843
|
+
function computeBubbleDomain(values) {
|
|
6844
|
+
let min = Infinity;
|
|
6845
|
+
let max = -Infinity;
|
|
6846
|
+
for (const v of values) {
|
|
6847
|
+
if (!Number.isFinite(v)) continue;
|
|
6848
|
+
if (v < min) min = v;
|
|
6849
|
+
if (v > max) max = v;
|
|
6850
|
+
}
|
|
6851
|
+
return isFinite(min) ? { min, max } : null;
|
|
6852
|
+
}
|
|
6853
|
+
function bubbleGradientColorExpression(prop, min, max) {
|
|
6854
|
+
if (!(max > min)) return gradientColor(0.5);
|
|
6855
|
+
const expr = ["interpolate", ["linear"], ["get", prop]];
|
|
6856
|
+
const span = max - min;
|
|
6857
|
+
GRADIENT_RAMP.forEach((color, i) => {
|
|
6858
|
+
expr.push(min + span * i / (GRADIENT_RAMP.length - 1), color);
|
|
6859
|
+
});
|
|
6860
|
+
return expr;
|
|
6861
|
+
}
|
|
6862
|
+
function createClusterGradientManager(map, sourceId, options) {
|
|
6863
|
+
const clusterProp = options.valueProp ?? "point_count";
|
|
6864
|
+
let scheduled = false;
|
|
6865
|
+
let lastDomainKey = "";
|
|
6866
|
+
let reportedFailure = false;
|
|
6867
|
+
function reportFailure(stage, error) {
|
|
6868
|
+
if (reportedFailure) return;
|
|
6869
|
+
reportedFailure = true;
|
|
6870
|
+
console.error(`[map-component] cluster gradient ${stage} failed; bubbles keep their current colors:`, error);
|
|
6871
|
+
}
|
|
6872
|
+
function apply() {
|
|
6873
|
+
scheduled = false;
|
|
6874
|
+
let values;
|
|
6875
|
+
try {
|
|
6876
|
+
if (!map.getSource(sourceId)) return;
|
|
6877
|
+
values = map.querySourceFeatures(sourceId, { filter: ["has", "point_count"] }).map((f) => {
|
|
6878
|
+
var _a;
|
|
6879
|
+
return Number((_a = f.properties) == null ? void 0 : _a[clusterProp]);
|
|
6880
|
+
});
|
|
6881
|
+
if (options.singleLayerId) {
|
|
6882
|
+
const singles = map.querySourceFeatures(sourceId, {
|
|
6883
|
+
filter: ["all", ["!", ["has", "point_count"]], [">", ["get", CLUSTER_COUNT_VALUE_PROP], 1]]
|
|
6884
|
+
});
|
|
6885
|
+
values.push(...singles.map((f) => {
|
|
6886
|
+
var _a;
|
|
6887
|
+
return Number((_a = f.properties) == null ? void 0 : _a[CLUSTER_COUNT_VALUE_PROP]);
|
|
6888
|
+
}));
|
|
6889
|
+
}
|
|
6890
|
+
} catch (error) {
|
|
6891
|
+
reportFailure("domain query", error);
|
|
6892
|
+
return;
|
|
6893
|
+
}
|
|
6894
|
+
const domain = computeBubbleDomain(values);
|
|
6895
|
+
if (!domain) return;
|
|
6896
|
+
const key = `${domain.min}|${domain.max}`;
|
|
6897
|
+
if (key === lastDomainKey) return;
|
|
6898
|
+
lastDomainKey = key;
|
|
6899
|
+
try {
|
|
6900
|
+
if (map.getLayer(options.clustersLayerId)) {
|
|
6901
|
+
map.setPaintProperty(
|
|
6902
|
+
options.clustersLayerId,
|
|
6903
|
+
"circle-color",
|
|
6904
|
+
bubbleGradientColorExpression(clusterProp, domain.min, domain.max)
|
|
6905
|
+
);
|
|
6906
|
+
}
|
|
6907
|
+
if (options.singleLayerId && map.getLayer(options.singleLayerId)) {
|
|
6908
|
+
map.setPaintProperty(
|
|
6909
|
+
options.singleLayerId,
|
|
6910
|
+
"circle-color",
|
|
6911
|
+
bubbleGradientColorExpression(CLUSTER_COUNT_VALUE_PROP, domain.min, domain.max)
|
|
6912
|
+
);
|
|
6913
|
+
}
|
|
6914
|
+
} catch (error) {
|
|
6915
|
+
reportFailure("paint update", error);
|
|
6916
|
+
lastDomainKey = "";
|
|
6917
|
+
}
|
|
6918
|
+
}
|
|
6919
|
+
function schedule() {
|
|
6920
|
+
if (scheduled) return;
|
|
6921
|
+
scheduled = true;
|
|
6922
|
+
requestAnimationFrame(apply);
|
|
6923
|
+
}
|
|
6924
|
+
function onData(e) {
|
|
6925
|
+
if (e.sourceId === sourceId) schedule();
|
|
6926
|
+
}
|
|
6927
|
+
map.on("moveend", schedule);
|
|
6928
|
+
map.on("data", onData);
|
|
6929
|
+
schedule();
|
|
6930
|
+
return {
|
|
6931
|
+
destroy: () => {
|
|
6932
|
+
map.off("moveend", schedule);
|
|
6933
|
+
map.off("data", onData);
|
|
6934
|
+
}
|
|
6935
|
+
};
|
|
6936
|
+
}
|
|
6937
|
+
const LABEL_NEVER_HIDE_PROP = "_labelNeverHide";
|
|
6938
|
+
const PINNED_LABEL_FILTER = ["==", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
6939
|
+
const UNPINNED_LABEL_FILTER = ["!=", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
6940
|
+
function computeLabelNeverHide(label) {
|
|
6941
|
+
return (label == null ? void 0 : label.neverHide) && !label.hidden ? 1 : 0;
|
|
6942
|
+
}
|
|
6943
|
+
function buildCustomLabelLayout() {
|
|
6944
|
+
return {
|
|
6945
|
+
// Hide labels for trace points (except last point which has isTraceLabel),
|
|
6946
|
+
// arrows handled by the custom-arrow-labels layer. Features blanked by
|
|
6947
|
+
// heatmap/cluster/trace modes stay blank in BOTH layers: "never hide"
|
|
6948
|
+
// exempts labels from collision and density culling, it does not resurrect
|
|
6949
|
+
// labels other mode choices explicitly blank.
|
|
6950
|
+
"text-field": [
|
|
6951
|
+
"case",
|
|
6952
|
+
["==", ["get", "isHiddenByTrace"], true],
|
|
6953
|
+
"",
|
|
6954
|
+
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
6955
|
+
"",
|
|
6956
|
+
["==", ["get", "isHiddenByCluster"], 1],
|
|
6957
|
+
"",
|
|
6958
|
+
["==", ["get", "kind"], "arrow"],
|
|
6959
|
+
"",
|
|
6960
|
+
// Trace points: only show label if isTraceLabel is true (last point in group)
|
|
6961
|
+
["all", ["==", ["get", "isTracePoint"], true], ["!=", ["get", "isTraceLabel"], true]],
|
|
6962
|
+
"",
|
|
6963
|
+
["==", ["get", "kind"], "text"],
|
|
6964
|
+
["coalesce", ["get", "label"], ["get", "text"], "New Label"],
|
|
6965
|
+
["coalesce", ["get", "name"], ""]
|
|
6966
|
+
],
|
|
6967
|
+
// Text features use their fontSize property; trace labels 14px; others 12px
|
|
6968
|
+
"text-size": [
|
|
6969
|
+
"case",
|
|
6970
|
+
["==", ["get", "kind"], "text"],
|
|
6971
|
+
["coalesce", ["get", "fontSize"], 14],
|
|
6972
|
+
["==", ["get", "isTraceLabel"], true],
|
|
6973
|
+
14,
|
|
6974
|
+
12
|
|
6975
|
+
],
|
|
6976
|
+
// Text features: center anchor; others: top anchor
|
|
6977
|
+
"text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
|
|
6978
|
+
"text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
|
|
6979
|
+
"text-padding": 2,
|
|
6980
|
+
// Bold font for text features with fontWeight=bold, trace labels, others regular
|
|
6981
|
+
"text-font": [
|
|
6982
|
+
"case",
|
|
6983
|
+
["all", ["==", ["get", "kind"], "text"], ["==", ["get", "fontWeight"], "bold"]],
|
|
6984
|
+
["literal", ["Montserrat SemiBold", "Noto Sans Regular"]],
|
|
6985
|
+
["==", ["get", "isTraceLabel"], true],
|
|
6986
|
+
["literal", ["Montserrat Medium", "Noto Sans Regular"]],
|
|
6987
|
+
["literal", ["Montserrat Regular", "Noto Sans Regular"]]
|
|
6988
|
+
]
|
|
6989
|
+
};
|
|
6990
|
+
}
|
|
6991
|
+
function buildCustomLabelPaint() {
|
|
6992
|
+
return {
|
|
6993
|
+
// Text features use fontColor; others use default
|
|
6994
|
+
"text-color": [
|
|
6995
|
+
"case",
|
|
6996
|
+
["==", ["get", "kind"], "text"],
|
|
6997
|
+
["coalesce", ["get", "fontColor"], "#000000"],
|
|
6998
|
+
"#1f2937"
|
|
6999
|
+
],
|
|
7000
|
+
"text-halo-color": "#ffffff",
|
|
7001
|
+
// Thicker halo for trace labels and text features
|
|
7002
|
+
"text-halo-width": [
|
|
7003
|
+
"case",
|
|
7004
|
+
["==", ["get", "kind"], "text"],
|
|
7005
|
+
2,
|
|
7006
|
+
["==", ["get", "isTraceLabel"], true],
|
|
7007
|
+
2,
|
|
7008
|
+
1.5
|
|
7009
|
+
],
|
|
7010
|
+
"text-opacity": ["*", 0.9, ["get", "stroke-opacity"]]
|
|
7011
|
+
};
|
|
7012
|
+
}
|
|
6480
7013
|
const OTHER_BUCKET_KEY = "__other__";
|
|
6481
7014
|
const OTHER_BUCKET_LABEL = "Other";
|
|
6482
7015
|
const OTHER_BUCKET_COLOR = "#9ca3af";
|
|
6483
7016
|
function toDisplayName(name) {
|
|
6484
7017
|
return name === OTHER_BUCKET_KEY ? OTHER_BUCKET_LABEL : name;
|
|
6485
7018
|
}
|
|
6486
|
-
function createPieSVG(categories, total, size = 44, onSliceHover) {
|
|
7019
|
+
function createPieSVG(categories, total, size = 44, onSliceHover, badgeValue) {
|
|
6487
7020
|
const container = document.createElement("div");
|
|
6488
7021
|
container.style.width = `${size}px`;
|
|
6489
7022
|
container.style.height = `${size}px`;
|
|
@@ -6581,16 +7114,17 @@ function createPieSVG(categories, total, size = 44, onSliceHover) {
|
|
|
6581
7114
|
centerCircle.setAttribute("r", String(innerRadius - 2));
|
|
6582
7115
|
centerCircle.setAttribute("fill", "#1f2937");
|
|
6583
7116
|
svg.appendChild(centerCircle);
|
|
7117
|
+
const badgeText = formatClusterBadge(badgeValue ?? total);
|
|
6584
7118
|
const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
6585
7119
|
text.setAttribute("x", String(radius));
|
|
6586
7120
|
text.setAttribute("y", String(radius));
|
|
6587
7121
|
text.setAttribute("text-anchor", "middle");
|
|
6588
7122
|
text.setAttribute("dominant-baseline", "central");
|
|
6589
7123
|
text.setAttribute("fill", "white");
|
|
6590
|
-
text.setAttribute("font-size",
|
|
7124
|
+
text.setAttribute("font-size", badgeText.length >= 6 ? "8" : badgeText.length >= 4 ? "9" : badgeText.length >= 3 ? "10" : "11");
|
|
6591
7125
|
text.setAttribute("font-weight", "bold");
|
|
6592
7126
|
text.setAttribute("font-family", "system-ui, sans-serif");
|
|
6593
|
-
text.textContent =
|
|
7127
|
+
text.textContent = badgeText;
|
|
6594
7128
|
svg.appendChild(text);
|
|
6595
7129
|
container.appendChild(svg);
|
|
6596
7130
|
return container;
|
|
@@ -6637,17 +7171,17 @@ function hideTooltip() {
|
|
|
6637
7171
|
tooltipEl.style.display = "none";
|
|
6638
7172
|
}
|
|
6639
7173
|
}
|
|
6640
|
-
function fingerprintCluster(pointCount, counts, size) {
|
|
6641
|
-
return `${size}|${pointCount}|${counts.join(",")}`;
|
|
7174
|
+
function fingerprintCluster(pointCount, counts, size, badgeValue) {
|
|
7175
|
+
return `${size}|${pointCount}|${badgeValue ?? ""}|${counts.join(",")}`;
|
|
6642
7176
|
}
|
|
6643
|
-
function buildPieElement(categories, pointCount, size, source, clusterId, map, coords) {
|
|
7177
|
+
function buildPieElement(categories, pointCount, size, source, clusterId, map, coords, badgeValue) {
|
|
6644
7178
|
const el = createPieSVG(categories, pointCount, size, (cat, event) => {
|
|
6645
7179
|
if (cat) {
|
|
6646
7180
|
showTooltip(cat, event.clientX, event.clientY);
|
|
6647
7181
|
} else {
|
|
6648
7182
|
hideTooltip();
|
|
6649
7183
|
}
|
|
6650
|
-
});
|
|
7184
|
+
}, badgeValue);
|
|
6651
7185
|
el.addEventListener("click", () => {
|
|
6652
7186
|
source.getClusterExpansionZoom(clusterId).then((zoom) => {
|
|
6653
7187
|
if (typeof zoom === "number") {
|
|
@@ -6666,13 +7200,16 @@ function renderClusterPies(map, sourceId, categoryValues, categoryColorMap, mark
|
|
|
6666
7200
|
});
|
|
6667
7201
|
const visibleClusterIds = /* @__PURE__ */ new Set();
|
|
6668
7202
|
clusters.forEach((feature) => {
|
|
6669
|
-
var _a, _b;
|
|
7203
|
+
var _a, _b, _c;
|
|
6670
7204
|
const clusterId = (_a = feature.properties) == null ? void 0 : _a.cluster_id;
|
|
6671
7205
|
if (clusterId === void 0) return;
|
|
6672
7206
|
const clusterKey = `${clusterId}`;
|
|
6673
7207
|
visibleClusterIds.add(clusterKey);
|
|
6674
7208
|
const coords = feature.geometry.coordinates;
|
|
6675
7209
|
const pointCount = ((_b = feature.properties) == null ? void 0 : _b.point_count) || 0;
|
|
7210
|
+
const sumRaw = (_c = feature.properties) == null ? void 0 : _c[CLUSTER_SUM_PROP];
|
|
7211
|
+
const sumNum = typeof sumRaw === "number" ? sumRaw : sumRaw != null ? Number(sumRaw) : NaN;
|
|
7212
|
+
const badgeValue = Number.isFinite(sumNum) ? sumNum : void 0;
|
|
6676
7213
|
const allCounts = categoryValues.map((_, i) => {
|
|
6677
7214
|
var _a2;
|
|
6678
7215
|
return Number(((_a2 = feature.properties) == null ? void 0 : _a2[`cat_${i}`]) || 0);
|
|
@@ -6684,13 +7221,13 @@ function renderClusterPies(map, sourceId, categoryValues, categoryColorMap, mark
|
|
|
6684
7221
|
color: categoryColorMap[cat] || "#3b82f6"
|
|
6685
7222
|
})).filter((c) => c.count > 0);
|
|
6686
7223
|
const size = pointCount < 100 ? 40 : pointCount < 750 ? 50 : 60;
|
|
6687
|
-
const fingerprint = fingerprintCluster(pointCount, allCounts, size);
|
|
7224
|
+
const fingerprint = fingerprintCluster(pointCount, allCounts, size, badgeValue);
|
|
6688
7225
|
const existing = markers.get(clusterKey);
|
|
6689
7226
|
if (existing && existing.fingerprint === fingerprint) {
|
|
6690
7227
|
existing.marker.setLngLat(coords);
|
|
6691
7228
|
return;
|
|
6692
7229
|
}
|
|
6693
|
-
const el = buildPieElement(categories, pointCount, size, source, clusterId, map, coords);
|
|
7230
|
+
const el = buildPieElement(categories, pointCount, size, source, clusterId, map, coords, badgeValue);
|
|
6694
7231
|
if (existing) {
|
|
6695
7232
|
existing.marker.remove();
|
|
6696
7233
|
}
|
|
@@ -6842,6 +7379,7 @@ const CustomSimpleSelect = {
|
|
|
6842
7379
|
startBoxSelect() {
|
|
6843
7380
|
}
|
|
6844
7381
|
};
|
|
7382
|
+
const ENRICHED_EXPORT_KEEP_KEYS = /* @__PURE__ */ new Set(["_layerIndex"]);
|
|
6845
7383
|
function createFlightPath3DLayer(layerId, mapInstance, flightPaths) {
|
|
6846
7384
|
let camera;
|
|
6847
7385
|
let scene;
|
|
@@ -7131,6 +7669,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7131
7669
|
const loadingBasemaps = useRef(/* @__PURE__ */ new Set());
|
|
7132
7670
|
const customBasemapRegistry = useRef(/* @__PURE__ */ new Map());
|
|
7133
7671
|
const clusterPieManagers = useRef(/* @__PURE__ */ new Map());
|
|
7672
|
+
const clusterGradientManagers = useRef(/* @__PURE__ */ new Map());
|
|
7673
|
+
const clusterLayerHandlers = useRef(/* @__PURE__ */ new Map());
|
|
7134
7674
|
const handleMapStyleChangeRef = useRef(null);
|
|
7135
7675
|
const flightPath3DLayerId = useRef(null);
|
|
7136
7676
|
const update3DFlightPathsRef = useRef(null);
|
|
@@ -7145,6 +7685,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7145
7685
|
const [selectedFeatureIds, setSelectedFeatureIds] = useState([]);
|
|
7146
7686
|
const [featureCount, setFeatureCount] = useState(0);
|
|
7147
7687
|
const [featureUpdateCounter, setFeatureUpdateCounter] = useState(0);
|
|
7688
|
+
const [clusterDataVersion, setClusterDataVersion] = useState(0);
|
|
7148
7689
|
const [showProperties, setShowProperties] = useState(false);
|
|
7149
7690
|
const [autoFocusLabel, setAutoFocusLabel] = useState(false);
|
|
7150
7691
|
const [showLayers, setShowLayers] = useState(false);
|
|
@@ -7476,6 +8017,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7476
8017
|
});
|
|
7477
8018
|
});
|
|
7478
8019
|
});
|
|
8020
|
+
const layerGradientRanges = /* @__PURE__ */ new Map();
|
|
7479
8021
|
selectedFeatureIds.forEach((fid) => {
|
|
7480
8022
|
var _a;
|
|
7481
8023
|
const feature = featById.get(fid);
|
|
@@ -7485,22 +8027,29 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7485
8027
|
colorMap.set(fid, tracePointColors.get(fid));
|
|
7486
8028
|
return;
|
|
7487
8029
|
}
|
|
7488
|
-
|
|
8030
|
+
const fallback = ((_a = feature == null ? void 0 : feature.properties) == null ? void 0 : _a.stroke) || "#3b82f6";
|
|
8031
|
+
let color = fallback;
|
|
7489
8032
|
const colorConfig = visualConfig == null ? void 0 : visualConfig.color;
|
|
7490
8033
|
if (colorConfig && feature) {
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7496
|
-
|
|
8034
|
+
let range;
|
|
8035
|
+
if (layer && colorConfig.mode === "field" && colorConfig.scale === "gradient" && colorConfig.fieldName) {
|
|
8036
|
+
const cached = layerGradientRanges.get(layer.id);
|
|
8037
|
+
if (cached === void 0) {
|
|
8038
|
+
range = computeNumericRange(layer.featureIds, (id) => {
|
|
8039
|
+
var _a2;
|
|
8040
|
+
return (_a2 = featById.get(id)) == null ? void 0 : _a2.properties;
|
|
8041
|
+
}, colorConfig.fieldName);
|
|
8042
|
+
layerGradientRanges.set(layer.id, range);
|
|
8043
|
+
} else {
|
|
8044
|
+
range = cached;
|
|
7497
8045
|
}
|
|
7498
8046
|
}
|
|
8047
|
+
color = resolveFeatureColor(colorConfig, feature.properties, fallback, range);
|
|
7499
8048
|
}
|
|
7500
8049
|
colorMap.set(fid, color);
|
|
7501
8050
|
});
|
|
7502
8051
|
return colorMap;
|
|
7503
|
-
}, [selectedFeatureIds, layers, getAllFeatures
|
|
8052
|
+
}, [selectedFeatureIds, layers, getAllFeatures]);
|
|
7504
8053
|
const countVisibleFeatures = useCallback((threshold) => {
|
|
7505
8054
|
const m = map.current;
|
|
7506
8055
|
if (!m) return 0;
|
|
@@ -7651,27 +8200,38 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7651
8200
|
layer.featureIds.forEach((fid) => featureToLayer.set(fid, layer));
|
|
7652
8201
|
});
|
|
7653
8202
|
const sizeFieldRanges = /* @__PURE__ */ new Map();
|
|
8203
|
+
const colorFieldRanges = /* @__PURE__ */ new Map();
|
|
7654
8204
|
currentLayers.forEach((layer) => {
|
|
7655
|
-
var _a;
|
|
8205
|
+
var _a, _b;
|
|
7656
8206
|
if (!layer.visible) return;
|
|
7657
8207
|
const sizeConfig = (_a = layer.visualConfig) == null ? void 0 : _a.size;
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
8208
|
+
const colorConfig = (_b = layer.visualConfig) == null ? void 0 : _b.color;
|
|
8209
|
+
const sizeField = (sizeConfig == null ? void 0 : sizeConfig.mode) === "field" && sizeConfig.fieldName ? sizeConfig.fieldName : null;
|
|
8210
|
+
const colorField = (colorConfig == null ? void 0 : colorConfig.mode) === "field" && colorConfig.scale === "gradient" && colorConfig.fieldName ? colorConfig.fieldName : null;
|
|
8211
|
+
if (!sizeField && !colorField) return;
|
|
8212
|
+
let sMin = Infinity, sMax = -Infinity;
|
|
8213
|
+
let cMin = Infinity, cMax = -Infinity;
|
|
8214
|
+
layer.featureIds.forEach((fid) => {
|
|
8215
|
+
var _a2;
|
|
8216
|
+
const props = (_a2 = featureById.get(fid)) == null ? void 0 : _a2.properties;
|
|
8217
|
+
if (!props) return;
|
|
8218
|
+
if (sizeField) {
|
|
8219
|
+
const v = coerceFiniteNumber(props[sizeField]);
|
|
8220
|
+
if (v !== null) {
|
|
8221
|
+
if (v < sMin) sMin = v;
|
|
8222
|
+
if (v > sMax) sMax = v;
|
|
7669
8223
|
}
|
|
7670
|
-
});
|
|
7671
|
-
if (isFinite(min) && isFinite(max)) {
|
|
7672
|
-
sizeFieldRanges.set(layer.id, { min, max });
|
|
7673
8224
|
}
|
|
7674
|
-
|
|
8225
|
+
if (colorField) {
|
|
8226
|
+
const v = coerceFiniteNumber(props[colorField]);
|
|
8227
|
+
if (v !== null) {
|
|
8228
|
+
if (v < cMin) cMin = v;
|
|
8229
|
+
if (v > cMax) cMax = v;
|
|
8230
|
+
}
|
|
8231
|
+
}
|
|
8232
|
+
});
|
|
8233
|
+
if (sizeField && isFinite(sMin)) sizeFieldRanges.set(layer.id, { min: sMin, max: sMax });
|
|
8234
|
+
if (colorField && isFinite(cMin)) colorFieldRanges.set(layer.id, { min: cMin, max: cMax });
|
|
7675
8235
|
});
|
|
7676
8236
|
const lastTracePointIds = /* @__PURE__ */ new Set();
|
|
7677
8237
|
const tracePointColors = /* @__PURE__ */ new Map();
|
|
@@ -7736,7 +8296,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7736
8296
|
const sourceData = {
|
|
7737
8297
|
type: "FeatureCollection",
|
|
7738
8298
|
features: allFeatures.map((f) => {
|
|
7739
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
8299
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
7740
8300
|
const featureId = String(f.id);
|
|
7741
8301
|
const layer = featureToLayer.get(featureId);
|
|
7742
8302
|
const visualConfig = layer == null ? void 0 : layer.visualConfig;
|
|
@@ -7745,14 +8305,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7745
8305
|
let strokeColor = ((_b = f.properties) == null ? void 0 : _b.stroke) || "#3b82f6";
|
|
7746
8306
|
const colorConfig = visualConfig == null ? void 0 : visualConfig.color;
|
|
7747
8307
|
if (colorConfig) {
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
}
|
|
7755
|
-
}
|
|
8308
|
+
strokeColor = resolveFeatureColor(
|
|
8309
|
+
colorConfig,
|
|
8310
|
+
f.properties,
|
|
8311
|
+
strokeColor,
|
|
8312
|
+
layer ? colorFieldRanges.get(layer.id) : void 0
|
|
8313
|
+
);
|
|
7756
8314
|
}
|
|
7757
8315
|
let strokeWidth = ((_c = f.properties) == null ? void 0 : _c["stroke-width"]) || 2;
|
|
7758
8316
|
let pointRadius = Math.round(3 + strokeWidth);
|
|
@@ -7880,7 +8438,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
7880
8438
|
pointRadius,
|
|
7881
8439
|
isHiddenFor3DOnly: hideFlatFor3DOnly ? 1 : 0,
|
|
7882
8440
|
isTimelineHidden: isTimelineVisible ? 0 : 1,
|
|
7883
|
-
_labelPriority: labelPriority
|
|
8441
|
+
_labelPriority: labelPriority,
|
|
8442
|
+
[LABEL_NEVER_HIDE_PROP]: computeLabelNeverHide((_o = layer == null ? void 0 : layer.visualConfig) == null ? void 0 : _o.label)
|
|
7884
8443
|
}
|
|
7885
8444
|
};
|
|
7886
8445
|
})
|
|
@@ -8194,6 +8753,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8194
8753
|
clusterPieManagers.current.delete(layerId);
|
|
8195
8754
|
}
|
|
8196
8755
|
});
|
|
8756
|
+
clusterGradientManagers.current.forEach((mgr, layerId) => {
|
|
8757
|
+
if (!liveLayerIds.has(layerId)) {
|
|
8758
|
+
try {
|
|
8759
|
+
mgr.destroy();
|
|
8760
|
+
} catch {
|
|
8761
|
+
}
|
|
8762
|
+
clusterGradientManagers.current.delete(layerId);
|
|
8763
|
+
}
|
|
8764
|
+
});
|
|
8197
8765
|
const m = map.current;
|
|
8198
8766
|
if (!m) return;
|
|
8199
8767
|
let style;
|
|
@@ -8202,7 +8770,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8202
8770
|
} catch {
|
|
8203
8771
|
return;
|
|
8204
8772
|
}
|
|
8205
|
-
const layerPrefixes = ["heatmap-layer-", "cluster-count-", "clusters-", "unclustered-point-"];
|
|
8773
|
+
const layerPrefixes = ["heatmap-layer-", "cluster-count-", "cluster-single-count-", "cluster-single-", "clusters-", "unclustered-point-"];
|
|
8206
8774
|
const sourcePrefixes = ["heatmap-source-", "cluster-source-"];
|
|
8207
8775
|
((style == null ? void 0 : style.layers) ?? []).forEach((sl) => {
|
|
8208
8776
|
const prefix = layerPrefixes.find((p) => sl.id.startsWith(p));
|
|
@@ -8652,39 +9220,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8652
9220
|
id: "custom-labels",
|
|
8653
9221
|
type: "symbol",
|
|
8654
9222
|
source: "custom-features",
|
|
9223
|
+
filter: UNPINNED_LABEL_FILTER,
|
|
8655
9224
|
layout: {
|
|
9225
|
+
...buildCustomLabelLayout(),
|
|
8656
9226
|
"visibility": "none",
|
|
8657
|
-
// Hide labels for trace points (except last point which has isTraceLabel), arrows handled separately
|
|
8658
|
-
"text-field": [
|
|
8659
|
-
"case",
|
|
8660
|
-
["==", ["get", "isHiddenByTrace"], true],
|
|
8661
|
-
"",
|
|
8662
|
-
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
8663
|
-
"",
|
|
8664
|
-
["==", ["get", "isHiddenByCluster"], 1],
|
|
8665
|
-
"",
|
|
8666
|
-
["==", ["get", "kind"], "arrow"],
|
|
8667
|
-
"",
|
|
8668
|
-
// Arrows use custom-arrow-labels layer
|
|
8669
|
-
// Trace points: only show label if isTraceLabel is true (last point in group)
|
|
8670
|
-
["all", ["==", ["get", "isTracePoint"], true], ["!=", ["get", "isTraceLabel"], true]],
|
|
8671
|
-
"",
|
|
8672
|
-
["==", ["get", "kind"], "text"],
|
|
8673
|
-
["coalesce", ["get", "label"], ["get", "text"], "New Label"],
|
|
8674
|
-
["coalesce", ["get", "name"], ""]
|
|
8675
|
-
],
|
|
8676
|
-
// Text features use their fontSize property; trace labels 14px; others 12px
|
|
8677
|
-
"text-size": [
|
|
8678
|
-
"case",
|
|
8679
|
-
["==", ["get", "kind"], "text"],
|
|
8680
|
-
["coalesce", ["get", "fontSize"], 14],
|
|
8681
|
-
["==", ["get", "isTraceLabel"], true],
|
|
8682
|
-
14,
|
|
8683
|
-
12
|
|
8684
|
-
],
|
|
8685
|
-
// Text features: center anchor; others: top anchor
|
|
8686
|
-
"text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
|
|
8687
|
-
"text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
|
|
8688
9227
|
// Native collision-based de-overlap.
|
|
8689
9228
|
//
|
|
8690
9229
|
// History: a prior PR turned collision off (`text-allow-overlap: true`)
|
|
@@ -8711,40 +9250,28 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8711
9250
|
"text-allow-overlap": false,
|
|
8712
9251
|
"text-ignore-placement": false,
|
|
8713
9252
|
"text-optional": true,
|
|
8714
|
-
"text-padding": 2,
|
|
8715
9253
|
// Lower value = higher collision priority (placed first).
|
|
8716
9254
|
// Computed per-feature in syncFeaturesToCustomLayers.
|
|
8717
|
-
"symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
|
|
8718
|
-
// Bold font for text features with fontWeight=bold, trace labels, others regular
|
|
8719
|
-
"text-font": [
|
|
8720
|
-
"case",
|
|
8721
|
-
["all", ["==", ["get", "kind"], "text"], ["==", ["get", "fontWeight"], "bold"]],
|
|
8722
|
-
["literal", ["Montserrat SemiBold", "Noto Sans Regular"]],
|
|
8723
|
-
["==", ["get", "isTraceLabel"], true],
|
|
8724
|
-
["literal", ["Montserrat Medium", "Noto Sans Regular"]],
|
|
8725
|
-
["literal", ["Montserrat Regular", "Noto Sans Regular"]]
|
|
8726
|
-
]
|
|
9255
|
+
"symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
|
|
8727
9256
|
},
|
|
8728
|
-
paint:
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
"text-
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
"text-opacity": ["*", 0.9, ["get", "stroke-opacity"]]
|
|
8747
|
-
}
|
|
9257
|
+
paint: buildCustomLabelPaint()
|
|
9258
|
+
});
|
|
9259
|
+
mapInstance.addLayer({
|
|
9260
|
+
id: "custom-labels-pinned",
|
|
9261
|
+
type: "symbol",
|
|
9262
|
+
source: "custom-features",
|
|
9263
|
+
filter: PINNED_LABEL_FILTER,
|
|
9264
|
+
layout: {
|
|
9265
|
+
...buildCustomLabelLayout(),
|
|
9266
|
+
"visibility": "visible",
|
|
9267
|
+
"text-allow-overlap": true,
|
|
9268
|
+
"text-ignore-placement": true,
|
|
9269
|
+
// With allow-overlap the collision pass is gone and the key only
|
|
9270
|
+
// orders painting, where HIGHER paints on top — negate so important
|
|
9271
|
+
// (low-priority-value) labels draw over their neighbours' halos.
|
|
9272
|
+
"symbol-sort-key": ["*", -1, ["coalesce", ["get", "_labelPriority"], 100]]
|
|
9273
|
+
},
|
|
9274
|
+
paint: buildCustomLabelPaint()
|
|
8748
9275
|
});
|
|
8749
9276
|
mapInstance.addSource("arrow-heads", {
|
|
8750
9277
|
type: "geojson",
|
|
@@ -9570,7 +10097,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9570
10097
|
scheduleSync();
|
|
9571
10098
|
});
|
|
9572
10099
|
mapInstance.on("click", (e) => {
|
|
9573
|
-
var _a;
|
|
10100
|
+
var _a, _b;
|
|
9574
10101
|
if (!enableSelectionRef.current) return;
|
|
9575
10102
|
if (e.originalEvent.button !== 0) return;
|
|
9576
10103
|
if (contextMenuFiredRef.current) return;
|
|
@@ -9579,14 +10106,24 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9579
10106
|
const features = mapInstance.queryRenderedFeatures(e.point, {
|
|
9580
10107
|
layers: ["custom-polygon-fill", "custom-line", "custom-point"]
|
|
9581
10108
|
});
|
|
10109
|
+
let clusteredFeatureId = null;
|
|
9582
10110
|
if (features.length === 0) {
|
|
9583
|
-
|
|
9584
|
-
|
|
10111
|
+
const clusterOverlayIds = layersRef.current.filter((l) => {
|
|
10112
|
+
var _a2;
|
|
10113
|
+
return (_a2 = l.clusterConfig) == null ? void 0 : _a2.enabled;
|
|
10114
|
+
}).flatMap((l) => [`clusters-${l.id}`, `cluster-single-${l.id}`, `cluster-single-count-${l.id}`, `unclustered-point-${l.id}`]).filter((id) => mapInstance.getLayer(id));
|
|
10115
|
+
const clusterHit = clusterOverlayIds.length > 0 ? mapInstance.queryRenderedFeatures(e.point, { layers: clusterOverlayIds })[0] : void 0;
|
|
10116
|
+
if (!clusterHit) {
|
|
10117
|
+
if (selectedFeatureIdsRef.current.length > 0 && !isModifierKey) {
|
|
10118
|
+
applySelectionState([]);
|
|
10119
|
+
}
|
|
10120
|
+
return;
|
|
9585
10121
|
}
|
|
9586
|
-
|
|
10122
|
+
const memberId = (_a = clusterHit.properties) == null ? void 0 : _a[CLUSTER_MEMBER_ID_PROP];
|
|
10123
|
+
if (memberId == null || memberId === "") return;
|
|
10124
|
+
clusteredFeatureId = String(memberId);
|
|
9587
10125
|
}
|
|
9588
|
-
const
|
|
9589
|
-
const featureId = (_a = hitFeature.properties) == null ? void 0 : _a.id;
|
|
10126
|
+
const featureId = clusteredFeatureId ?? ((_b = features[0].properties) == null ? void 0 : _b.id);
|
|
9590
10127
|
if (!featureId) return;
|
|
9591
10128
|
let isReadOnly = false;
|
|
9592
10129
|
readOnlyFeatures.current.forEach((layerFeatures) => {
|
|
@@ -10887,10 +11424,17 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10887
11424
|
scheduleSync();
|
|
10888
11425
|
scheduleTimelineUpdate();
|
|
10889
11426
|
setFeatureUpdateCounter((c) => c + 1);
|
|
11427
|
+
if (hasRealChange && !(options == null ? void 0 : options.fromRefresh) && layersRef.current.some((l) => {
|
|
11428
|
+
var _a2;
|
|
11429
|
+
return (_a2 = l.clusterConfig) == null ? void 0 : _a2.enabled;
|
|
11430
|
+
})) {
|
|
11431
|
+
setClusterDataVersion((c) => c + 1);
|
|
11432
|
+
}
|
|
10890
11433
|
const updated = draw.current.get(featureId);
|
|
10891
11434
|
if (updated) onFeatureUpdate == null ? void 0 : onFeatureUpdate(updated);
|
|
10892
11435
|
} else {
|
|
10893
11436
|
let updatedFeature;
|
|
11437
|
+
let anyRealChange = false;
|
|
10894
11438
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
10895
11439
|
var _a2;
|
|
10896
11440
|
const idx = features.findIndex((f) => String(f.id) === featureId);
|
|
@@ -10902,6 +11446,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10902
11446
|
const oldVal = (_a3 = f.properties) == null ? void 0 : _a3[key];
|
|
10903
11447
|
if (JSON.stringify(oldVal) !== JSON.stringify(value)) hasRealChange = true;
|
|
10904
11448
|
});
|
|
11449
|
+
if (hasRealChange) anyRealChange = true;
|
|
10905
11450
|
const currentUnsaved = (_a2 = f.properties) == null ? void 0 : _a2._unsaved;
|
|
10906
11451
|
const nextProperties = { ...f.properties, ...normalizedProperties };
|
|
10907
11452
|
if (!externalPersistence && hasRealChange && currentUnsaved !== false && !(options == null ? void 0 : options.fromRefresh)) {
|
|
@@ -10922,6 +11467,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10922
11467
|
scheduleSync();
|
|
10923
11468
|
scheduleTimelineUpdate();
|
|
10924
11469
|
setFeatureUpdateCounter((c) => c + 1);
|
|
11470
|
+
if (anyRealChange && !(options == null ? void 0 : options.fromRefresh) && layersRef.current.some((l) => {
|
|
11471
|
+
var _a2;
|
|
11472
|
+
return (_a2 = l.clusterConfig) == null ? void 0 : _a2.enabled;
|
|
11473
|
+
})) {
|
|
11474
|
+
setClusterDataVersion((c) => c + 1);
|
|
11475
|
+
}
|
|
10925
11476
|
onFeatureUpdate == null ? void 0 : onFeatureUpdate(updatedFeature);
|
|
10926
11477
|
}
|
|
10927
11478
|
}
|
|
@@ -10949,6 +11500,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10949
11500
|
draw.current.changeMode("simple_select", { featureIds: [featureId] });
|
|
10950
11501
|
scheduleSync();
|
|
10951
11502
|
setFeatureUpdateCounter((c) => c + 1);
|
|
11503
|
+
if (layersRef.current.some((l) => {
|
|
11504
|
+
var _a;
|
|
11505
|
+
return (_a = l.clusterConfig) == null ? void 0 : _a.enabled;
|
|
11506
|
+
})) {
|
|
11507
|
+
setClusterDataVersion((c) => c + 1);
|
|
11508
|
+
}
|
|
10952
11509
|
const updated = draw.current.get(featureId);
|
|
10953
11510
|
if (updated) {
|
|
10954
11511
|
onFeatureUpdate == null ? void 0 : onFeatureUpdate(updated);
|
|
@@ -11303,11 +11860,17 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11303
11860
|
try {
|
|
11304
11861
|
if (firstVisibleBasemapSymbol) {
|
|
11305
11862
|
m.moveLayer("custom-labels", firstVisibleBasemapSymbol.id);
|
|
11863
|
+
if (m.getLayer("custom-labels-pinned")) {
|
|
11864
|
+
m.moveLayer("custom-labels-pinned", firstVisibleBasemapSymbol.id);
|
|
11865
|
+
}
|
|
11306
11866
|
if (m.getLayer("custom-arrow-labels")) {
|
|
11307
11867
|
m.moveLayer("custom-arrow-labels", firstVisibleBasemapSymbol.id);
|
|
11308
11868
|
}
|
|
11309
11869
|
} else {
|
|
11310
11870
|
m.moveLayer("custom-labels");
|
|
11871
|
+
if (m.getLayer("custom-labels-pinned")) {
|
|
11872
|
+
m.moveLayer("custom-labels-pinned");
|
|
11873
|
+
}
|
|
11311
11874
|
if (m.getLayer("custom-arrow-labels")) {
|
|
11312
11875
|
m.moveLayer("custom-arrow-labels");
|
|
11313
11876
|
}
|
|
@@ -11612,7 +12175,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11612
12175
|
const layer = layers.find((l) => l.id === layerId);
|
|
11613
12176
|
if (!layer) return [];
|
|
11614
12177
|
const fieldsMap = /* @__PURE__ */ new Map();
|
|
11615
|
-
const excludedFields = /* @__PURE__ */ new Set(["name", "startDate", "endDate", "opacity"]);
|
|
12178
|
+
const excludedFields = /* @__PURE__ */ new Set(["name", "startDate", "endDate", "opacity", ...STYLING_PROPERTY_KEYS]);
|
|
11616
12179
|
const MAX_SAMPLES = 1e4;
|
|
11617
12180
|
let features = [];
|
|
11618
12181
|
if (layer.readOnly) {
|
|
@@ -11622,22 +12185,41 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11622
12185
|
} else {
|
|
11623
12186
|
features = hiddenFeatures.current.get(layerId) || [];
|
|
11624
12187
|
}
|
|
11625
|
-
const
|
|
12188
|
+
const sampled = !layer.readOnly && features.length > MAX_SAMPLES;
|
|
12189
|
+
const sampleFeatures = layer.readOnly ? features : features.slice(0, MAX_SAMPLES);
|
|
11626
12190
|
sampleFeatures.forEach((f) => {
|
|
11627
12191
|
if (f && f.properties) {
|
|
11628
12192
|
Object.entries(f.properties).forEach(([key, value]) => {
|
|
11629
|
-
if (
|
|
11630
|
-
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
|
|
12193
|
+
if (excludedFields.has(key)) return;
|
|
12194
|
+
let acc = fieldsMap.get(key);
|
|
12195
|
+
if (!acc) {
|
|
12196
|
+
acc = { isNumeric: false, numericCount: 0, nonEmptyCount: 0, min: Infinity, max: -Infinity };
|
|
12197
|
+
fieldsMap.set(key, acc);
|
|
12198
|
+
}
|
|
12199
|
+
if (typeof value === "number" || typeof value === "string" && value.trim() !== "" && !isNaN(Number(value))) {
|
|
12200
|
+
acc.isNumeric = true;
|
|
12201
|
+
}
|
|
12202
|
+
if (!(value == null || typeof value === "string" && value.trim() === "")) {
|
|
12203
|
+
acc.nonEmptyCount++;
|
|
12204
|
+
}
|
|
12205
|
+
const num = coerceFiniteNumber(value);
|
|
12206
|
+
if (num !== null) {
|
|
12207
|
+
acc.numericCount++;
|
|
12208
|
+
if (num < acc.min) acc.min = num;
|
|
12209
|
+
if (num > acc.max) acc.max = num;
|
|
11636
12210
|
}
|
|
11637
12211
|
});
|
|
11638
12212
|
}
|
|
11639
12213
|
});
|
|
11640
|
-
|
|
12214
|
+
const sampledFeatureCount = sampleFeatures.length;
|
|
12215
|
+
return Array.from(fieldsMap.entries()).map(([name, acc]) => ({
|
|
12216
|
+
name,
|
|
12217
|
+
isNumeric: acc.isNumeric,
|
|
12218
|
+
numericRatio: acc.nonEmptyCount > 0 ? acc.numericCount / acc.nonEmptyCount : 0,
|
|
12219
|
+
coverage: sampledFeatureCount > 0 ? acc.nonEmptyCount / sampledFeatureCount : 0,
|
|
12220
|
+
sampled,
|
|
12221
|
+
...acc.numericCount > 0 ? { min: acc.min, max: acc.max } : {}
|
|
12222
|
+
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
11641
12223
|
}, [layers]);
|
|
11642
12224
|
const getFieldValueDistribution = useCallback(
|
|
11643
12225
|
(layerId, fieldName, maxValues = 50) => {
|
|
@@ -12592,29 +13174,22 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12592
13174
|
}, [measurePoints, measureMode, isMapLoaded]);
|
|
12593
13175
|
const handleSaveLayerGeoJSON = useCallback((layerId) => {
|
|
12594
13176
|
const layer = layers.find((l) => l.id === layerId);
|
|
12595
|
-
if (!layer
|
|
12596
|
-
const features =
|
|
12597
|
-
|
|
12598
|
-
|
|
12599
|
-
|
|
12600
|
-
|
|
12601
|
-
|
|
12602
|
-
|
|
12603
|
-
|
|
12604
|
-
pushAll(features, hidden);
|
|
12605
|
-
}
|
|
13177
|
+
if (!layer) return;
|
|
13178
|
+
const features = collectLayerFeatures(layer, {
|
|
13179
|
+
getDrawFeature: (id) => {
|
|
13180
|
+
var _a;
|
|
13181
|
+
return (_a = draw.current) == null ? void 0 : _a.get(id);
|
|
13182
|
+
},
|
|
13183
|
+
hiddenFeatures: hiddenFeatures.current,
|
|
13184
|
+
readOnlyFeatures: readOnlyFeatures.current
|
|
13185
|
+
});
|
|
12606
13186
|
const layerMetadata = {
|
|
12607
13187
|
name: layer.name
|
|
12608
13188
|
};
|
|
12609
13189
|
if (layer.traceConfig) layerMetadata.traceConfig = layer.traceConfig;
|
|
12610
13190
|
if (layer.heatmapConfig) layerMetadata.heatmapConfig = layer.heatmapConfig;
|
|
12611
13191
|
if (layer.visualConfig) layerMetadata.visualConfig = layer.visualConfig;
|
|
12612
|
-
const cleanedFeatures = features
|
|
12613
|
-
...f,
|
|
12614
|
-
properties: Object.fromEntries(
|
|
12615
|
-
Object.entries(f.properties || {}).filter(([key]) => !key.startsWith("_"))
|
|
12616
|
-
)
|
|
12617
|
-
}));
|
|
13192
|
+
const cleanedFeatures = stripInternalProperties(features);
|
|
12618
13193
|
const geojson = {
|
|
12619
13194
|
type: "FeatureCollection",
|
|
12620
13195
|
features: cleanedFeatures,
|
|
@@ -12646,18 +13221,14 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12646
13221
|
var _a;
|
|
12647
13222
|
const isDataViewing = ((_a = layer.metadata) == null ? void 0 : _a.dataViewing) === true;
|
|
12648
13223
|
if (!isDataViewing) {
|
|
12649
|
-
const layerFeatures =
|
|
12650
|
-
|
|
12651
|
-
|
|
12652
|
-
|
|
12653
|
-
|
|
12654
|
-
|
|
12655
|
-
|
|
12656
|
-
|
|
12657
|
-
pushAll(layerFeatures, hidden);
|
|
12658
|
-
}
|
|
12659
|
-
const roFeatures = readOnlyFeatures.current.get(layer.id);
|
|
12660
|
-
if (roFeatures) pushAll(layerFeatures, roFeatures);
|
|
13224
|
+
const layerFeatures = collectLayerFeatures(layer, {
|
|
13225
|
+
getDrawFeature: (id) => {
|
|
13226
|
+
var _a2;
|
|
13227
|
+
return (_a2 = draw.current) == null ? void 0 : _a2.get(id);
|
|
13228
|
+
},
|
|
13229
|
+
hiddenFeatures: hiddenFeatures.current,
|
|
13230
|
+
readOnlyFeatures: readOnlyFeatures.current
|
|
13231
|
+
});
|
|
12661
13232
|
layerFeatures.forEach((f) => {
|
|
12662
13233
|
allFeatures.push({
|
|
12663
13234
|
...f,
|
|
@@ -12668,14 +13239,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12668
13239
|
const { id: _id, featureIds: _fids, hasAltitudeData: _alt, ...persistable } = layer;
|
|
12669
13240
|
layerStates.push({ index: idx, ...persistable });
|
|
12670
13241
|
});
|
|
12671
|
-
const cleanedFeatures = allFeatures
|
|
12672
|
-
...f,
|
|
12673
|
-
properties: Object.fromEntries(
|
|
12674
|
-
Object.entries(f.properties || {}).filter(
|
|
12675
|
-
([key]) => !key.startsWith("_") || key === "_layerIndex"
|
|
12676
|
-
)
|
|
12677
|
-
)
|
|
12678
|
-
}));
|
|
13242
|
+
const cleanedFeatures = stripInternalProperties(allFeatures, ENRICHED_EXPORT_KEEP_KEYS);
|
|
12679
13243
|
let viewport;
|
|
12680
13244
|
if (map.current && isMapLoaded) {
|
|
12681
13245
|
const c = map.current.getCenter();
|
|
@@ -13006,6 +13570,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13006
13570
|
}
|
|
13007
13571
|
}, [ingestProgressStore]);
|
|
13008
13572
|
const loadGeoJSONFile = useCallback(async (file, requestedTargetLayerId, createNewLayer) => {
|
|
13573
|
+
var _a;
|
|
13009
13574
|
let result;
|
|
13010
13575
|
try {
|
|
13011
13576
|
result = await ingestWithProgress(file.name, file, {
|
|
@@ -13094,14 +13659,49 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13094
13659
|
return;
|
|
13095
13660
|
}
|
|
13096
13661
|
const currentLayers = layersRef.current;
|
|
13097
|
-
let targetLayer = currentLayers.find((l) => l.id === requestedTargetLayerId
|
|
13662
|
+
let targetLayer = currentLayers.find((l) => l.id === requestedTargetLayerId);
|
|
13663
|
+
if (((_a = targetLayer == null ? void 0 : targetLayer.metadata) == null ? void 0 : _a.dataViewing) === true) {
|
|
13664
|
+
toast({
|
|
13665
|
+
title: "Can't load into a data-viewing layer",
|
|
13666
|
+
description: "Its features are fetched from data and aren't saved with the map. Load the file into another layer.",
|
|
13667
|
+
variant: "destructive"
|
|
13668
|
+
});
|
|
13669
|
+
return;
|
|
13670
|
+
}
|
|
13098
13671
|
if (!targetLayer) {
|
|
13099
13672
|
targetLayer = currentLayers.find((l) => l.visible && !l.readOnly);
|
|
13100
13673
|
}
|
|
13101
13674
|
if (!targetLayer) {
|
|
13102
13675
|
targetLayer = currentLayers.find((l) => !l.readOnly);
|
|
13103
13676
|
}
|
|
13104
|
-
if (targetLayer
|
|
13677
|
+
if (!targetLayer) {
|
|
13678
|
+
toast({
|
|
13679
|
+
title: "No layer to load into",
|
|
13680
|
+
description: "Create a layer first, then load the file again.",
|
|
13681
|
+
variant: "destructive"
|
|
13682
|
+
});
|
|
13683
|
+
return;
|
|
13684
|
+
}
|
|
13685
|
+
const targetId = targetLayer.id;
|
|
13686
|
+
const withLayerMetadata = (l, addedIds) => ({
|
|
13687
|
+
...l,
|
|
13688
|
+
featureIds: [...l.featureIds, ...addedIds],
|
|
13689
|
+
...(layerMetadata == null ? void 0 : layerMetadata.traceConfig) && { traceConfig: layerMetadata.traceConfig },
|
|
13690
|
+
...(layerMetadata == null ? void 0 : layerMetadata.heatmapConfig) && { heatmapConfig: layerMetadata.heatmapConfig },
|
|
13691
|
+
...(layerMetadata == null ? void 0 : layerMetadata.visualConfig) && { visualConfig: layerMetadata.visualConfig }
|
|
13692
|
+
});
|
|
13693
|
+
if (targetLayer.readOnly) {
|
|
13694
|
+
const addedFeatures = normalizedFeatures.map((f) => ({ ...f, id: crypto.randomUUID() }));
|
|
13695
|
+
const addedIds = addedFeatures.map((f) => String(f.id));
|
|
13696
|
+
const existing = readOnlyFeatures.current.get(targetId) || [];
|
|
13697
|
+
readOnlyFeatures.current.set(targetId, [...existing, ...addedFeatures]);
|
|
13698
|
+
const cached = layerTemporalCacheRef.current.get(targetId);
|
|
13699
|
+
layerTemporalCacheRef.current.set(targetId, {
|
|
13700
|
+
featureCount: ((cached == null ? void 0 : cached.featureCount) ?? existing.length) + addedFeatures.length,
|
|
13701
|
+
hasTemporal: ((cached == null ? void 0 : cached.hasTemporal) ?? false) || fileHasTemporal
|
|
13702
|
+
});
|
|
13703
|
+
setLayers((prev) => prev.map((l) => l.id === targetId ? withLayerMetadata(l, addedIds) : l));
|
|
13704
|
+
} else if (targetLayer.visible) {
|
|
13105
13705
|
const addedIds = [];
|
|
13106
13706
|
isApiAddingRef.current = true;
|
|
13107
13707
|
try {
|
|
@@ -13112,32 +13712,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13112
13712
|
} finally {
|
|
13113
13713
|
isApiAddingRef.current = false;
|
|
13114
13714
|
}
|
|
13115
|
-
|
|
13116
|
-
|
|
13117
|
-
if (l.id !== targetId) return l;
|
|
13118
|
-
return {
|
|
13119
|
-
...l,
|
|
13120
|
-
featureIds: [...l.featureIds, ...addedIds],
|
|
13121
|
-
...(layerMetadata == null ? void 0 : layerMetadata.traceConfig) && { traceConfig: layerMetadata.traceConfig },
|
|
13122
|
-
...(layerMetadata == null ? void 0 : layerMetadata.heatmapConfig) && { heatmapConfig: layerMetadata.heatmapConfig },
|
|
13123
|
-
...(layerMetadata == null ? void 0 : layerMetadata.visualConfig) && { visualConfig: layerMetadata.visualConfig }
|
|
13124
|
-
};
|
|
13125
|
-
}));
|
|
13126
|
-
} else if (targetLayer) {
|
|
13127
|
-
const targetId = targetLayer.id;
|
|
13715
|
+
setLayers((prev) => prev.map((l) => l.id === targetId ? withLayerMetadata(l, addedIds) : l));
|
|
13716
|
+
} else {
|
|
13128
13717
|
const addedIds = normalizedFeatures.map((f) => String(f.id));
|
|
13129
13718
|
const existing = hiddenFeatures.current.get(targetId) || [];
|
|
13130
13719
|
hiddenFeatures.current.set(targetId, [...existing, ...normalizedFeatures]);
|
|
13131
|
-
setLayers((prev) => prev.map((l) =>
|
|
13132
|
-
if (l.id !== targetId) return l;
|
|
13133
|
-
return {
|
|
13134
|
-
...l,
|
|
13135
|
-
featureIds: [...l.featureIds, ...addedIds],
|
|
13136
|
-
...(layerMetadata == null ? void 0 : layerMetadata.traceConfig) && { traceConfig: layerMetadata.traceConfig },
|
|
13137
|
-
...(layerMetadata == null ? void 0 : layerMetadata.heatmapConfig) && { heatmapConfig: layerMetadata.heatmapConfig },
|
|
13138
|
-
...(layerMetadata == null ? void 0 : layerMetadata.visualConfig) && { visualConfig: layerMetadata.visualConfig }
|
|
13139
|
-
};
|
|
13140
|
-
}));
|
|
13720
|
+
setLayers((prev) => prev.map((l) => l.id === targetId ? withLayerMetadata(l, addedIds) : l));
|
|
13141
13721
|
}
|
|
13142
13722
|
updateFeatureCount();
|
|
13143
13723
|
scheduleTimelineUpdate();
|
|
@@ -13385,16 +13965,33 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13385
13965
|
mapInstance.once("idle", rebuildClusters);
|
|
13386
13966
|
return;
|
|
13387
13967
|
}
|
|
13968
|
+
clusterLayerHandlers.current.forEach((handlers, layerId) => {
|
|
13969
|
+
const clustersLayerId = `clusters-${layerId}`;
|
|
13970
|
+
try {
|
|
13971
|
+
mapInstance.off("click", clustersLayerId, handlers.click);
|
|
13972
|
+
mapInstance.off("mouseenter", clustersLayerId, handlers.enter);
|
|
13973
|
+
mapInstance.off("mouseleave", clustersLayerId, handlers.leave);
|
|
13974
|
+
} catch {
|
|
13975
|
+
}
|
|
13976
|
+
});
|
|
13977
|
+
clusterLayerHandlers.current.clear();
|
|
13388
13978
|
layers.forEach((layer) => {
|
|
13389
13979
|
const sourceId = `cluster-source-${layer.id}`;
|
|
13390
13980
|
const clustersLayerId = `clusters-${layer.id}`;
|
|
13391
13981
|
const clusterCountLayerId = `cluster-count-${layer.id}`;
|
|
13392
13982
|
const unclusteredLayerId = `unclustered-point-${layer.id}`;
|
|
13983
|
+
const singleValueLayerId = `cluster-single-${layer.id}`;
|
|
13984
|
+
const singleValueCountLayerId = `cluster-single-count-${layer.id}`;
|
|
13393
13985
|
const existingPieManager = clusterPieManagers.current.get(layer.id);
|
|
13394
13986
|
if (existingPieManager) {
|
|
13395
13987
|
existingPieManager.destroy();
|
|
13396
13988
|
clusterPieManagers.current.delete(layer.id);
|
|
13397
13989
|
}
|
|
13990
|
+
const existingGradientManager = clusterGradientManagers.current.get(layer.id);
|
|
13991
|
+
if (existingGradientManager) {
|
|
13992
|
+
existingGradientManager.destroy();
|
|
13993
|
+
clusterGradientManagers.current.delete(layer.id);
|
|
13994
|
+
}
|
|
13398
13995
|
try {
|
|
13399
13996
|
if (mapInstance.getLayer(clusterCountLayerId)) {
|
|
13400
13997
|
mapInstance.removeLayer(clusterCountLayerId);
|
|
@@ -13402,6 +13999,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13402
13999
|
if (mapInstance.getLayer(clustersLayerId)) {
|
|
13403
14000
|
mapInstance.removeLayer(clustersLayerId);
|
|
13404
14001
|
}
|
|
14002
|
+
if (mapInstance.getLayer(singleValueCountLayerId)) {
|
|
14003
|
+
mapInstance.removeLayer(singleValueCountLayerId);
|
|
14004
|
+
}
|
|
14005
|
+
if (mapInstance.getLayer(singleValueLayerId)) {
|
|
14006
|
+
mapInstance.removeLayer(singleValueLayerId);
|
|
14007
|
+
}
|
|
13405
14008
|
if (mapInstance.getLayer(unclusteredLayerId)) {
|
|
13406
14009
|
mapInstance.removeLayer(unclusteredLayerId);
|
|
13407
14010
|
}
|
|
@@ -13412,12 +14015,14 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13412
14015
|
}
|
|
13413
14016
|
});
|
|
13414
14017
|
layers.forEach((layer) => {
|
|
13415
|
-
var _a, _b, _c, _d;
|
|
14018
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
13416
14019
|
if (!((_a = layer.clusterConfig) == null ? void 0 : _a.enabled) || !layer.visible) return;
|
|
13417
14020
|
const sourceId = `cluster-source-${layer.id}`;
|
|
13418
14021
|
const clustersLayerId = `clusters-${layer.id}`;
|
|
13419
14022
|
const clusterCountLayerId = `cluster-count-${layer.id}`;
|
|
13420
14023
|
const unclusteredLayerId = `unclustered-point-${layer.id}`;
|
|
14024
|
+
const singleValueLayerId = `cluster-single-${layer.id}`;
|
|
14025
|
+
const singleValueCountLayerId = `cluster-single-count-${layer.id}`;
|
|
13421
14026
|
let pointFeatures = [];
|
|
13422
14027
|
if (layer.visible) {
|
|
13423
14028
|
if (layer.readOnly) {
|
|
@@ -13444,10 +14049,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13444
14049
|
}
|
|
13445
14050
|
if (pointFeatures.length === 0) return;
|
|
13446
14051
|
const groupByField = (_b = layer.clusterConfig) == null ? void 0 : _b.groupByField;
|
|
14052
|
+
const countByField = ((_c = layer.clusterConfig) == null ? void 0 : _c.countByFieldEnabled) && ((_d = layer.clusterConfig) == null ? void 0 : _d.countByField) || null;
|
|
14053
|
+
const bubbleGradient = !!((_e = layer.clusterConfig) == null ? void 0 : _e.bubbleGradient) && !groupByField;
|
|
13447
14054
|
const OTHER_COLOR = OTHER_BUCKET_COLOR;
|
|
13448
14055
|
const MAX_CATEGORIES = 15;
|
|
13449
14056
|
try {
|
|
13450
|
-
const layerColor = ((
|
|
14057
|
+
const layerColor = ((_g = (_f = layer.visualConfig) == null ? void 0 : _f.color) == null ? void 0 : _g.fixedColor) || "#3b82f6";
|
|
13451
14058
|
let clusterProperties = {};
|
|
13452
14059
|
let categoryValues = [];
|
|
13453
14060
|
let categoryColorMap = {};
|
|
@@ -13477,12 +14084,16 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13477
14084
|
const otherExpr = topKeys.length === 0 ? 1 : ["match", fieldAsString, topKeys, 0, 1];
|
|
13478
14085
|
clusterProperties[`cat_${categoryValues.length - 1}`] = ["+", otherExpr];
|
|
13479
14086
|
}
|
|
14087
|
+
if (countByField) {
|
|
14088
|
+
clusterProperties[CLUSTER_SUM_PROP] = ["+", ["get", CLUSTER_COUNT_VALUE_PROP]];
|
|
14089
|
+
}
|
|
14090
|
+
const sourceFeatures = countByField ? injectClusterCountValues(pointFeatures, countByField) : pointFeatures;
|
|
13480
14091
|
const mapStyleMaxZoom = typeof mapInstance.getMaxZoom === "function" ? mapInstance.getMaxZoom() : 24;
|
|
13481
14092
|
const clusterMaxZoom = Math.min(24, Math.max(1, mapStyleMaxZoom - 1));
|
|
13482
14093
|
const geojsonSourceMaxZoom = Math.min(24, Math.max(clusterMaxZoom + 1, mapStyleMaxZoom));
|
|
13483
14094
|
mapInstance.addSource(sourceId, {
|
|
13484
14095
|
type: "geojson",
|
|
13485
|
-
data: { type: "FeatureCollection", features:
|
|
14096
|
+
data: { type: "FeatureCollection", features: sourceFeatures },
|
|
13486
14097
|
maxzoom: geojsonSourceMaxZoom,
|
|
13487
14098
|
cluster: true,
|
|
13488
14099
|
clusterMaxZoom,
|
|
@@ -13540,12 +14151,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13540
14151
|
source: sourceId,
|
|
13541
14152
|
filter: ["has", "point_count"],
|
|
13542
14153
|
layout: {
|
|
13543
|
-
"text-field": ["get", "point_count_abbreviated"],
|
|
14154
|
+
"text-field": countByField ? clusterBadgeTextField(CLUSTER_SUM_PROP) : ["get", "point_count_abbreviated"],
|
|
13544
14155
|
"text-font": ["Open Sans Bold", "Arial Unicode MS Bold"],
|
|
13545
14156
|
"text-size": 12
|
|
13546
14157
|
},
|
|
13547
14158
|
paint: {
|
|
13548
|
-
"text-color": "#ffffff"
|
|
14159
|
+
"text-color": "#ffffff",
|
|
14160
|
+
// The gradient's pale end needs a dark halo for the white
|
|
14161
|
+
// badge text to stay readable at every ramp stop.
|
|
14162
|
+
...bubbleGradient ? { "text-halo-color": "#111827", "text-halo-width": 1.1 } : {}
|
|
13549
14163
|
}
|
|
13550
14164
|
});
|
|
13551
14165
|
}
|
|
@@ -13560,7 +14174,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13560
14174
|
id: unclusteredLayerId,
|
|
13561
14175
|
type: "circle",
|
|
13562
14176
|
source: sourceId,
|
|
13563
|
-
|
|
14177
|
+
// With count-by-field on, points whose value exceeds 1 render as
|
|
14178
|
+
// value bubbles below instead of plain dots.
|
|
14179
|
+
filter: countByField ? ["all", ["!", ["has", "point_count"]], ["<=", ["get", CLUSTER_COUNT_VALUE_PROP], 1]] : ["!", ["has", "point_count"]],
|
|
13564
14180
|
paint: {
|
|
13565
14181
|
"circle-color": unclusteredColor,
|
|
13566
14182
|
"circle-radius": 6,
|
|
@@ -13568,7 +14184,50 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13568
14184
|
"circle-stroke-color": "#ffffff"
|
|
13569
14185
|
}
|
|
13570
14186
|
});
|
|
13571
|
-
|
|
14187
|
+
if (countByField) {
|
|
14188
|
+
const singleValueFilter = ["all", ["!", ["has", "point_count"]], [">", ["get", CLUSTER_COUNT_VALUE_PROP], 1]];
|
|
14189
|
+
mapInstance.addLayer({
|
|
14190
|
+
id: singleValueLayerId,
|
|
14191
|
+
type: "circle",
|
|
14192
|
+
source: sourceId,
|
|
14193
|
+
filter: singleValueFilter,
|
|
14194
|
+
paint: {
|
|
14195
|
+
"circle-color": unclusteredColor,
|
|
14196
|
+
"circle-radius": 14,
|
|
14197
|
+
"circle-stroke-width": 2,
|
|
14198
|
+
"circle-stroke-color": "#ffffff"
|
|
14199
|
+
}
|
|
14200
|
+
});
|
|
14201
|
+
mapInstance.addLayer({
|
|
14202
|
+
id: singleValueCountLayerId,
|
|
14203
|
+
type: "symbol",
|
|
14204
|
+
source: sourceId,
|
|
14205
|
+
filter: singleValueFilter,
|
|
14206
|
+
layout: {
|
|
14207
|
+
"text-field": clusterBadgeTextField(CLUSTER_COUNT_VALUE_PROP),
|
|
14208
|
+
"text-font": ["Open Sans Bold", "Arial Unicode MS Bold"],
|
|
14209
|
+
"text-size": 11,
|
|
14210
|
+
// A bubble without its number reads as broken - never cull.
|
|
14211
|
+
"text-allow-overlap": true,
|
|
14212
|
+
"text-ignore-placement": true
|
|
14213
|
+
},
|
|
14214
|
+
paint: {
|
|
14215
|
+
"text-color": "#ffffff",
|
|
14216
|
+
...bubbleGradient ? { "text-halo-color": "#111827", "text-halo-width": 1.1 } : {}
|
|
14217
|
+
}
|
|
14218
|
+
});
|
|
14219
|
+
}
|
|
14220
|
+
if (bubbleGradient) {
|
|
14221
|
+
clusterGradientManagers.current.set(
|
|
14222
|
+
layer.id,
|
|
14223
|
+
createClusterGradientManager(mapInstance, sourceId, {
|
|
14224
|
+
clustersLayerId,
|
|
14225
|
+
valueProp: countByField ? CLUSTER_SUM_PROP : null,
|
|
14226
|
+
...countByField ? { singleLayerId: singleValueLayerId } : {}
|
|
14227
|
+
})
|
|
14228
|
+
);
|
|
14229
|
+
}
|
|
14230
|
+
const handleClusterClick = async (e) => {
|
|
13572
14231
|
var _a2;
|
|
13573
14232
|
const features = mapInstance.queryRenderedFeatures(e.point, {
|
|
13574
14233
|
layers: [clustersLayerId]
|
|
@@ -13587,12 +14246,20 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13587
14246
|
}
|
|
13588
14247
|
} catch {
|
|
13589
14248
|
}
|
|
13590
|
-
}
|
|
13591
|
-
|
|
14249
|
+
};
|
|
14250
|
+
const handleClusterMouseEnter = () => {
|
|
13592
14251
|
mapInstance.getCanvas().style.cursor = "pointer";
|
|
13593
|
-
}
|
|
13594
|
-
|
|
14252
|
+
};
|
|
14253
|
+
const handleClusterMouseLeave = () => {
|
|
13595
14254
|
mapInstance.getCanvas().style.cursor = "";
|
|
14255
|
+
};
|
|
14256
|
+
mapInstance.on("click", clustersLayerId, handleClusterClick);
|
|
14257
|
+
mapInstance.on("mouseenter", clustersLayerId, handleClusterMouseEnter);
|
|
14258
|
+
mapInstance.on("mouseleave", clustersLayerId, handleClusterMouseLeave);
|
|
14259
|
+
clusterLayerHandlers.current.set(layer.id, {
|
|
14260
|
+
click: handleClusterClick,
|
|
14261
|
+
enter: handleClusterMouseEnter,
|
|
14262
|
+
leave: handleClusterMouseLeave
|
|
13596
14263
|
});
|
|
13597
14264
|
} catch (e) {
|
|
13598
14265
|
console.warn("Error creating cluster layer:", e);
|
|
@@ -13610,7 +14277,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13610
14277
|
} catch {
|
|
13611
14278
|
}
|
|
13612
14279
|
};
|
|
13613
|
-
}, [isMapLoaded, layers, currentMapStyle, hashStringToColor$1]);
|
|
14280
|
+
}, [isMapLoaded, layers, currentMapStyle, hashStringToColor$1, clusterDataVersion]);
|
|
13614
14281
|
if (mapError) {
|
|
13615
14282
|
return /* @__PURE__ */ jsx("div", { className: `flex items-center justify-center h-full bg-muted/30 ${className || ""}`, "data-testid": "map-error", children: /* @__PURE__ */ jsxs(Card, { className: "max-w-md", children: [
|
|
13616
14283
|
/* @__PURE__ */ jsx("div", { className: "p-4 border-b border-border", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
@@ -15130,40 +15797,6 @@ function DebugSidebar({ onAddRandomPoints, onImportKML, onAddDomMarkers, onRemov
|
|
|
15130
15797
|
}
|
|
15131
15798
|
);
|
|
15132
15799
|
}
|
|
15133
|
-
const INTERNAL_PROPERTY_KEYS = /* @__PURE__ */ new Set([
|
|
15134
|
-
"fill",
|
|
15135
|
-
"fill-opacity",
|
|
15136
|
-
"pointRadius",
|
|
15137
|
-
"pointIcon",
|
|
15138
|
-
"pointIconSize",
|
|
15139
|
-
"circleCenter",
|
|
15140
|
-
"circleRadius",
|
|
15141
|
-
"icon",
|
|
15142
|
-
"iconSize",
|
|
15143
|
-
"fontSize",
|
|
15144
|
-
"fontColor",
|
|
15145
|
-
"fontWeight",
|
|
15146
|
-
"arrowSize",
|
|
15147
|
-
"label",
|
|
15148
|
-
"entityType",
|
|
15149
|
-
"kind",
|
|
15150
|
-
"meta:type",
|
|
15151
|
-
"stroke",
|
|
15152
|
-
"stroke-width",
|
|
15153
|
-
"stroke-opacity"
|
|
15154
|
-
]);
|
|
15155
|
-
const INTERNAL_PROPERTY_PREFIXES = [
|
|
15156
|
-
"IsHiddenBy",
|
|
15157
|
-
"isHidden",
|
|
15158
|
-
"isSelected",
|
|
15159
|
-
"isTrace",
|
|
15160
|
-
"isTimeline",
|
|
15161
|
-
"trace"
|
|
15162
|
-
];
|
|
15163
|
-
function isInternalProperty(key) {
|
|
15164
|
-
if (INTERNAL_PROPERTY_KEYS.has(key)) return true;
|
|
15165
|
-
return INTERNAL_PROPERTY_PREFIXES.some((prefix) => key.startsWith(prefix));
|
|
15166
|
-
}
|
|
15167
15800
|
export {
|
|
15168
15801
|
ActionPanel,
|
|
15169
15802
|
ClusterPieManager,
|