@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 CHANGED
@@ -131,6 +131,7 @@ function DrawingToolbar({
131
131
  onGoTo,
132
132
  onDropPoint,
133
133
  showGoToButton = false,
134
+ onFitToFeatures,
134
135
  isSelectionToolActive = true,
135
136
  onSelectionToolActiveChange,
136
137
  showClearFilter = false,
@@ -627,28 +628,45 @@ function DrawingToolbar({
627
628
  ),
628
629
  /* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { className: "!my-0.5 !min-w-0" })
629
630
  ] }),
630
- onGoTo && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
631
- /* @__PURE__ */ jsxRuntime.jsx(
632
- antd.Tooltip,
633
- {
634
- title: "Go To",
635
- placement: "right",
636
- children: /* @__PURE__ */ jsxRuntime.jsx(
637
- antd.Button,
638
- {
639
- type: "text",
640
- onClick: () => setGoToDialogOpen(true),
641
- disabled,
642
- className: "relative transition-all duration-150 flex items-center justify-center !w-9 !h-9 !min-w-0 !p-0",
643
- "aria-label": "Go To",
644
- "data-testid": "button-goto-address",
645
- icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Navigation, { className: "w-5 h-5" })
646
- }
647
- )
648
- }
649
- ),
650
- !enableMeasurement && /* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { className: "!my-0.5 !min-w-0" })
651
- ] }),
631
+ onGoTo && /* @__PURE__ */ jsxRuntime.jsx(
632
+ antd.Tooltip,
633
+ {
634
+ title: "Go To",
635
+ placement: "right",
636
+ children: /* @__PURE__ */ jsxRuntime.jsx(
637
+ antd.Button,
638
+ {
639
+ type: "text",
640
+ onClick: () => setGoToDialogOpen(true),
641
+ disabled,
642
+ className: "relative transition-all duration-150 flex items-center justify-center !w-9 !h-9 !min-w-0 !p-0",
643
+ "aria-label": "Go To",
644
+ "data-testid": "button-goto-address",
645
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Navigation, { className: "w-5 h-5" })
646
+ }
647
+ )
648
+ }
649
+ ),
650
+ onFitToFeatures && /* @__PURE__ */ jsxRuntime.jsx(
651
+ antd.Tooltip,
652
+ {
653
+ title: "Fit to Data",
654
+ placement: "right",
655
+ children: /* @__PURE__ */ jsxRuntime.jsx(
656
+ antd.Button,
657
+ {
658
+ type: "text",
659
+ onClick: onFitToFeatures,
660
+ disabled,
661
+ className: "relative transition-all duration-150 flex items-center justify-center !w-9 !h-9 !min-w-0 !p-0",
662
+ "aria-label": "Fit to Data",
663
+ "data-testid": "button-fit-to-data",
664
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Scan, { className: "w-5 h-5" })
665
+ }
666
+ )
667
+ }
668
+ ),
669
+ (onGoTo || onFitToFeatures) && !enableMeasurement && /* @__PURE__ */ jsxRuntime.jsx(antd.Divider, { className: "!my-0.5 !min-w-0" }),
652
670
  !selectionOnly && /* @__PURE__ */ jsxRuntime.jsx(
653
671
  antd.Tooltip,
654
672
  {
@@ -8250,22 +8268,25 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
8250
8268
  } catch (err) {
8251
8269
  }
8252
8270
  });
8253
- const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
8254
- applySelectionState(finalIds, { focusProperties: true });
8255
8271
  const isFilterAction = filterActiveRef.current || !showFilterTool;
8256
- if (onSelectionComplete && isFilterAction) {
8257
- onSelectionComplete(selectionPolygon.geometry);
8272
+ if (isFilterAction) {
8273
+ if (onSelectionComplete) {
8274
+ onSelectionComplete(selectionPolygon.geometry);
8275
+ }
8276
+ if (persistSelection) {
8277
+ setPersistedSelectionPolygon([
8278
+ [minLng, maxLat],
8279
+ [maxLng, maxLat],
8280
+ [maxLng, minLat],
8281
+ [minLng, minLat],
8282
+ [minLng, maxLat]
8283
+ ]);
8284
+ }
8285
+ } else {
8286
+ const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
8287
+ applySelectionState(finalIds, { focusProperties: true });
8258
8288
  }
8259
8289
  setIsSelectionToolActive(false);
8260
- if (persistSelection && isFilterAction) {
8261
- setPersistedSelectionPolygon([
8262
- [minLng, maxLat],
8263
- [maxLng, maxLat],
8264
- [maxLng, minLat],
8265
- [minLng, minLat],
8266
- [minLng, maxLat]
8267
- ]);
8268
- }
8269
8290
  startPoint = null;
8270
8291
  setSelectionPoints([]);
8271
8292
  } else if (selectionMode === "circle" && isDrawingSelection.current && startPoint) {
@@ -8300,16 +8321,19 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
8300
8321
  } catch (err) {
8301
8322
  }
8302
8323
  });
8303
- const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
8304
- applySelectionState(finalIds, { focusProperties: true });
8305
8324
  const isFilterAction = filterActiveRef.current || !showFilterTool;
8306
- if (onSelectionComplete && isFilterAction) {
8307
- onSelectionComplete(selectionPolygon.geometry);
8325
+ if (isFilterAction) {
8326
+ if (onSelectionComplete) {
8327
+ onSelectionComplete(selectionPolygon.geometry);
8328
+ }
8329
+ if (persistSelection) {
8330
+ setPersistedSelectionPolygon(selectionPolygon.geometry.coordinates[0]);
8331
+ }
8332
+ } else {
8333
+ const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
8334
+ applySelectionState(finalIds, { focusProperties: true });
8308
8335
  }
8309
8336
  setIsSelectionToolActive(false);
8310
- if (persistSelection && isFilterAction) {
8311
- setPersistedSelectionPolygon(selectionPolygon.geometry.coordinates[0]);
8312
- }
8313
8337
  }
8314
8338
  startPoint = null;
8315
8339
  setSelectionPoints([]);
@@ -8355,16 +8379,19 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
8355
8379
  } catch (err) {
8356
8380
  }
8357
8381
  });
8358
- const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
8359
- applySelectionState(finalIds, { focusProperties: true });
8360
8382
  const isFilterAction = filterActiveRef.current || !showFilterTool;
8361
- if (onSelectionComplete && isFilterAction) {
8362
- onSelectionComplete(selectionPolygon.geometry);
8383
+ if (isFilterAction) {
8384
+ if (onSelectionComplete) {
8385
+ onSelectionComplete(selectionPolygon.geometry);
8386
+ }
8387
+ if (persistSelection) {
8388
+ setPersistedSelectionPolygon(closedPoints);
8389
+ }
8390
+ } else {
8391
+ const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
8392
+ applySelectionState(finalIds, { focusProperties: true });
8363
8393
  }
8364
8394
  setIsSelectionToolActive(false);
8365
- if (persistSelection && isFilterAction) {
8366
- setPersistedSelectionPolygon(closedPoints);
8367
- }
8368
8395
  setSelectionPoints([]);
8369
8396
  setSelectionHoverPoint(null);
8370
8397
  }
@@ -9239,18 +9266,24 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9239
9266
  }
9240
9267
  }, [onWorkspaceSave, toast]);
9241
9268
  const handleFitToFeatures = react.useCallback(() => {
9242
- if (!map.current || !draw.current) return;
9269
+ if (!map.current) return;
9243
9270
  const allFeatures = [];
9244
- layers.forEach((layer) => {
9245
- if (layer.visible) {
9246
- layer.featureIds.forEach((id) => {
9247
- const f = draw.current.get(id);
9248
- if (f) allFeatures.push(f);
9249
- });
9250
- } else {
9251
- const hidden = hiddenFeatures.current.get(layer.id) || [];
9252
- allFeatures.push(...hidden);
9253
- }
9271
+ if (draw.current) {
9272
+ layers.forEach((layer) => {
9273
+ if (layer.visible) {
9274
+ layer.featureIds.forEach((id) => {
9275
+ const f = draw.current.get(id);
9276
+ if (f) allFeatures.push(f);
9277
+ });
9278
+ } else {
9279
+ const hidden = hiddenFeatures.current.get(layer.id) || [];
9280
+ allFeatures.push(...hidden);
9281
+ }
9282
+ });
9283
+ }
9284
+ readOnlyFeatures.current.forEach((features, lid) => {
9285
+ const layer = layersRef.current.find((l) => l.id === lid);
9286
+ if (!layer || layer.visible) allFeatures.push(...features);
9254
9287
  });
9255
9288
  if (allFeatures.length === 0) {
9256
9289
  toast({
@@ -9266,7 +9299,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9266
9299
  const bbox = turf__namespace.bbox(fc);
9267
9300
  map.current.fitBounds([[bbox[0], bbox[1]], [bbox[2], bbox[3]]], {
9268
9301
  padding: 80,
9269
- maxZoom: 16
9302
+ maxZoom: 16,
9303
+ duration: 1e3
9270
9304
  });
9271
9305
  }, [layers, toast]);
9272
9306
  const handleFileChange = react.useCallback((e) => {
@@ -10118,7 +10152,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10118
10152
  onGoTo: (coords, zoom) => {
10119
10153
  if (map.current) {
10120
10154
  const currentZoom = map.current.getZoom();
10121
- map.current.flyTo({ center: coords, zoom: zoom ?? Math.max(currentZoom, 14), duration: 2e3 });
10155
+ map.current.flyTo({ center: coords, zoom: zoom ?? Math.max(currentZoom, 20), duration: 2e3 });
10122
10156
  }
10123
10157
  },
10124
10158
  showClearFilter,
@@ -10127,6 +10161,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10127
10161
  filterActiveRef.current = active;
10128
10162
  },
10129
10163
  showGoToButton,
10164
+ onFitToFeatures: handleFitToFeatures,
10130
10165
  onDropPoint,
10131
10166
  geocodingUrl,
10132
10167
  geocoderProvider,