@octostar/map-component 0.11.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/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";
@@ -3874,7 +3874,7 @@ function CursorCoordinatesOverlay({ map }) {
3874
3874
  );
3875
3875
  }
3876
3876
  const NO_IMPORTS = Object.freeze([]);
3877
- const getServerSnapshot = () => NO_IMPORTS;
3877
+ const getServerSnapshot$1 = () => NO_IMPORTS;
3878
3878
  function describeActivity(entry, labels) {
3879
3879
  switch (entry.activity) {
3880
3880
  case "rendering":
@@ -3890,7 +3890,7 @@ function IngestProgressOverlay({
3890
3890
  bottomPx
3891
3891
  }) {
3892
3892
  const { ingest: labels } = useMapLabels();
3893
- const entries = useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot);
3893
+ const entries = useSyncExternalStore(store.subscribe, store.getSnapshot, getServerSnapshot$1);
3894
3894
  if (entries.length === 0) return null;
3895
3895
  return /* @__PURE__ */ jsx(
3896
3896
  "div",
@@ -3921,6 +3921,143 @@ function IngestProgressOverlay({
3921
3921
  }
3922
3922
  );
3923
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
+ }
3924
4061
  const EMOJI_GROUPS = ["smileys", "people", "nature", "food", "travel", "activities", "objects", "symbols"];
3925
4062
  const EMOJI_LIST = {
3926
4063
  smileys: [
@@ -13437,6 +13574,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
13437
13574
  const hiddenFeatures = useRef(/* @__PURE__ */ new Map());
13438
13575
  const tracePopupRef = useRef(null);
13439
13576
  const tooltipElRef = useRef(null);
13577
+ const [tooltipSlot] = useState(createPopupSlot);
13578
+ const [tracePopupSlot] = useState(createPopupSlot);
13440
13579
  const layersRef = useRef([
13441
13580
  { id: DEFAULT_LAYER_ID, name: DEFAULT_LAYER_NAME, visible: true, featureIds: [] }
13442
13581
  ]);
@@ -15062,6 +15201,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
15062
15201
  tooltipEl2.style.cssText = "position:fixed;z-index:1000;pointer-events:auto;display:none;max-width:480px;box-sizing:border-box;";
15063
15202
  document.body.appendChild(tooltipEl2);
15064
15203
  tooltipElRef.current = tooltipEl2;
15204
+ const tracePopupContentEl = document.createElement("div");
15065
15205
  let tooltipLngLat = null;
15066
15206
  let tooltipHideTimeout = null;
15067
15207
  let tooltipShowTimeout = null;
@@ -15095,9 +15235,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
15095
15235
  tooltipEl2.style.left = left + "px";
15096
15236
  tooltipEl2.style.top = top + "px";
15097
15237
  };
15098
- const showTooltip2 = (lngLat, html) => {
15099
- tooltipEl2.innerHTML = html;
15238
+ const showTooltip2 = (lngLat, content) => {
15100
15239
  tooltipEl2.style.display = "block";
15240
+ tooltipSlot.render(tooltipEl2, content);
15101
15241
  tooltipLngLat = lngLat;
15102
15242
  requestAnimationFrame(() => positionTooltip());
15103
15243
  };
@@ -15107,6 +15247,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
15107
15247
  tooltipShowTimeout = null;
15108
15248
  }
15109
15249
  tooltipEl2.style.display = "none";
15250
+ tooltipSlot.render(tooltipEl2, null);
15110
15251
  tooltipEl2.style.minWidth = "";
15111
15252
  tooltipEl2.style.minHeight = "";
15112
15253
  tooltipLngLat = null;
@@ -15159,67 +15300,46 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
15159
15300
  }
15160
15301
  });
15161
15302
  const hoverHandlersByLayer = /* @__PURE__ */ new Map();
15162
- const buildBuiltinTooltipHtml = (feature) => {
15163
- var _a2, _b2;
15164
- const props = feature.properties || {};
15165
- const featureId = String(feature.id ?? props.id ?? "");
15166
- const currentLayers = layersRef.current;
15167
- const featureLayer = currentLayers.find((l) => l.featureIds.includes(featureId));
15168
- 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;
15169
15307
  const highlightFields = /* @__PURE__ */ new Set();
15170
- if (((_a2 = visualConfig == null ? void 0 : visualConfig.size) == null ? void 0 : _a2.mode) === "field" && visualConfig.size.fieldName) highlightFields.add(visualConfig.size.fieldName);
15171
- if (((_b2 = visualConfig == null ? void 0 : visualConfig.color) == null ? void 0 : _b2.mode) === "field" && visualConfig.color.fieldName) highlightFields.add(visualConfig.color.fieldName);
15172
- const displayProps = Object.entries(props).filter(([key, value]) => !isInternalProperty(key) && !key.startsWith("_") && value != null && value !== "").slice(0, 5);
15173
- const name = props.name;
15174
- let html = '<div class="text-sm space-y-0.5">';
15175
- if (name) html += `<div class="font-medium">${escapeHtml(name)}</div>`;
15176
- if (featureId) html += `<div class="text-xs text-muted-foreground"><span class="opacity-70">${escapeHtml(labelsRef.current.canvas.tooltipId)}</span> ${escapeHtml(featureId.slice(0, 30))}</div>`;
15177
- const otherProps = displayProps.filter(([k]) => k !== "name" && k !== "id");
15178
- if (otherProps.length > 0) {
15179
- html += '<div class="text-xs text-muted-foreground space-y-0.5">';
15180
- otherProps.forEach(([key, value]) => {
15181
- html += `<div><span class="opacity-70">${escapeHtml(key)}:</span> ${escapeHtml(String(value).slice(0, 30))}</div>`;
15182
- });
15183
- html += "</div>";
15184
- }
15185
- if (highlightFields.size > 0) {
15186
- html += '<div class="text-xs border-t border-border/50 mt-1 pt-1 space-y-0.5">';
15187
- highlightFields.forEach((fieldName) => {
15188
- const value = props[fieldName];
15189
- 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>`;
15190
- });
15191
- html += "</div>";
15192
- }
15193
- html += "</div>";
15194
- 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
+ );
15195
15319
  };
15196
- const tooltipPageHtml = () => {
15320
+ const tooltipPageContent = () => {
15197
15321
  const feature = resolveRendered(tooltipFeatures[tooltipPageIndex]);
15198
- let html = null;
15199
- if (tooltipProviderRef.current) {
15200
- html = tooltipProviderRef.current(feature);
15201
- } else {
15202
- html = buildBuiltinTooltipHtml(feature);
15203
- }
15204
- if (!html) return null;
15205
- if (tooltipFeatures.length > 1) {
15206
- const prevDisabled = tooltipPageIndex === 0;
15207
- const nextDisabled = tooltipPageIndex === tooltipFeatures.length - 1;
15208
- const btnBase = "background:none;border-radius:4px;padding:1px 8px;font-size:12px;line-height:1.4;";
15209
- 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" : ""}>&lsaquo;</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" : ""}>&rsaquo;</button></div>`;
15210
- html = navHtml + html;
15211
- }
15212
- 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
+ );
15213
15333
  };
15214
15334
  const renderTooltipPage = () => {
15215
15335
  if (tooltipFeatures.length === 0 || !tooltipLngLatForPagination) return;
15216
- const html = tooltipPageHtml();
15217
- if (!html) return;
15336
+ const content = tooltipPageContent();
15337
+ if (!content) return;
15218
15338
  if (tooltipPageIndex > 0 && tooltipFeatures.length > 1) {
15219
15339
  tooltipEl2.style.minWidth = tooltipEl2.offsetWidth + "px";
15220
15340
  tooltipEl2.style.minHeight = tooltipEl2.offsetHeight + "px";
15221
15341
  }
15222
- showTooltip2(tooltipLngLatForPagination, html);
15342
+ showTooltip2(tooltipLngLatForPagination, content);
15223
15343
  };
15224
15344
  const getFeatureKey = (f) => {
15225
15345
  const props = f.properties || {};
@@ -15258,10 +15378,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
15258
15378
  clearTimeout(tooltipHideTimeout);
15259
15379
  tooltipHideTimeout = null;
15260
15380
  }
15261
- tooltipEl2.style.display = "none";
15262
- tooltipEl2.style.minWidth = "";
15263
- tooltipEl2.style.minHeight = "";
15264
- tooltipLngLat = null;
15381
+ hideTooltip2();
15265
15382
  if (tooltipHideTimeout) {
15266
15383
  clearTimeout(tooltipHideTimeout);
15267
15384
  tooltipHideTimeout = null;
@@ -15322,9 +15439,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
15322
15439
  tooltipLngLatForPagination = anchorLngLat;
15323
15440
  tooltipEl2.style.minWidth = "";
15324
15441
  tooltipEl2.style.minHeight = "";
15325
- const html = tooltipPageHtml();
15326
- if (html) {
15327
- tooltipEl2.innerHTML = html;
15442
+ const content = tooltipPageContent();
15443
+ if (content) {
15444
+ tooltipSlot.render(tooltipEl2, content);
15328
15445
  tooltipLngLat = anchorLngLat;
15329
15446
  positionTooltip();
15330
15447
  }
@@ -15397,26 +15514,24 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
15397
15514
  mapInstance.getCanvas().style.cursor = "pointer";
15398
15515
  if (e.features && e.features.length > 0) {
15399
15516
  const props = e.features[0].properties || {};
15400
- const duration = props.duration || "";
15401
- const distance2 = props.distance || "";
15402
- const avgSpeed = props.avgSpeed || "";
15403
- const group = props.group !== "__all__" ? props.group : null;
15404
- const fromName = props.fromName || "";
15405
- const toName = props.toName || "";
15406
- const traceLabels = labelsRef.current.canvas;
15407
- let html = '<div class="text-sm space-y-1">';
15408
- if (fromName || toName) {
15409
- html += `<div class="font-medium text-xs text-muted-foreground">${escapeHtml(fromName || "?")} → ${escapeHtml(toName || "?")}</div>`;
15410
- }
15411
- html += '<div class="space-y-0.5">';
15412
- html += `<div><span class="text-muted-foreground">${escapeHtml(traceLabels.traceDuration)}</span> <span class="font-medium">${escapeHtml(duration)}</span></div>`;
15413
- html += `<div><span class="text-muted-foreground">${escapeHtml(traceLabels.traceDistance)}</span> <span class="font-medium">${escapeHtml(distance2)}</span></div>`;
15414
- html += `<div><span class="text-muted-foreground">${escapeHtml(traceLabels.traceAvgSpeed)}</span> <span class="font-medium">${escapeHtml(avgSpeed)}</span></div>`;
15415
- html += "</div>";
15416
- if (group) {
15417
- html += `<div class="text-xs text-muted-foreground border-t border-border/50 mt-1 pt-1">${escapeHtml(traceLabels.traceGroup(group))}</div>`;
15418
- }
15419
- 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
+ );
15420
15535
  if (!tracePopupRef.current) {
15421
15536
  tracePopupRef.current = new maplibregl.Popup({
15422
15537
  closeButton: false,
@@ -15426,7 +15541,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
15426
15541
  offset: [0, -10]
15427
15542
  });
15428
15543
  }
15429
- tracePopupRef.current.setLngLat(e.lngLat).setHTML(html).addTo(mapInstance);
15544
+ tracePopupRef.current.setLngLat(e.lngLat).setDOMContent(tracePopupContentEl).addTo(mapInstance);
15430
15545
  }
15431
15546
  });
15432
15547
  mapInstance.on("mouseleave", "trace-lines", () => {
@@ -20447,491 +20562,495 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
20447
20562
  ] }) });
20448
20563
  }
20449
20564
  const toastContextValue = toastProvider ?? null;
20450
- return /* @__PURE__ */ jsx(MapLabelsContext.Provider, { value: labels, children: /* @__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: [
20451
- /* @__PURE__ */ jsx(
20452
- "div",
20453
- {
20454
- ref: mapContainer,
20455
- className: `w-full h-full ${activeMode.startsWith("draw_") ? "cursor-crosshair" : ""}`,
20456
- "data-testid": "map-canvas",
20457
- tabIndex: enableKeyboardShortcuts ? 0 : void 0,
20458
- style: { outline: "none" }
20459
- }
20460
- ),
20461
- filterSvgPoints && /* @__PURE__ */ jsx(
20462
- "svg",
20463
- {
20464
- className: "absolute inset-0 w-full h-full pointer-events-none z-[10]",
20465
- "data-testid": "filter-overlay",
20466
- children: /* @__PURE__ */ jsx(
20467
- "polygon",
20468
- {
20469
- ref: filterPolygonRef,
20470
- points: filterSvgPoints,
20471
- fill: "rgba(0, 0, 0, 0.03)",
20472
- stroke: "#555",
20473
- strokeWidth: "1.5",
20474
- strokeDasharray: "6,3",
20475
- strokeOpacity: "0.6"
20476
- }
20477
- )
20478
- }
20479
- ),
20480
- selectionPoints.length >= 4 && (selectionMode === "rectangle" || selectionMode === "click") && map.current && /* @__PURE__ */ jsx(
20481
- "svg",
20482
- {
20483
- className: "absolute inset-0 w-full h-full pointer-events-none z-[100]",
20484
- "data-testid": "selection-overlay",
20485
- children: /* @__PURE__ */ jsx(
20486
- "polygon",
20487
- {
20488
- points: selectionPoints.map(([lng, lat]) => {
20489
- const point2 = map.current.project([lng, lat]);
20490
- return `${point2.x},${point2.y}`;
20491
- }).join(" "),
20492
- fill: "rgba(59, 130, 246, 0.15)",
20493
- stroke: "rgb(59, 130, 246)",
20494
- strokeWidth: "2",
20495
- strokeDasharray: "6,3"
20496
- }
20497
- )
20498
- }
20499
- ),
20500
- selectionMode === "polygon" && map.current && (selectionPoints.length >= 1 || selectionHoverPoint) && /* @__PURE__ */ jsxs(
20501
- "svg",
20502
- {
20503
- className: "absolute inset-0 w-full h-full pointer-events-none z-[100]",
20504
- "data-testid": "polygon-points-overlay",
20505
- children: [
20506
- selectionPoints.length >= 2 && selectionPoints.map(([lng, lat], i) => {
20507
- if (i === 0) return null;
20508
- const prevPoint = map.current.project([selectionPoints[i - 1][0], selectionPoints[i - 1][1]]);
20509
- const currPoint = map.current.project([lng, lat]);
20510
- return /* @__PURE__ */ jsx(
20511
- "line",
20512
- {
20513
- x1: prevPoint.x,
20514
- y1: prevPoint.y,
20515
- x2: currPoint.x,
20516
- y2: currPoint.y,
20517
- stroke: "rgb(59, 130, 246)",
20518
- strokeWidth: "2"
20519
- },
20520
- `line-${i}`
20521
- );
20522
- }),
20523
- selectionPoints.length >= 1 && selectionHoverPoint && /* @__PURE__ */ jsx(
20524
- "line",
20525
- {
20526
- x1: map.current.project([selectionPoints[selectionPoints.length - 1][0], selectionPoints[selectionPoints.length - 1][1]]).x,
20527
- y1: map.current.project([selectionPoints[selectionPoints.length - 1][0], selectionPoints[selectionPoints.length - 1][1]]).y,
20528
- x2: map.current.project(selectionHoverPoint).x,
20529
- y2: map.current.project(selectionHoverPoint).y,
20530
- stroke: "rgb(59, 130, 246)",
20531
- strokeWidth: "2",
20532
- strokeDasharray: "6,3"
20533
- }
20534
- ),
20535
- selectionPoints.length >= 3 && selectionHoverPoint && /* @__PURE__ */ jsx(
20536
- "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",
20537
20586
  {
20538
- x1: map.current.project(selectionHoverPoint).x,
20539
- y1: map.current.project(selectionHoverPoint).y,
20540
- x2: map.current.project([selectionPoints[0][0], selectionPoints[0][1]]).x,
20541
- y2: map.current.project([selectionPoints[0][0], selectionPoints[0][1]]).y,
20542
- stroke: "rgb(59, 130, 246)",
20543
- strokeWidth: "2",
20587
+ ref: filterPolygonRef,
20588
+ points: filterSvgPoints,
20589
+ fill: "rgba(0, 0, 0, 0.03)",
20590
+ stroke: "#555",
20591
+ strokeWidth: "1.5",
20544
20592
  strokeDasharray: "6,3",
20545
- opacity: "0.5"
20546
- }
20547
- ),
20548
- selectionPoints.map(([lng, lat], i) => {
20549
- const point2 = map.current.project([lng, lat]);
20550
- return /* @__PURE__ */ jsx(
20551
- "circle",
20552
- {
20553
- cx: point2.x,
20554
- cy: point2.y,
20555
- r: "5",
20556
- fill: "rgb(59, 130, 246)",
20557
- stroke: "white",
20558
- strokeWidth: "2"
20559
- },
20560
- `point-${i}`
20561
- );
20562
- }),
20563
- selectionHoverPoint && /* @__PURE__ */ jsx(
20564
- "circle",
20565
- {
20566
- cx: map.current.project(selectionHoverPoint).x,
20567
- cy: map.current.project(selectionHoverPoint).y,
20568
- r: "4",
20569
- fill: "rgba(59, 130, 246, 0.5)",
20570
- stroke: "white",
20571
- strokeWidth: "1"
20593
+ strokeOpacity: "0.6"
20572
20594
  }
20573
20595
  )
20574
- ]
20575
- }
20576
- ),
20577
- selectionMode === "circle" && selectionPoints.length >= 4 && map.current && /* @__PURE__ */ jsx(
20578
- "svg",
20579
- {
20580
- className: "absolute inset-0 w-full h-full pointer-events-none z-[100]",
20581
- "data-testid": "circle-selection-overlay",
20582
- children: /* @__PURE__ */ jsx(
20583
- "polygon",
20584
- {
20585
- points: selectionPoints.map(([lng, lat]) => {
20586
- const point2 = map.current.project([lng, lat]);
20587
- return `${point2.x},${point2.y}`;
20588
- }).join(" "),
20589
- fill: "rgba(59, 130, 246, 0.15)",
20590
- stroke: "rgb(59, 130, 246)",
20591
- strokeWidth: "2",
20592
- strokeDasharray: "6,3"
20593
- }
20594
- )
20595
- }
20596
- ),
20597
- activeMode === "draw_circle" && circleDrawPreview && circleDrawPreview.length >= 4 && map.current && /* @__PURE__ */ jsxs(
20598
- "svg",
20599
- {
20600
- className: "absolute inset-0 w-full h-full pointer-events-none z-[100]",
20601
- "data-testid": "circle-draw-preview",
20602
- children: [
20603
- /* @__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(
20604
20604
  "polygon",
20605
20605
  {
20606
- points: circleDrawPreview.map(([lng, lat]) => {
20606
+ points: selectionPoints.map(([lng, lat]) => {
20607
20607
  const point2 = map.current.project([lng, lat]);
20608
20608
  return `${point2.x},${point2.y}`;
20609
20609
  }).join(" "),
20610
- fill: "rgba(34, 197, 94, 0.15)",
20611
- stroke: "rgb(34, 197, 94)",
20610
+ fill: "rgba(59, 130, 246, 0.15)",
20611
+ stroke: "rgb(59, 130, 246)",
20612
20612
  strokeWidth: "2",
20613
20613
  strokeDasharray: "6,3"
20614
20614
  }
20615
- ),
20616
- circleDrawCenter && /* @__PURE__ */ jsx(
20617
- "circle",
20618
- {
20619
- cx: map.current.project(circleDrawCenter).x,
20620
- cy: map.current.project(circleDrawCenter).y,
20621
- r: "6",
20622
- fill: "rgb(34, 197, 94)",
20623
- stroke: "white",
20624
- strokeWidth: "2"
20625
- }
20626
20615
  )
20627
- ]
20628
- }
20629
- ),
20630
- activeMode === "draw_rectangle" && rectangleDrawPreview && rectangleDrawPreview.length >= 4 && map.current && /* @__PURE__ */ jsxs(
20631
- "svg",
20632
- {
20633
- className: "absolute inset-0 w-full h-full pointer-events-none z-[100]",
20634
- "data-testid": "rectangle-draw-preview",
20635
- children: [
20636
- /* @__PURE__ */ jsx(
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(
20637
20701
  "polygon",
20638
20702
  {
20639
- points: rectangleDrawPreview.map(([lng, lat]) => {
20703
+ points: selectionPoints.map(([lng, lat]) => {
20640
20704
  const point2 = map.current.project([lng, lat]);
20641
20705
  return `${point2.x},${point2.y}`;
20642
20706
  }).join(" "),
20643
- fill: "rgba(34, 197, 94, 0.15)",
20644
- stroke: "rgb(34, 197, 94)",
20707
+ fill: "rgba(59, 130, 246, 0.15)",
20708
+ stroke: "rgb(59, 130, 246)",
20645
20709
  strokeWidth: "2",
20646
20710
  strokeDasharray: "6,3"
20647
20711
  }
20648
- ),
20649
- rectangleDrawCorner && /* @__PURE__ */ jsx(
20650
- "circle",
20651
- {
20652
- cx: map.current.project(rectangleDrawCorner).x,
20653
- cy: map.current.project(rectangleDrawCorner).y,
20654
- r: "5",
20655
- fill: "rgb(34, 197, 94)",
20656
- stroke: "white",
20657
- strokeWidth: "2"
20658
- }
20659
20712
  )
20660
- ]
20661
- }
20662
- ),
20663
- (enableDrawing || enableSelection) && /* @__PURE__ */ jsx(
20664
- DrawingToolbar,
20665
- {
20666
- activeMode,
20667
- onModeChange: handleModeChange,
20668
- onClear: handleClear,
20669
- onDeleteSelected: handleDeleteSelected,
20670
- onUndo: history.undo,
20671
- onRedo: history.redo,
20672
- featureCount,
20673
- selectedCount: selectedFeatureIds.length,
20674
- canDeleteSelected,
20675
- canUndo: history.canUndo,
20676
- canRedo: history.canRedo,
20677
- showUndoRedo: true,
20678
- disabled: !isMapLoaded,
20679
- isEditMode,
20680
- onToggleEditMode: handleToggleEditMode,
20681
- hasVisibleLayers,
20682
- hasEditableLayer,
20683
- measureMode,
20684
- onMeasureModeChange: handleMeasureModeChange,
20685
- selectionMode,
20686
- onSelectionModeChange: handleSelectionModeChange,
20687
- isSelectionToolActive,
20688
- onSelectionToolActiveChange: setIsSelectionToolActive,
20689
- enableMeasurement,
20690
- enableSelection,
20691
- hiddenDrawingTools,
20692
- hiddenSelectionTools,
20693
- expandSelectionTools,
20694
- showFilterTool,
20695
- selectionOnly: !enableDrawing && enableSelection,
20696
- showShortcutHints: enableKeyboardShortcuts,
20697
- onGoTo: (coords, zoom) => {
20698
- if (map.current) {
20699
- const currentZoom = map.current.getZoom();
20700
- map.current.flyTo({ center: coords, zoom: zoom ?? Math.max(currentZoom, 20), duration: 2e3 });
20701
- }
20702
- },
20703
- showClearFilter,
20704
- onClearFilter,
20705
- onFilterActiveChange: (active) => {
20706
- filterActiveRef.current = active;
20707
- },
20708
- onFitToFeatures: handleFitToFeatures,
20709
- onDropPoint,
20710
- geocoder: endpoints == null ? void 0 : endpoints.geocoder,
20711
- onSearchEngineRequest: onSearchEngineRequest ? handleSearchAndAddToNewLayer : void 0,
20712
- getAllFeatures,
20713
- onFlyToFeature: (feature) => {
20714
- if (!map.current) return;
20715
- try {
20716
- const center = turf.center(feature);
20717
- const [lng, lat] = center.geometry.coordinates;
20718
- const currentZoom = map.current.getZoom();
20719
- map.current.flyTo({ center: [lng, lat], zoom: Math.max(currentZoom, 14), duration: 1500 });
20720
- } catch {
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;
20721
20833
  try {
20722
- const bbox = turf.bbox(feature);
20723
- map.current.fitBounds([[bbox[0], bbox[1]], [bbox[2], bbox[3]]], { padding: 80, maxZoom: 16, duration: 1500 });
20724
- } catch (e) {
20725
- console.error("Could not fly to feature", e);
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
+ }
20726
20845
  }
20727
20846
  }
20728
20847
  }
20729
- }
20730
- ),
20731
- enableMeasurement && measureMode !== "none" && /* @__PURE__ */ jsx(
20732
- "div",
20733
- {
20734
- className: "absolute top-4 left-16 z-10 bg-background/90 floating-panel rounded-lg shadow-lg border border-border px-4 py-2",
20735
- "data-testid": "measure-result-panel",
20736
- children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
20737
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: measureMode === "distance" ? labels.canvas.measureDistance : labels.canvas.measureArea }),
20738
- /* @__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) }),
20739
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: labels.canvas.measureClearHint })
20740
- ] })
20741
- }
20742
- ),
20743
- enableTimeline && (timelineHasData || timelineFields || keepTimebarExtra) && /* @__PURE__ */ jsx(
20744
- "div",
20745
- {
20746
- className: "absolute left-4 z-[200] transition-all",
20747
- style: { bottom: timelineEnabled ? timebarHeight + TIMEBAR_BOTTOM_OFFSET + 8 : 48 },
20748
- children: /* @__PURE__ */ jsx(Tooltip, { title: labels.canvas.timelineToggle, placement: "right", children: /* @__PURE__ */ jsx(
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(
20749
20891
  Button,
20750
20892
  {
20751
20893
  type: "default",
20752
- icon: /* @__PURE__ */ jsx(Clock, { className: "w-5 h-5" }),
20753
- onClick: () => timelineStoreApi.getState().setEnabled(!timelineEnabled),
20894
+ icon: /* @__PURE__ */ jsx(Layers, { className: "w-6 h-6" }),
20895
+ onClick: handleToggleLayers,
20754
20896
  disabled: !isMapLoaded,
20755
- className: `!w-10 !h-10 !min-w-0 !p-0 bg-background shadow-lg ${timelineEnabled ? "bg-primary/10" : ""}`,
20756
- "aria-label": labels.timebar.toggle,
20757
- "aria-pressed": timelineEnabled,
20758
- "data-testid": "button-toggle-timeline"
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"
20759
20901
  }
20760
20902
  ) })
20761
- }
20762
- ),
20763
- enableLayers && /* @__PURE__ */ jsxs("div", { className: "absolute top-4 right-4 z-[200] flex items-center gap-2", children: [
20764
- getMapUnsavedCount() > 0 && /* @__PURE__ */ jsx(
20765
- "div",
20903
+ ] }),
20904
+ enableLayers && showLayers && /* @__PURE__ */ jsx(
20905
+ LayersPanel,
20766
20906
  {
20767
- className: "px-2 py-1 bg-orange-500 text-white text-xs font-medium rounded-md shadow-lg",
20768
- "data-testid": "badge-unsaved-count",
20769
- children: labels.canvas.unsavedCount(getMapUnsavedCount())
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
20770
20958
  }
20771
20959
  ),
20772
- /* @__PURE__ */ jsx(Tooltip, { title: labels.canvas.layersToggle, placement: "left", children: /* @__PURE__ */ jsx(
20773
- Button,
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,
20774
21007
  {
20775
- type: "default",
20776
- icon: /* @__PURE__ */ jsx(Layers, { className: "w-6 h-6" }),
20777
- onClick: handleToggleLayers,
20778
- disabled: !isMapLoaded,
20779
- 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"}`,
20780
- "aria-label": labels.canvas.layersToggleAriaLabel,
20781
- "aria-pressed": showLayers,
20782
- "data-testid": "button-toggle-layers"
21008
+ activeMode,
21009
+ featureCount,
21010
+ selectedCount: selectedFeatureIds.length,
21011
+ selectionMode
20783
21012
  }
20784
- ) })
20785
- ] }),
20786
- enableLayers && showLayers && /* @__PURE__ */ jsx(
20787
- LayersPanel,
20788
- {
20789
- layers,
20790
- onAddLayer: handleAddLayer,
20791
- onRemoveLayer: handleRemoveLayer,
20792
- onRenameLayer: handleRenameLayer,
20793
- onToggleLayerVisibility: handleToggleLayerVisibility,
20794
- onMoveFeatureToLayer: handleMoveFeatureToLayer,
20795
- selectedFeatureIds,
20796
- getFeatureCount: getFeatureCountForLayer,
20797
- getLayerUnsavedCount,
20798
- getMapUnsavedCount,
20799
- activeEditingLayerId,
20800
- onSetActiveEditingLayer: setActiveEditingLayerId,
20801
- onSaveLayerGeoJSON: handleSaveLayerGeoJSON,
20802
- onLoadLayerGeoJSON: handleLoadLayerGeoJSON,
20803
- onLoadNewLayerGeoJSON: handleLoadNewLayerGeoJSON,
20804
- onSaveAllGeoJSON: handleSaveAllGeoJSON,
20805
- onSearchAndAddToNewLayer: onSearchEngineRequest ? handleSearchAndAddToNewLayer : void 0,
20806
- onWorkspaceLoad: onWorkspaceLoad ? handleWorkspaceLoad : void 0,
20807
- onWorkspaceSave: onWorkspaceSave ? handleWorkspaceSave : void 0,
20808
- onFitToFeatures: handleFitToFeatures,
20809
- currentMapStyle,
20810
- onMapStyleChange: handleMapStyleChange,
20811
- onUpdateTraceConfig: handleUpdateTraceConfig,
20812
- getAvailableTraceFields,
20813
- getSuggestedTraceField,
20814
- getFieldValueDistribution,
20815
- getClusterPieCategories,
20816
- iconSuggestionProvider,
20817
- onUpdateHeatmapConfig: handleUpdateHeatmapConfig,
20818
- onUpdateClusterConfig: handleUpdateClusterConfig,
20819
- hasPointFeatures,
20820
- onUpdateVisualConfig: handleUpdateVisualConfig,
20821
- getLayerFields,
20822
- onFitToLayerFeatures: handleFitToLayerFeatures,
20823
- autoLabelConfig,
20824
- onUpdateAutoLabelConfig: handleUpdateAutoLabelConfig,
20825
- visibleFeatureCount,
20826
- is3DTerrainEnabled,
20827
- onToggle3DTerrain: handleToggle3DTerrain,
20828
- onUpdateAltitudeDisplayMode: handleUpdateAltitudeDisplayMode,
20829
- availableBasemaps,
20830
- hideSatellite: !resolvedEndpoints.satellite,
20831
- hideDark: !resolvedEndpoints.vectorStyles.dark,
20832
- hideTerrain: !resolvedEndpoints.terrain,
20833
- hideBasemapSwitcher,
20834
- externalPersistence,
20835
- customGlobalMenuItems,
20836
- extraLayerToolbarButtons,
20837
- extraNewLayerButtons,
20838
- layerBadgeProvider,
20839
- featureCountProvider
20840
- }
20841
- ),
20842
- showProperties && selectedFeatures.length > 0 && (() => {
20843
- var _a, _b;
20844
- const firstFeatureId = (_a = selectedFeatures[0]) == null ? void 0 : _a.id;
20845
- const featureLayer = layers.find((l) => l.featureIds.includes(firstFeatureId));
20846
- const layerName = featureLayer == null ? void 0 : featureLayer.name;
20847
- const layerId = featureLayer == null ? void 0 : featureLayer.id;
20848
- const isLayerReadOnly = (featureLayer == null ? void 0 : featureLayer.readOnly) === true;
20849
- return /* @__PURE__ */ jsx(
20850
- PropertiesPanel,
21013
+ ),
21014
+ enableTimeline && timelineEnabled && /* @__PURE__ */ jsx(
21015
+ Timebar,
20851
21016
  {
20852
- selectedFeatures: selectedFeatures.map((f) => ({
20853
- id: f.id,
20854
- type: f.type,
20855
- properties: f.properties || {},
20856
- geometry: f.geometry
20857
- })),
20858
- onUpdateProperties: handleUpdateProperties,
20859
- onUpdateGeometry: handleUpdateGeometry,
20860
- onClose: handleCloseProperties,
20861
- isEditMode,
20862
- isReadOnlyLayer: isLayerReadOnly,
20863
- layerName,
20864
- layerId,
20865
- autoFocusLabel,
20866
- entityCardProvider,
20867
- entityCardPlacement,
20868
- inlineEntityCardLabel,
20869
- typePickerProvider,
20870
- featureSaveProvider,
20871
- featureRefreshProvider,
20872
- onFeatureSaved: handleFeatureSaved,
20873
- onDeleteFeatures: () => handleDeleteSelected(),
20874
- onOpenInNewTab,
20875
- onEntityContextMenu,
20876
- layers: layers.map((l) => ({ id: l.id, name: l.name, readOnly: l.readOnly })),
20877
- onMoveFeaturesToLayer: handleMoveFeaturesToLayer,
20878
- onCopyFeaturesToLayer: handleCopyFeaturesToLayer,
20879
- onCreateLayerAndMoveFeatures: handleCreateLayerAndMoveFeatures,
20880
- onCreateLayerAndCopyFeatures: handleCreateLayerAndCopyFeatures,
20881
- getFeatureColor: (featureId) => selectedFeatureColors.get(featureId),
20882
- anchorEl: isMapLoaded ? ((_b = map.current) == null ? void 0 : _b.getContainer()) ?? null : null,
20883
- 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
20884
21022
  }
20885
- );
20886
- })(),
20887
- showStatusPanel && /* @__PURE__ */ jsx(
20888
- StatusIndicator,
20889
- {
20890
- activeMode,
20891
- featureCount,
20892
- selectedCount: selectedFeatureIds.length,
20893
- selectionMode
20894
- }
20895
- ),
20896
- enableTimeline && timelineEnabled && /* @__PURE__ */ jsx(
20897
- Timebar,
20898
- {
20899
- selectedFeatureIds,
20900
- selectedFeatureColors,
20901
- selectionDisplay: "line",
20902
- timebarExtra,
20903
- keepExtraWhenEmpty: !!timelineFields || keepTimebarExtra
20904
- }
20905
- ),
20906
- contextMenu && /* @__PURE__ */ jsx(
20907
- MapContextMenu,
20908
- {
20909
- x: contextMenu.x,
20910
- y: contextMenu.y,
20911
- items: contextMenu.items,
20912
- onClose: () => setContextMenu(null)
20913
- }
20914
- ),
20915
- /* @__PURE__ */ jsx(CursorCoordinatesOverlay, { map: isMapLoaded ? map.current : null }),
20916
- /* @__PURE__ */ jsx(
20917
- IngestProgressOverlay,
20918
- {
20919
- store: ingestProgressStore,
20920
- bottomPx: timelineEnabled ? timebarHeight + TIMEBAR_BOTTOM_OFFSET + 8 : 32
20921
- }
20922
- ),
20923
- /* @__PURE__ */ jsx(
20924
- "input",
20925
- {
20926
- ref: fileInputRef,
20927
- type: "file",
20928
- accept: ".geojson,.json",
20929
- onChange: handleFileChange,
20930
- className: "hidden",
20931
- "data-testid": "input-file-geojson"
20932
- }
20933
- )
20934
- ] }) }) }) }) });
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
+ ] });
20935
21054
  });
20936
21055
  function ActionPanel({ onSave, onLoad, disabled }) {
20937
21056
  const { actionPanel: labels } = useMapLabels();