@octostar/map-component 0.1.17 → 0.1.19

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
@@ -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__ */ jsxs(Fragment, { children: [
610
- /* @__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
- !enableMeasurement && /* @__PURE__ */ jsx(Divider, { className: "!my-0.5 !min-w-0" })
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
  {
@@ -9218,18 +9236,24 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
9218
9236
  }
9219
9237
  }, [onWorkspaceSave, toast]);
9220
9238
  const handleFitToFeatures = useCallback(() => {
9221
- if (!map.current || !draw.current) return;
9239
+ if (!map.current) return;
9222
9240
  const allFeatures = [];
9223
- layers.forEach((layer) => {
9224
- if (layer.visible) {
9225
- layer.featureIds.forEach((id) => {
9226
- const f = draw.current.get(id);
9227
- if (f) allFeatures.push(f);
9228
- });
9229
- } else {
9230
- const hidden = hiddenFeatures.current.get(layer.id) || [];
9231
- allFeatures.push(...hidden);
9232
- }
9241
+ if (draw.current) {
9242
+ layers.forEach((layer) => {
9243
+ if (layer.visible) {
9244
+ layer.featureIds.forEach((id) => {
9245
+ const f = draw.current.get(id);
9246
+ if (f) allFeatures.push(f);
9247
+ });
9248
+ } else {
9249
+ const hidden = hiddenFeatures.current.get(layer.id) || [];
9250
+ allFeatures.push(...hidden);
9251
+ }
9252
+ });
9253
+ }
9254
+ readOnlyFeatures.current.forEach((features, lid) => {
9255
+ const layer = layersRef.current.find((l) => l.id === lid);
9256
+ if (!layer || layer.visible) allFeatures.push(...features);
9233
9257
  });
9234
9258
  if (allFeatures.length === 0) {
9235
9259
  toast({
@@ -9245,7 +9269,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
9245
9269
  const bbox = turf.bbox(fc);
9246
9270
  map.current.fitBounds([[bbox[0], bbox[1]], [bbox[2], bbox[3]]], {
9247
9271
  padding: 80,
9248
- maxZoom: 16
9272
+ maxZoom: 16,
9273
+ duration: 1e3
9249
9274
  });
9250
9275
  }, [layers, toast]);
9251
9276
  const handleFileChange = useCallback((e) => {
@@ -10097,7 +10122,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
10097
10122
  onGoTo: (coords, zoom) => {
10098
10123
  if (map.current) {
10099
10124
  const currentZoom = map.current.getZoom();
10100
- map.current.flyTo({ center: coords, zoom: zoom ?? Math.max(currentZoom, 14), duration: 2e3 });
10125
+ map.current.flyTo({ center: coords, zoom: zoom ?? Math.max(currentZoom, 20), duration: 2e3 });
10101
10126
  }
10102
10127
  },
10103
10128
  showClearFilter,
@@ -10106,6 +10131,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
10106
10131
  filterActiveRef.current = active;
10107
10132
  },
10108
10133
  showGoToButton,
10134
+ onFitToFeatures: handleFitToFeatures,
10109
10135
  onDropPoint,
10110
10136
  geocodingUrl,
10111
10137
  geocoderProvider,