@octostar/map-component 0.10.0 → 0.12.0
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/{de-CiibAOpt.js → de-baB1tmXy.js} +4 -1
- package/dist/{fr-ftr3hxY2.js.map → de-baB1tmXy.js.map} +1 -1
- package/dist/{es-D8jViCNt.js → es-BOFeFpOn.js} +4 -1
- package/dist/{de-CiibAOpt.js.map → es-BOFeFpOn.js.map} +1 -1
- package/dist/{fr-ftr3hxY2.js → fr-CaNTJBXD.js} +4 -1
- package/dist/{it-JiSfNdMa.js.map → fr-CaNTJBXD.js.map} +1 -1
- package/dist/index.mjs +1256 -1031
- package/dist/index.mjs.map +1 -1
- package/dist/{it-JiSfNdMa.js → it-D8wMaegA.js} +4 -1
- package/dist/{es-D8jViCNt.js.map → it-D8wMaegA.js.map} +1 -1
- package/dist/{pt-BR-DfnZxiOD.js → pt-BR-DU8z2z6T.js} +4 -1
- package/dist/{pt-BR-DfnZxiOD.js.map → pt-BR-DU8z2z6T.js.map} +1 -1
- package/dist/{pt-PT-Cvl_rDbf.js → pt-PT-ByMcI3iF.js} +4 -1
- package/dist/{pt-PT-Cvl_rDbf.js.map → pt-PT-ByMcI3iF.js.map} +1 -1
- package/dist/styles.css +5 -1
- package/dist/types/components/feature-popups.d.ts +65 -0
- package/dist/types/components/feature-popups.d.ts.map +1 -0
- package/dist/types/components/layers-panel.d.ts +4 -1
- 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/components/value-legend.d.ts +29 -0
- package/dist/types/components/value-legend.d.ts.map +1 -0
- package/dist/types/lib/field-values.d.ts +13 -0
- package/dist/types/lib/field-values.d.ts.map +1 -1
- package/dist/types/lib/labels/panel-labels.d.ts +3 -0
- package/dist/types/lib/labels/panel-labels.d.ts.map +1 -1
- package/dist/types/lib/map-editor-api.d.ts +9 -5
- package/dist/types/lib/map-editor-api.d.ts.map +1 -1
- package/dist/types/lib/map-labels.d.ts +6 -0
- package/dist/types/lib/map-labels.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useSyncExternalStore, useEffect, useContext, createContext, useRef, useLayoutEffect, useState, useCallback, useMemo, forwardRef, useImperativeHandle } from "react";
|
|
2
|
+
import { useSyncExternalStore, useEffect, useContext, createContext, useRef, useLayoutEffect, useState, Suspense, Fragment as Fragment$1, Component, useCallback, useMemo, forwardRef, useImperativeHandle } from "react";
|
|
3
3
|
import * as maplibregl from "maplibre-gl";
|
|
4
4
|
import { getWorkerUrl, getVersion, setWorkerUrl } from "maplibre-gl";
|
|
5
5
|
import MapboxDraw from "@mapbox/mapbox-gl-draw";
|
|
@@ -9,11 +9,11 @@ import * as THREE from "three";
|
|
|
9
9
|
import proj4 from "proj4";
|
|
10
10
|
import i18next from "i18next";
|
|
11
11
|
import ICU from "i18next-icu";
|
|
12
|
+
import { flushSync, createPortal } from "react-dom";
|
|
12
13
|
import { Button, Modal, Input, App, message, ConfigProvider, Tooltip, Dropdown, Divider, Popover, Slider, Switch, Segmented, Select, Tag, DatePicker, Collapse, ColorPicker, Tabs, Card, Table } from "antd";
|
|
13
14
|
import { clsx } from "clsx";
|
|
14
15
|
import { twMerge } from "tailwind-merge";
|
|
15
16
|
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, Smile, Sparkles, Map as Map$1, Satellite, FolderOpen, Upload, Download, MoreHorizontal, Focus, Box, Layers, Plus, ChevronRight, Eye, EyeOff, Lock, Package, Copy, FolderInput, Save, Calendar, Palette, Blend, RotateCcw, RefreshCw, ExternalLink, Info, ChevronLeft, SkipBack, Pause, Play, Clock, AlertTriangle, TestTube, Users, GripVertical, Plane, FileJson, Check, Phone, Car, AlertCircle } from "lucide-react";
|
|
16
|
-
import { createPortal } from "react-dom";
|
|
17
17
|
import dayjs from "dayjs";
|
|
18
18
|
import { createStore, useStore } from "zustand";
|
|
19
19
|
import Flatbush from "flatbush";
|
|
@@ -858,12 +858,12 @@ void instance.use(ICUWithContext).init({
|
|
|
858
858
|
interpolation: { escapeValue: false }
|
|
859
859
|
});
|
|
860
860
|
const CATALOGS = {
|
|
861
|
-
it: () => import("./it-
|
|
862
|
-
fr: () => import("./fr-
|
|
863
|
-
de: () => import("./de-
|
|
864
|
-
es: () => import("./es-
|
|
865
|
-
"pt-BR": () => import("./pt-BR-
|
|
866
|
-
"pt-PT": () => import("./pt-PT-
|
|
861
|
+
it: () => import("./it-D8wMaegA.js"),
|
|
862
|
+
fr: () => import("./fr-CaNTJBXD.js"),
|
|
863
|
+
de: () => import("./de-baB1tmXy.js"),
|
|
864
|
+
es: () => import("./es-BOFeFpOn.js"),
|
|
865
|
+
"pt-BR": () => import("./pt-BR-DU8z2z6T.js"),
|
|
866
|
+
"pt-PT": () => import("./pt-PT-ByMcI3iF.js")
|
|
867
867
|
};
|
|
868
868
|
const loaded = /* @__PURE__ */ new Set([DEFAULT_LANGUAGE]);
|
|
869
869
|
const loading = /* @__PURE__ */ new Map();
|
|
@@ -1327,7 +1327,10 @@ const visualLayerSettingLabels = (t) => ({
|
|
|
1327
1327
|
filterValues: t("Filter values…"),
|
|
1328
1328
|
noMatches: t("No matches"),
|
|
1329
1329
|
showLess: t("Show less"),
|
|
1330
|
-
showAll: (count) => t("Show all ({count})", { count })
|
|
1330
|
+
showAll: (count) => t("Show all ({count})", { count }),
|
|
1331
|
+
legendCount: (count) => t("{count, number}", { count }),
|
|
1332
|
+
legendRowTitle: (value, count) => t("{value} ({count, number})", { value, count }),
|
|
1333
|
+
legendRowShare: (value, count, share) => t("{value} ({count, number}, {share, number, percent})", { value, count, share })
|
|
1331
1334
|
});
|
|
1332
1335
|
const pointIconLabels = (t) => ({
|
|
1333
1336
|
iconSameForAll: t("Same for all", { context: "map point icon" }),
|
|
@@ -3871,7 +3874,7 @@ function CursorCoordinatesOverlay({ map }) {
|
|
|
3871
3874
|
);
|
|
3872
3875
|
}
|
|
3873
3876
|
const NO_IMPORTS = Object.freeze([]);
|
|
3874
|
-
const getServerSnapshot = () => NO_IMPORTS;
|
|
3877
|
+
const getServerSnapshot$1 = () => NO_IMPORTS;
|
|
3875
3878
|
function describeActivity(entry, labels) {
|
|
3876
3879
|
switch (entry.activity) {
|
|
3877
3880
|
case "rendering":
|
|
@@ -3887,7 +3890,7 @@ function IngestProgressOverlay({
|
|
|
3887
3890
|
bottomPx
|
|
3888
3891
|
}) {
|
|
3889
3892
|
const { ingest: labels } = useMapLabels();
|
|
3890
|
-
const entries = useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
|
|
3893
|
+
const entries = useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot$1);
|
|
3891
3894
|
if (entries.length === 0) return null;
|
|
3892
3895
|
return /* @__PURE__ */ jsx(
|
|
3893
3896
|
"div",
|
|
@@ -3918,6 +3921,143 @@ function IngestProgressOverlay({
|
|
|
3918
3921
|
}
|
|
3919
3922
|
);
|
|
3920
3923
|
}
|
|
3924
|
+
function createPopupSlot() {
|
|
3925
|
+
const listeners2 = /* @__PURE__ */ new Set();
|
|
3926
|
+
let view = null;
|
|
3927
|
+
let seq = 0;
|
|
3928
|
+
return {
|
|
3929
|
+
render(container, content) {
|
|
3930
|
+
view = { container, content, seq: ++seq };
|
|
3931
|
+
flushSync(() => listeners2.forEach((listener) => listener()));
|
|
3932
|
+
},
|
|
3933
|
+
subscribe(listener) {
|
|
3934
|
+
listeners2.add(listener);
|
|
3935
|
+
return () => {
|
|
3936
|
+
listeners2.delete(listener);
|
|
3937
|
+
};
|
|
3938
|
+
},
|
|
3939
|
+
getSnapshot: () => view
|
|
3940
|
+
};
|
|
3941
|
+
}
|
|
3942
|
+
const getServerSnapshot = () => null;
|
|
3943
|
+
class PopupErrorBoundary extends Component {
|
|
3944
|
+
constructor() {
|
|
3945
|
+
super(...arguments);
|
|
3946
|
+
this.state = { failed: false };
|
|
3947
|
+
}
|
|
3948
|
+
static getDerivedStateFromError() {
|
|
3949
|
+
return { failed: true };
|
|
3950
|
+
}
|
|
3951
|
+
render() {
|
|
3952
|
+
return this.state.failed ? null : this.props.children;
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3955
|
+
function PopupPortal({ slot }) {
|
|
3956
|
+
const view = useSyncExternalStore(slot.subscribe, slot.getSnapshot, getServerSnapshot);
|
|
3957
|
+
return view ? createPortal(/* @__PURE__ */ jsx(Fragment$1, { children: view.content }, view.seq), view.container) : null;
|
|
3958
|
+
}
|
|
3959
|
+
function isEmptyTooltip(content) {
|
|
3960
|
+
return content == null || typeof content === "boolean" || content === "";
|
|
3961
|
+
}
|
|
3962
|
+
const PAGER_STYLE = {
|
|
3963
|
+
display: "flex",
|
|
3964
|
+
alignItems: "center",
|
|
3965
|
+
justifyContent: "space-between",
|
|
3966
|
+
borderBottom: "1px solid #eee",
|
|
3967
|
+
padding: "4px 0 6px",
|
|
3968
|
+
marginBottom: 4,
|
|
3969
|
+
fontSize: 12,
|
|
3970
|
+
color: "#666",
|
|
3971
|
+
userSelect: "none"
|
|
3972
|
+
};
|
|
3973
|
+
const pagerButtonStyle = (disabled) => ({
|
|
3974
|
+
background: "none",
|
|
3975
|
+
borderRadius: 4,
|
|
3976
|
+
padding: "1px 8px",
|
|
3977
|
+
fontSize: 12,
|
|
3978
|
+
lineHeight: 1.4,
|
|
3979
|
+
border: `1px solid ${disabled ? "#eee" : "#ddd"}`,
|
|
3980
|
+
cursor: disabled ? "default" : "pointer",
|
|
3981
|
+
color: disabled ? "#ccc" : "#444"
|
|
3982
|
+
});
|
|
3983
|
+
function TooltipPager({ page, moreHint }) {
|
|
3984
|
+
const prevDisabled = page.index === 0;
|
|
3985
|
+
const nextDisabled = page.index === page.count - 1;
|
|
3986
|
+
return /* @__PURE__ */ jsxs("div", { style: PAGER_STYLE, children: [
|
|
3987
|
+
/* @__PURE__ */ jsx("button", { type: "button", "data-tooltip-nav": "prev", style: pagerButtonStyle(prevDisabled), disabled: prevDisabled, children: "‹" }),
|
|
3988
|
+
/* @__PURE__ */ jsxs("span", { title: page.more ? moreHint : void 0, children: [
|
|
3989
|
+
page.index + 1,
|
|
3990
|
+
" / ",
|
|
3991
|
+
page.count,
|
|
3992
|
+
page.more ? "+" : ""
|
|
3993
|
+
] }),
|
|
3994
|
+
/* @__PURE__ */ jsx("button", { type: "button", "data-tooltip-nav": "next", style: pagerButtonStyle(nextDisabled), disabled: nextDisabled, children: "›" })
|
|
3995
|
+
] });
|
|
3996
|
+
}
|
|
3997
|
+
function TooltipBody({ content, page, moreHint }) {
|
|
3998
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3999
|
+
page && /* @__PURE__ */ jsx(TooltipPager, { page, moreHint }),
|
|
4000
|
+
/* @__PURE__ */ jsx(PopupErrorBoundary, { children: /* @__PURE__ */ jsx(Suspense, { fallback: null, children: typeof content === "string" ? /* @__PURE__ */ jsx("div", { style: { display: "contents" }, dangerouslySetInnerHTML: { __html: content } }) : content }) })
|
|
4001
|
+
] });
|
|
4002
|
+
}
|
|
4003
|
+
const hasValue = (value) => value != null && value !== "";
|
|
4004
|
+
function BuiltinTooltip({ feature, featureId, highlightFields, idLabel }) {
|
|
4005
|
+
const props = feature.properties || {};
|
|
4006
|
+
const name = props.name;
|
|
4007
|
+
const otherProps = Object.entries(props).filter(([key, value]) => !isInternalProperty(key) && !key.startsWith("_") && hasValue(value)).slice(0, 5).filter(([key]) => key !== "name" && key !== "id");
|
|
4008
|
+
const highlighted = Array.from(highlightFields).filter((fieldName) => hasValue(props[fieldName]));
|
|
4009
|
+
return /* @__PURE__ */ jsxs("div", { className: "text-sm space-y-0.5", children: [
|
|
4010
|
+
name ? /* @__PURE__ */ jsx("div", { className: "font-medium", children: String(name) }) : null,
|
|
4011
|
+
featureId ? /* @__PURE__ */ jsxs("div", { className: "text-xs text-muted-foreground", children: [
|
|
4012
|
+
/* @__PURE__ */ jsx("span", { className: "opacity-70", children: idLabel }),
|
|
4013
|
+
" ",
|
|
4014
|
+
featureId.slice(0, 30)
|
|
4015
|
+
] }) : null,
|
|
4016
|
+
otherProps.length > 0 && /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground space-y-0.5", children: otherProps.map(([key, value]) => /* @__PURE__ */ jsxs("div", { children: [
|
|
4017
|
+
/* @__PURE__ */ jsxs("span", { className: "opacity-70", children: [
|
|
4018
|
+
key,
|
|
4019
|
+
":"
|
|
4020
|
+
] }),
|
|
4021
|
+
" ",
|
|
4022
|
+
String(value).slice(0, 30)
|
|
4023
|
+
] }, key)) }),
|
|
4024
|
+
highlightFields.size > 0 && /* @__PURE__ */ jsx("div", { className: "text-xs border-t border-border/50 mt-1 pt-1 space-y-0.5", children: highlighted.map((fieldName) => /* @__PURE__ */ jsxs("div", { className: "flex justify-between gap-2", children: [
|
|
4025
|
+
/* @__PURE__ */ jsxs("span", { className: "opacity-70", children: [
|
|
4026
|
+
fieldName,
|
|
4027
|
+
":"
|
|
4028
|
+
] }),
|
|
4029
|
+
" ",
|
|
4030
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: String(props[fieldName]).slice(0, 20) })
|
|
4031
|
+
] }, fieldName)) })
|
|
4032
|
+
] });
|
|
4033
|
+
}
|
|
4034
|
+
function TracePopup({ fromName, toName, duration, distance: distance2, avgSpeed, groupLabel, labels }) {
|
|
4035
|
+
return /* @__PURE__ */ jsxs("div", { className: "text-sm space-y-1", children: [
|
|
4036
|
+
fromName || toName ? /* @__PURE__ */ jsxs("div", { className: "font-medium text-xs text-muted-foreground", children: [
|
|
4037
|
+
fromName || "?",
|
|
4038
|
+
" → ",
|
|
4039
|
+
toName || "?"
|
|
4040
|
+
] }) : null,
|
|
4041
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
4042
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4043
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: labels.traceDuration }),
|
|
4044
|
+
" ",
|
|
4045
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: duration })
|
|
4046
|
+
] }),
|
|
4047
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4048
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: labels.traceDistance }),
|
|
4049
|
+
" ",
|
|
4050
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: distance2 })
|
|
4051
|
+
] }),
|
|
4052
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
4053
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: labels.traceAvgSpeed }),
|
|
4054
|
+
" ",
|
|
4055
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: avgSpeed })
|
|
4056
|
+
] })
|
|
4057
|
+
] }),
|
|
4058
|
+
groupLabel ? /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground border-t border-border/50 mt-1 pt-1", children: groupLabel }) : null
|
|
4059
|
+
] });
|
|
4060
|
+
}
|
|
3921
4061
|
const EMOJI_GROUPS = ["smileys", "people", "nature", "food", "travel", "activities", "objects", "symbols"];
|
|
3922
4062
|
const EMOJI_LIST = {
|
|
3923
4063
|
smileys: [
|
|
@@ -7571,108 +7711,493 @@ function PointIconSettings({
|
|
|
7571
7711
|
] })
|
|
7572
7712
|
] });
|
|
7573
7713
|
}
|
|
7574
|
-
const
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
function
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7714
|
+
const OTHER_BUCKET_KEY = "__other__";
|
|
7715
|
+
const OTHER_BUCKET_COLOR = "#9ca3af";
|
|
7716
|
+
function toDisplayName(name, otherLabel) {
|
|
7717
|
+
return name === OTHER_BUCKET_KEY ? otherLabel : name;
|
|
7718
|
+
}
|
|
7719
|
+
function createPieSVG(categories, total, otherLabel, size = 44, onSliceHover, badgeValue) {
|
|
7720
|
+
const container = document.createElement("div");
|
|
7721
|
+
container.style.width = `${size}px`;
|
|
7722
|
+
container.style.height = `${size}px`;
|
|
7723
|
+
container.style.cursor = "pointer";
|
|
7724
|
+
const radius = size / 2;
|
|
7725
|
+
const innerRadius = radius * 0.5;
|
|
7726
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
7727
|
+
svg.setAttribute("width", String(size));
|
|
7728
|
+
svg.setAttribute("height", String(size));
|
|
7729
|
+
svg.setAttribute("viewBox", `0 0 ${size} ${size}`);
|
|
7730
|
+
svg.style.display = "block";
|
|
7731
|
+
const bgCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
7732
|
+
bgCircle.setAttribute("cx", String(radius));
|
|
7733
|
+
bgCircle.setAttribute("cy", String(radius));
|
|
7734
|
+
bgCircle.setAttribute("r", String(radius));
|
|
7735
|
+
bgCircle.setAttribute("fill", "white");
|
|
7736
|
+
svg.appendChild(bgCircle);
|
|
7737
|
+
const slicesSum = categories.reduce((s, c) => s + c.count, 0);
|
|
7738
|
+
const remainder = Math.max(0, total - slicesSum);
|
|
7739
|
+
const renderList = remainder > 0 ? [...categories, { name: "__remainder__", displayName: otherLabel, count: remainder, color: OTHER_BUCKET_COLOR }] : categories;
|
|
7740
|
+
const nonZeroSlices = renderList.filter((c) => c.count > 0);
|
|
7741
|
+
const isSingleFullSlice = nonZeroSlices.length === 1 && nonZeroSlices[0].count >= total;
|
|
7742
|
+
if (isSingleFullSlice) {
|
|
7743
|
+
const cat = nonZeroSlices[0];
|
|
7744
|
+
const ring = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
7745
|
+
const d = [
|
|
7746
|
+
`M 0 ${radius}`,
|
|
7747
|
+
`a ${radius} ${radius} 0 1 0 ${radius * 2} 0`,
|
|
7748
|
+
`a ${radius} ${radius} 0 1 0 ${-radius * 2} 0`,
|
|
7749
|
+
`M ${radius - innerRadius} ${radius}`,
|
|
7750
|
+
`a ${innerRadius} ${innerRadius} 0 1 1 ${innerRadius * 2} 0`,
|
|
7751
|
+
`a ${innerRadius} ${innerRadius} 0 1 1 ${-innerRadius * 2} 0`,
|
|
7752
|
+
"Z"
|
|
7753
|
+
].join(" ");
|
|
7754
|
+
ring.setAttribute("d", d);
|
|
7755
|
+
ring.setAttribute("fill-rule", "evenodd");
|
|
7756
|
+
ring.setAttribute("fill", cat.color);
|
|
7757
|
+
ring.setAttribute("stroke", "white");
|
|
7758
|
+
ring.setAttribute("stroke-width", "1");
|
|
7759
|
+
ring.style.transition = "opacity 0.15s";
|
|
7760
|
+
ring.addEventListener("mouseenter", (e) => {
|
|
7761
|
+
ring.style.opacity = "0.8";
|
|
7762
|
+
if (onSliceHover) onSliceHover(cat, e);
|
|
7763
|
+
});
|
|
7764
|
+
ring.addEventListener("mouseleave", (e) => {
|
|
7765
|
+
ring.style.opacity = "1";
|
|
7766
|
+
if (onSliceHover) onSliceHover(null, e);
|
|
7767
|
+
});
|
|
7768
|
+
svg.appendChild(ring);
|
|
7589
7769
|
}
|
|
7770
|
+
let currentAngle = -90;
|
|
7771
|
+
(isSingleFullSlice ? [] : renderList).forEach((cat) => {
|
|
7772
|
+
if (cat.count === 0) return;
|
|
7773
|
+
const sliceAngle = cat.count / total * 360;
|
|
7774
|
+
const startAngle = currentAngle;
|
|
7775
|
+
const endAngle = currentAngle + sliceAngle;
|
|
7776
|
+
const startRad = startAngle * Math.PI / 180;
|
|
7777
|
+
const endRad = endAngle * Math.PI / 180;
|
|
7778
|
+
const x1 = radius + radius * Math.cos(startRad);
|
|
7779
|
+
const y1 = radius + radius * Math.sin(startRad);
|
|
7780
|
+
const x2 = radius + radius * Math.cos(endRad);
|
|
7781
|
+
const y2 = radius + radius * Math.sin(endRad);
|
|
7782
|
+
const x3 = radius + innerRadius * Math.cos(endRad);
|
|
7783
|
+
const y3 = radius + innerRadius * Math.sin(endRad);
|
|
7784
|
+
const x4 = radius + innerRadius * Math.cos(startRad);
|
|
7785
|
+
const y4 = radius + innerRadius * Math.sin(startRad);
|
|
7786
|
+
const largeArc = sliceAngle > 180 ? 1 : 0;
|
|
7787
|
+
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
7788
|
+
const d = [
|
|
7789
|
+
`M ${x1} ${y1}`,
|
|
7790
|
+
`A ${radius} ${radius} 0 ${largeArc} 1 ${x2} ${y2}`,
|
|
7791
|
+
`L ${x3} ${y3}`,
|
|
7792
|
+
`A ${innerRadius} ${innerRadius} 0 ${largeArc} 0 ${x4} ${y4}`,
|
|
7793
|
+
"Z"
|
|
7794
|
+
].join(" ");
|
|
7795
|
+
path.setAttribute("d", d);
|
|
7796
|
+
path.setAttribute("fill", cat.color);
|
|
7797
|
+
path.setAttribute("stroke", "white");
|
|
7798
|
+
path.setAttribute("stroke-width", "1");
|
|
7799
|
+
path.style.transition = "opacity 0.15s";
|
|
7800
|
+
path.addEventListener("mouseenter", (e) => {
|
|
7801
|
+
path.style.opacity = "0.8";
|
|
7802
|
+
if (onSliceHover) onSliceHover(cat, e);
|
|
7803
|
+
});
|
|
7804
|
+
path.addEventListener("mouseleave", (e) => {
|
|
7805
|
+
path.style.opacity = "1";
|
|
7806
|
+
if (onSliceHover) onSliceHover(null, e);
|
|
7807
|
+
});
|
|
7808
|
+
svg.appendChild(path);
|
|
7809
|
+
currentAngle = endAngle;
|
|
7810
|
+
});
|
|
7811
|
+
const centerCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
7812
|
+
centerCircle.setAttribute("cx", String(radius));
|
|
7813
|
+
centerCircle.setAttribute("cy", String(radius));
|
|
7814
|
+
centerCircle.setAttribute("r", String(innerRadius - 2));
|
|
7815
|
+
centerCircle.setAttribute("fill", "#1f2937");
|
|
7816
|
+
svg.appendChild(centerCircle);
|
|
7817
|
+
const badgeText = formatClusterBadge(badgeValue ?? total);
|
|
7818
|
+
const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
7819
|
+
text.setAttribute("x", String(radius));
|
|
7820
|
+
text.setAttribute("y", String(radius));
|
|
7821
|
+
text.setAttribute("text-anchor", "middle");
|
|
7822
|
+
text.setAttribute("dominant-baseline", "central");
|
|
7823
|
+
text.setAttribute("fill", "white");
|
|
7824
|
+
text.setAttribute("font-size", badgeText.length >= 6 ? "8" : badgeText.length >= 4 ? "9" : badgeText.length >= 3 ? "10" : "11");
|
|
7825
|
+
text.setAttribute("font-weight", "bold");
|
|
7826
|
+
text.setAttribute("font-family", "system-ui, sans-serif");
|
|
7827
|
+
text.textContent = badgeText;
|
|
7828
|
+
svg.appendChild(text);
|
|
7829
|
+
container.appendChild(svg);
|
|
7830
|
+
return container;
|
|
7590
7831
|
}
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
size: "small",
|
|
7628
|
-
allowClear: true,
|
|
7629
|
-
placeholder: labels.filterValues,
|
|
7630
|
-
value: filter,
|
|
7631
|
-
onChange: (e) => setFilter(e.target.value),
|
|
7632
|
-
className: "mb-1 !text-[11px]",
|
|
7633
|
-
"data-testid": `legend-filter-${layerId}`
|
|
7634
|
-
}
|
|
7635
|
-
),
|
|
7636
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-0.5 max-h-40 overflow-y-auto", children: [
|
|
7637
|
-
visible.map(({ value, count }) => /* @__PURE__ */ jsxs(
|
|
7638
|
-
"div",
|
|
7639
|
-
{
|
|
7640
|
-
className: "flex items-center gap-1.5 text-[11px]",
|
|
7641
|
-
title: `${value} (${count})`,
|
|
7642
|
-
children: [
|
|
7643
|
-
/* @__PURE__ */ jsx(
|
|
7644
|
-
"span",
|
|
7645
|
-
{
|
|
7646
|
-
className: "inline-block w-2.5 h-2.5 rounded-sm shrink-0 border border-black/10",
|
|
7647
|
-
style: { backgroundColor: hashStringToColor(value) }
|
|
7648
|
-
}
|
|
7649
|
-
),
|
|
7650
|
-
/* @__PURE__ */ jsx("span", { className: "truncate flex-1 text-foreground", children: value }),
|
|
7651
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground tabular-nums", children: count })
|
|
7652
|
-
]
|
|
7653
|
-
},
|
|
7654
|
-
value
|
|
7655
|
-
)),
|
|
7656
|
-
visible.length === 0 && /* @__PURE__ */ jsx("div", { className: "text-[11px] text-muted-foreground italic", children: labels.noMatches })
|
|
7657
|
-
] }),
|
|
7658
|
-
(hiddenCount > 0 || expanded && filtered.length > LEGEND_INITIAL_VISIBLE) && /* @__PURE__ */ jsx(
|
|
7659
|
-
"button",
|
|
7660
|
-
{
|
|
7661
|
-
type: "button",
|
|
7662
|
-
className: "mt-1 text-[11px] text-primary hover:underline",
|
|
7663
|
-
onClick: () => setExpanded((e) => !e),
|
|
7664
|
-
"data-testid": `legend-toggle-${layerId}`,
|
|
7665
|
-
children: expanded ? labels.showLess : labels.showAll(filtered.length)
|
|
7666
|
-
}
|
|
7667
|
-
)
|
|
7668
|
-
]
|
|
7669
|
-
}
|
|
7670
|
-
);
|
|
7832
|
+
let tooltipEl = null;
|
|
7833
|
+
function showTooltip(cat, x, y) {
|
|
7834
|
+
if (!tooltipEl) {
|
|
7835
|
+
tooltipEl = document.createElement("div");
|
|
7836
|
+
tooltipEl.style.cssText = `
|
|
7837
|
+
position: fixed;
|
|
7838
|
+
background: rgba(0,0,0,0.85);
|
|
7839
|
+
color: white;
|
|
7840
|
+
padding: 6px 10px;
|
|
7841
|
+
border-radius: 4px;
|
|
7842
|
+
font-size: 12px;
|
|
7843
|
+
font-family: system-ui, sans-serif;
|
|
7844
|
+
pointer-events: none;
|
|
7845
|
+
z-index: 10000;
|
|
7846
|
+
white-space: nowrap;
|
|
7847
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
|
|
7848
|
+
`;
|
|
7849
|
+
document.body.appendChild(tooltipEl);
|
|
7850
|
+
}
|
|
7851
|
+
while (tooltipEl.firstChild) tooltipEl.removeChild(tooltipEl.firstChild);
|
|
7852
|
+
const row = document.createElement("div");
|
|
7853
|
+
row.style.cssText = "display: flex; align-items: center; gap: 6px;";
|
|
7854
|
+
const swatch = document.createElement("span");
|
|
7855
|
+
swatch.style.cssText = "width: 10px; height: 10px; border-radius: 2px;";
|
|
7856
|
+
swatch.style.backgroundColor = cat.color;
|
|
7857
|
+
row.appendChild(swatch);
|
|
7858
|
+
const label = document.createElement("span");
|
|
7859
|
+
const name = document.createElement("strong");
|
|
7860
|
+
name.textContent = cat.displayName;
|
|
7861
|
+
label.appendChild(name);
|
|
7862
|
+
label.appendChild(document.createTextNode(`: ${cat.count}`));
|
|
7863
|
+
row.appendChild(label);
|
|
7864
|
+
tooltipEl.appendChild(row);
|
|
7865
|
+
tooltipEl.style.left = `${x + 12}px`;
|
|
7866
|
+
tooltipEl.style.top = `${y - 10}px`;
|
|
7867
|
+
tooltipEl.style.display = "block";
|
|
7671
7868
|
}
|
|
7672
|
-
function
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7869
|
+
function hideTooltip() {
|
|
7870
|
+
if (tooltipEl) {
|
|
7871
|
+
tooltipEl.style.display = "none";
|
|
7872
|
+
}
|
|
7873
|
+
}
|
|
7874
|
+
function fingerprintCluster(pointCount, counts2, size, badgeValue) {
|
|
7875
|
+
return `${size}|${pointCount}|${badgeValue ?? ""}|${counts2.join(",")}`;
|
|
7876
|
+
}
|
|
7877
|
+
function buildPieElement(categories, pointCount, otherLabel, size, source, clusterId, map, coords, badgeValue) {
|
|
7878
|
+
const el = createPieSVG(categories, pointCount, otherLabel, size, (cat, event) => {
|
|
7879
|
+
if (cat) {
|
|
7880
|
+
showTooltip(cat, event.clientX, event.clientY);
|
|
7881
|
+
} else {
|
|
7882
|
+
hideTooltip();
|
|
7883
|
+
}
|
|
7884
|
+
}, badgeValue);
|
|
7885
|
+
el.addEventListener("click", () => {
|
|
7886
|
+
source.getClusterExpansionZoom(clusterId).then((zoom) => {
|
|
7887
|
+
if (typeof zoom === "number") {
|
|
7888
|
+
map.easeTo({ center: coords, zoom: zoom + 0.5 });
|
|
7889
|
+
}
|
|
7890
|
+
}).catch(() => {
|
|
7891
|
+
});
|
|
7892
|
+
});
|
|
7893
|
+
return el;
|
|
7894
|
+
}
|
|
7895
|
+
function renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markers, otherLabel) {
|
|
7896
|
+
const source = map.getSource(sourceId);
|
|
7897
|
+
if (!source) return;
|
|
7898
|
+
const clusters = map.querySourceFeatures(sourceId, {
|
|
7899
|
+
filter: ["has", "point_count"]
|
|
7900
|
+
});
|
|
7901
|
+
const visibleClusterIds = /* @__PURE__ */ new Set();
|
|
7902
|
+
clusters.forEach((feature) => {
|
|
7903
|
+
var _a, _b, _c;
|
|
7904
|
+
const clusterId = (_a = feature.properties) == null ? void 0 : _a.cluster_id;
|
|
7905
|
+
if (clusterId === void 0) return;
|
|
7906
|
+
const clusterKey = `${clusterId}`;
|
|
7907
|
+
visibleClusterIds.add(clusterKey);
|
|
7908
|
+
const coords = feature.geometry.coordinates;
|
|
7909
|
+
const pointCount = ((_b = feature.properties) == null ? void 0 : _b.point_count) || 0;
|
|
7910
|
+
const sumRaw = (_c = feature.properties) == null ? void 0 : _c[CLUSTER_SUM_PROP];
|
|
7911
|
+
const sumNum = typeof sumRaw === "number" ? sumRaw : sumRaw != null ? Number(sumRaw) : NaN;
|
|
7912
|
+
const badgeValue = Number.isFinite(sumNum) ? sumNum : void 0;
|
|
7913
|
+
const allCounts = categoryValues.map((_, i) => {
|
|
7914
|
+
var _a2;
|
|
7915
|
+
return Number(((_a2 = feature.properties) == null ? void 0 : _a2[`cat_${i}`]) || 0);
|
|
7916
|
+
});
|
|
7917
|
+
const categories = categoryValues.map((cat, i) => ({
|
|
7918
|
+
name: cat,
|
|
7919
|
+
displayName: toDisplayName(cat, otherLabel),
|
|
7920
|
+
count: allCounts[i],
|
|
7921
|
+
color: categoryColorMap[cat] || "#3b82f6"
|
|
7922
|
+
})).filter((c) => c.count > 0);
|
|
7923
|
+
const size = pointCount < 100 ? 40 : pointCount < 750 ? 50 : 60;
|
|
7924
|
+
const fingerprint = fingerprintCluster(pointCount, allCounts, size, badgeValue);
|
|
7925
|
+
const existing = markers.get(clusterKey);
|
|
7926
|
+
if (existing && existing.fingerprint === fingerprint) {
|
|
7927
|
+
existing.marker.setLngLat(coords);
|
|
7928
|
+
return;
|
|
7929
|
+
}
|
|
7930
|
+
const el = buildPieElement(categories, pointCount, otherLabel, size, source, clusterId, map, coords, badgeValue);
|
|
7931
|
+
if (existing) {
|
|
7932
|
+
existing.marker.remove();
|
|
7933
|
+
}
|
|
7934
|
+
const marker = new maplibregl.Marker({ element: el }).setLngLat(coords).addTo(map);
|
|
7935
|
+
markers.set(clusterKey, { marker, fingerprint });
|
|
7936
|
+
});
|
|
7937
|
+
markers.forEach((entry, key) => {
|
|
7938
|
+
if (!visibleClusterIds.has(key)) {
|
|
7939
|
+
entry.marker.remove();
|
|
7940
|
+
markers.delete(key);
|
|
7941
|
+
}
|
|
7942
|
+
});
|
|
7943
|
+
}
|
|
7944
|
+
function createClusterPieManager(map, sourceId, categoryValues, categoryColorMap, otherLabel = DEFAULT_MAP_LABELS.canvas.clusterOther) {
|
|
7945
|
+
const markers = /* @__PURE__ */ new Map();
|
|
7946
|
+
let updateScheduled = false;
|
|
7947
|
+
function scheduleUpdate() {
|
|
7948
|
+
if (updateScheduled) return;
|
|
7949
|
+
updateScheduled = true;
|
|
7950
|
+
requestAnimationFrame(() => {
|
|
7951
|
+
updateScheduled = false;
|
|
7952
|
+
renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markers, otherLabel);
|
|
7953
|
+
});
|
|
7954
|
+
}
|
|
7955
|
+
function onData(e) {
|
|
7956
|
+
if (e.dataType === "source" && e.sourceId === sourceId) {
|
|
7957
|
+
scheduleUpdate();
|
|
7958
|
+
}
|
|
7959
|
+
}
|
|
7960
|
+
map.on("moveend", scheduleUpdate);
|
|
7961
|
+
map.on("data", onData);
|
|
7962
|
+
scheduleUpdate();
|
|
7963
|
+
return {
|
|
7964
|
+
update: scheduleUpdate,
|
|
7965
|
+
destroy: () => {
|
|
7966
|
+
map.off("moveend", scheduleUpdate);
|
|
7967
|
+
map.off("data", onData);
|
|
7968
|
+
markers.forEach((entry) => entry.marker.remove());
|
|
7969
|
+
markers.clear();
|
|
7970
|
+
hideTooltip();
|
|
7971
|
+
}
|
|
7972
|
+
};
|
|
7973
|
+
}
|
|
7974
|
+
function ClusterPieManager(props) {
|
|
7975
|
+
const { map, sourceId, categoryValues, categoryColorMap, visible } = props;
|
|
7976
|
+
const otherLabel = useMapLabels().canvas.clusterOther;
|
|
7977
|
+
const markersRef = useRef(/* @__PURE__ */ new Map());
|
|
7978
|
+
const updateScheduled = useRef(false);
|
|
7979
|
+
const updateMarkers = useCallback(() => {
|
|
7980
|
+
if (!map || !visible) {
|
|
7981
|
+
markersRef.current.forEach((entry) => entry.marker.remove());
|
|
7982
|
+
markersRef.current.clear();
|
|
7983
|
+
return;
|
|
7984
|
+
}
|
|
7985
|
+
renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markersRef.current, otherLabel);
|
|
7986
|
+
}, [map, sourceId, categoryValues, categoryColorMap, visible, otherLabel]);
|
|
7987
|
+
useEffect(() => {
|
|
7988
|
+
if (!map) return;
|
|
7989
|
+
const scheduleUpdate = () => {
|
|
7990
|
+
if (updateScheduled.current) return;
|
|
7991
|
+
updateScheduled.current = true;
|
|
7992
|
+
requestAnimationFrame(() => {
|
|
7993
|
+
updateScheduled.current = false;
|
|
7994
|
+
updateMarkers();
|
|
7995
|
+
});
|
|
7996
|
+
};
|
|
7997
|
+
const onData = (e) => {
|
|
7998
|
+
if (e.dataType === "source" && e.sourceId === sourceId) {
|
|
7999
|
+
scheduleUpdate();
|
|
8000
|
+
}
|
|
8001
|
+
};
|
|
8002
|
+
scheduleUpdate();
|
|
8003
|
+
map.on("moveend", scheduleUpdate);
|
|
8004
|
+
map.on("data", onData);
|
|
8005
|
+
return () => {
|
|
8006
|
+
map.off("moveend", scheduleUpdate);
|
|
8007
|
+
map.off("data", onData);
|
|
8008
|
+
markersRef.current.forEach((entry) => entry.marker.remove());
|
|
8009
|
+
markersRef.current.clear();
|
|
8010
|
+
hideTooltip();
|
|
8011
|
+
};
|
|
8012
|
+
}, [map, sourceId, updateMarkers]);
|
|
8013
|
+
useEffect(() => {
|
|
8014
|
+
if (!visible) {
|
|
8015
|
+
markersRef.current.forEach((entry) => entry.marker.remove());
|
|
8016
|
+
markersRef.current.clear();
|
|
8017
|
+
hideTooltip();
|
|
8018
|
+
} else {
|
|
8019
|
+
updateMarkers();
|
|
8020
|
+
}
|
|
8021
|
+
}, [visible, updateMarkers]);
|
|
8022
|
+
return null;
|
|
8023
|
+
}
|
|
8024
|
+
const LEGEND_MAX_VALUES = 50;
|
|
8025
|
+
const LEGEND_INITIAL_VISIBLE = 8;
|
|
8026
|
+
function LegendTitle({ children }) {
|
|
8027
|
+
return /* @__PURE__ */ jsx("div", { className: "text-[10px] font-semibold uppercase tracking-wide text-foreground mb-1.5", children });
|
|
8028
|
+
}
|
|
8029
|
+
function LegendRowView({
|
|
8030
|
+
row,
|
|
8031
|
+
maxCount,
|
|
8032
|
+
total,
|
|
8033
|
+
bucket = false
|
|
8034
|
+
}) {
|
|
8035
|
+
const { layerSettings: labels } = useMapLabels();
|
|
8036
|
+
return /* @__PURE__ */ jsxs(
|
|
8037
|
+
"div",
|
|
8038
|
+
{
|
|
8039
|
+
className: "relative flex items-center gap-2 px-1 py-0.5 text-[11px]",
|
|
8040
|
+
title: total ? labels.legendRowShare(row.value, row.count, row.count / total) : labels.legendRowTitle(row.value, row.count),
|
|
8041
|
+
"data-testid": "legend-row",
|
|
8042
|
+
children: [
|
|
8043
|
+
/* @__PURE__ */ jsx(
|
|
8044
|
+
"span",
|
|
8045
|
+
{
|
|
8046
|
+
"aria-hidden": true,
|
|
8047
|
+
className: "absolute inset-y-0 left-0 rounded-sm bg-muted/60",
|
|
8048
|
+
style: { width: `${row.count / maxCount * 100}%` }
|
|
8049
|
+
}
|
|
8050
|
+
),
|
|
8051
|
+
/* @__PURE__ */ jsx(
|
|
8052
|
+
"span",
|
|
8053
|
+
{
|
|
8054
|
+
className: "relative inline-block w-3 h-3 rounded-full shrink-0 ring-1 ring-inset ring-black/15",
|
|
8055
|
+
style: { backgroundColor: row.color },
|
|
8056
|
+
"data-testid": "legend-swatch"
|
|
8057
|
+
}
|
|
8058
|
+
),
|
|
8059
|
+
/* @__PURE__ */ jsx(
|
|
8060
|
+
"span",
|
|
8061
|
+
{
|
|
8062
|
+
className: `relative truncate flex-1 ${bucket ? "italic text-muted-foreground" : "text-foreground"}`,
|
|
8063
|
+
"data-testid": "legend-value",
|
|
8064
|
+
children: row.value
|
|
8065
|
+
}
|
|
8066
|
+
),
|
|
8067
|
+
/* @__PURE__ */ jsx("span", { className: "relative text-muted-foreground tabular-nums", "data-testid": "legend-count", children: labels.legendCount(row.count) })
|
|
8068
|
+
]
|
|
8069
|
+
}
|
|
8070
|
+
);
|
|
8071
|
+
}
|
|
8072
|
+
function ValueLegend({
|
|
8073
|
+
testId,
|
|
8074
|
+
title,
|
|
8075
|
+
rows,
|
|
8076
|
+
pinned,
|
|
8077
|
+
total,
|
|
8078
|
+
layerId,
|
|
8079
|
+
fieldName
|
|
8080
|
+
}) {
|
|
8081
|
+
const { layerSettings: labels } = useMapLabels();
|
|
8082
|
+
const [expanded, setExpanded] = useState(false);
|
|
8083
|
+
const [filter, setFilter] = useState("");
|
|
8084
|
+
useEffect(() => {
|
|
8085
|
+
setFilter("");
|
|
8086
|
+
setExpanded(false);
|
|
8087
|
+
}, [layerId, fieldName]);
|
|
8088
|
+
const filtered = useMemo(() => {
|
|
8089
|
+
const q = filter.trim().toLowerCase();
|
|
8090
|
+
if (!q) return rows;
|
|
8091
|
+
return rows.filter((r) => r.value.toLowerCase().includes(q));
|
|
8092
|
+
}, [rows, filter]);
|
|
8093
|
+
if (rows.length === 0 && !pinned) return null;
|
|
8094
|
+
const visible = expanded ? filtered : filtered.slice(0, LEGEND_INITIAL_VISIBLE);
|
|
8095
|
+
const hiddenCount = filtered.length - visible.length;
|
|
8096
|
+
const maxCount = Math.max(1, ...rows.map((r) => r.count), (pinned == null ? void 0 : pinned.count) ?? 0);
|
|
8097
|
+
return /* @__PURE__ */ jsxs("div", { className: "mt-1 rounded border border-border/50 bg-background/40 p-1.5", "data-testid": testId, children: [
|
|
8098
|
+
/* @__PURE__ */ jsx(LegendTitle, { children: title }),
|
|
8099
|
+
(rows.length > LEGEND_INITIAL_VISIBLE || expanded) && /* @__PURE__ */ jsx(
|
|
8100
|
+
Input,
|
|
8101
|
+
{
|
|
8102
|
+
size: "small",
|
|
8103
|
+
allowClear: true,
|
|
8104
|
+
placeholder: labels.filterValues,
|
|
8105
|
+
value: filter,
|
|
8106
|
+
onChange: (e) => setFilter(e.target.value),
|
|
8107
|
+
className: "mb-1 !text-[11px]",
|
|
8108
|
+
"data-testid": `${testId}-filter`
|
|
8109
|
+
}
|
|
8110
|
+
),
|
|
8111
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-0.5 max-h-48 overflow-y-auto", "data-testid": `${testId}-rows`, children: [
|
|
8112
|
+
visible.map((row) => /* @__PURE__ */ jsx(LegendRowView, { row, maxCount, total }, row.value)),
|
|
8113
|
+
visible.length === 0 && rows.length > 0 && /* @__PURE__ */ jsx("div", { className: "text-[11px] text-muted-foreground italic", children: labels.noMatches })
|
|
8114
|
+
] }),
|
|
8115
|
+
pinned && /* @__PURE__ */ jsx("div", { className: "mt-0.5 pt-0.5 border-t border-border/50", "data-testid": `${testId}-pinned`, children: /* @__PURE__ */ jsx(LegendRowView, { row: pinned, maxCount, total, bucket: true }) }),
|
|
8116
|
+
(hiddenCount > 0 || expanded && filtered.length > LEGEND_INITIAL_VISIBLE) && /* @__PURE__ */ jsx(
|
|
8117
|
+
"button",
|
|
8118
|
+
{
|
|
8119
|
+
type: "button",
|
|
8120
|
+
className: "mt-1 text-[11px] text-primary hover:underline",
|
|
8121
|
+
onClick: () => setExpanded((e) => !e),
|
|
8122
|
+
"data-testid": `${testId}-toggle`,
|
|
8123
|
+
children: expanded ? labels.showLess : labels.showAll(filtered.length)
|
|
8124
|
+
}
|
|
8125
|
+
)
|
|
8126
|
+
] });
|
|
8127
|
+
}
|
|
8128
|
+
function ColorByFieldLegend({
|
|
8129
|
+
layerId,
|
|
8130
|
+
fieldName,
|
|
8131
|
+
getFieldValueDistribution
|
|
8132
|
+
}) {
|
|
8133
|
+
const { layerSettings: labels } = useMapLabels();
|
|
8134
|
+
const distribution = useMemo(
|
|
8135
|
+
() => getFieldValueDistribution(layerId, fieldName, LEGEND_MAX_VALUES),
|
|
8136
|
+
[getFieldValueDistribution, layerId, fieldName]
|
|
8137
|
+
);
|
|
8138
|
+
const rows = useMemo(() => distribution.map((d) => ({ ...d, color: hashStringToColor(d.value) })), [distribution]);
|
|
8139
|
+
return /* @__PURE__ */ jsx(
|
|
8140
|
+
ValueLegend,
|
|
8141
|
+
{
|
|
8142
|
+
testId: `legend-color-by-${layerId}`,
|
|
8143
|
+
title: distribution.length >= LEGEND_MAX_VALUES ? labels.legendTop(LEGEND_MAX_VALUES) : labels.legend,
|
|
8144
|
+
rows,
|
|
8145
|
+
layerId,
|
|
8146
|
+
fieldName
|
|
8147
|
+
}
|
|
8148
|
+
);
|
|
8149
|
+
}
|
|
8150
|
+
function ClusterPieLegend({
|
|
8151
|
+
layerId,
|
|
8152
|
+
fieldName,
|
|
8153
|
+
getClusterPieCategories
|
|
8154
|
+
}) {
|
|
8155
|
+
const { layerSettings: labels, canvas } = useMapLabels();
|
|
8156
|
+
const categories = useMemo(
|
|
8157
|
+
() => getClusterPieCategories(layerId, fieldName),
|
|
8158
|
+
[getClusterPieCategories, layerId, fieldName]
|
|
8159
|
+
);
|
|
8160
|
+
const rows = useMemo(
|
|
8161
|
+
() => ((categories == null ? void 0 : categories.values) ?? []).map((v) => ({ ...v, color: hashStringToColor(v.value) })),
|
|
8162
|
+
[categories]
|
|
8163
|
+
);
|
|
8164
|
+
if (!categories) return null;
|
|
8165
|
+
const { otherCount } = categories;
|
|
8166
|
+
const total = rows.reduce((sum, r) => sum + r.count, otherCount);
|
|
8167
|
+
return /* @__PURE__ */ jsx(
|
|
8168
|
+
ValueLegend,
|
|
8169
|
+
{
|
|
8170
|
+
testId: `legend-cluster-pie-${layerId}`,
|
|
8171
|
+
title: labels.legend,
|
|
8172
|
+
rows,
|
|
8173
|
+
pinned: otherCount > 0 ? { value: canvas.clusterOther, count: otherCount, color: OTHER_BUCKET_COLOR } : void 0,
|
|
8174
|
+
total,
|
|
8175
|
+
layerId,
|
|
8176
|
+
fieldName
|
|
8177
|
+
}
|
|
8178
|
+
);
|
|
8179
|
+
}
|
|
8180
|
+
const MAP_STYLES = [
|
|
8181
|
+
{ id: "streets", name: "Streets", icon: Map$1 },
|
|
8182
|
+
{ id: "satellite", name: "Satellite", icon: Satellite },
|
|
8183
|
+
{ id: "dark", name: "Dark", icon: Map$1 }
|
|
8184
|
+
];
|
|
8185
|
+
function builtInBasemapName(id, labels) {
|
|
8186
|
+
switch (id) {
|
|
8187
|
+
case "streets":
|
|
8188
|
+
return labels.basemapStreets;
|
|
8189
|
+
case "satellite":
|
|
8190
|
+
return labels.basemapSatellite;
|
|
8191
|
+
case "dark":
|
|
8192
|
+
return labels.basemapDark;
|
|
8193
|
+
default:
|
|
8194
|
+
return void 0;
|
|
8195
|
+
}
|
|
8196
|
+
}
|
|
8197
|
+
function ColorGradientLegend({
|
|
8198
|
+
layerId,
|
|
8199
|
+
min,
|
|
8200
|
+
max,
|
|
7676
8201
|
sampled
|
|
7677
8202
|
}) {
|
|
7678
8203
|
const { layerSettings: labels } = useMapLabels();
|
|
@@ -7683,7 +8208,7 @@ function ColorGradientLegend({
|
|
|
7683
8208
|
className: "mt-1 rounded border border-border/50 bg-background/40 p-1.5",
|
|
7684
8209
|
"data-testid": `legend-gradient-${layerId}`,
|
|
7685
8210
|
children: [
|
|
7686
|
-
/* @__PURE__ */ jsx(
|
|
8211
|
+
/* @__PURE__ */ jsx(LegendTitle, { children: sampled ? labels.legendSampled : labels.legend }),
|
|
7687
8212
|
/* @__PURE__ */ jsx(
|
|
7688
8213
|
"div",
|
|
7689
8214
|
{
|
|
@@ -7728,6 +8253,7 @@ function LayersPanel({
|
|
|
7728
8253
|
getSuggestedTraceField,
|
|
7729
8254
|
getLayerFields,
|
|
7730
8255
|
getFieldValueDistribution,
|
|
8256
|
+
getClusterPieCategories,
|
|
7731
8257
|
onUpdateHeatmapConfig,
|
|
7732
8258
|
onUpdateClusterConfig,
|
|
7733
8259
|
onUpdateVisualConfig,
|
|
@@ -8252,11 +8778,19 @@ function LayersPanel({
|
|
|
8252
8778
|
}
|
|
8253
8779
|
),
|
|
8254
8780
|
/* @__PURE__ */ jsx("span", { className: "text-[10px]", children: settingsLabels.colorBubblesByValue })
|
|
8255
|
-
] })
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8781
|
+
] }),
|
|
8782
|
+
layer.clusterConfig.groupByField && getClusterPieCategories && /* @__PURE__ */ jsx(
|
|
8783
|
+
ClusterPieLegend,
|
|
8784
|
+
{
|
|
8785
|
+
layerId: layer.id,
|
|
8786
|
+
fieldName: layer.clusterConfig.groupByField,
|
|
8787
|
+
getClusterPieCategories
|
|
8788
|
+
}
|
|
8789
|
+
)
|
|
8790
|
+
] })
|
|
8791
|
+
] })
|
|
8792
|
+
] }),
|
|
8793
|
+
layer.hasAltitudeData && onUpdateAltitudeDisplayMode && /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-1.5 bg-muted/30 rounded-md", children: [
|
|
8260
8794
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 text-xs font-medium", children: [
|
|
8261
8795
|
/* @__PURE__ */ jsx(Box, { className: "w-3.5 h-3.5" }),
|
|
8262
8796
|
/* @__PURE__ */ jsx("span", { children: settingsLabels.altitudeDisplay })
|
|
@@ -12383,6 +12917,29 @@ function fieldValueDistribution(features, fieldName, maxValues, scanLimit = feat
|
|
|
12383
12917
|
}
|
|
12384
12918
|
return Array.from(counts2.entries()).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).slice(0, maxValues).map(([value, count]) => ({ value, count }));
|
|
12385
12919
|
}
|
|
12920
|
+
const CLUSTER_PIE_MAX_CATEGORIES = 15;
|
|
12921
|
+
function clusterPieKey(raw) {
|
|
12922
|
+
return raw !== null && typeof raw === "object" ? JSON.stringify(raw) : categoricalKey(raw);
|
|
12923
|
+
}
|
|
12924
|
+
const ranksAbove = (value, count, other) => count > other.count || count === other.count && value < other.value;
|
|
12925
|
+
function clusterPieCategories(points, fieldName) {
|
|
12926
|
+
var _a;
|
|
12927
|
+
const counts2 = /* @__PURE__ */ new Map();
|
|
12928
|
+
for (const point2 of points) {
|
|
12929
|
+
const key = clusterPieKey((_a = point2.properties) == null ? void 0 : _a[fieldName]);
|
|
12930
|
+
if (key !== null) counts2.set(key, (counts2.get(key) ?? 0) + 1);
|
|
12931
|
+
}
|
|
12932
|
+
const values = [];
|
|
12933
|
+
counts2.forEach((count, value) => {
|
|
12934
|
+
let at = values.length;
|
|
12935
|
+
while (at > 0 && ranksAbove(value, count, values[at - 1])) at--;
|
|
12936
|
+
if (at >= CLUSTER_PIE_MAX_CATEGORIES) return;
|
|
12937
|
+
values.splice(at, 0, { value, count });
|
|
12938
|
+
if (values.length > CLUSTER_PIE_MAX_CATEGORIES) values.pop();
|
|
12939
|
+
});
|
|
12940
|
+
const inSlices = values.reduce((sum, v) => sum + v.count, 0);
|
|
12941
|
+
return { values, otherCount: points.length - inSlices };
|
|
12942
|
+
}
|
|
12386
12943
|
const SELECTION_OVERLAY_SOURCE_ID = "selection-overlay";
|
|
12387
12944
|
const SELECTION_OVERLAY_LAYER_IDS = {
|
|
12388
12945
|
iconRing: "selection-overlay-icon-ring",
|
|
@@ -12665,365 +13222,55 @@ function createClusterGradientManager(map, sourceId, options) {
|
|
|
12665
13222
|
}
|
|
12666
13223
|
};
|
|
12667
13224
|
}
|
|
12668
|
-
const
|
|
12669
|
-
const
|
|
12670
|
-
|
|
12671
|
-
|
|
12672
|
-
|
|
12673
|
-
function
|
|
12674
|
-
const
|
|
12675
|
-
|
|
12676
|
-
|
|
12677
|
-
|
|
12678
|
-
const
|
|
12679
|
-
|
|
12680
|
-
|
|
12681
|
-
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
|
|
12685
|
-
const bgCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
12686
|
-
bgCircle.setAttribute("cx", String(radius));
|
|
12687
|
-
bgCircle.setAttribute("cy", String(radius));
|
|
12688
|
-
bgCircle.setAttribute("r", String(radius));
|
|
12689
|
-
bgCircle.setAttribute("fill", "white");
|
|
12690
|
-
svg.appendChild(bgCircle);
|
|
12691
|
-
const slicesSum = categories.reduce((s, c) => s + c.count, 0);
|
|
12692
|
-
const remainder = Math.max(0, total - slicesSum);
|
|
12693
|
-
const renderList = remainder > 0 ? [...categories, { name: "__remainder__", displayName: otherLabel, count: remainder, color: OTHER_BUCKET_COLOR }] : categories;
|
|
12694
|
-
const nonZeroSlices = renderList.filter((c) => c.count > 0);
|
|
12695
|
-
const isSingleFullSlice = nonZeroSlices.length === 1 && nonZeroSlices[0].count >= total;
|
|
12696
|
-
if (isSingleFullSlice) {
|
|
12697
|
-
const cat = nonZeroSlices[0];
|
|
12698
|
-
const ring = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
12699
|
-
const d = [
|
|
12700
|
-
`M 0 ${radius}`,
|
|
12701
|
-
`a ${radius} ${radius} 0 1 0 ${radius * 2} 0`,
|
|
12702
|
-
`a ${radius} ${radius} 0 1 0 ${-radius * 2} 0`,
|
|
12703
|
-
`M ${radius - innerRadius} ${radius}`,
|
|
12704
|
-
`a ${innerRadius} ${innerRadius} 0 1 1 ${innerRadius * 2} 0`,
|
|
12705
|
-
`a ${innerRadius} ${innerRadius} 0 1 1 ${-innerRadius * 2} 0`,
|
|
12706
|
-
"Z"
|
|
12707
|
-
].join(" ");
|
|
12708
|
-
ring.setAttribute("d", d);
|
|
12709
|
-
ring.setAttribute("fill-rule", "evenodd");
|
|
12710
|
-
ring.setAttribute("fill", cat.color);
|
|
12711
|
-
ring.setAttribute("stroke", "white");
|
|
12712
|
-
ring.setAttribute("stroke-width", "1");
|
|
12713
|
-
ring.style.transition = "opacity 0.15s";
|
|
12714
|
-
ring.addEventListener("mouseenter", (e) => {
|
|
12715
|
-
ring.style.opacity = "0.8";
|
|
12716
|
-
if (onSliceHover) onSliceHover(cat, e);
|
|
12717
|
-
});
|
|
12718
|
-
ring.addEventListener("mouseleave", (e) => {
|
|
12719
|
-
ring.style.opacity = "1";
|
|
12720
|
-
if (onSliceHover) onSliceHover(null, e);
|
|
12721
|
-
});
|
|
12722
|
-
svg.appendChild(ring);
|
|
12723
|
-
}
|
|
12724
|
-
let currentAngle = -90;
|
|
12725
|
-
(isSingleFullSlice ? [] : renderList).forEach((cat) => {
|
|
12726
|
-
if (cat.count === 0) return;
|
|
12727
|
-
const sliceAngle = cat.count / total * 360;
|
|
12728
|
-
const startAngle = currentAngle;
|
|
12729
|
-
const endAngle = currentAngle + sliceAngle;
|
|
12730
|
-
const startRad = startAngle * Math.PI / 180;
|
|
12731
|
-
const endRad = endAngle * Math.PI / 180;
|
|
12732
|
-
const x1 = radius + radius * Math.cos(startRad);
|
|
12733
|
-
const y1 = radius + radius * Math.sin(startRad);
|
|
12734
|
-
const x2 = radius + radius * Math.cos(endRad);
|
|
12735
|
-
const y2 = radius + radius * Math.sin(endRad);
|
|
12736
|
-
const x3 = radius + innerRadius * Math.cos(endRad);
|
|
12737
|
-
const y3 = radius + innerRadius * Math.sin(endRad);
|
|
12738
|
-
const x4 = radius + innerRadius * Math.cos(startRad);
|
|
12739
|
-
const y4 = radius + innerRadius * Math.sin(startRad);
|
|
12740
|
-
const largeArc = sliceAngle > 180 ? 1 : 0;
|
|
12741
|
-
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
12742
|
-
const d = [
|
|
12743
|
-
`M ${x1} ${y1}`,
|
|
12744
|
-
`A ${radius} ${radius} 0 ${largeArc} 1 ${x2} ${y2}`,
|
|
12745
|
-
`L ${x3} ${y3}`,
|
|
12746
|
-
`A ${innerRadius} ${innerRadius} 0 ${largeArc} 0 ${x4} ${y4}`,
|
|
12747
|
-
"Z"
|
|
12748
|
-
].join(" ");
|
|
12749
|
-
path.setAttribute("d", d);
|
|
12750
|
-
path.setAttribute("fill", cat.color);
|
|
12751
|
-
path.setAttribute("stroke", "white");
|
|
12752
|
-
path.setAttribute("stroke-width", "1");
|
|
12753
|
-
path.style.transition = "opacity 0.15s";
|
|
12754
|
-
path.addEventListener("mouseenter", (e) => {
|
|
12755
|
-
path.style.opacity = "0.8";
|
|
12756
|
-
if (onSliceHover) onSliceHover(cat, e);
|
|
12757
|
-
});
|
|
12758
|
-
path.addEventListener("mouseleave", (e) => {
|
|
12759
|
-
path.style.opacity = "1";
|
|
12760
|
-
if (onSliceHover) onSliceHover(null, e);
|
|
12761
|
-
});
|
|
12762
|
-
svg.appendChild(path);
|
|
12763
|
-
currentAngle = endAngle;
|
|
12764
|
-
});
|
|
12765
|
-
const centerCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
12766
|
-
centerCircle.setAttribute("cx", String(radius));
|
|
12767
|
-
centerCircle.setAttribute("cy", String(radius));
|
|
12768
|
-
centerCircle.setAttribute("r", String(innerRadius - 2));
|
|
12769
|
-
centerCircle.setAttribute("fill", "#1f2937");
|
|
12770
|
-
svg.appendChild(centerCircle);
|
|
12771
|
-
const badgeText = formatClusterBadge(badgeValue ?? total);
|
|
12772
|
-
const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
12773
|
-
text.setAttribute("x", String(radius));
|
|
12774
|
-
text.setAttribute("y", String(radius));
|
|
12775
|
-
text.setAttribute("text-anchor", "middle");
|
|
12776
|
-
text.setAttribute("dominant-baseline", "central");
|
|
12777
|
-
text.setAttribute("fill", "white");
|
|
12778
|
-
text.setAttribute("font-size", badgeText.length >= 6 ? "8" : badgeText.length >= 4 ? "9" : badgeText.length >= 3 ? "10" : "11");
|
|
12779
|
-
text.setAttribute("font-weight", "bold");
|
|
12780
|
-
text.setAttribute("font-family", "system-ui, sans-serif");
|
|
12781
|
-
text.textContent = badgeText;
|
|
12782
|
-
svg.appendChild(text);
|
|
12783
|
-
container.appendChild(svg);
|
|
12784
|
-
return container;
|
|
12785
|
-
}
|
|
12786
|
-
let tooltipEl = null;
|
|
12787
|
-
function showTooltip(cat, x, y) {
|
|
12788
|
-
if (!tooltipEl) {
|
|
12789
|
-
tooltipEl = document.createElement("div");
|
|
12790
|
-
tooltipEl.style.cssText = `
|
|
12791
|
-
position: fixed;
|
|
12792
|
-
background: rgba(0,0,0,0.85);
|
|
12793
|
-
color: white;
|
|
12794
|
-
padding: 6px 10px;
|
|
12795
|
-
border-radius: 4px;
|
|
12796
|
-
font-size: 12px;
|
|
12797
|
-
font-family: system-ui, sans-serif;
|
|
12798
|
-
pointer-events: none;
|
|
12799
|
-
z-index: 10000;
|
|
12800
|
-
white-space: nowrap;
|
|
12801
|
-
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
|
|
12802
|
-
`;
|
|
12803
|
-
document.body.appendChild(tooltipEl);
|
|
12804
|
-
}
|
|
12805
|
-
while (tooltipEl.firstChild) tooltipEl.removeChild(tooltipEl.firstChild);
|
|
12806
|
-
const row = document.createElement("div");
|
|
12807
|
-
row.style.cssText = "display: flex; align-items: center; gap: 6px;";
|
|
12808
|
-
const swatch = document.createElement("span");
|
|
12809
|
-
swatch.style.cssText = "width: 10px; height: 10px; border-radius: 2px;";
|
|
12810
|
-
swatch.style.backgroundColor = cat.color;
|
|
12811
|
-
row.appendChild(swatch);
|
|
12812
|
-
const label = document.createElement("span");
|
|
12813
|
-
const name = document.createElement("strong");
|
|
12814
|
-
name.textContent = cat.displayName;
|
|
12815
|
-
label.appendChild(name);
|
|
12816
|
-
label.appendChild(document.createTextNode(`: ${cat.count}`));
|
|
12817
|
-
row.appendChild(label);
|
|
12818
|
-
tooltipEl.appendChild(row);
|
|
12819
|
-
tooltipEl.style.left = `${x + 12}px`;
|
|
12820
|
-
tooltipEl.style.top = `${y - 10}px`;
|
|
12821
|
-
tooltipEl.style.display = "block";
|
|
12822
|
-
}
|
|
12823
|
-
function hideTooltip() {
|
|
12824
|
-
if (tooltipEl) {
|
|
12825
|
-
tooltipEl.style.display = "none";
|
|
12826
|
-
}
|
|
13225
|
+
const EMPTY_ID_SET = /* @__PURE__ */ new Set();
|
|
13226
|
+
const EMPTY_SOURCES = [];
|
|
13227
|
+
const EMPTY_LABEL_MAP = /* @__PURE__ */ new Map();
|
|
13228
|
+
const TICK_COUNT_SETTLE_MS = 300;
|
|
13229
|
+
const SPATIAL_COUNT_MIN_FEATURES = 5e3;
|
|
13230
|
+
function renderEmojiToCanvas(emoji, size = EMOJI_CANVAS_SIZE) {
|
|
13231
|
+
const ratio = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
13232
|
+
const canvas = document.createElement("canvas");
|
|
13233
|
+
canvas.width = size * ratio;
|
|
13234
|
+
canvas.height = size * ratio;
|
|
13235
|
+
const ctx = canvas.getContext("2d");
|
|
13236
|
+
ctx.scale(ratio, ratio);
|
|
13237
|
+
ctx.font = `${size * 0.75}px "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif`;
|
|
13238
|
+
ctx.textAlign = "center";
|
|
13239
|
+
ctx.textBaseline = "middle";
|
|
13240
|
+
ctx.fillText(emoji, size / 2, size / 2);
|
|
13241
|
+
return canvas;
|
|
12827
13242
|
}
|
|
12828
|
-
function
|
|
12829
|
-
|
|
13243
|
+
function emojiCanvasToImageData(canvas) {
|
|
13244
|
+
const ctx = canvas.getContext("2d");
|
|
13245
|
+
const id = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
13246
|
+
return { width: canvas.width, height: canvas.height, data: new Uint8Array(id.data.buffer) };
|
|
12830
13247
|
}
|
|
12831
|
-
function
|
|
12832
|
-
const
|
|
12833
|
-
|
|
12834
|
-
|
|
12835
|
-
|
|
12836
|
-
|
|
13248
|
+
function loadEmojiIconsIntoMap(mapInstance, hostImages) {
|
|
13249
|
+
const ratio = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
13250
|
+
for (const { emoji } of ICONS) {
|
|
13251
|
+
if (!emoji || mapInstance.hasImage(emoji)) continue;
|
|
13252
|
+
try {
|
|
13253
|
+
const canvas = renderEmojiToCanvas(emoji);
|
|
13254
|
+
mapInstance.addImage(emoji, emojiCanvasToImageData(canvas), { pixelRatio: ratio });
|
|
13255
|
+
} catch {
|
|
12837
13256
|
}
|
|
12838
|
-
}
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
|
|
12842
|
-
|
|
13257
|
+
}
|
|
13258
|
+
mapInstance.setMissingStyleImageResolver((id) => {
|
|
13259
|
+
if (mapInstance.hasImage(id)) return;
|
|
13260
|
+
try {
|
|
13261
|
+
if (id === ARROWHEAD_IMAGE_ID) {
|
|
13262
|
+
mapInstance.addImage(id, buildArrowheadImage(ratio), { pixelRatio: ratio, sdf: true });
|
|
13263
|
+
return;
|
|
12843
13264
|
}
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12853
|
-
filter: ["has", "point_count"]
|
|
12854
|
-
});
|
|
12855
|
-
const visibleClusterIds = /* @__PURE__ */ new Set();
|
|
12856
|
-
clusters.forEach((feature) => {
|
|
12857
|
-
var _a, _b, _c;
|
|
12858
|
-
const clusterId = (_a = feature.properties) == null ? void 0 : _a.cluster_id;
|
|
12859
|
-
if (clusterId === void 0) return;
|
|
12860
|
-
const clusterKey = `${clusterId}`;
|
|
12861
|
-
visibleClusterIds.add(clusterKey);
|
|
12862
|
-
const coords = feature.geometry.coordinates;
|
|
12863
|
-
const pointCount = ((_b = feature.properties) == null ? void 0 : _b.point_count) || 0;
|
|
12864
|
-
const sumRaw = (_c = feature.properties) == null ? void 0 : _c[CLUSTER_SUM_PROP];
|
|
12865
|
-
const sumNum = typeof sumRaw === "number" ? sumRaw : sumRaw != null ? Number(sumRaw) : NaN;
|
|
12866
|
-
const badgeValue = Number.isFinite(sumNum) ? sumNum : void 0;
|
|
12867
|
-
const allCounts = categoryValues.map((_, i) => {
|
|
12868
|
-
var _a2;
|
|
12869
|
-
return Number(((_a2 = feature.properties) == null ? void 0 : _a2[`cat_${i}`]) || 0);
|
|
12870
|
-
});
|
|
12871
|
-
const categories = categoryValues.map((cat, i) => ({
|
|
12872
|
-
name: cat,
|
|
12873
|
-
displayName: toDisplayName(cat, otherLabel),
|
|
12874
|
-
count: allCounts[i],
|
|
12875
|
-
color: categoryColorMap[cat] || "#3b82f6"
|
|
12876
|
-
})).filter((c) => c.count > 0);
|
|
12877
|
-
const size = pointCount < 100 ? 40 : pointCount < 750 ? 50 : 60;
|
|
12878
|
-
const fingerprint = fingerprintCluster(pointCount, allCounts, size, badgeValue);
|
|
12879
|
-
const existing = markers.get(clusterKey);
|
|
12880
|
-
if (existing && existing.fingerprint === fingerprint) {
|
|
12881
|
-
existing.marker.setLngLat(coords);
|
|
12882
|
-
return;
|
|
12883
|
-
}
|
|
12884
|
-
const el = buildPieElement(categories, pointCount, otherLabel, size, source, clusterId, map, coords, badgeValue);
|
|
12885
|
-
if (existing) {
|
|
12886
|
-
existing.marker.remove();
|
|
12887
|
-
}
|
|
12888
|
-
const marker = new maplibregl.Marker({ element: el }).setLngLat(coords).addTo(map);
|
|
12889
|
-
markers.set(clusterKey, { marker, fingerprint });
|
|
12890
|
-
});
|
|
12891
|
-
markers.forEach((entry, key) => {
|
|
12892
|
-
if (!visibleClusterIds.has(key)) {
|
|
12893
|
-
entry.marker.remove();
|
|
12894
|
-
markers.delete(key);
|
|
12895
|
-
}
|
|
12896
|
-
});
|
|
12897
|
-
}
|
|
12898
|
-
function createClusterPieManager(map, sourceId, categoryValues, categoryColorMap, otherLabel = DEFAULT_MAP_LABELS.canvas.clusterOther) {
|
|
12899
|
-
const markers = /* @__PURE__ */ new Map();
|
|
12900
|
-
let updateScheduled = false;
|
|
12901
|
-
function scheduleUpdate() {
|
|
12902
|
-
if (updateScheduled) return;
|
|
12903
|
-
updateScheduled = true;
|
|
12904
|
-
requestAnimationFrame(() => {
|
|
12905
|
-
updateScheduled = false;
|
|
12906
|
-
renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markers, otherLabel);
|
|
12907
|
-
});
|
|
12908
|
-
}
|
|
12909
|
-
function onData(e) {
|
|
12910
|
-
if (e.dataType === "source" && e.sourceId === sourceId) {
|
|
12911
|
-
scheduleUpdate();
|
|
12912
|
-
}
|
|
12913
|
-
}
|
|
12914
|
-
map.on("moveend", scheduleUpdate);
|
|
12915
|
-
map.on("data", onData);
|
|
12916
|
-
scheduleUpdate();
|
|
12917
|
-
return {
|
|
12918
|
-
update: scheduleUpdate,
|
|
12919
|
-
destroy: () => {
|
|
12920
|
-
map.off("moveend", scheduleUpdate);
|
|
12921
|
-
map.off("data", onData);
|
|
12922
|
-
markers.forEach((entry) => entry.marker.remove());
|
|
12923
|
-
markers.clear();
|
|
12924
|
-
hideTooltip();
|
|
12925
|
-
}
|
|
12926
|
-
};
|
|
12927
|
-
}
|
|
12928
|
-
function ClusterPieManager(props) {
|
|
12929
|
-
const { map, sourceId, categoryValues, categoryColorMap, visible } = props;
|
|
12930
|
-
const otherLabel = useMapLabels().canvas.clusterOther;
|
|
12931
|
-
const markersRef = useRef(/* @__PURE__ */ new Map());
|
|
12932
|
-
const updateScheduled = useRef(false);
|
|
12933
|
-
const updateMarkers = useCallback(() => {
|
|
12934
|
-
if (!map || !visible) {
|
|
12935
|
-
markersRef.current.forEach((entry) => entry.marker.remove());
|
|
12936
|
-
markersRef.current.clear();
|
|
12937
|
-
return;
|
|
12938
|
-
}
|
|
12939
|
-
renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markersRef.current, otherLabel);
|
|
12940
|
-
}, [map, sourceId, categoryValues, categoryColorMap, visible, otherLabel]);
|
|
12941
|
-
useEffect(() => {
|
|
12942
|
-
if (!map) return;
|
|
12943
|
-
const scheduleUpdate = () => {
|
|
12944
|
-
if (updateScheduled.current) return;
|
|
12945
|
-
updateScheduled.current = true;
|
|
12946
|
-
requestAnimationFrame(() => {
|
|
12947
|
-
updateScheduled.current = false;
|
|
12948
|
-
updateMarkers();
|
|
12949
|
-
});
|
|
12950
|
-
};
|
|
12951
|
-
const onData = (e) => {
|
|
12952
|
-
if (e.dataType === "source" && e.sourceId === sourceId) {
|
|
12953
|
-
scheduleUpdate();
|
|
12954
|
-
}
|
|
12955
|
-
};
|
|
12956
|
-
scheduleUpdate();
|
|
12957
|
-
map.on("moveend", scheduleUpdate);
|
|
12958
|
-
map.on("data", onData);
|
|
12959
|
-
return () => {
|
|
12960
|
-
map.off("moveend", scheduleUpdate);
|
|
12961
|
-
map.off("data", onData);
|
|
12962
|
-
markersRef.current.forEach((entry) => entry.marker.remove());
|
|
12963
|
-
markersRef.current.clear();
|
|
12964
|
-
hideTooltip();
|
|
12965
|
-
};
|
|
12966
|
-
}, [map, sourceId, updateMarkers]);
|
|
12967
|
-
useEffect(() => {
|
|
12968
|
-
if (!visible) {
|
|
12969
|
-
markersRef.current.forEach((entry) => entry.marker.remove());
|
|
12970
|
-
markersRef.current.clear();
|
|
12971
|
-
hideTooltip();
|
|
12972
|
-
} else {
|
|
12973
|
-
updateMarkers();
|
|
12974
|
-
}
|
|
12975
|
-
}, [visible, updateMarkers]);
|
|
12976
|
-
return null;
|
|
12977
|
-
}
|
|
12978
|
-
const EMPTY_ID_SET = /* @__PURE__ */ new Set();
|
|
12979
|
-
const EMPTY_SOURCES = [];
|
|
12980
|
-
const EMPTY_LABEL_MAP = /* @__PURE__ */ new Map();
|
|
12981
|
-
const TICK_COUNT_SETTLE_MS = 300;
|
|
12982
|
-
const SPATIAL_COUNT_MIN_FEATURES = 5e3;
|
|
12983
|
-
function renderEmojiToCanvas(emoji, size = EMOJI_CANVAS_SIZE) {
|
|
12984
|
-
const ratio = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
12985
|
-
const canvas = document.createElement("canvas");
|
|
12986
|
-
canvas.width = size * ratio;
|
|
12987
|
-
canvas.height = size * ratio;
|
|
12988
|
-
const ctx = canvas.getContext("2d");
|
|
12989
|
-
ctx.scale(ratio, ratio);
|
|
12990
|
-
ctx.font = `${size * 0.75}px "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif`;
|
|
12991
|
-
ctx.textAlign = "center";
|
|
12992
|
-
ctx.textBaseline = "middle";
|
|
12993
|
-
ctx.fillText(emoji, size / 2, size / 2);
|
|
12994
|
-
return canvas;
|
|
12995
|
-
}
|
|
12996
|
-
function emojiCanvasToImageData(canvas) {
|
|
12997
|
-
const ctx = canvas.getContext("2d");
|
|
12998
|
-
const id = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
12999
|
-
return { width: canvas.width, height: canvas.height, data: new Uint8Array(id.data.buffer) };
|
|
13000
|
-
}
|
|
13001
|
-
function loadEmojiIconsIntoMap(mapInstance, hostImages) {
|
|
13002
|
-
const ratio = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
13003
|
-
for (const { emoji } of ICONS) {
|
|
13004
|
-
if (!emoji || mapInstance.hasImage(emoji)) continue;
|
|
13005
|
-
try {
|
|
13006
|
-
const canvas = renderEmojiToCanvas(emoji);
|
|
13007
|
-
mapInstance.addImage(emoji, emojiCanvasToImageData(canvas), { pixelRatio: ratio });
|
|
13008
|
-
} catch {
|
|
13009
|
-
}
|
|
13010
|
-
}
|
|
13011
|
-
mapInstance.setMissingStyleImageResolver((id) => {
|
|
13012
|
-
if (mapInstance.hasImage(id)) return;
|
|
13013
|
-
try {
|
|
13014
|
-
if (id === ARROWHEAD_IMAGE_ID) {
|
|
13015
|
-
mapInstance.addImage(id, buildArrowheadImage(ratio), { pixelRatio: ratio, sdf: true });
|
|
13016
|
-
return;
|
|
13017
|
-
}
|
|
13018
|
-
const resolved = resolveMissingImage(id, hostImages());
|
|
13019
|
-
if (resolved.kind === "host") {
|
|
13020
|
-
mapInstance.addImage(id, resolved.image.data, { pixelRatio: resolved.image.pixelRatio ?? 1 });
|
|
13021
|
-
} else if (resolved.kind === "emoji" && isEmojiIcon(id)) {
|
|
13022
|
-
const canvas = renderEmojiToCanvas(id);
|
|
13023
|
-
mapInstance.addImage(id, emojiCanvasToImageData(canvas), { pixelRatio: ratio });
|
|
13024
|
-
}
|
|
13025
|
-
} catch {
|
|
13026
|
-
}
|
|
13265
|
+
const resolved = resolveMissingImage(id, hostImages());
|
|
13266
|
+
if (resolved.kind === "host") {
|
|
13267
|
+
mapInstance.addImage(id, resolved.image.data, { pixelRatio: resolved.image.pixelRatio ?? 1 });
|
|
13268
|
+
} else if (resolved.kind === "emoji" && isEmojiIcon(id)) {
|
|
13269
|
+
const canvas = renderEmojiToCanvas(id);
|
|
13270
|
+
mapInstance.addImage(id, emojiCanvasToImageData(canvas), { pixelRatio: ratio });
|
|
13271
|
+
}
|
|
13272
|
+
} catch {
|
|
13273
|
+
}
|
|
13027
13274
|
});
|
|
13028
13275
|
}
|
|
13029
13276
|
function onDrawEvent(mapInstance, type, listener) {
|
|
@@ -13205,6 +13452,15 @@ function basemapInsertAnchor(map) {
|
|
|
13205
13452
|
if (map.getLayer("custom-polygon-fill")) return "custom-polygon-fill";
|
|
13206
13453
|
return void 0;
|
|
13207
13454
|
}
|
|
13455
|
+
function layerPointFeatures(layer, stores) {
|
|
13456
|
+
const isPoint = (f) => {
|
|
13457
|
+
var _a;
|
|
13458
|
+
return ((_a = f == null ? void 0 : f.geometry) == null ? void 0 : _a.type) === "Point";
|
|
13459
|
+
};
|
|
13460
|
+
if (layer.readOnly) return (stores.readOnly.get(layer.id) ?? []).filter(isPoint);
|
|
13461
|
+
if (layer.visible) return layer.featureIds.map((id) => stores.draw.get(id)).filter(isPoint);
|
|
13462
|
+
return (stores.hidden.get(layer.id) ?? []).filter(isPoint);
|
|
13463
|
+
}
|
|
13208
13464
|
function featureStateHostFor(m) {
|
|
13209
13465
|
return {
|
|
13210
13466
|
setFeatureState: (source, id, state) => m.setFeatureState({ source, id }, state),
|
|
@@ -13318,6 +13574,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13318
13574
|
const hiddenFeatures = useRef(/* @__PURE__ */ new Map());
|
|
13319
13575
|
const tracePopupRef = useRef(null);
|
|
13320
13576
|
const tooltipElRef = useRef(null);
|
|
13577
|
+
const [tooltipSlot] = useState(createPopupSlot);
|
|
13578
|
+
const [tracePopupSlot] = useState(createPopupSlot);
|
|
13321
13579
|
const layersRef = useRef([
|
|
13322
13580
|
{ id: DEFAULT_LAYER_ID, name: DEFAULT_LAYER_NAME, visible: true, featureIds: [] }
|
|
13323
13581
|
]);
|
|
@@ -14943,6 +15201,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14943
15201
|
tooltipEl2.style.cssText = "position:fixed;z-index:1000;pointer-events:auto;display:none;max-width:480px;box-sizing:border-box;";
|
|
14944
15202
|
document.body.appendChild(tooltipEl2);
|
|
14945
15203
|
tooltipElRef.current = tooltipEl2;
|
|
15204
|
+
const tracePopupContentEl = document.createElement("div");
|
|
14946
15205
|
let tooltipLngLat = null;
|
|
14947
15206
|
let tooltipHideTimeout = null;
|
|
14948
15207
|
let tooltipShowTimeout = null;
|
|
@@ -14976,9 +15235,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14976
15235
|
tooltipEl2.style.left = left + "px";
|
|
14977
15236
|
tooltipEl2.style.top = top + "px";
|
|
14978
15237
|
};
|
|
14979
|
-
const showTooltip2 = (lngLat,
|
|
14980
|
-
tooltipEl2.innerHTML = html;
|
|
15238
|
+
const showTooltip2 = (lngLat, content) => {
|
|
14981
15239
|
tooltipEl2.style.display = "block";
|
|
15240
|
+
tooltipSlot.render(tooltipEl2, content);
|
|
14982
15241
|
tooltipLngLat = lngLat;
|
|
14983
15242
|
requestAnimationFrame(() => positionTooltip());
|
|
14984
15243
|
};
|
|
@@ -14988,6 +15247,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14988
15247
|
tooltipShowTimeout = null;
|
|
14989
15248
|
}
|
|
14990
15249
|
tooltipEl2.style.display = "none";
|
|
15250
|
+
tooltipSlot.render(tooltipEl2, null);
|
|
14991
15251
|
tooltipEl2.style.minWidth = "";
|
|
14992
15252
|
tooltipEl2.style.minHeight = "";
|
|
14993
15253
|
tooltipLngLat = null;
|
|
@@ -15040,67 +15300,46 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
15040
15300
|
}
|
|
15041
15301
|
});
|
|
15042
15302
|
const hoverHandlersByLayer = /* @__PURE__ */ new Map();
|
|
15043
|
-
const
|
|
15044
|
-
var _a2, _b2;
|
|
15045
|
-
const
|
|
15046
|
-
const
|
|
15047
|
-
const currentLayers = layersRef.current;
|
|
15048
|
-
const featureLayer = currentLayers.find((l) => l.featureIds.includes(featureId));
|
|
15049
|
-
const visualConfig = featureLayer == null ? void 0 : featureLayer.visualConfig;
|
|
15303
|
+
const builtinTooltip = (feature) => {
|
|
15304
|
+
var _a2, _b2, _c, _d;
|
|
15305
|
+
const featureId = String(feature.id ?? ((_a2 = feature.properties) == null ? void 0 : _a2.id) ?? "");
|
|
15306
|
+
const visualConfig = (_b2 = layersRef.current.find((l) => l.featureIds.includes(featureId))) == null ? void 0 : _b2.visualConfig;
|
|
15050
15307
|
const highlightFields = /* @__PURE__ */ new Set();
|
|
15051
|
-
if (((
|
|
15052
|
-
if (((
|
|
15053
|
-
|
|
15054
|
-
|
|
15055
|
-
|
|
15056
|
-
|
|
15057
|
-
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
html += `<div><span class="opacity-70">${escapeHtml(key)}:</span> ${escapeHtml(String(value).slice(0, 30))}</div>`;
|
|
15063
|
-
});
|
|
15064
|
-
html += "</div>";
|
|
15065
|
-
}
|
|
15066
|
-
if (highlightFields.size > 0) {
|
|
15067
|
-
html += '<div class="text-xs border-t border-border/50 mt-1 pt-1 space-y-0.5">';
|
|
15068
|
-
highlightFields.forEach((fieldName) => {
|
|
15069
|
-
const value = props[fieldName];
|
|
15070
|
-
if (value != null && value !== "") html += `<div class="flex justify-between gap-2"><span class="opacity-70">${escapeHtml(fieldName)}:</span> <span class="font-medium">${escapeHtml(String(value).slice(0, 20))}</span></div>`;
|
|
15071
|
-
});
|
|
15072
|
-
html += "</div>";
|
|
15073
|
-
}
|
|
15074
|
-
html += "</div>";
|
|
15075
|
-
return html;
|
|
15308
|
+
if (((_c = visualConfig == null ? void 0 : visualConfig.size) == null ? void 0 : _c.mode) === "field" && visualConfig.size.fieldName) highlightFields.add(visualConfig.size.fieldName);
|
|
15309
|
+
if (((_d = visualConfig == null ? void 0 : visualConfig.color) == null ? void 0 : _d.mode) === "field" && visualConfig.color.fieldName) highlightFields.add(visualConfig.color.fieldName);
|
|
15310
|
+
return /* @__PURE__ */ jsx(
|
|
15311
|
+
BuiltinTooltip,
|
|
15312
|
+
{
|
|
15313
|
+
feature,
|
|
15314
|
+
featureId,
|
|
15315
|
+
highlightFields,
|
|
15316
|
+
idLabel: labelsRef.current.canvas.tooltipId
|
|
15317
|
+
}
|
|
15318
|
+
);
|
|
15076
15319
|
};
|
|
15077
|
-
const
|
|
15320
|
+
const tooltipPageContent = () => {
|
|
15078
15321
|
const feature = resolveRendered(tooltipFeatures[tooltipPageIndex]);
|
|
15079
|
-
|
|
15080
|
-
if (
|
|
15081
|
-
|
|
15082
|
-
|
|
15083
|
-
|
|
15084
|
-
|
|
15085
|
-
|
|
15086
|
-
|
|
15087
|
-
|
|
15088
|
-
|
|
15089
|
-
|
|
15090
|
-
const navHtml = `<div style="display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #eee;padding:4px 0 6px;margin-bottom:4px;font-size:12px;color:#666;user-select:none"><button data-tooltip-nav="prev" style="${btnBase}border:1px solid ${prevDisabled ? "#eee" : "#ddd"};cursor:${prevDisabled ? "default" : "pointer"};color:${prevDisabled ? "#ccc" : "#444"}"${prevDisabled ? " disabled" : ""}>‹</button><span${tooltipMore ? ` title="${escapeHtml(labelsRef.current.canvas.morePointsHint)}"` : ""}>${tooltipPageIndex + 1} / ${tooltipFeatures.length}${tooltipMore ? "+" : ""}</span><button data-tooltip-nav="next" style="${btnBase}border:1px solid ${nextDisabled ? "#eee" : "#ddd"};cursor:${nextDisabled ? "default" : "pointer"};color:${nextDisabled ? "#ccc" : "#444"}"${nextDisabled ? " disabled" : ""}>›</button></div>`;
|
|
15091
|
-
html = navHtml + html;
|
|
15092
|
-
}
|
|
15093
|
-
return html;
|
|
15322
|
+
const content = tooltipProviderRef.current ? tooltipProviderRef.current(feature) : builtinTooltip(feature);
|
|
15323
|
+
if (isEmptyTooltip(content)) return null;
|
|
15324
|
+
const page = tooltipFeatures.length > 1 ? { index: tooltipPageIndex, count: tooltipFeatures.length, more: tooltipMore } : null;
|
|
15325
|
+
return /* @__PURE__ */ jsx(
|
|
15326
|
+
TooltipBody,
|
|
15327
|
+
{
|
|
15328
|
+
content,
|
|
15329
|
+
page,
|
|
15330
|
+
moreHint: labelsRef.current.canvas.morePointsHint
|
|
15331
|
+
}
|
|
15332
|
+
);
|
|
15094
15333
|
};
|
|
15095
15334
|
const renderTooltipPage = () => {
|
|
15096
15335
|
if (tooltipFeatures.length === 0 || !tooltipLngLatForPagination) return;
|
|
15097
|
-
const
|
|
15098
|
-
if (!
|
|
15336
|
+
const content = tooltipPageContent();
|
|
15337
|
+
if (!content) return;
|
|
15099
15338
|
if (tooltipPageIndex > 0 && tooltipFeatures.length > 1) {
|
|
15100
15339
|
tooltipEl2.style.minWidth = tooltipEl2.offsetWidth + "px";
|
|
15101
15340
|
tooltipEl2.style.minHeight = tooltipEl2.offsetHeight + "px";
|
|
15102
15341
|
}
|
|
15103
|
-
showTooltip2(tooltipLngLatForPagination,
|
|
15342
|
+
showTooltip2(tooltipLngLatForPagination, content);
|
|
15104
15343
|
};
|
|
15105
15344
|
const getFeatureKey = (f) => {
|
|
15106
15345
|
const props = f.properties || {};
|
|
@@ -15139,10 +15378,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
15139
15378
|
clearTimeout(tooltipHideTimeout);
|
|
15140
15379
|
tooltipHideTimeout = null;
|
|
15141
15380
|
}
|
|
15142
|
-
|
|
15143
|
-
tooltipEl2.style.minWidth = "";
|
|
15144
|
-
tooltipEl2.style.minHeight = "";
|
|
15145
|
-
tooltipLngLat = null;
|
|
15381
|
+
hideTooltip2();
|
|
15146
15382
|
if (tooltipHideTimeout) {
|
|
15147
15383
|
clearTimeout(tooltipHideTimeout);
|
|
15148
15384
|
tooltipHideTimeout = null;
|
|
@@ -15203,9 +15439,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
15203
15439
|
tooltipLngLatForPagination = anchorLngLat;
|
|
15204
15440
|
tooltipEl2.style.minWidth = "";
|
|
15205
15441
|
tooltipEl2.style.minHeight = "";
|
|
15206
|
-
const
|
|
15207
|
-
if (
|
|
15208
|
-
tooltipEl2
|
|
15442
|
+
const content = tooltipPageContent();
|
|
15443
|
+
if (content) {
|
|
15444
|
+
tooltipSlot.render(tooltipEl2, content);
|
|
15209
15445
|
tooltipLngLat = anchorLngLat;
|
|
15210
15446
|
positionTooltip();
|
|
15211
15447
|
}
|
|
@@ -15278,26 +15514,24 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
15278
15514
|
mapInstance.getCanvas().style.cursor = "pointer";
|
|
15279
15515
|
if (e.features && e.features.length > 0) {
|
|
15280
15516
|
const props = e.features[0].properties || {};
|
|
15281
|
-
const
|
|
15282
|
-
const
|
|
15283
|
-
const
|
|
15284
|
-
|
|
15285
|
-
|
|
15286
|
-
|
|
15287
|
-
|
|
15288
|
-
|
|
15289
|
-
|
|
15290
|
-
|
|
15291
|
-
|
|
15292
|
-
|
|
15293
|
-
|
|
15294
|
-
|
|
15295
|
-
|
|
15296
|
-
|
|
15297
|
-
|
|
15298
|
-
|
|
15299
|
-
}
|
|
15300
|
-
html += "</div>";
|
|
15517
|
+
const text = (value) => value ? String(value) : "";
|
|
15518
|
+
const labels2 = labelsRef.current.canvas;
|
|
15519
|
+
const group = props.group && props.group !== "__all__" ? String(props.group) : null;
|
|
15520
|
+
tracePopupSlot.render(
|
|
15521
|
+
tracePopupContentEl,
|
|
15522
|
+
/* @__PURE__ */ jsx(
|
|
15523
|
+
TracePopup,
|
|
15524
|
+
{
|
|
15525
|
+
fromName: text(props.fromName),
|
|
15526
|
+
toName: text(props.toName),
|
|
15527
|
+
duration: text(props.duration),
|
|
15528
|
+
distance: text(props.distance),
|
|
15529
|
+
avgSpeed: text(props.avgSpeed),
|
|
15530
|
+
groupLabel: group ? labels2.traceGroup(group) : null,
|
|
15531
|
+
labels: labels2
|
|
15532
|
+
}
|
|
15533
|
+
)
|
|
15534
|
+
);
|
|
15301
15535
|
if (!tracePopupRef.current) {
|
|
15302
15536
|
tracePopupRef.current = new maplibregl.Popup({
|
|
15303
15537
|
closeButton: false,
|
|
@@ -15307,7 +15541,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
15307
15541
|
offset: [0, -10]
|
|
15308
15542
|
});
|
|
15309
15543
|
}
|
|
15310
|
-
tracePopupRef.current.setLngLat(e.lngLat).
|
|
15544
|
+
tracePopupRef.current.setLngLat(e.lngLat).setDOMContent(tracePopupContentEl).addTo(mapInstance);
|
|
15311
15545
|
}
|
|
15312
15546
|
});
|
|
15313
15547
|
mapInstance.on("mouseleave", "trace-lines", () => {
|
|
@@ -18027,6 +18261,20 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
18027
18261
|
},
|
|
18028
18262
|
[layers]
|
|
18029
18263
|
);
|
|
18264
|
+
const getClusterPieCategories = useCallback(
|
|
18265
|
+
(layerId, fieldName) => {
|
|
18266
|
+
const layer = layers.find((l) => l.id === layerId);
|
|
18267
|
+
if (!layer || !draw.current) return null;
|
|
18268
|
+
const points = layerPointFeatures(layer, {
|
|
18269
|
+
readOnly: readOnlyFeatures.current,
|
|
18270
|
+
hidden: hiddenFeatures.current,
|
|
18271
|
+
draw: draw.current
|
|
18272
|
+
});
|
|
18273
|
+
return clusterPieCategories(points, fieldName);
|
|
18274
|
+
},
|
|
18275
|
+
// Property edits change the pie counts without a new `layers`, as in the cluster effect.
|
|
18276
|
+
[layers, clusterDataVersion]
|
|
18277
|
+
);
|
|
18030
18278
|
const handleFitToLayerFeatures = useCallback((layerId) => {
|
|
18031
18279
|
if (!map.current) return;
|
|
18032
18280
|
const customBounds = fitBoundsProvider == null ? void 0 : fitBoundsProvider(layerId);
|
|
@@ -20070,36 +20318,16 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
20070
20318
|
const unclusteredLayerId = `unclustered-point-${layer.id}`;
|
|
20071
20319
|
const singleValueLayerId = `cluster-single-${layer.id}`;
|
|
20072
20320
|
const singleValueCountLayerId = `cluster-single-count-${layer.id}`;
|
|
20073
|
-
|
|
20074
|
-
|
|
20075
|
-
|
|
20076
|
-
|
|
20077
|
-
|
|
20078
|
-
var _a2;
|
|
20079
|
-
return ((_a2 = f.geometry) == null ? void 0 : _a2.type) === "Point";
|
|
20080
|
-
});
|
|
20081
|
-
} else {
|
|
20082
|
-
layer.featureIds.forEach((id) => {
|
|
20083
|
-
var _a2;
|
|
20084
|
-
const f = drawInstance.get(id);
|
|
20085
|
-
if (f && ((_a2 = f.geometry) == null ? void 0 : _a2.type) === "Point") {
|
|
20086
|
-
pointFeatures.push(f);
|
|
20087
|
-
}
|
|
20088
|
-
});
|
|
20089
|
-
}
|
|
20090
|
-
} else {
|
|
20091
|
-
const hidden = hiddenFeatures.current.get(layer.id) || [];
|
|
20092
|
-
pointFeatures = hidden.filter((f) => {
|
|
20093
|
-
var _a2;
|
|
20094
|
-
return ((_a2 = f.geometry) == null ? void 0 : _a2.type) === "Point";
|
|
20095
|
-
});
|
|
20096
|
-
}
|
|
20321
|
+
const pointFeatures = layerPointFeatures(layer, {
|
|
20322
|
+
readOnly: readOnlyFeatures.current,
|
|
20323
|
+
hidden: hiddenFeatures.current,
|
|
20324
|
+
draw: drawInstance
|
|
20325
|
+
});
|
|
20097
20326
|
if (pointFeatures.length === 0) return;
|
|
20098
20327
|
const groupByField = (_b = layer.clusterConfig) == null ? void 0 : _b.groupByField;
|
|
20099
20328
|
const countByField = ((_c = layer.clusterConfig) == null ? void 0 : _c.countByFieldEnabled) && ((_d = layer.clusterConfig) == null ? void 0 : _d.countByField) || null;
|
|
20100
20329
|
const bubbleGradient = !!((_e = layer.clusterConfig) == null ? void 0 : _e.bubbleGradient) && !groupByField;
|
|
20101
20330
|
const OTHER_COLOR = OTHER_BUCKET_COLOR;
|
|
20102
|
-
const MAX_CATEGORIES = 15;
|
|
20103
20331
|
try {
|
|
20104
20332
|
const layerColor = ((_g = (_f = layer.visualConfig) == null ? void 0 : _f.color) == null ? void 0 : _g.fixedColor) || "#3b82f6";
|
|
20105
20333
|
let clusterProperties = {};
|
|
@@ -20107,15 +20335,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
20107
20335
|
let categoryColorMap = {};
|
|
20108
20336
|
let hasOtherBucket = false;
|
|
20109
20337
|
if (groupByField) {
|
|
20110
|
-
const
|
|
20111
|
-
pointFeatures.forEach((f) => {
|
|
20112
|
-
var _a2;
|
|
20113
|
-
const key = categoricalKey((_a2 = f.properties) == null ? void 0 : _a2[groupByField]);
|
|
20114
|
-
if (key === null) return;
|
|
20115
|
-
counts2.set(key, (counts2.get(key) ?? 0) + 1);
|
|
20116
|
-
});
|
|
20117
|
-
const sorted = Array.from(counts2.entries()).sort((a, b) => b[1] - a[1]);
|
|
20118
|
-
const topKeys = sorted.slice(0, MAX_CATEGORIES).map(([k]) => k);
|
|
20338
|
+
const topKeys = clusterPieCategories(pointFeatures, groupByField).values.map((v) => v.value);
|
|
20119
20339
|
categoryValues = [...topKeys];
|
|
20120
20340
|
hasOtherBucket = true;
|
|
20121
20341
|
const fieldAsString = ["to-string", ["coalesce", ["get", groupByField], ""]];
|
|
@@ -20342,490 +20562,495 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
20342
20562
|
] }) });
|
|
20343
20563
|
}
|
|
20344
20564
|
const toastContextValue = toastProvider ?? null;
|
|
20345
|
-
return /* @__PURE__ */
|
|
20346
|
-
/* @__PURE__ */ jsx(
|
|
20347
|
-
|
|
20348
|
-
|
|
20349
|
-
|
|
20350
|
-
|
|
20351
|
-
|
|
20352
|
-
|
|
20353
|
-
|
|
20354
|
-
|
|
20355
|
-
|
|
20356
|
-
|
|
20357
|
-
|
|
20358
|
-
|
|
20359
|
-
|
|
20360
|
-
"
|
|
20361
|
-
|
|
20362
|
-
"
|
|
20363
|
-
|
|
20364
|
-
|
|
20365
|
-
|
|
20366
|
-
fill: "rgba(0, 0, 0, 0.03)",
|
|
20367
|
-
stroke: "#555",
|
|
20368
|
-
strokeWidth: "1.5",
|
|
20369
|
-
strokeDasharray: "6,3",
|
|
20370
|
-
strokeOpacity: "0.6"
|
|
20371
|
-
}
|
|
20372
|
-
)
|
|
20373
|
-
}
|
|
20374
|
-
),
|
|
20375
|
-
selectionPoints.length >= 4 && (selectionMode === "rectangle" || selectionMode === "click") && map.current && /* @__PURE__ */ jsx(
|
|
20376
|
-
"svg",
|
|
20377
|
-
{
|
|
20378
|
-
className: "absolute inset-0 w-full h-full pointer-events-none z-[100]",
|
|
20379
|
-
"data-testid": "selection-overlay",
|
|
20380
|
-
children: /* @__PURE__ */ jsx(
|
|
20381
|
-
"polygon",
|
|
20382
|
-
{
|
|
20383
|
-
points: selectionPoints.map(([lng, lat]) => {
|
|
20384
|
-
const point2 = map.current.project([lng, lat]);
|
|
20385
|
-
return `${point2.x},${point2.y}`;
|
|
20386
|
-
}).join(" "),
|
|
20387
|
-
fill: "rgba(59, 130, 246, 0.15)",
|
|
20388
|
-
stroke: "rgb(59, 130, 246)",
|
|
20389
|
-
strokeWidth: "2",
|
|
20390
|
-
strokeDasharray: "6,3"
|
|
20391
|
-
}
|
|
20392
|
-
)
|
|
20393
|
-
}
|
|
20394
|
-
),
|
|
20395
|
-
selectionMode === "polygon" && map.current && (selectionPoints.length >= 1 || selectionHoverPoint) && /* @__PURE__ */ jsxs(
|
|
20396
|
-
"svg",
|
|
20397
|
-
{
|
|
20398
|
-
className: "absolute inset-0 w-full h-full pointer-events-none z-[100]",
|
|
20399
|
-
"data-testid": "polygon-points-overlay",
|
|
20400
|
-
children: [
|
|
20401
|
-
selectionPoints.length >= 2 && selectionPoints.map(([lng, lat], i) => {
|
|
20402
|
-
if (i === 0) return null;
|
|
20403
|
-
const prevPoint = map.current.project([selectionPoints[i - 1][0], selectionPoints[i - 1][1]]);
|
|
20404
|
-
const currPoint = map.current.project([lng, lat]);
|
|
20405
|
-
return /* @__PURE__ */ jsx(
|
|
20406
|
-
"line",
|
|
20407
|
-
{
|
|
20408
|
-
x1: prevPoint.x,
|
|
20409
|
-
y1: prevPoint.y,
|
|
20410
|
-
x2: currPoint.x,
|
|
20411
|
-
y2: currPoint.y,
|
|
20412
|
-
stroke: "rgb(59, 130, 246)",
|
|
20413
|
-
strokeWidth: "2"
|
|
20414
|
-
},
|
|
20415
|
-
`line-${i}`
|
|
20416
|
-
);
|
|
20417
|
-
}),
|
|
20418
|
-
selectionPoints.length >= 1 && selectionHoverPoint && /* @__PURE__ */ jsx(
|
|
20419
|
-
"line",
|
|
20420
|
-
{
|
|
20421
|
-
x1: map.current.project([selectionPoints[selectionPoints.length - 1][0], selectionPoints[selectionPoints.length - 1][1]]).x,
|
|
20422
|
-
y1: map.current.project([selectionPoints[selectionPoints.length - 1][0], selectionPoints[selectionPoints.length - 1][1]]).y,
|
|
20423
|
-
x2: map.current.project(selectionHoverPoint).x,
|
|
20424
|
-
y2: map.current.project(selectionHoverPoint).y,
|
|
20425
|
-
stroke: "rgb(59, 130, 246)",
|
|
20426
|
-
strokeWidth: "2",
|
|
20427
|
-
strokeDasharray: "6,3"
|
|
20428
|
-
}
|
|
20429
|
-
),
|
|
20430
|
-
selectionPoints.length >= 3 && selectionHoverPoint && /* @__PURE__ */ jsx(
|
|
20431
|
-
"line",
|
|
20565
|
+
return /* @__PURE__ */ jsxs(MapLabelsContext.Provider, { value: labels, children: [
|
|
20566
|
+
/* @__PURE__ */ jsx(PopupPortal, { slot: tooltipSlot }),
|
|
20567
|
+
/* @__PURE__ */ jsx(PopupPortal, { slot: tracePopupSlot }),
|
|
20568
|
+
/* @__PURE__ */ jsx(TimelineStoreContext.Provider, { value: timelineStoreApi, children: /* @__PURE__ */ jsx(ToastContext.Provider, { value: toastContextValue, children: /* @__PURE__ */ jsx(MapDropZone, { onDrop: handleDropGeoJSON, onDropFile: handleDropGeoJSONFile, children: /* @__PURE__ */ jsxs("div", { className: `map-container w-full h-full min-w-0 relative overflow-hidden isolate ${className || ""}`, "data-testid": "map-editor-canvas", children: [
|
|
20569
|
+
/* @__PURE__ */ jsx(
|
|
20570
|
+
"div",
|
|
20571
|
+
{
|
|
20572
|
+
ref: mapContainer,
|
|
20573
|
+
className: `w-full h-full ${activeMode.startsWith("draw_") ? "cursor-crosshair" : ""}`,
|
|
20574
|
+
"data-testid": "map-canvas",
|
|
20575
|
+
tabIndex: enableKeyboardShortcuts ? 0 : void 0,
|
|
20576
|
+
style: { outline: "none" }
|
|
20577
|
+
}
|
|
20578
|
+
),
|
|
20579
|
+
filterSvgPoints && /* @__PURE__ */ jsx(
|
|
20580
|
+
"svg",
|
|
20581
|
+
{
|
|
20582
|
+
className: "absolute inset-0 w-full h-full pointer-events-none z-[10]",
|
|
20583
|
+
"data-testid": "filter-overlay",
|
|
20584
|
+
children: /* @__PURE__ */ jsx(
|
|
20585
|
+
"polygon",
|
|
20432
20586
|
{
|
|
20433
|
-
|
|
20434
|
-
|
|
20435
|
-
|
|
20436
|
-
|
|
20437
|
-
|
|
20438
|
-
strokeWidth: "2",
|
|
20587
|
+
ref: filterPolygonRef,
|
|
20588
|
+
points: filterSvgPoints,
|
|
20589
|
+
fill: "rgba(0, 0, 0, 0.03)",
|
|
20590
|
+
stroke: "#555",
|
|
20591
|
+
strokeWidth: "1.5",
|
|
20439
20592
|
strokeDasharray: "6,3",
|
|
20440
|
-
|
|
20441
|
-
}
|
|
20442
|
-
),
|
|
20443
|
-
selectionPoints.map(([lng, lat], i) => {
|
|
20444
|
-
const point2 = map.current.project([lng, lat]);
|
|
20445
|
-
return /* @__PURE__ */ jsx(
|
|
20446
|
-
"circle",
|
|
20447
|
-
{
|
|
20448
|
-
cx: point2.x,
|
|
20449
|
-
cy: point2.y,
|
|
20450
|
-
r: "5",
|
|
20451
|
-
fill: "rgb(59, 130, 246)",
|
|
20452
|
-
stroke: "white",
|
|
20453
|
-
strokeWidth: "2"
|
|
20454
|
-
},
|
|
20455
|
-
`point-${i}`
|
|
20456
|
-
);
|
|
20457
|
-
}),
|
|
20458
|
-
selectionHoverPoint && /* @__PURE__ */ jsx(
|
|
20459
|
-
"circle",
|
|
20460
|
-
{
|
|
20461
|
-
cx: map.current.project(selectionHoverPoint).x,
|
|
20462
|
-
cy: map.current.project(selectionHoverPoint).y,
|
|
20463
|
-
r: "4",
|
|
20464
|
-
fill: "rgba(59, 130, 246, 0.5)",
|
|
20465
|
-
stroke: "white",
|
|
20466
|
-
strokeWidth: "1"
|
|
20593
|
+
strokeOpacity: "0.6"
|
|
20467
20594
|
}
|
|
20468
20595
|
)
|
|
20469
|
-
|
|
20470
|
-
|
|
20471
|
-
|
|
20472
|
-
|
|
20473
|
-
|
|
20474
|
-
|
|
20475
|
-
|
|
20476
|
-
|
|
20477
|
-
children: /* @__PURE__ */ jsx(
|
|
20478
|
-
"polygon",
|
|
20479
|
-
{
|
|
20480
|
-
points: selectionPoints.map(([lng, lat]) => {
|
|
20481
|
-
const point2 = map.current.project([lng, lat]);
|
|
20482
|
-
return `${point2.x},${point2.y}`;
|
|
20483
|
-
}).join(" "),
|
|
20484
|
-
fill: "rgba(59, 130, 246, 0.15)",
|
|
20485
|
-
stroke: "rgb(59, 130, 246)",
|
|
20486
|
-
strokeWidth: "2",
|
|
20487
|
-
strokeDasharray: "6,3"
|
|
20488
|
-
}
|
|
20489
|
-
)
|
|
20490
|
-
}
|
|
20491
|
-
),
|
|
20492
|
-
activeMode === "draw_circle" && circleDrawPreview && circleDrawPreview.length >= 4 && map.current && /* @__PURE__ */ jsxs(
|
|
20493
|
-
"svg",
|
|
20494
|
-
{
|
|
20495
|
-
className: "absolute inset-0 w-full h-full pointer-events-none z-[100]",
|
|
20496
|
-
"data-testid": "circle-draw-preview",
|
|
20497
|
-
children: [
|
|
20498
|
-
/* @__PURE__ */ jsx(
|
|
20596
|
+
}
|
|
20597
|
+
),
|
|
20598
|
+
selectionPoints.length >= 4 && (selectionMode === "rectangle" || selectionMode === "click") && map.current && /* @__PURE__ */ jsx(
|
|
20599
|
+
"svg",
|
|
20600
|
+
{
|
|
20601
|
+
className: "absolute inset-0 w-full h-full pointer-events-none z-[100]",
|
|
20602
|
+
"data-testid": "selection-overlay",
|
|
20603
|
+
children: /* @__PURE__ */ jsx(
|
|
20499
20604
|
"polygon",
|
|
20500
20605
|
{
|
|
20501
|
-
points:
|
|
20606
|
+
points: selectionPoints.map(([lng, lat]) => {
|
|
20502
20607
|
const point2 = map.current.project([lng, lat]);
|
|
20503
20608
|
return `${point2.x},${point2.y}`;
|
|
20504
20609
|
}).join(" "),
|
|
20505
|
-
fill: "rgba(
|
|
20506
|
-
stroke: "rgb(
|
|
20610
|
+
fill: "rgba(59, 130, 246, 0.15)",
|
|
20611
|
+
stroke: "rgb(59, 130, 246)",
|
|
20507
20612
|
strokeWidth: "2",
|
|
20508
20613
|
strokeDasharray: "6,3"
|
|
20509
20614
|
}
|
|
20510
|
-
),
|
|
20511
|
-
circleDrawCenter && /* @__PURE__ */ jsx(
|
|
20512
|
-
"circle",
|
|
20513
|
-
{
|
|
20514
|
-
cx: map.current.project(circleDrawCenter).x,
|
|
20515
|
-
cy: map.current.project(circleDrawCenter).y,
|
|
20516
|
-
r: "6",
|
|
20517
|
-
fill: "rgb(34, 197, 94)",
|
|
20518
|
-
stroke: "white",
|
|
20519
|
-
strokeWidth: "2"
|
|
20520
|
-
}
|
|
20521
20615
|
)
|
|
20522
|
-
|
|
20523
|
-
|
|
20524
|
-
|
|
20525
|
-
|
|
20526
|
-
|
|
20527
|
-
|
|
20528
|
-
|
|
20529
|
-
|
|
20530
|
-
|
|
20531
|
-
|
|
20616
|
+
}
|
|
20617
|
+
),
|
|
20618
|
+
selectionMode === "polygon" && map.current && (selectionPoints.length >= 1 || selectionHoverPoint) && /* @__PURE__ */ jsxs(
|
|
20619
|
+
"svg",
|
|
20620
|
+
{
|
|
20621
|
+
className: "absolute inset-0 w-full h-full pointer-events-none z-[100]",
|
|
20622
|
+
"data-testid": "polygon-points-overlay",
|
|
20623
|
+
children: [
|
|
20624
|
+
selectionPoints.length >= 2 && selectionPoints.map(([lng, lat], i) => {
|
|
20625
|
+
if (i === 0) return null;
|
|
20626
|
+
const prevPoint = map.current.project([selectionPoints[i - 1][0], selectionPoints[i - 1][1]]);
|
|
20627
|
+
const currPoint = map.current.project([lng, lat]);
|
|
20628
|
+
return /* @__PURE__ */ jsx(
|
|
20629
|
+
"line",
|
|
20630
|
+
{
|
|
20631
|
+
x1: prevPoint.x,
|
|
20632
|
+
y1: prevPoint.y,
|
|
20633
|
+
x2: currPoint.x,
|
|
20634
|
+
y2: currPoint.y,
|
|
20635
|
+
stroke: "rgb(59, 130, 246)",
|
|
20636
|
+
strokeWidth: "2"
|
|
20637
|
+
},
|
|
20638
|
+
`line-${i}`
|
|
20639
|
+
);
|
|
20640
|
+
}),
|
|
20641
|
+
selectionPoints.length >= 1 && selectionHoverPoint && /* @__PURE__ */ jsx(
|
|
20642
|
+
"line",
|
|
20643
|
+
{
|
|
20644
|
+
x1: map.current.project([selectionPoints[selectionPoints.length - 1][0], selectionPoints[selectionPoints.length - 1][1]]).x,
|
|
20645
|
+
y1: map.current.project([selectionPoints[selectionPoints.length - 1][0], selectionPoints[selectionPoints.length - 1][1]]).y,
|
|
20646
|
+
x2: map.current.project(selectionHoverPoint).x,
|
|
20647
|
+
y2: map.current.project(selectionHoverPoint).y,
|
|
20648
|
+
stroke: "rgb(59, 130, 246)",
|
|
20649
|
+
strokeWidth: "2",
|
|
20650
|
+
strokeDasharray: "6,3"
|
|
20651
|
+
}
|
|
20652
|
+
),
|
|
20653
|
+
selectionPoints.length >= 3 && selectionHoverPoint && /* @__PURE__ */ jsx(
|
|
20654
|
+
"line",
|
|
20655
|
+
{
|
|
20656
|
+
x1: map.current.project(selectionHoverPoint).x,
|
|
20657
|
+
y1: map.current.project(selectionHoverPoint).y,
|
|
20658
|
+
x2: map.current.project([selectionPoints[0][0], selectionPoints[0][1]]).x,
|
|
20659
|
+
y2: map.current.project([selectionPoints[0][0], selectionPoints[0][1]]).y,
|
|
20660
|
+
stroke: "rgb(59, 130, 246)",
|
|
20661
|
+
strokeWidth: "2",
|
|
20662
|
+
strokeDasharray: "6,3",
|
|
20663
|
+
opacity: "0.5"
|
|
20664
|
+
}
|
|
20665
|
+
),
|
|
20666
|
+
selectionPoints.map(([lng, lat], i) => {
|
|
20667
|
+
const point2 = map.current.project([lng, lat]);
|
|
20668
|
+
return /* @__PURE__ */ jsx(
|
|
20669
|
+
"circle",
|
|
20670
|
+
{
|
|
20671
|
+
cx: point2.x,
|
|
20672
|
+
cy: point2.y,
|
|
20673
|
+
r: "5",
|
|
20674
|
+
fill: "rgb(59, 130, 246)",
|
|
20675
|
+
stroke: "white",
|
|
20676
|
+
strokeWidth: "2"
|
|
20677
|
+
},
|
|
20678
|
+
`point-${i}`
|
|
20679
|
+
);
|
|
20680
|
+
}),
|
|
20681
|
+
selectionHoverPoint && /* @__PURE__ */ jsx(
|
|
20682
|
+
"circle",
|
|
20683
|
+
{
|
|
20684
|
+
cx: map.current.project(selectionHoverPoint).x,
|
|
20685
|
+
cy: map.current.project(selectionHoverPoint).y,
|
|
20686
|
+
r: "4",
|
|
20687
|
+
fill: "rgba(59, 130, 246, 0.5)",
|
|
20688
|
+
stroke: "white",
|
|
20689
|
+
strokeWidth: "1"
|
|
20690
|
+
}
|
|
20691
|
+
)
|
|
20692
|
+
]
|
|
20693
|
+
}
|
|
20694
|
+
),
|
|
20695
|
+
selectionMode === "circle" && selectionPoints.length >= 4 && map.current && /* @__PURE__ */ jsx(
|
|
20696
|
+
"svg",
|
|
20697
|
+
{
|
|
20698
|
+
className: "absolute inset-0 w-full h-full pointer-events-none z-[100]",
|
|
20699
|
+
"data-testid": "circle-selection-overlay",
|
|
20700
|
+
children: /* @__PURE__ */ jsx(
|
|
20532
20701
|
"polygon",
|
|
20533
20702
|
{
|
|
20534
|
-
points:
|
|
20703
|
+
points: selectionPoints.map(([lng, lat]) => {
|
|
20535
20704
|
const point2 = map.current.project([lng, lat]);
|
|
20536
20705
|
return `${point2.x},${point2.y}`;
|
|
20537
20706
|
}).join(" "),
|
|
20538
|
-
fill: "rgba(
|
|
20539
|
-
stroke: "rgb(
|
|
20707
|
+
fill: "rgba(59, 130, 246, 0.15)",
|
|
20708
|
+
stroke: "rgb(59, 130, 246)",
|
|
20540
20709
|
strokeWidth: "2",
|
|
20541
20710
|
strokeDasharray: "6,3"
|
|
20542
20711
|
}
|
|
20543
|
-
),
|
|
20544
|
-
rectangleDrawCorner && /* @__PURE__ */ jsx(
|
|
20545
|
-
"circle",
|
|
20546
|
-
{
|
|
20547
|
-
cx: map.current.project(rectangleDrawCorner).x,
|
|
20548
|
-
cy: map.current.project(rectangleDrawCorner).y,
|
|
20549
|
-
r: "5",
|
|
20550
|
-
fill: "rgb(34, 197, 94)",
|
|
20551
|
-
stroke: "white",
|
|
20552
|
-
strokeWidth: "2"
|
|
20553
|
-
}
|
|
20554
20712
|
)
|
|
20555
|
-
|
|
20556
|
-
|
|
20557
|
-
|
|
20558
|
-
|
|
20559
|
-
|
|
20560
|
-
|
|
20561
|
-
|
|
20562
|
-
|
|
20563
|
-
|
|
20564
|
-
|
|
20565
|
-
|
|
20566
|
-
|
|
20567
|
-
|
|
20568
|
-
|
|
20569
|
-
|
|
20570
|
-
|
|
20571
|
-
|
|
20572
|
-
|
|
20573
|
-
|
|
20574
|
-
|
|
20575
|
-
|
|
20576
|
-
|
|
20577
|
-
|
|
20578
|
-
|
|
20579
|
-
|
|
20580
|
-
|
|
20581
|
-
|
|
20582
|
-
|
|
20583
|
-
|
|
20584
|
-
|
|
20585
|
-
|
|
20586
|
-
|
|
20587
|
-
|
|
20588
|
-
|
|
20589
|
-
|
|
20590
|
-
|
|
20591
|
-
|
|
20592
|
-
|
|
20593
|
-
|
|
20594
|
-
|
|
20595
|
-
|
|
20596
|
-
|
|
20597
|
-
|
|
20598
|
-
|
|
20599
|
-
|
|
20600
|
-
|
|
20601
|
-
|
|
20602
|
-
|
|
20603
|
-
|
|
20604
|
-
|
|
20605
|
-
|
|
20606
|
-
|
|
20607
|
-
|
|
20608
|
-
|
|
20609
|
-
|
|
20610
|
-
|
|
20611
|
-
|
|
20612
|
-
|
|
20613
|
-
|
|
20614
|
-
|
|
20615
|
-
|
|
20713
|
+
}
|
|
20714
|
+
),
|
|
20715
|
+
activeMode === "draw_circle" && circleDrawPreview && circleDrawPreview.length >= 4 && map.current && /* @__PURE__ */ jsxs(
|
|
20716
|
+
"svg",
|
|
20717
|
+
{
|
|
20718
|
+
className: "absolute inset-0 w-full h-full pointer-events-none z-[100]",
|
|
20719
|
+
"data-testid": "circle-draw-preview",
|
|
20720
|
+
children: [
|
|
20721
|
+
/* @__PURE__ */ jsx(
|
|
20722
|
+
"polygon",
|
|
20723
|
+
{
|
|
20724
|
+
points: circleDrawPreview.map(([lng, lat]) => {
|
|
20725
|
+
const point2 = map.current.project([lng, lat]);
|
|
20726
|
+
return `${point2.x},${point2.y}`;
|
|
20727
|
+
}).join(" "),
|
|
20728
|
+
fill: "rgba(34, 197, 94, 0.15)",
|
|
20729
|
+
stroke: "rgb(34, 197, 94)",
|
|
20730
|
+
strokeWidth: "2",
|
|
20731
|
+
strokeDasharray: "6,3"
|
|
20732
|
+
}
|
|
20733
|
+
),
|
|
20734
|
+
circleDrawCenter && /* @__PURE__ */ jsx(
|
|
20735
|
+
"circle",
|
|
20736
|
+
{
|
|
20737
|
+
cx: map.current.project(circleDrawCenter).x,
|
|
20738
|
+
cy: map.current.project(circleDrawCenter).y,
|
|
20739
|
+
r: "6",
|
|
20740
|
+
fill: "rgb(34, 197, 94)",
|
|
20741
|
+
stroke: "white",
|
|
20742
|
+
strokeWidth: "2"
|
|
20743
|
+
}
|
|
20744
|
+
)
|
|
20745
|
+
]
|
|
20746
|
+
}
|
|
20747
|
+
),
|
|
20748
|
+
activeMode === "draw_rectangle" && rectangleDrawPreview && rectangleDrawPreview.length >= 4 && map.current && /* @__PURE__ */ jsxs(
|
|
20749
|
+
"svg",
|
|
20750
|
+
{
|
|
20751
|
+
className: "absolute inset-0 w-full h-full pointer-events-none z-[100]",
|
|
20752
|
+
"data-testid": "rectangle-draw-preview",
|
|
20753
|
+
children: [
|
|
20754
|
+
/* @__PURE__ */ jsx(
|
|
20755
|
+
"polygon",
|
|
20756
|
+
{
|
|
20757
|
+
points: rectangleDrawPreview.map(([lng, lat]) => {
|
|
20758
|
+
const point2 = map.current.project([lng, lat]);
|
|
20759
|
+
return `${point2.x},${point2.y}`;
|
|
20760
|
+
}).join(" "),
|
|
20761
|
+
fill: "rgba(34, 197, 94, 0.15)",
|
|
20762
|
+
stroke: "rgb(34, 197, 94)",
|
|
20763
|
+
strokeWidth: "2",
|
|
20764
|
+
strokeDasharray: "6,3"
|
|
20765
|
+
}
|
|
20766
|
+
),
|
|
20767
|
+
rectangleDrawCorner && /* @__PURE__ */ jsx(
|
|
20768
|
+
"circle",
|
|
20769
|
+
{
|
|
20770
|
+
cx: map.current.project(rectangleDrawCorner).x,
|
|
20771
|
+
cy: map.current.project(rectangleDrawCorner).y,
|
|
20772
|
+
r: "5",
|
|
20773
|
+
fill: "rgb(34, 197, 94)",
|
|
20774
|
+
stroke: "white",
|
|
20775
|
+
strokeWidth: "2"
|
|
20776
|
+
}
|
|
20777
|
+
)
|
|
20778
|
+
]
|
|
20779
|
+
}
|
|
20780
|
+
),
|
|
20781
|
+
(enableDrawing || enableSelection) && /* @__PURE__ */ jsx(
|
|
20782
|
+
DrawingToolbar,
|
|
20783
|
+
{
|
|
20784
|
+
activeMode,
|
|
20785
|
+
onModeChange: handleModeChange,
|
|
20786
|
+
onClear: handleClear,
|
|
20787
|
+
onDeleteSelected: handleDeleteSelected,
|
|
20788
|
+
onUndo: history.undo,
|
|
20789
|
+
onRedo: history.redo,
|
|
20790
|
+
featureCount,
|
|
20791
|
+
selectedCount: selectedFeatureIds.length,
|
|
20792
|
+
canDeleteSelected,
|
|
20793
|
+
canUndo: history.canUndo,
|
|
20794
|
+
canRedo: history.canRedo,
|
|
20795
|
+
showUndoRedo: true,
|
|
20796
|
+
disabled: !isMapLoaded,
|
|
20797
|
+
isEditMode,
|
|
20798
|
+
onToggleEditMode: handleToggleEditMode,
|
|
20799
|
+
hasVisibleLayers,
|
|
20800
|
+
hasEditableLayer,
|
|
20801
|
+
measureMode,
|
|
20802
|
+
onMeasureModeChange: handleMeasureModeChange,
|
|
20803
|
+
selectionMode,
|
|
20804
|
+
onSelectionModeChange: handleSelectionModeChange,
|
|
20805
|
+
isSelectionToolActive,
|
|
20806
|
+
onSelectionToolActiveChange: setIsSelectionToolActive,
|
|
20807
|
+
enableMeasurement,
|
|
20808
|
+
enableSelection,
|
|
20809
|
+
hiddenDrawingTools,
|
|
20810
|
+
hiddenSelectionTools,
|
|
20811
|
+
expandSelectionTools,
|
|
20812
|
+
showFilterTool,
|
|
20813
|
+
selectionOnly: !enableDrawing && enableSelection,
|
|
20814
|
+
showShortcutHints: enableKeyboardShortcuts,
|
|
20815
|
+
onGoTo: (coords, zoom) => {
|
|
20816
|
+
if (map.current) {
|
|
20817
|
+
const currentZoom = map.current.getZoom();
|
|
20818
|
+
map.current.flyTo({ center: coords, zoom: zoom ?? Math.max(currentZoom, 20), duration: 2e3 });
|
|
20819
|
+
}
|
|
20820
|
+
},
|
|
20821
|
+
showClearFilter,
|
|
20822
|
+
onClearFilter,
|
|
20823
|
+
onFilterActiveChange: (active) => {
|
|
20824
|
+
filterActiveRef.current = active;
|
|
20825
|
+
},
|
|
20826
|
+
onFitToFeatures: handleFitToFeatures,
|
|
20827
|
+
onDropPoint,
|
|
20828
|
+
geocoder: endpoints == null ? void 0 : endpoints.geocoder,
|
|
20829
|
+
onSearchEngineRequest: onSearchEngineRequest ? handleSearchAndAddToNewLayer : void 0,
|
|
20830
|
+
getAllFeatures,
|
|
20831
|
+
onFlyToFeature: (feature) => {
|
|
20832
|
+
if (!map.current) return;
|
|
20616
20833
|
try {
|
|
20617
|
-
const
|
|
20618
|
-
|
|
20619
|
-
|
|
20620
|
-
|
|
20834
|
+
const center = turf.center(feature);
|
|
20835
|
+
const [lng, lat] = center.geometry.coordinates;
|
|
20836
|
+
const currentZoom = map.current.getZoom();
|
|
20837
|
+
map.current.flyTo({ center: [lng, lat], zoom: Math.max(currentZoom, 14), duration: 1500 });
|
|
20838
|
+
} catch {
|
|
20839
|
+
try {
|
|
20840
|
+
const bbox = turf.bbox(feature);
|
|
20841
|
+
map.current.fitBounds([[bbox[0], bbox[1]], [bbox[2], bbox[3]]], { padding: 80, maxZoom: 16, duration: 1500 });
|
|
20842
|
+
} catch (e) {
|
|
20843
|
+
console.error("Could not fly to feature", e);
|
|
20844
|
+
}
|
|
20621
20845
|
}
|
|
20622
20846
|
}
|
|
20623
20847
|
}
|
|
20624
|
-
|
|
20625
|
-
|
|
20626
|
-
|
|
20627
|
-
|
|
20628
|
-
|
|
20629
|
-
|
|
20630
|
-
|
|
20631
|
-
|
|
20632
|
-
|
|
20633
|
-
|
|
20634
|
-
|
|
20635
|
-
|
|
20636
|
-
|
|
20637
|
-
|
|
20638
|
-
|
|
20639
|
-
|
|
20640
|
-
|
|
20641
|
-
|
|
20642
|
-
|
|
20643
|
-
|
|
20848
|
+
),
|
|
20849
|
+
enableMeasurement && measureMode !== "none" && /* @__PURE__ */ jsx(
|
|
20850
|
+
"div",
|
|
20851
|
+
{
|
|
20852
|
+
className: "absolute top-4 left-16 z-10 bg-background/90 floating-panel rounded-lg shadow-lg border border-border px-4 py-2",
|
|
20853
|
+
"data-testid": "measure-result-panel",
|
|
20854
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
20855
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: measureMode === "distance" ? labels.canvas.measureDistance : labels.canvas.measureArea }),
|
|
20856
|
+
/* @__PURE__ */ jsx("span", { className: "font-mono text-sm font-medium", "data-testid": "text-measure-result", children: measureResult || (measureMode === "distance" ? labels.canvas.measureDistanceHint : labels.canvas.measureAreaHint) }),
|
|
20857
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: labels.canvas.measureClearHint })
|
|
20858
|
+
] })
|
|
20859
|
+
}
|
|
20860
|
+
),
|
|
20861
|
+
enableTimeline && (timelineHasData || timelineFields || keepTimebarExtra) && /* @__PURE__ */ jsx(
|
|
20862
|
+
"div",
|
|
20863
|
+
{
|
|
20864
|
+
className: "absolute left-4 z-[200] transition-all",
|
|
20865
|
+
style: { bottom: timelineEnabled ? timebarHeight + TIMEBAR_BOTTOM_OFFSET + 8 : 48 },
|
|
20866
|
+
children: /* @__PURE__ */ jsx(Tooltip, { title: labels.canvas.timelineToggle, placement: "right", children: /* @__PURE__ */ jsx(
|
|
20867
|
+
Button,
|
|
20868
|
+
{
|
|
20869
|
+
type: "default",
|
|
20870
|
+
icon: /* @__PURE__ */ jsx(Clock, { className: "w-5 h-5" }),
|
|
20871
|
+
onClick: () => timelineStoreApi.getState().setEnabled(!timelineEnabled),
|
|
20872
|
+
disabled: !isMapLoaded,
|
|
20873
|
+
className: `!w-10 !h-10 !min-w-0 !p-0 bg-background shadow-lg ${timelineEnabled ? "bg-primary/10" : ""}`,
|
|
20874
|
+
"aria-label": labels.timebar.toggle,
|
|
20875
|
+
"aria-pressed": timelineEnabled,
|
|
20876
|
+
"data-testid": "button-toggle-timeline"
|
|
20877
|
+
}
|
|
20878
|
+
) })
|
|
20879
|
+
}
|
|
20880
|
+
),
|
|
20881
|
+
enableLayers && /* @__PURE__ */ jsxs("div", { className: "absolute top-4 right-4 z-[200] flex items-center gap-2", children: [
|
|
20882
|
+
getMapUnsavedCount() > 0 && /* @__PURE__ */ jsx(
|
|
20883
|
+
"div",
|
|
20884
|
+
{
|
|
20885
|
+
className: "px-2 py-1 bg-orange-500 text-white text-xs font-medium rounded-md shadow-lg",
|
|
20886
|
+
"data-testid": "badge-unsaved-count",
|
|
20887
|
+
children: labels.canvas.unsavedCount(getMapUnsavedCount())
|
|
20888
|
+
}
|
|
20889
|
+
),
|
|
20890
|
+
/* @__PURE__ */ jsx(Tooltip, { title: labels.canvas.layersToggle, placement: "left", children: /* @__PURE__ */ jsx(
|
|
20644
20891
|
Button,
|
|
20645
20892
|
{
|
|
20646
20893
|
type: "default",
|
|
20647
|
-
icon: /* @__PURE__ */ jsx(
|
|
20648
|
-
onClick:
|
|
20894
|
+
icon: /* @__PURE__ */ jsx(Layers, { className: "w-6 h-6" }),
|
|
20895
|
+
onClick: handleToggleLayers,
|
|
20649
20896
|
disabled: !isMapLoaded,
|
|
20650
|
-
className: `!w-
|
|
20651
|
-
"aria-label": labels.
|
|
20652
|
-
"aria-pressed":
|
|
20653
|
-
"data-testid": "button-toggle-
|
|
20897
|
+
className: `!w-[46px] !h-[46px] !min-w-0 !p-0 !rounded-lg floating-panel !border !border-border shadow-[0_2px_8px_rgba(0,0,0,0.12)] ${showLayers ? "tool-active !bg-primary/10" : "!bg-background/80"}`,
|
|
20898
|
+
"aria-label": labels.canvas.layersToggleAriaLabel,
|
|
20899
|
+
"aria-pressed": showLayers,
|
|
20900
|
+
"data-testid": "button-toggle-layers"
|
|
20654
20901
|
}
|
|
20655
20902
|
) })
|
|
20656
|
-
}
|
|
20657
|
-
|
|
20658
|
-
|
|
20659
|
-
getMapUnsavedCount() > 0 && /* @__PURE__ */ jsx(
|
|
20660
|
-
"div",
|
|
20903
|
+
] }),
|
|
20904
|
+
enableLayers && showLayers && /* @__PURE__ */ jsx(
|
|
20905
|
+
LayersPanel,
|
|
20661
20906
|
{
|
|
20662
|
-
|
|
20663
|
-
|
|
20664
|
-
|
|
20907
|
+
layers,
|
|
20908
|
+
onAddLayer: handleAddLayer,
|
|
20909
|
+
onRemoveLayer: handleRemoveLayer,
|
|
20910
|
+
onRenameLayer: handleRenameLayer,
|
|
20911
|
+
onToggleLayerVisibility: handleToggleLayerVisibility,
|
|
20912
|
+
onMoveFeatureToLayer: handleMoveFeatureToLayer,
|
|
20913
|
+
selectedFeatureIds,
|
|
20914
|
+
getFeatureCount: getFeatureCountForLayer,
|
|
20915
|
+
getLayerUnsavedCount,
|
|
20916
|
+
getMapUnsavedCount,
|
|
20917
|
+
activeEditingLayerId,
|
|
20918
|
+
onSetActiveEditingLayer: setActiveEditingLayerId,
|
|
20919
|
+
onSaveLayerGeoJSON: handleSaveLayerGeoJSON,
|
|
20920
|
+
onLoadLayerGeoJSON: handleLoadLayerGeoJSON,
|
|
20921
|
+
onLoadNewLayerGeoJSON: handleLoadNewLayerGeoJSON,
|
|
20922
|
+
onSaveAllGeoJSON: handleSaveAllGeoJSON,
|
|
20923
|
+
onSearchAndAddToNewLayer: onSearchEngineRequest ? handleSearchAndAddToNewLayer : void 0,
|
|
20924
|
+
onWorkspaceLoad: onWorkspaceLoad ? handleWorkspaceLoad : void 0,
|
|
20925
|
+
onWorkspaceSave: onWorkspaceSave ? handleWorkspaceSave : void 0,
|
|
20926
|
+
onFitToFeatures: handleFitToFeatures,
|
|
20927
|
+
currentMapStyle,
|
|
20928
|
+
onMapStyleChange: handleMapStyleChange,
|
|
20929
|
+
onUpdateTraceConfig: handleUpdateTraceConfig,
|
|
20930
|
+
getAvailableTraceFields,
|
|
20931
|
+
getSuggestedTraceField,
|
|
20932
|
+
getFieldValueDistribution,
|
|
20933
|
+
getClusterPieCategories,
|
|
20934
|
+
iconSuggestionProvider,
|
|
20935
|
+
onUpdateHeatmapConfig: handleUpdateHeatmapConfig,
|
|
20936
|
+
onUpdateClusterConfig: handleUpdateClusterConfig,
|
|
20937
|
+
hasPointFeatures,
|
|
20938
|
+
onUpdateVisualConfig: handleUpdateVisualConfig,
|
|
20939
|
+
getLayerFields,
|
|
20940
|
+
onFitToLayerFeatures: handleFitToLayerFeatures,
|
|
20941
|
+
autoLabelConfig,
|
|
20942
|
+
onUpdateAutoLabelConfig: handleUpdateAutoLabelConfig,
|
|
20943
|
+
visibleFeatureCount,
|
|
20944
|
+
is3DTerrainEnabled,
|
|
20945
|
+
onToggle3DTerrain: handleToggle3DTerrain,
|
|
20946
|
+
onUpdateAltitudeDisplayMode: handleUpdateAltitudeDisplayMode,
|
|
20947
|
+
availableBasemaps,
|
|
20948
|
+
hideSatellite: !resolvedEndpoints.satellite,
|
|
20949
|
+
hideDark: !resolvedEndpoints.vectorStyles.dark,
|
|
20950
|
+
hideTerrain: !resolvedEndpoints.terrain,
|
|
20951
|
+
hideBasemapSwitcher,
|
|
20952
|
+
externalPersistence,
|
|
20953
|
+
customGlobalMenuItems,
|
|
20954
|
+
extraLayerToolbarButtons,
|
|
20955
|
+
extraNewLayerButtons,
|
|
20956
|
+
layerBadgeProvider,
|
|
20957
|
+
featureCountProvider
|
|
20665
20958
|
}
|
|
20666
20959
|
),
|
|
20667
|
-
|
|
20668
|
-
|
|
20960
|
+
showProperties && selectedFeatures.length > 0 && (() => {
|
|
20961
|
+
var _a, _b;
|
|
20962
|
+
const firstFeatureId = (_a = selectedFeatures[0]) == null ? void 0 : _a.id;
|
|
20963
|
+
const featureLayer = layers.find((l) => l.featureIds.includes(firstFeatureId));
|
|
20964
|
+
const layerName = featureLayer == null ? void 0 : featureLayer.name;
|
|
20965
|
+
const layerId = featureLayer == null ? void 0 : featureLayer.id;
|
|
20966
|
+
const isLayerReadOnly = (featureLayer == null ? void 0 : featureLayer.readOnly) === true;
|
|
20967
|
+
return /* @__PURE__ */ jsx(
|
|
20968
|
+
PropertiesPanel,
|
|
20969
|
+
{
|
|
20970
|
+
selectedFeatures: selectedFeatures.map((f) => ({
|
|
20971
|
+
id: f.id,
|
|
20972
|
+
type: f.type,
|
|
20973
|
+
properties: f.properties || {},
|
|
20974
|
+
geometry: f.geometry
|
|
20975
|
+
})),
|
|
20976
|
+
onUpdateProperties: handleUpdateProperties,
|
|
20977
|
+
onUpdateGeometry: handleUpdateGeometry,
|
|
20978
|
+
onClose: handleCloseProperties,
|
|
20979
|
+
isEditMode,
|
|
20980
|
+
isReadOnlyLayer: isLayerReadOnly,
|
|
20981
|
+
layerName,
|
|
20982
|
+
layerId,
|
|
20983
|
+
autoFocusLabel,
|
|
20984
|
+
entityCardProvider,
|
|
20985
|
+
entityCardPlacement,
|
|
20986
|
+
inlineEntityCardLabel,
|
|
20987
|
+
typePickerProvider,
|
|
20988
|
+
featureSaveProvider,
|
|
20989
|
+
featureRefreshProvider,
|
|
20990
|
+
onFeatureSaved: handleFeatureSaved,
|
|
20991
|
+
onDeleteFeatures: () => handleDeleteSelected(),
|
|
20992
|
+
onOpenInNewTab,
|
|
20993
|
+
onEntityContextMenu,
|
|
20994
|
+
layers: layers.map((l) => ({ id: l.id, name: l.name, readOnly: l.readOnly })),
|
|
20995
|
+
onMoveFeaturesToLayer: handleMoveFeaturesToLayer,
|
|
20996
|
+
onCopyFeaturesToLayer: handleCopyFeaturesToLayer,
|
|
20997
|
+
onCreateLayerAndMoveFeatures: handleCreateLayerAndMoveFeatures,
|
|
20998
|
+
onCreateLayerAndCopyFeatures: handleCreateLayerAndCopyFeatures,
|
|
20999
|
+
getFeatureColor: (featureId) => selectedFeatureColors.get(featureId),
|
|
21000
|
+
anchorEl: isMapLoaded ? ((_b = map.current) == null ? void 0 : _b.getContainer()) ?? null : null,
|
|
21001
|
+
stack: selectionStack && selectionStackPosition >= 0 ? { position: selectionStackPosition, count: selectionStack.ids.length, more: selectionStack.more, onStep: stepSelectionStack } : void 0
|
|
21002
|
+
}
|
|
21003
|
+
);
|
|
21004
|
+
})(),
|
|
21005
|
+
showStatusPanel && /* @__PURE__ */ jsx(
|
|
21006
|
+
StatusIndicator,
|
|
20669
21007
|
{
|
|
20670
|
-
|
|
20671
|
-
|
|
20672
|
-
|
|
20673
|
-
|
|
20674
|
-
className: `!w-[46px] !h-[46px] !min-w-0 !p-0 !rounded-lg floating-panel !border !border-border shadow-[0_2px_8px_rgba(0,0,0,0.12)] ${showLayers ? "tool-active !bg-primary/10" : "!bg-background/80"}`,
|
|
20675
|
-
"aria-label": labels.canvas.layersToggleAriaLabel,
|
|
20676
|
-
"aria-pressed": showLayers,
|
|
20677
|
-
"data-testid": "button-toggle-layers"
|
|
21008
|
+
activeMode,
|
|
21009
|
+
featureCount,
|
|
21010
|
+
selectedCount: selectedFeatureIds.length,
|
|
21011
|
+
selectionMode
|
|
20678
21012
|
}
|
|
20679
|
-
)
|
|
20680
|
-
|
|
20681
|
-
|
|
20682
|
-
LayersPanel,
|
|
20683
|
-
{
|
|
20684
|
-
layers,
|
|
20685
|
-
onAddLayer: handleAddLayer,
|
|
20686
|
-
onRemoveLayer: handleRemoveLayer,
|
|
20687
|
-
onRenameLayer: handleRenameLayer,
|
|
20688
|
-
onToggleLayerVisibility: handleToggleLayerVisibility,
|
|
20689
|
-
onMoveFeatureToLayer: handleMoveFeatureToLayer,
|
|
20690
|
-
selectedFeatureIds,
|
|
20691
|
-
getFeatureCount: getFeatureCountForLayer,
|
|
20692
|
-
getLayerUnsavedCount,
|
|
20693
|
-
getMapUnsavedCount,
|
|
20694
|
-
activeEditingLayerId,
|
|
20695
|
-
onSetActiveEditingLayer: setActiveEditingLayerId,
|
|
20696
|
-
onSaveLayerGeoJSON: handleSaveLayerGeoJSON,
|
|
20697
|
-
onLoadLayerGeoJSON: handleLoadLayerGeoJSON,
|
|
20698
|
-
onLoadNewLayerGeoJSON: handleLoadNewLayerGeoJSON,
|
|
20699
|
-
onSaveAllGeoJSON: handleSaveAllGeoJSON,
|
|
20700
|
-
onSearchAndAddToNewLayer: onSearchEngineRequest ? handleSearchAndAddToNewLayer : void 0,
|
|
20701
|
-
onWorkspaceLoad: onWorkspaceLoad ? handleWorkspaceLoad : void 0,
|
|
20702
|
-
onWorkspaceSave: onWorkspaceSave ? handleWorkspaceSave : void 0,
|
|
20703
|
-
onFitToFeatures: handleFitToFeatures,
|
|
20704
|
-
currentMapStyle,
|
|
20705
|
-
onMapStyleChange: handleMapStyleChange,
|
|
20706
|
-
onUpdateTraceConfig: handleUpdateTraceConfig,
|
|
20707
|
-
getAvailableTraceFields,
|
|
20708
|
-
getSuggestedTraceField,
|
|
20709
|
-
getFieldValueDistribution,
|
|
20710
|
-
iconSuggestionProvider,
|
|
20711
|
-
onUpdateHeatmapConfig: handleUpdateHeatmapConfig,
|
|
20712
|
-
onUpdateClusterConfig: handleUpdateClusterConfig,
|
|
20713
|
-
hasPointFeatures,
|
|
20714
|
-
onUpdateVisualConfig: handleUpdateVisualConfig,
|
|
20715
|
-
getLayerFields,
|
|
20716
|
-
onFitToLayerFeatures: handleFitToLayerFeatures,
|
|
20717
|
-
autoLabelConfig,
|
|
20718
|
-
onUpdateAutoLabelConfig: handleUpdateAutoLabelConfig,
|
|
20719
|
-
visibleFeatureCount,
|
|
20720
|
-
is3DTerrainEnabled,
|
|
20721
|
-
onToggle3DTerrain: handleToggle3DTerrain,
|
|
20722
|
-
onUpdateAltitudeDisplayMode: handleUpdateAltitudeDisplayMode,
|
|
20723
|
-
availableBasemaps,
|
|
20724
|
-
hideSatellite: !resolvedEndpoints.satellite,
|
|
20725
|
-
hideDark: !resolvedEndpoints.vectorStyles.dark,
|
|
20726
|
-
hideTerrain: !resolvedEndpoints.terrain,
|
|
20727
|
-
hideBasemapSwitcher,
|
|
20728
|
-
externalPersistence,
|
|
20729
|
-
customGlobalMenuItems,
|
|
20730
|
-
extraLayerToolbarButtons,
|
|
20731
|
-
extraNewLayerButtons,
|
|
20732
|
-
layerBadgeProvider,
|
|
20733
|
-
featureCountProvider
|
|
20734
|
-
}
|
|
20735
|
-
),
|
|
20736
|
-
showProperties && selectedFeatures.length > 0 && (() => {
|
|
20737
|
-
var _a, _b;
|
|
20738
|
-
const firstFeatureId = (_a = selectedFeatures[0]) == null ? void 0 : _a.id;
|
|
20739
|
-
const featureLayer = layers.find((l) => l.featureIds.includes(firstFeatureId));
|
|
20740
|
-
const layerName = featureLayer == null ? void 0 : featureLayer.name;
|
|
20741
|
-
const layerId = featureLayer == null ? void 0 : featureLayer.id;
|
|
20742
|
-
const isLayerReadOnly = (featureLayer == null ? void 0 : featureLayer.readOnly) === true;
|
|
20743
|
-
return /* @__PURE__ */ jsx(
|
|
20744
|
-
PropertiesPanel,
|
|
21013
|
+
),
|
|
21014
|
+
enableTimeline && timelineEnabled && /* @__PURE__ */ jsx(
|
|
21015
|
+
Timebar,
|
|
20745
21016
|
{
|
|
20746
|
-
|
|
20747
|
-
|
|
20748
|
-
|
|
20749
|
-
|
|
20750
|
-
|
|
20751
|
-
})),
|
|
20752
|
-
onUpdateProperties: handleUpdateProperties,
|
|
20753
|
-
onUpdateGeometry: handleUpdateGeometry,
|
|
20754
|
-
onClose: handleCloseProperties,
|
|
20755
|
-
isEditMode,
|
|
20756
|
-
isReadOnlyLayer: isLayerReadOnly,
|
|
20757
|
-
layerName,
|
|
20758
|
-
layerId,
|
|
20759
|
-
autoFocusLabel,
|
|
20760
|
-
entityCardProvider,
|
|
20761
|
-
entityCardPlacement,
|
|
20762
|
-
inlineEntityCardLabel,
|
|
20763
|
-
typePickerProvider,
|
|
20764
|
-
featureSaveProvider,
|
|
20765
|
-
featureRefreshProvider,
|
|
20766
|
-
onFeatureSaved: handleFeatureSaved,
|
|
20767
|
-
onDeleteFeatures: () => handleDeleteSelected(),
|
|
20768
|
-
onOpenInNewTab,
|
|
20769
|
-
onEntityContextMenu,
|
|
20770
|
-
layers: layers.map((l) => ({ id: l.id, name: l.name, readOnly: l.readOnly })),
|
|
20771
|
-
onMoveFeaturesToLayer: handleMoveFeaturesToLayer,
|
|
20772
|
-
onCopyFeaturesToLayer: handleCopyFeaturesToLayer,
|
|
20773
|
-
onCreateLayerAndMoveFeatures: handleCreateLayerAndMoveFeatures,
|
|
20774
|
-
onCreateLayerAndCopyFeatures: handleCreateLayerAndCopyFeatures,
|
|
20775
|
-
getFeatureColor: (featureId) => selectedFeatureColors.get(featureId),
|
|
20776
|
-
anchorEl: isMapLoaded ? ((_b = map.current) == null ? void 0 : _b.getContainer()) ?? null : null,
|
|
20777
|
-
stack: selectionStack && selectionStackPosition >= 0 ? { position: selectionStackPosition, count: selectionStack.ids.length, more: selectionStack.more, onStep: stepSelectionStack } : void 0
|
|
21017
|
+
selectedFeatureIds,
|
|
21018
|
+
selectedFeatureColors,
|
|
21019
|
+
selectionDisplay: "line",
|
|
21020
|
+
timebarExtra,
|
|
21021
|
+
keepExtraWhenEmpty: !!timelineFields || keepTimebarExtra
|
|
20778
21022
|
}
|
|
20779
|
-
)
|
|
20780
|
-
|
|
20781
|
-
|
|
20782
|
-
|
|
20783
|
-
|
|
20784
|
-
|
|
20785
|
-
|
|
20786
|
-
|
|
20787
|
-
|
|
20788
|
-
|
|
20789
|
-
|
|
20790
|
-
|
|
20791
|
-
|
|
20792
|
-
|
|
20793
|
-
|
|
20794
|
-
|
|
20795
|
-
|
|
20796
|
-
|
|
20797
|
-
|
|
20798
|
-
|
|
20799
|
-
|
|
20800
|
-
|
|
20801
|
-
|
|
20802
|
-
|
|
20803
|
-
|
|
20804
|
-
|
|
20805
|
-
|
|
20806
|
-
|
|
20807
|
-
|
|
20808
|
-
)
|
|
20809
|
-
|
|
20810
|
-
/* @__PURE__ */ jsx(
|
|
20811
|
-
IngestProgressOverlay,
|
|
20812
|
-
{
|
|
20813
|
-
store: ingestProgressStore,
|
|
20814
|
-
bottomPx: timelineEnabled ? timebarHeight + TIMEBAR_BOTTOM_OFFSET + 8 : 32
|
|
20815
|
-
}
|
|
20816
|
-
),
|
|
20817
|
-
/* @__PURE__ */ jsx(
|
|
20818
|
-
"input",
|
|
20819
|
-
{
|
|
20820
|
-
ref: fileInputRef,
|
|
20821
|
-
type: "file",
|
|
20822
|
-
accept: ".geojson,.json",
|
|
20823
|
-
onChange: handleFileChange,
|
|
20824
|
-
className: "hidden",
|
|
20825
|
-
"data-testid": "input-file-geojson"
|
|
20826
|
-
}
|
|
20827
|
-
)
|
|
20828
|
-
] }) }) }) }) });
|
|
21023
|
+
),
|
|
21024
|
+
contextMenu && /* @__PURE__ */ jsx(
|
|
21025
|
+
MapContextMenu,
|
|
21026
|
+
{
|
|
21027
|
+
x: contextMenu.x,
|
|
21028
|
+
y: contextMenu.y,
|
|
21029
|
+
items: contextMenu.items,
|
|
21030
|
+
onClose: () => setContextMenu(null)
|
|
21031
|
+
}
|
|
21032
|
+
),
|
|
21033
|
+
/* @__PURE__ */ jsx(CursorCoordinatesOverlay, { map: isMapLoaded ? map.current : null }),
|
|
21034
|
+
/* @__PURE__ */ jsx(
|
|
21035
|
+
IngestProgressOverlay,
|
|
21036
|
+
{
|
|
21037
|
+
store: ingestProgressStore,
|
|
21038
|
+
bottomPx: timelineEnabled ? timebarHeight + TIMEBAR_BOTTOM_OFFSET + 8 : 32
|
|
21039
|
+
}
|
|
21040
|
+
),
|
|
21041
|
+
/* @__PURE__ */ jsx(
|
|
21042
|
+
"input",
|
|
21043
|
+
{
|
|
21044
|
+
ref: fileInputRef,
|
|
21045
|
+
type: "file",
|
|
21046
|
+
accept: ".geojson,.json",
|
|
21047
|
+
onChange: handleFileChange,
|
|
21048
|
+
className: "hidden",
|
|
21049
|
+
"data-testid": "input-file-geojson"
|
|
21050
|
+
}
|
|
21051
|
+
)
|
|
21052
|
+
] }) }) }) })
|
|
21053
|
+
] });
|
|
20829
21054
|
});
|
|
20830
21055
|
function ActionPanel({ onSave, onLoad, disabled }) {
|
|
20831
21056
|
const { actionPanel: labels } = useMapLabels();
|