@octostar/map-component 0.1.17 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +97 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +98 -63
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/drawing-toolbar.d.ts +2 -1
- package/dist/types/components/drawing-toolbar.d.ts.map +1 -1
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import * as turf from "@turf/turf";
|
|
|
6
6
|
import proj4 from "proj4";
|
|
7
7
|
import * as THREE from "three";
|
|
8
8
|
import { saveAs } from "file-saver";
|
|
9
|
-
import { MousePointer2, Square, Hexagon, Circle, MoreVertical, ChevronDown, Filter, X, Ruler, Move, Navigation, Pencil, Database, Search, MapPin, Minus, Pentagon, Type, MoveRight, Undo2, Redo2, Trash2, Loader2, Home, Building2, Store, Factory, Warehouse, Church, Hospital, School, GraduationCap, Library, Landmark, Castle, Car, Bus, Train, Plane, Ship, Bike, Fuel, Utensils, Coffee, Beer, Wine, Pizza, IceCream, Trees, Mountain, Waves, Sun, Cloud, Umbrella, Flower2, Leaf, Heart, Star, Flag, AlertTriangle, Info, HelpCircle, CheckCircle, XCircle, PlusCircle, MinusCircle, Zap, Flame, Camera, Music, Film, Gamepad2, Trophy, Medal, Tent, Compass, Briefcase, Wrench, Hammer, Scissors, Paintbrush, Palette, ShoppingCart, Gift, Package, CreditCard, Wallet, Phone, Mail, Globe, Wifi, Radio, Tv, User, Users, Baby, Dog, Cat, Bird, Apple, Carrot, Egg, Anchor, Lock, Key, Shield, Eye, Clock, Calendar, Bookmark, Tag, Triangle, Octagon, ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Map as Map$1, Satellite, MoreHorizontal, Upload, Download, FolderOpen, Focus, Box, Layers, ChevronRight, EyeOff, Smile, Plus, Save, Blend, SkipBack, Pause, Play, TestTube, GripVertical, FileJson, Check, AlertCircle } from "lucide-react";
|
|
9
|
+
import { MousePointer2, Square, Hexagon, Circle, MoreVertical, ChevronDown, Filter, X, Ruler, Move, Navigation, Scan, Pencil, Database, Search, MapPin, Minus, Pentagon, Type, MoveRight, Undo2, Redo2, Trash2, Loader2, Home, Building2, Store, Factory, Warehouse, Church, Hospital, School, GraduationCap, Library, Landmark, Castle, Car, Bus, Train, Plane, Ship, Bike, Fuel, Utensils, Coffee, Beer, Wine, Pizza, IceCream, Trees, Mountain, Waves, Sun, Cloud, Umbrella, Flower2, Leaf, Heart, Star, Flag, AlertTriangle, Info, HelpCircle, CheckCircle, XCircle, PlusCircle, MinusCircle, Zap, Flame, Camera, Music, Film, Gamepad2, Trophy, Medal, Tent, Compass, Briefcase, Wrench, Hammer, Scissors, Paintbrush, Palette, ShoppingCart, Gift, Package, CreditCard, Wallet, Phone, Mail, Globe, Wifi, Radio, Tv, User, Users, Baby, Dog, Cat, Bird, Apple, Carrot, Egg, Anchor, Lock, Key, Shield, Eye, Clock, Calendar, Bookmark, Tag, Triangle, Octagon, ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Map as Map$1, Satellite, MoreHorizontal, Upload, Download, FolderOpen, Focus, Box, Layers, ChevronRight, EyeOff, Smile, Plus, Save, Blend, SkipBack, Pause, Play, TestTube, GripVertical, FileJson, Check, AlertCircle } from "lucide-react";
|
|
10
10
|
import { App, message, Tooltip, Dropdown, Button, Divider, Modal, Tabs, Input, Popover, Switch, Slider, Tag as Tag$1, Select, Collapse, ColorPicker, Card, Table, DatePicker } from "antd";
|
|
11
11
|
import { clsx } from "clsx";
|
|
12
12
|
import { twMerge } from "tailwind-merge";
|
|
@@ -110,6 +110,7 @@ function DrawingToolbar({
|
|
|
110
110
|
onGoTo,
|
|
111
111
|
onDropPoint,
|
|
112
112
|
showGoToButton = false,
|
|
113
|
+
onFitToFeatures,
|
|
113
114
|
isSelectionToolActive = true,
|
|
114
115
|
onSelectionToolActiveChange,
|
|
115
116
|
showClearFilter = false,
|
|
@@ -606,28 +607,45 @@ function DrawingToolbar({
|
|
|
606
607
|
),
|
|
607
608
|
/* @__PURE__ */ jsx(Divider, { className: "!my-0.5 !min-w-0" })
|
|
608
609
|
] }),
|
|
609
|
-
onGoTo && /* @__PURE__ */
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
610
|
+
onGoTo && /* @__PURE__ */ jsx(
|
|
611
|
+
Tooltip,
|
|
612
|
+
{
|
|
613
|
+
title: "Go To",
|
|
614
|
+
placement: "right",
|
|
615
|
+
children: /* @__PURE__ */ jsx(
|
|
616
|
+
Button,
|
|
617
|
+
{
|
|
618
|
+
type: "text",
|
|
619
|
+
onClick: () => setGoToDialogOpen(true),
|
|
620
|
+
disabled,
|
|
621
|
+
className: "relative transition-all duration-150 flex items-center justify-center !w-9 !h-9 !min-w-0 !p-0",
|
|
622
|
+
"aria-label": "Go To",
|
|
623
|
+
"data-testid": "button-goto-address",
|
|
624
|
+
icon: /* @__PURE__ */ jsx(Navigation, { className: "w-5 h-5" })
|
|
625
|
+
}
|
|
626
|
+
)
|
|
627
|
+
}
|
|
628
|
+
),
|
|
629
|
+
onFitToFeatures && /* @__PURE__ */ jsx(
|
|
630
|
+
Tooltip,
|
|
631
|
+
{
|
|
632
|
+
title: "Fit to Data",
|
|
633
|
+
placement: "right",
|
|
634
|
+
children: /* @__PURE__ */ jsx(
|
|
635
|
+
Button,
|
|
636
|
+
{
|
|
637
|
+
type: "text",
|
|
638
|
+
onClick: onFitToFeatures,
|
|
639
|
+
disabled,
|
|
640
|
+
className: "relative transition-all duration-150 flex items-center justify-center !w-9 !h-9 !min-w-0 !p-0",
|
|
641
|
+
"aria-label": "Fit to Data",
|
|
642
|
+
"data-testid": "button-fit-to-data",
|
|
643
|
+
icon: /* @__PURE__ */ jsx(Scan, { className: "w-5 h-5" })
|
|
644
|
+
}
|
|
645
|
+
)
|
|
646
|
+
}
|
|
647
|
+
),
|
|
648
|
+
(onGoTo || onFitToFeatures) && !enableMeasurement && /* @__PURE__ */ jsx(Divider, { className: "!my-0.5 !min-w-0" }),
|
|
631
649
|
!selectionOnly && /* @__PURE__ */ jsx(
|
|
632
650
|
Tooltip,
|
|
633
651
|
{
|
|
@@ -8229,22 +8247,25 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8229
8247
|
} catch (err) {
|
|
8230
8248
|
}
|
|
8231
8249
|
});
|
|
8232
|
-
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
8233
|
-
applySelectionState(finalIds, { focusProperties: true });
|
|
8234
8250
|
const isFilterAction = filterActiveRef.current || !showFilterTool;
|
|
8235
|
-
if (
|
|
8236
|
-
onSelectionComplete
|
|
8251
|
+
if (isFilterAction) {
|
|
8252
|
+
if (onSelectionComplete) {
|
|
8253
|
+
onSelectionComplete(selectionPolygon.geometry);
|
|
8254
|
+
}
|
|
8255
|
+
if (persistSelection) {
|
|
8256
|
+
setPersistedSelectionPolygon([
|
|
8257
|
+
[minLng, maxLat],
|
|
8258
|
+
[maxLng, maxLat],
|
|
8259
|
+
[maxLng, minLat],
|
|
8260
|
+
[minLng, minLat],
|
|
8261
|
+
[minLng, maxLat]
|
|
8262
|
+
]);
|
|
8263
|
+
}
|
|
8264
|
+
} else {
|
|
8265
|
+
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
8266
|
+
applySelectionState(finalIds, { focusProperties: true });
|
|
8237
8267
|
}
|
|
8238
8268
|
setIsSelectionToolActive(false);
|
|
8239
|
-
if (persistSelection && isFilterAction) {
|
|
8240
|
-
setPersistedSelectionPolygon([
|
|
8241
|
-
[minLng, maxLat],
|
|
8242
|
-
[maxLng, maxLat],
|
|
8243
|
-
[maxLng, minLat],
|
|
8244
|
-
[minLng, minLat],
|
|
8245
|
-
[minLng, maxLat]
|
|
8246
|
-
]);
|
|
8247
|
-
}
|
|
8248
8269
|
startPoint = null;
|
|
8249
8270
|
setSelectionPoints([]);
|
|
8250
8271
|
} else if (selectionMode === "circle" && isDrawingSelection.current && startPoint) {
|
|
@@ -8279,16 +8300,19 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8279
8300
|
} catch (err) {
|
|
8280
8301
|
}
|
|
8281
8302
|
});
|
|
8282
|
-
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
8283
|
-
applySelectionState(finalIds, { focusProperties: true });
|
|
8284
8303
|
const isFilterAction = filterActiveRef.current || !showFilterTool;
|
|
8285
|
-
if (
|
|
8286
|
-
onSelectionComplete
|
|
8304
|
+
if (isFilterAction) {
|
|
8305
|
+
if (onSelectionComplete) {
|
|
8306
|
+
onSelectionComplete(selectionPolygon.geometry);
|
|
8307
|
+
}
|
|
8308
|
+
if (persistSelection) {
|
|
8309
|
+
setPersistedSelectionPolygon(selectionPolygon.geometry.coordinates[0]);
|
|
8310
|
+
}
|
|
8311
|
+
} else {
|
|
8312
|
+
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
8313
|
+
applySelectionState(finalIds, { focusProperties: true });
|
|
8287
8314
|
}
|
|
8288
8315
|
setIsSelectionToolActive(false);
|
|
8289
|
-
if (persistSelection && isFilterAction) {
|
|
8290
|
-
setPersistedSelectionPolygon(selectionPolygon.geometry.coordinates[0]);
|
|
8291
|
-
}
|
|
8292
8316
|
}
|
|
8293
8317
|
startPoint = null;
|
|
8294
8318
|
setSelectionPoints([]);
|
|
@@ -8334,16 +8358,19 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
8334
8358
|
} catch (err) {
|
|
8335
8359
|
}
|
|
8336
8360
|
});
|
|
8337
|
-
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
8338
|
-
applySelectionState(finalIds, { focusProperties: true });
|
|
8339
8361
|
const isFilterAction = filterActiveRef.current || !showFilterTool;
|
|
8340
|
-
if (
|
|
8341
|
-
onSelectionComplete
|
|
8362
|
+
if (isFilterAction) {
|
|
8363
|
+
if (onSelectionComplete) {
|
|
8364
|
+
onSelectionComplete(selectionPolygon.geometry);
|
|
8365
|
+
}
|
|
8366
|
+
if (persistSelection) {
|
|
8367
|
+
setPersistedSelectionPolygon(closedPoints);
|
|
8368
|
+
}
|
|
8369
|
+
} else {
|
|
8370
|
+
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
8371
|
+
applySelectionState(finalIds, { focusProperties: true });
|
|
8342
8372
|
}
|
|
8343
8373
|
setIsSelectionToolActive(false);
|
|
8344
|
-
if (persistSelection && isFilterAction) {
|
|
8345
|
-
setPersistedSelectionPolygon(closedPoints);
|
|
8346
|
-
}
|
|
8347
8374
|
setSelectionPoints([]);
|
|
8348
8375
|
setSelectionHoverPoint(null);
|
|
8349
8376
|
}
|
|
@@ -9218,18 +9245,24 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9218
9245
|
}
|
|
9219
9246
|
}, [onWorkspaceSave, toast]);
|
|
9220
9247
|
const handleFitToFeatures = useCallback(() => {
|
|
9221
|
-
if (!map.current
|
|
9248
|
+
if (!map.current) return;
|
|
9222
9249
|
const allFeatures = [];
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
layer.
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
|
|
9230
|
-
|
|
9231
|
-
|
|
9232
|
-
|
|
9250
|
+
if (draw.current) {
|
|
9251
|
+
layers.forEach((layer) => {
|
|
9252
|
+
if (layer.visible) {
|
|
9253
|
+
layer.featureIds.forEach((id) => {
|
|
9254
|
+
const f = draw.current.get(id);
|
|
9255
|
+
if (f) allFeatures.push(f);
|
|
9256
|
+
});
|
|
9257
|
+
} else {
|
|
9258
|
+
const hidden = hiddenFeatures.current.get(layer.id) || [];
|
|
9259
|
+
allFeatures.push(...hidden);
|
|
9260
|
+
}
|
|
9261
|
+
});
|
|
9262
|
+
}
|
|
9263
|
+
readOnlyFeatures.current.forEach((features, lid) => {
|
|
9264
|
+
const layer = layersRef.current.find((l) => l.id === lid);
|
|
9265
|
+
if (!layer || layer.visible) allFeatures.push(...features);
|
|
9233
9266
|
});
|
|
9234
9267
|
if (allFeatures.length === 0) {
|
|
9235
9268
|
toast({
|
|
@@ -9245,7 +9278,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9245
9278
|
const bbox = turf.bbox(fc);
|
|
9246
9279
|
map.current.fitBounds([[bbox[0], bbox[1]], [bbox[2], bbox[3]]], {
|
|
9247
9280
|
padding: 80,
|
|
9248
|
-
maxZoom: 16
|
|
9281
|
+
maxZoom: 16,
|
|
9282
|
+
duration: 1e3
|
|
9249
9283
|
});
|
|
9250
9284
|
}, [layers, toast]);
|
|
9251
9285
|
const handleFileChange = useCallback((e) => {
|
|
@@ -10097,7 +10131,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10097
10131
|
onGoTo: (coords, zoom) => {
|
|
10098
10132
|
if (map.current) {
|
|
10099
10133
|
const currentZoom = map.current.getZoom();
|
|
10100
|
-
map.current.flyTo({ center: coords, zoom: zoom ?? Math.max(currentZoom,
|
|
10134
|
+
map.current.flyTo({ center: coords, zoom: zoom ?? Math.max(currentZoom, 20), duration: 2e3 });
|
|
10101
10135
|
}
|
|
10102
10136
|
},
|
|
10103
10137
|
showClearFilter,
|
|
@@ -10106,6 +10140,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10106
10140
|
filterActiveRef.current = active;
|
|
10107
10141
|
},
|
|
10108
10142
|
showGoToButton,
|
|
10143
|
+
onFitToFeatures: handleFitToFeatures,
|
|
10109
10144
|
onDropPoint,
|
|
10110
10145
|
geocodingUrl,
|
|
10111
10146
|
geocoderProvider,
|