@accelint/map-toolkit 0.6.0 → 1.0.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/CHANGELOG.md +68 -0
- package/catalog-info.yaml +5 -4
- package/dist/camera/index.d.ts +2 -2
- package/dist/camera/index.js +2 -2
- package/dist/camera/store.d.ts +120 -0
- package/dist/camera/store.js +279 -0
- package/dist/camera/store.js.map +1 -0
- package/dist/deckgl/base-map/constants.d.ts +1 -6
- package/dist/deckgl/base-map/constants.js +1 -6
- package/dist/deckgl/base-map/constants.js.map +1 -1
- package/dist/deckgl/base-map/controls.js +2 -0
- package/dist/deckgl/base-map/controls.js.map +1 -1
- package/dist/deckgl/base-map/index.d.ts +2 -2
- package/dist/deckgl/base-map/index.js +10 -11
- package/dist/deckgl/base-map/index.js.map +1 -1
- package/dist/deckgl/base-map/provider.js +1 -1
- package/dist/deckgl/index.d.ts +4 -4
- package/dist/deckgl/index.js +4 -4
- package/dist/deckgl/saved-viewports/storage.js +10 -2
- package/dist/deckgl/saved-viewports/storage.js.map +1 -1
- package/dist/deckgl/shapes/display-shape-layer/constants.js +5 -8
- package/dist/deckgl/shapes/display-shape-layer/constants.js.map +1 -1
- package/dist/deckgl/shapes/display-shape-layer/index.d.ts +18 -14
- package/dist/deckgl/shapes/display-shape-layer/index.js +63 -30
- package/dist/deckgl/shapes/display-shape-layer/index.js.map +1 -1
- package/dist/deckgl/shapes/display-shape-layer/shape-label-layer.js +2 -16
- package/dist/deckgl/shapes/display-shape-layer/shape-label-layer.js.map +1 -1
- package/dist/deckgl/shapes/display-shape-layer/store.js +58 -272
- package/dist/deckgl/shapes/display-shape-layer/store.js.map +1 -1
- package/dist/deckgl/shapes/display-shape-layer/types.d.ts +22 -11
- package/dist/deckgl/shapes/display-shape-layer/{use-shape-selection.d.ts → use-select-shape.d.ts} +9 -9
- package/dist/deckgl/shapes/display-shape-layer/{use-shape-selection.js → use-select-shape.js} +12 -12
- package/dist/deckgl/shapes/display-shape-layer/use-select-shape.js.map +1 -0
- package/dist/deckgl/shapes/display-shape-layer/utils/display-style.js +5 -66
- package/dist/deckgl/shapes/display-shape-layer/utils/display-style.js.map +1 -1
- package/dist/deckgl/shapes/display-shape-layer/utils/labels.d.ts +2 -65
- package/dist/deckgl/shapes/display-shape-layer/utils/labels.js +3 -121
- package/dist/deckgl/shapes/display-shape-layer/utils/labels.js.map +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/constants.js +46 -0
- package/dist/deckgl/shapes/draw-shape-layer/constants.js.map +1 -0
- package/dist/deckgl/shapes/draw-shape-layer/events.d.ts +92 -0
- package/dist/deckgl/shapes/draw-shape-layer/events.js +56 -0
- package/dist/deckgl/shapes/draw-shape-layer/events.js.map +1 -0
- package/dist/deckgl/shapes/draw-shape-layer/fiber.d.ts +11 -0
- package/dist/{maplibre/constants.js → deckgl/shapes/draw-shape-layer/fiber.js} +6 -12
- package/dist/deckgl/shapes/draw-shape-layer/fiber.js.map +1 -0
- package/dist/deckgl/shapes/draw-shape-layer/index.d.ts +53 -0
- package/dist/deckgl/shapes/draw-shape-layer/index.js +95 -0
- package/dist/deckgl/shapes/draw-shape-layer/index.js.map +1 -0
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-circle-mode-with-tooltip.js +51 -0
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-circle-mode-with-tooltip.js.map +1 -0
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-ellipse-mode-with-tooltip.js +73 -0
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-ellipse-mode-with-tooltip.js.map +1 -0
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-line-string-mode-with-tooltip.js +87 -0
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-line-string-mode-with-tooltip.js.map +1 -0
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-polygon-mode-with-tooltip.js +88 -0
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-polygon-mode-with-tooltip.js.map +1 -0
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-rectangle-mode-with-tooltip.js +77 -0
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-rectangle-mode-with-tooltip.js.map +1 -0
- package/dist/deckgl/shapes/draw-shape-layer/modes/index.js +64 -0
- package/dist/deckgl/shapes/draw-shape-layer/modes/index.js.map +1 -0
- package/dist/deckgl/shapes/draw-shape-layer/store.js +175 -0
- package/dist/deckgl/shapes/draw-shape-layer/store.js.map +1 -0
- package/dist/deckgl/shapes/draw-shape-layer/types.d.ts +86 -0
- package/dist/{viewport/constants.js → deckgl/shapes/draw-shape-layer/types.js} +1 -12
- package/dist/deckgl/shapes/draw-shape-layer/use-draw-shape.d.ts +82 -0
- package/dist/deckgl/shapes/draw-shape-layer/use-draw-shape.js +112 -0
- package/dist/deckgl/shapes/draw-shape-layer/use-draw-shape.js.map +1 -0
- package/dist/deckgl/shapes/draw-shape-layer/utils/feature-conversion.js +147 -0
- package/dist/deckgl/shapes/draw-shape-layer/utils/feature-conversion.js.map +1 -0
- package/dist/deckgl/shapes/edit-shape-layer/constants.js +41 -0
- package/dist/deckgl/shapes/edit-shape-layer/constants.js.map +1 -0
- package/dist/deckgl/shapes/edit-shape-layer/events.d.ts +92 -0
- package/dist/deckgl/shapes/edit-shape-layer/events.js +56 -0
- package/dist/deckgl/shapes/edit-shape-layer/events.js.map +1 -0
- package/dist/deckgl/shapes/edit-shape-layer/fiber.d.ts +13 -0
- package/dist/deckgl/shapes/edit-shape-layer/fiber.js +14 -0
- package/dist/deckgl/shapes/edit-shape-layer/index.d.ts +63 -0
- package/dist/deckgl/shapes/edit-shape-layer/index.js +162 -0
- package/dist/deckgl/shapes/edit-shape-layer/index.js.map +1 -0
- package/dist/deckgl/shapes/edit-shape-layer/modes/base-transform-mode.js +154 -0
- package/dist/deckgl/shapes/edit-shape-layer/modes/base-transform-mode.js.map +1 -0
- package/dist/deckgl/shapes/edit-shape-layer/modes/bounding-transform-mode.js +147 -0
- package/dist/deckgl/shapes/edit-shape-layer/modes/bounding-transform-mode.js.map +1 -0
- package/dist/deckgl/shapes/edit-shape-layer/modes/circle-transform-mode.js +87 -0
- package/dist/deckgl/shapes/edit-shape-layer/modes/circle-transform-mode.js.map +1 -0
- package/dist/deckgl/shapes/edit-shape-layer/modes/index.js +61 -0
- package/dist/deckgl/shapes/edit-shape-layer/modes/index.js.map +1 -0
- package/dist/deckgl/shapes/edit-shape-layer/modes/rotate-mode-with-snap.js +109 -0
- package/dist/deckgl/shapes/edit-shape-layer/modes/rotate-mode-with-snap.js.map +1 -0
- package/dist/deckgl/shapes/edit-shape-layer/modes/scale-mode-with-free-transform.js +289 -0
- package/dist/deckgl/shapes/edit-shape-layer/modes/scale-mode-with-free-transform.js.map +1 -0
- package/dist/deckgl/shapes/edit-shape-layer/modes/vertex-transform-mode.js +121 -0
- package/dist/deckgl/shapes/edit-shape-layer/modes/vertex-transform-mode.js.map +1 -0
- package/dist/deckgl/shapes/edit-shape-layer/store.js +194 -0
- package/dist/deckgl/shapes/edit-shape-layer/store.js.map +1 -0
- package/dist/deckgl/shapes/edit-shape-layer/types.d.ts +93 -0
- package/dist/deckgl/shapes/edit-shape-layer/types.js +14 -0
- package/dist/deckgl/shapes/edit-shape-layer/use-edit-shape.d.ts +82 -0
- package/dist/deckgl/shapes/edit-shape-layer/use-edit-shape.js +114 -0
- package/dist/deckgl/shapes/edit-shape-layer/use-edit-shape.js.map +1 -0
- package/dist/deckgl/shapes/index.d.ts +15 -6
- package/dist/deckgl/shapes/index.js +12 -5
- package/dist/deckgl/shapes/shared/constants.d.ts +27 -32
- package/dist/deckgl/shapes/shared/constants.js +189 -25
- package/dist/deckgl/shapes/shared/constants.js.map +1 -1
- package/dist/deckgl/shapes/shared/events.d.ts +1 -20
- package/dist/deckgl/shapes/shared/events.js +1 -31
- package/dist/deckgl/shapes/shared/events.js.map +1 -1
- package/dist/deckgl/shapes/shared/hooks/use-shift-zoom-disable.js +84 -0
- package/dist/deckgl/shapes/shared/hooks/use-shift-zoom-disable.js.map +1 -0
- package/dist/deckgl/shapes/shared/types.d.ts +187 -28
- package/dist/deckgl/shapes/shared/types.js +55 -1
- package/dist/deckgl/shapes/shared/types.js.map +1 -1
- package/dist/deckgl/shapes/shared/utils/geometry-measurements.js +128 -0
- package/dist/deckgl/shapes/shared/utils/geometry-measurements.js.map +1 -0
- package/dist/deckgl/shapes/shared/utils/layer-config.js +50 -0
- package/dist/deckgl/shapes/shared/utils/layer-config.js.map +1 -0
- package/dist/deckgl/shapes/shared/utils/mode-utils.js +113 -0
- package/dist/deckgl/shapes/shared/utils/mode-utils.js.map +1 -0
- package/dist/deckgl/shapes/shared/utils/pick-filtering.js +57 -0
- package/dist/deckgl/shapes/shared/utils/pick-filtering.js.map +1 -0
- package/dist/deckgl/shapes/shared/utils/style-utils.d.ts +64 -0
- package/dist/deckgl/shapes/shared/utils/style-utils.js +101 -0
- package/dist/deckgl/shapes/shared/utils/style-utils.js.map +1 -0
- package/dist/deckgl/text-layer/default-settings.js +4 -24
- package/dist/deckgl/text-layer/default-settings.js.map +1 -1
- package/dist/deckgl/text-settings.d.ts +77 -0
- package/dist/deckgl/text-settings.js +83 -0
- package/dist/deckgl/text-settings.js.map +1 -0
- package/dist/map-cursor/index.d.ts +2 -2
- package/dist/map-cursor/index.js +2 -2
- package/dist/map-cursor/store.d.ts +32 -61
- package/dist/map-cursor/store.js +165 -294
- package/dist/map-cursor/store.js.map +1 -1
- package/dist/map-cursor/use-map-cursor.d.ts +5 -2
- package/dist/map-cursor/use-map-cursor.js +33 -15
- package/dist/map-cursor/use-map-cursor.js.map +1 -1
- package/dist/map-mode/index.d.ts +2 -2
- package/dist/map-mode/index.js +2 -2
- package/dist/map-mode/store.d.ts +36 -37
- package/dist/map-mode/store.js +131 -237
- package/dist/map-mode/store.js.map +1 -1
- package/dist/map-mode/use-map-mode.js +6 -5
- package/dist/map-mode/use-map-mode.js.map +1 -1
- package/dist/maplibre/index.d.ts +2 -2
- package/dist/maplibre/index.js +2 -2
- package/dist/shared/constants.d.ts +19 -0
- package/dist/shared/constants.js +33 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/shared/create-map-store.d.ts +202 -0
- package/dist/shared/create-map-store.js +223 -0
- package/dist/shared/create-map-store.js.map +1 -0
- package/dist/shared/units.d.ts +39 -0
- package/dist/shared/units.js +49 -0
- package/dist/shared/units.js.map +1 -0
- package/dist/viewport/index.d.ts +3 -3
- package/dist/viewport/index.js +3 -3
- package/dist/viewport/store.d.ts +69 -0
- package/dist/viewport/store.js +125 -0
- package/dist/viewport/store.js.map +1 -0
- package/dist/viewport/types.d.ts +2 -2
- package/dist/viewport/utils.js +2 -2
- package/dist/viewport/utils.js.map +1 -1
- package/dist/viewport/viewport-size.d.ts +2 -2
- package/dist/viewport/viewport-size.js +2 -2
- package/dist/viewport/viewport-size.js.map +1 -1
- package/package.json +36 -18
- package/dist/camera/use-camera-state.d.ts +0 -153
- package/dist/camera/use-camera-state.js +0 -418
- package/dist/camera/use-camera-state.js.map +0 -1
- package/dist/deckgl/shapes/display-shape-layer/constants.d.ts +0 -44
- package/dist/deckgl/shapes/display-shape-layer/shape-label-layer.d.ts +0 -66
- package/dist/deckgl/shapes/display-shape-layer/store.d.ts +0 -87
- package/dist/deckgl/shapes/display-shape-layer/use-shape-selection.js.map +0 -1
- package/dist/deckgl/shapes/display-shape-layer/utils/display-style.d.ts +0 -61
- package/dist/maplibre/constants.d.ts +0 -13
- package/dist/maplibre/constants.js.map +0 -1
- package/dist/viewport/constants.d.ts +0 -11
- package/dist/viewport/constants.js.map +0 -1
- package/dist/viewport/use-viewport-state.d.ts +0 -100
- package/dist/viewport/use-viewport-state.js +0 -222
- package/dist/viewport/use-viewport-state.js.map +0 -1
|
@@ -10,12 +10,19 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { Shape, ShapeId, StyledFeature as StyledFeature$1 } from "../shared/types.js";
|
|
14
14
|
import { LabelPositionOptions } from "./utils/labels.js";
|
|
15
15
|
import { UniqueId } from "@accelint/core";
|
|
16
16
|
import { CompositeLayerProps } from "@deck.gl/core";
|
|
17
17
|
|
|
18
18
|
//#region src/deckgl/shapes/display-shape-layer/types.d.ts
|
|
19
|
+
/**
|
|
20
|
+
* Label display mode for shapes
|
|
21
|
+
* - `'always'`: Show labels for all shapes
|
|
22
|
+
* - `'hover'`: Show label only for the currently hovered shape
|
|
23
|
+
* - `'never'`: Never show labels
|
|
24
|
+
*/
|
|
25
|
+
type ShowLabelsMode = 'always' | 'hover' | 'never';
|
|
19
26
|
/**
|
|
20
27
|
* Re-export StyledFeature from shared types
|
|
21
28
|
*/
|
|
@@ -50,7 +57,7 @@ interface DisplayShapeLayerProps extends CompositeLayerProps {
|
|
|
50
57
|
* Array of shapes to display
|
|
51
58
|
* Each shape must have a GeoJSON feature with styleProperties
|
|
52
59
|
*/
|
|
53
|
-
data:
|
|
60
|
+
data: Shape[];
|
|
54
61
|
/**
|
|
55
62
|
* Currently selected shape ID (for highlighting)
|
|
56
63
|
* When set, renders a highlight layer around the selected shape
|
|
@@ -61,19 +68,23 @@ interface DisplayShapeLayerProps extends CompositeLayerProps {
|
|
|
61
68
|
* Also triggers a shapes:selected event on the event bus
|
|
62
69
|
* @param shape - The clicked shape with full properties
|
|
63
70
|
*/
|
|
64
|
-
onShapeClick?: (shape:
|
|
71
|
+
onShapeClick?: (shape: Shape) => void;
|
|
65
72
|
/**
|
|
66
73
|
* Callback when a shape is hovered
|
|
67
74
|
* Called with null when hover ends
|
|
68
75
|
* @param shape - The hovered shape, or null when hover ends
|
|
69
76
|
*/
|
|
70
|
-
onShapeHover?: (shape:
|
|
77
|
+
onShapeHover?: (shape: Shape | null) => void;
|
|
71
78
|
/**
|
|
72
|
-
*
|
|
79
|
+
* Label display mode for shapes
|
|
80
|
+
* - `'always'`: Show labels for all shapes
|
|
81
|
+
* - `'hover'`: Show label only for the currently hovered shape (requires `pickable={true}`, the default)
|
|
82
|
+
* - `'never'`: Never show labels
|
|
83
|
+
*
|
|
73
84
|
* Labels use the shape's `label` property, or `name` if label is not set
|
|
74
|
-
* @default
|
|
85
|
+
* @default 'always'
|
|
75
86
|
*/
|
|
76
|
-
showLabels?:
|
|
87
|
+
showLabels?: ShowLabelsMode;
|
|
77
88
|
/**
|
|
78
89
|
* Global label positioning options
|
|
79
90
|
* Can be overridden per-shape via styleProperties
|
|
@@ -98,18 +109,18 @@ interface DisplayShapeLayerProps extends CompositeLayerProps {
|
|
|
98
109
|
*/
|
|
99
110
|
highlightColor?: [number, number, number, number];
|
|
100
111
|
/**
|
|
101
|
-
* When true (default),
|
|
102
|
-
*
|
|
112
|
+
* When true (default), multiplies fill color alpha by 0.2 (reducing to 20% of original opacity)
|
|
113
|
+
* for a standard semi-transparent look.
|
|
103
114
|
* When false, colors are rendered exactly as specified in styleProperties.
|
|
104
115
|
* @default true
|
|
105
116
|
* @example Standard semi-transparent fills
|
|
106
117
|
* ```tsx
|
|
107
118
|
* <DisplayShapeLayer data={shapes} applyBaseOpacity />
|
|
108
|
-
* // Shape with fillColor [98, 166, 255, 255] renders at alpha
|
|
119
|
+
* // Shape with fillColor [98, 166, 255, 255] renders at alpha 51 (255 × 0.2)
|
|
109
120
|
* ```
|
|
110
121
|
*/
|
|
111
122
|
applyBaseOpacity?: boolean;
|
|
112
123
|
}
|
|
113
124
|
//#endregion
|
|
114
|
-
export { DisplayShapeLayerProps, StyledFeature, StyledFeatureProperties };
|
|
125
|
+
export { DisplayShapeLayerProps, ShowLabelsMode, StyledFeature, StyledFeatureProperties };
|
|
115
126
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/deckgl/shapes/display-shape-layer/{use-shape-selection.d.ts → use-select-shape.d.ts}
RENAMED
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
import { ShapeId } from "../shared/types.js";
|
|
14
14
|
import { UniqueId } from "@accelint/core";
|
|
15
15
|
|
|
16
|
-
//#region src/deckgl/shapes/display-shape-layer/use-shape
|
|
16
|
+
//#region src/deckgl/shapes/display-shape-layer/use-select-shape.d.ts
|
|
17
17
|
/**
|
|
18
|
-
* Return type for
|
|
18
|
+
* Return type for useSelectShape hook
|
|
19
19
|
*/
|
|
20
|
-
interface
|
|
20
|
+
interface UseSelectShapeReturn {
|
|
21
21
|
/** Currently selected shape ID, or undefined if nothing selected */
|
|
22
22
|
selectedId: ShapeId | undefined;
|
|
23
23
|
/** Manually set the selected shape ID (useful for programmatic selection) */
|
|
@@ -43,10 +43,10 @@ interface UseShapeSelectionReturn {
|
|
|
43
43
|
*
|
|
44
44
|
* @example Basic usage
|
|
45
45
|
* ```tsx
|
|
46
|
-
* import {
|
|
46
|
+
* import { useSelectShape } from '@accelint/map-toolkit/deckgl/shapes';
|
|
47
47
|
*
|
|
48
48
|
* function MapWithShapes() {
|
|
49
|
-
* const { selectedId } =
|
|
49
|
+
* const { selectedId } = useSelectShape(MAP_ID);
|
|
50
50
|
*
|
|
51
51
|
* return (
|
|
52
52
|
* <BaseMap id={MAP_ID}>
|
|
@@ -64,7 +64,7 @@ interface UseShapeSelectionReturn {
|
|
|
64
64
|
* @example With programmatic selection control
|
|
65
65
|
* ```tsx
|
|
66
66
|
* function MapWithShapes() {
|
|
67
|
-
* const { selectedId, setSelectedId, clearSelection } =
|
|
67
|
+
* const { selectedId, setSelectedId, clearSelection } = useSelectShape(MAP_ID);
|
|
68
68
|
*
|
|
69
69
|
* return (
|
|
70
70
|
* <>
|
|
@@ -83,7 +83,7 @@ interface UseShapeSelectionReturn {
|
|
|
83
83
|
* }
|
|
84
84
|
* ```
|
|
85
85
|
*/
|
|
86
|
-
declare function
|
|
86
|
+
declare function useSelectShape(mapId: UniqueId): UseSelectShapeReturn;
|
|
87
87
|
//#endregion
|
|
88
|
-
export {
|
|
89
|
-
//# sourceMappingURL=use-shape
|
|
88
|
+
export { UseSelectShapeReturn, useSelectShape };
|
|
89
|
+
//# sourceMappingURL=use-select-shape.d.ts.map
|
package/dist/deckgl/shapes/display-shape-layer/{use-shape-selection.js → use-select-shape.js}
RENAMED
|
@@ -13,10 +13,9 @@
|
|
|
13
13
|
|
|
14
14
|
'use client';
|
|
15
15
|
|
|
16
|
-
import {
|
|
17
|
-
import { useSyncExternalStore } from "react";
|
|
16
|
+
import { shapeSelectionStore } from "./store.js";
|
|
18
17
|
|
|
19
|
-
//#region src/deckgl/shapes/display-shape-layer/use-shape
|
|
18
|
+
//#region src/deckgl/shapes/display-shape-layer/use-select-shape.ts
|
|
20
19
|
/**
|
|
21
20
|
* Hook to manage shape selection state with automatic deselection
|
|
22
21
|
*
|
|
@@ -35,10 +34,10 @@ import { useSyncExternalStore } from "react";
|
|
|
35
34
|
*
|
|
36
35
|
* @example Basic usage
|
|
37
36
|
* ```tsx
|
|
38
|
-
* import {
|
|
37
|
+
* import { useSelectShape } from '@accelint/map-toolkit/deckgl/shapes';
|
|
39
38
|
*
|
|
40
39
|
* function MapWithShapes() {
|
|
41
|
-
* const { selectedId } =
|
|
40
|
+
* const { selectedId } = useSelectShape(MAP_ID);
|
|
42
41
|
*
|
|
43
42
|
* return (
|
|
44
43
|
* <BaseMap id={MAP_ID}>
|
|
@@ -56,7 +55,7 @@ import { useSyncExternalStore } from "react";
|
|
|
56
55
|
* @example With programmatic selection control
|
|
57
56
|
* ```tsx
|
|
58
57
|
* function MapWithShapes() {
|
|
59
|
-
* const { selectedId, setSelectedId, clearSelection } =
|
|
58
|
+
* const { selectedId, setSelectedId, clearSelection } = useSelectShape(MAP_ID);
|
|
60
59
|
*
|
|
61
60
|
* return (
|
|
62
61
|
* <>
|
|
@@ -75,14 +74,15 @@ import { useSyncExternalStore } from "react";
|
|
|
75
74
|
* }
|
|
76
75
|
* ```
|
|
77
76
|
*/
|
|
78
|
-
function
|
|
77
|
+
function useSelectShape(mapId) {
|
|
78
|
+
const { state, setSelectedId, clearSelection } = shapeSelectionStore.use(mapId);
|
|
79
79
|
return {
|
|
80
|
-
selectedId:
|
|
81
|
-
setSelectedId
|
|
82
|
-
clearSelection
|
|
80
|
+
selectedId: state.selectedId,
|
|
81
|
+
setSelectedId,
|
|
82
|
+
clearSelection
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
//#endregion
|
|
87
|
-
export {
|
|
88
|
-
//# sourceMappingURL=use-shape
|
|
87
|
+
export { useSelectShape };
|
|
88
|
+
//# sourceMappingURL=use-select-shape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-select-shape.js","names":[],"sources":["../../../../src/deckgl/shapes/display-shape-layer/use-select-shape.ts"],"sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n'use client';\n\nimport { shapeSelectionStore } from './store';\nimport type { UniqueId } from '@accelint/core';\nimport type { ShapeId } from '../shared/types';\n\n/**\n * Return type for useSelectShape hook\n */\nexport interface UseSelectShapeReturn {\n /** Currently selected shape ID, or undefined if nothing selected */\n selectedId: ShapeId | undefined;\n /** Manually set the selected shape ID (useful for programmatic selection) */\n setSelectedId: (id: ShapeId | undefined) => void;\n /** Manually clear the selection */\n clearSelection: () => void;\n}\n\n/**\n * Hook to manage shape selection state with automatic deselection\n *\n * This hook encapsulates the common pattern of:\n * 1. Listening to `shapes:selected` events and updating state\n * 2. Listening to `shapes:deselected` events and clearing state\n * 3. Listening to map clicks on empty space and emitting `shapes:deselected`\n *\n * Uses a store pattern with `useSyncExternalStore` for proper listener cleanup\n * during HMR (Hot Module Replacement) in development. The store ensures only\n * one bus listener exists per map instance, regardless of how many React\n * components subscribe.\n *\n * @param mapId - The map instance ID for event filtering\n * @returns Selection state and control functions\n *\n * @example Basic usage\n * ```tsx\n * import { useSelectShape } from '@accelint/map-toolkit/deckgl/shapes';\n *\n * function MapWithShapes() {\n * const { selectedId } = useSelectShape(MAP_ID);\n *\n * return (\n * <BaseMap id={MAP_ID}>\n * <displayShapeLayer\n * id=\"shapes\"\n * mapId={MAP_ID}\n * data={shapes}\n * selectedShapeId={selectedId}\n * />\n * </BaseMap>\n * );\n * }\n * ```\n *\n * @example With programmatic selection control\n * ```tsx\n * function MapWithShapes() {\n * const { selectedId, setSelectedId, clearSelection } = useSelectShape(MAP_ID);\n *\n * return (\n * <>\n * <button onClick={() => setSelectedId(shapes[0].id)}>Select First Shape</button>\n * <button onClick={clearSelection}>Clear Selection</button>\n * <BaseMap id={MAP_ID}>\n * <displayShapeLayer\n * id=\"shapes\"\n * mapId={MAP_ID}\n * data={shapes}\n * selectedShapeId={selectedId}\n * />\n * </BaseMap>\n * </>\n * );\n * }\n * ```\n */\nexport function useSelectShape(mapId: UniqueId): UseSelectShapeReturn {\n const { state, setSelectedId, clearSelection } =\n shapeSelectionStore.use(mapId);\n\n return {\n selectedId: state.selectedId,\n setSelectedId,\n clearSelection,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFA,SAAgB,eAAe,OAAuC;CACpE,MAAM,EAAE,OAAO,eAAe,mBAC5B,oBAAoB,IAAI,MAAM;AAEhC,QAAO;EACL,YAAY,MAAM;EAClB;EACA;EACD"}
|
|
@@ -13,73 +13,12 @@
|
|
|
13
13
|
|
|
14
14
|
'use client';
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { DEFAULT_COLORS, HIGHLIGHT_WIDTH_INCREASE, HOVER_WIDTH_INCREASE } from "../../shared/constants.js";
|
|
17
|
+
import { getLineWidth, normalizeColor } from "../../shared/utils/style-utils.js";
|
|
17
18
|
|
|
18
19
|
//#region src/deckgl/shapes/display-shape-layer/utils/display-style.ts
|
|
19
20
|
/**
|
|
20
|
-
* Get
|
|
21
|
-
* Colors are passed through as-is unless applyBaseOpacity is true
|
|
22
|
-
*
|
|
23
|
-
* @param feature - The styled feature
|
|
24
|
-
* @param applyBaseOpacity - When true, multiplies alpha by BASE_FILL_OPACITY (0.6)
|
|
25
|
-
* @returns RGBA color array
|
|
26
|
-
*/
|
|
27
|
-
function getFillColor(feature, applyBaseOpacity = false) {
|
|
28
|
-
const rgba = normalizeColor((feature.properties?.styleProperties)?.fillColor ?? DEFAULT_COLORS.fill);
|
|
29
|
-
if (applyBaseOpacity) return [
|
|
30
|
-
rgba[0],
|
|
31
|
-
rgba[1],
|
|
32
|
-
rgba[2],
|
|
33
|
-
Math.round(rgba[3] * BASE_FILL_OPACITY)
|
|
34
|
-
];
|
|
35
|
-
return rgba;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Get stroke color for a feature
|
|
39
|
-
* Strokes are always rendered at their literal alpha value
|
|
40
|
-
*
|
|
41
|
-
* @param feature - The styled feature
|
|
42
|
-
* @returns RGBA color array
|
|
43
|
-
*/
|
|
44
|
-
function getStrokeColor(feature) {
|
|
45
|
-
return normalizeColor((feature.properties?.styleProperties)?.strokeColor ?? DEFAULT_COLORS.stroke);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Normalize a Color to a 4-element RGBA array
|
|
49
|
-
* Handles RGB arrays (adds alpha 255), RGBA arrays, and typed arrays
|
|
50
|
-
*/
|
|
51
|
-
function normalizeColor(color) {
|
|
52
|
-
if (color instanceof Uint8Array || color instanceof Uint8ClampedArray) return [
|
|
53
|
-
color[0] ?? 0,
|
|
54
|
-
color[1] ?? 0,
|
|
55
|
-
color[2] ?? 0,
|
|
56
|
-
color[3] ?? 255
|
|
57
|
-
];
|
|
58
|
-
return [
|
|
59
|
-
color[0],
|
|
60
|
-
color[1],
|
|
61
|
-
color[2],
|
|
62
|
-
color[3] ?? 255
|
|
63
|
-
];
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get line width for a feature
|
|
67
|
-
*/
|
|
68
|
-
function getLineWidth(feature) {
|
|
69
|
-
return (feature.properties?.styleProperties)?.strokeWidth ?? DEFAULT_STROKE_WIDTH;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Alias for getLineWidth (for compatibility)
|
|
73
|
-
*/
|
|
74
|
-
const getStrokeWidth = getLineWidth;
|
|
75
|
-
/**
|
|
76
|
-
* Get dash array for stroke pattern
|
|
77
|
-
*/
|
|
78
|
-
function getDashArray(feature) {
|
|
79
|
-
return DASH_ARRAYS[(feature.properties?.styleProperties)?.strokePattern ?? "solid"] || null;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Get hover-enhanced line width
|
|
21
|
+
* Get hover-enhanced border/outline width
|
|
83
22
|
*/
|
|
84
23
|
function getHoverLineWidth(feature, isHovered) {
|
|
85
24
|
const baseWidth = getLineWidth(feature);
|
|
@@ -100,12 +39,12 @@ function getHighlightColor(opacity) {
|
|
|
100
39
|
return rgba;
|
|
101
40
|
}
|
|
102
41
|
/**
|
|
103
|
-
* Get highlight
|
|
42
|
+
* Get highlight border/outline width (base width + increase)
|
|
104
43
|
*/
|
|
105
44
|
function getHighlightLineWidth(feature) {
|
|
106
45
|
return getLineWidth(feature) + HIGHLIGHT_WIDTH_INCREASE;
|
|
107
46
|
}
|
|
108
47
|
|
|
109
48
|
//#endregion
|
|
110
|
-
export {
|
|
49
|
+
export { getHighlightColor, getHighlightLineWidth, getHoverLineWidth };
|
|
111
50
|
//# sourceMappingURL=display-style.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display-style.js","names":[],"sources":["../../../../../src/deckgl/shapes/display-shape-layer/utils/display-style.ts"],"sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n'use client';\n\nimport {\n
|
|
1
|
+
{"version":3,"file":"display-style.js","names":[],"sources":["../../../../../src/deckgl/shapes/display-shape-layer/utils/display-style.ts"],"sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n'use client';\n\nimport {\n DEFAULT_COLORS,\n HIGHLIGHT_WIDTH_INCREASE,\n HOVER_WIDTH_INCREASE,\n} from '../../shared/constants';\nimport { getLineWidth, normalizeColor } from '../../shared/utils/style-utils';\nimport type { StyledFeature } from '../../shared/types';\n\n/**\n * Get hover-enhanced border/outline width\n */\nexport function getHoverLineWidth(\n feature: StyledFeature,\n isHovered: boolean,\n): number {\n const baseWidth = getLineWidth(feature);\n return isHovered ? baseWidth + HOVER_WIDTH_INCREASE : baseWidth;\n}\n\n/**\n * Get selection highlight color\n * Returns the default highlight color or allows custom opacity override\n */\nexport function getHighlightColor(\n opacity?: number,\n): [number, number, number, number] {\n const rgba = normalizeColor(DEFAULT_COLORS.highlight);\n\n if (opacity !== undefined) {\n return [rgba[0], rgba[1], rgba[2], Math.round(opacity * 255)];\n }\n\n return rgba;\n}\n\n/**\n * Get highlight border/outline width (base width + increase)\n */\nexport function getHighlightLineWidth(feature: StyledFeature): number {\n const baseWidth = getLineWidth(feature);\n return baseWidth + HIGHLIGHT_WIDTH_INCREASE;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,kBACd,SACA,WACQ;CACR,MAAM,YAAY,aAAa,QAAQ;AACvC,QAAO,YAAY,YAAY,uBAAuB;;;;;;AAOxD,SAAgB,kBACd,SACkC;CAClC,MAAM,OAAO,eAAe,eAAe,UAAU;AAErD,KAAI,YAAY,OACd,QAAO;EAAC,KAAK;EAAI,KAAK;EAAI,KAAK;EAAI,KAAK,MAAM,UAAU,IAAI;EAAC;AAG/D,QAAO;;;;;AAMT,SAAgB,sBAAsB,SAAgC;AAEpE,QADkB,aAAa,QAAQ,GACpB"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import
|
|
13
|
+
import "../../shared/types.js";
|
|
14
14
|
|
|
15
15
|
//#region src/deckgl/shapes/display-shape-layer/utils/labels.d.ts
|
|
16
16
|
/**
|
|
@@ -26,38 +26,6 @@ interface LabelPosition2d {
|
|
|
26
26
|
/** Pixel offset from coordinates [x, y] */
|
|
27
27
|
pixelOffset: [number, number];
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Calculate a point along a line segment
|
|
31
|
-
* @param start - Start coordinate [lon, lat]
|
|
32
|
-
* @param end - End coordinate [lon, lat]
|
|
33
|
-
* @param ratio - Position along segment (0 = start, 0.5 = middle, 1 = end)
|
|
34
|
-
* @returns Interpolated coordinate [lon, lat]
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* // Get a point 25% along a line segment
|
|
38
|
-
* const start: [number, number] = [-122.4, 37.8];
|
|
39
|
-
* const end: [number, number] = [-122.3, 37.9];
|
|
40
|
-
* const point = interpolatePoint(start, end, 0.25);
|
|
41
|
-
*/
|
|
42
|
-
declare function interpolatePoint(start: [number, number], end: [number, number], ratio: number): [number, number];
|
|
43
|
-
/**
|
|
44
|
-
* Get the midpoint of a LineString
|
|
45
|
-
* @param coordinates - LineString coordinates array
|
|
46
|
-
* @returns Midpoint coordinate [lon, lat]
|
|
47
|
-
*/
|
|
48
|
-
declare function getLineStringMidpoint(coordinates: [number, number][]): [number, number];
|
|
49
|
-
/**
|
|
50
|
-
* Get the end point of a LineString
|
|
51
|
-
* @param coordinates - LineString coordinates array
|
|
52
|
-
* @returns End coordinate [lon, lat]
|
|
53
|
-
*/
|
|
54
|
-
declare function getLineStringEndpoint(coordinates: [number, number][]): [number, number];
|
|
55
|
-
/**
|
|
56
|
-
* Get the midpoint of a Polygon's outer ring
|
|
57
|
-
* @param coordinates - Polygon coordinates array (rings)
|
|
58
|
-
* @returns Midpoint of outer ring [lon, lat]
|
|
59
|
-
*/
|
|
60
|
-
declare function getPolygonMidpoint(coordinates: [number, number][][]): [number, number];
|
|
61
29
|
/**
|
|
62
30
|
* Vertical label position relative to anchor point
|
|
63
31
|
*/
|
|
@@ -160,37 +128,6 @@ interface LabelPositionOptions {
|
|
|
160
128
|
/** Pixel offset for Circle labels [x, y] @default [0, 10] */
|
|
161
129
|
circleLabelOffset?: [number, number];
|
|
162
130
|
}
|
|
163
|
-
/**
|
|
164
|
-
* Get 2D position for label based on geometry type
|
|
165
|
-
* Uses pixel-based offsets for consistent positioning at all zoom levels
|
|
166
|
-
*
|
|
167
|
-
* Priority for positioning:
|
|
168
|
-
* 1. Per-shape properties in styleProperties (highest)
|
|
169
|
-
* 2. Global labelOptions from layer props
|
|
170
|
-
* 3. Default values (fallback)
|
|
171
|
-
*
|
|
172
|
-
* Returns null if no valid coordinates can be determined
|
|
173
|
-
*/
|
|
174
|
-
declare function getLabelPosition2d(shape: EditableShape, options?: LabelPositionOptions): LabelPosition2d | null;
|
|
175
|
-
/**
|
|
176
|
-
* Get label text for a shape
|
|
177
|
-
*
|
|
178
|
-
* Returns the display label for the shape on the map in uppercase.
|
|
179
|
-
* - `label`: Optional short display name shown on the map (e.g., "NYC")
|
|
180
|
-
* - `name`: Full shape name used internally (e.g., "New York City Office")
|
|
181
|
-
*
|
|
182
|
-
* If `label` is not provided, falls back to using `name`.
|
|
183
|
-
* Text is automatically converted to uppercase for display.
|
|
184
|
-
*/
|
|
185
|
-
declare function getLabelText(shape: EditableShape): string;
|
|
186
|
-
/**
|
|
187
|
-
* Get label background color (uses RGB from shape fill color with fixed label opacity)
|
|
188
|
-
*/
|
|
189
|
-
declare function getLabelFillColor(shape: EditableShape): [number, number, number, number];
|
|
190
|
-
/**
|
|
191
|
-
* Get label border color (uses RGB from shape stroke color with full opacity)
|
|
192
|
-
*/
|
|
193
|
-
declare function getLabelBorderColor(shape: EditableShape): [number, number, number, number];
|
|
194
131
|
//#endregion
|
|
195
|
-
export { CardinalLabelCoordinateAnchor, LabelHorizontalPosition, LabelPosition2d, LabelPositionOptions, LabelVerticalPosition
|
|
132
|
+
export { CardinalLabelCoordinateAnchor, LabelHorizontalPosition, LabelPosition2d, LabelPositionOptions, LabelVerticalPosition };
|
|
196
133
|
//# sourceMappingURL=labels.d.ts.map
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
'use client';
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { isCircleShape } from "../../shared/types.js";
|
|
17
17
|
|
|
18
18
|
//#region src/deckgl/shapes/display-shape-layer/utils/labels.ts
|
|
19
19
|
/**
|
|
@@ -59,90 +59,6 @@ import { LABEL_BACKGROUND_OPACITY, LABEL_BORDER_OPACITY } from "../../shared/con
|
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
61
|
/**
|
|
62
|
-
* Calculate a point along a line segment
|
|
63
|
-
* @param start - Start coordinate [lon, lat]
|
|
64
|
-
* @param end - End coordinate [lon, lat]
|
|
65
|
-
* @param ratio - Position along segment (0 = start, 0.5 = middle, 1 = end)
|
|
66
|
-
* @returns Interpolated coordinate [lon, lat]
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* // Get a point 25% along a line segment
|
|
70
|
-
* const start: [number, number] = [-122.4, 37.8];
|
|
71
|
-
* const end: [number, number] = [-122.3, 37.9];
|
|
72
|
-
* const point = interpolatePoint(start, end, 0.25);
|
|
73
|
-
*/
|
|
74
|
-
function interpolatePoint(start, end, ratio) {
|
|
75
|
-
const clampedRatio = Math.max(0, Math.min(1, ratio));
|
|
76
|
-
return [start[0] + (end[0] - start[0]) * clampedRatio, start[1] + (end[1] - start[1]) * clampedRatio];
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Calculate segment lengths for a line
|
|
80
|
-
*/
|
|
81
|
-
function calculateSegmentLengths(coordinates) {
|
|
82
|
-
let total = 0;
|
|
83
|
-
const lengths = [];
|
|
84
|
-
for (let i = 0; i < coordinates.length - 1; i++) {
|
|
85
|
-
const start = coordinates[i];
|
|
86
|
-
const end = coordinates[i + 1];
|
|
87
|
-
if (start && end) {
|
|
88
|
-
const length = Math.sqrt((end[0] - start[0]) ** 2 + (end[1] - start[1]) ** 2);
|
|
89
|
-
lengths.push(length);
|
|
90
|
-
total += length;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return {
|
|
94
|
-
lengths,
|
|
95
|
-
total
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Find point at specific distance along line
|
|
100
|
-
*/
|
|
101
|
-
function findPointAtDistance(coordinates, segmentLengths, targetDistance) {
|
|
102
|
-
let accumulatedLength = 0;
|
|
103
|
-
for (let i = 0; i < segmentLengths.length; i++) {
|
|
104
|
-
const segmentLength = segmentLengths[i];
|
|
105
|
-
if (!segmentLength) continue;
|
|
106
|
-
if (accumulatedLength + segmentLength >= targetDistance) {
|
|
107
|
-
const start = coordinates[i];
|
|
108
|
-
const end = coordinates[i + 1];
|
|
109
|
-
if (start && end) return interpolatePoint(start, end, (targetDistance - accumulatedLength) / segmentLength);
|
|
110
|
-
}
|
|
111
|
-
accumulatedLength += segmentLength;
|
|
112
|
-
}
|
|
113
|
-
return coordinates[coordinates.length - 1] ?? [0, 0];
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Get the midpoint of a LineString
|
|
117
|
-
* @param coordinates - LineString coordinates array
|
|
118
|
-
* @returns Midpoint coordinate [lon, lat]
|
|
119
|
-
*/
|
|
120
|
-
function getLineStringMidpoint(coordinates) {
|
|
121
|
-
if (coordinates.length === 0) return [0, 0];
|
|
122
|
-
if (coordinates.length === 1) return coordinates[0] ?? [0, 0];
|
|
123
|
-
const { lengths, total } = calculateSegmentLengths(coordinates);
|
|
124
|
-
return findPointAtDistance(coordinates, lengths, total / 2);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Get the end point of a LineString
|
|
128
|
-
* @param coordinates - LineString coordinates array
|
|
129
|
-
* @returns End coordinate [lon, lat]
|
|
130
|
-
*/
|
|
131
|
-
function getLineStringEndpoint(coordinates) {
|
|
132
|
-
if (coordinates.length === 0) return [0, 0];
|
|
133
|
-
return coordinates[coordinates.length - 1] ?? [0, 0];
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Get the midpoint of a Polygon's outer ring
|
|
137
|
-
* @param coordinates - Polygon coordinates array (rings)
|
|
138
|
-
* @returns Midpoint of outer ring [lon, lat]
|
|
139
|
-
*/
|
|
140
|
-
function getPolygonMidpoint(coordinates) {
|
|
141
|
-
const outerRing = coordinates[0];
|
|
142
|
-
if (!outerRing || outerRing.length === 0) return [0, 0];
|
|
143
|
-
return getLineStringMidpoint(outerRing);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
62
|
* Convert vertical/horizontal position to deck.gl textAnchor and alignmentBaseline
|
|
147
63
|
*/
|
|
148
64
|
function convertPositionToAnchors(vertical, horizontal) {
|
|
@@ -277,7 +193,7 @@ function getCirclePosition(ring, shapeOffset, shapeVertical, shapeHorizontal, sh
|
|
|
277
193
|
*/
|
|
278
194
|
function getPolygonPosition(geometry, shape, shapeOffset, shapeVertical, shapeHorizontal, shapeCoordinateAnchor, options) {
|
|
279
195
|
const ring = geometry.coordinates[0];
|
|
280
|
-
if (shape
|
|
196
|
+
if (isCircleShape(shape)) return getCirclePosition(ring, shapeOffset, shapeVertical, shapeHorizontal, shapeCoordinateAnchor, options);
|
|
281
197
|
const defaultOffset = [0, 10];
|
|
282
198
|
const defaultVertical = "top";
|
|
283
199
|
const defaultHorizontal = "center";
|
|
@@ -328,41 +244,7 @@ function getLabelPosition2d(shape, options) {
|
|
|
328
244
|
function getLabelText(shape) {
|
|
329
245
|
return (shape.label || shape.name).toUpperCase();
|
|
330
246
|
}
|
|
331
|
-
/**
|
|
332
|
-
* Get label background color (uses RGB from shape fill color with fixed label opacity)
|
|
333
|
-
*/
|
|
334
|
-
function getLabelFillColor(shape) {
|
|
335
|
-
const fillColor = (shape.feature.properties?.styleProperties)?.fillColor ?? [
|
|
336
|
-
98,
|
|
337
|
-
166,
|
|
338
|
-
255,
|
|
339
|
-
255
|
|
340
|
-
];
|
|
341
|
-
return [
|
|
342
|
-
fillColor[0] ?? 98,
|
|
343
|
-
fillColor[1] ?? 166,
|
|
344
|
-
fillColor[2] ?? 255,
|
|
345
|
-
LABEL_BACKGROUND_OPACITY
|
|
346
|
-
];
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Get label border color (uses RGB from shape stroke color with full opacity)
|
|
350
|
-
*/
|
|
351
|
-
function getLabelBorderColor(shape) {
|
|
352
|
-
const strokeColor = (shape.feature.properties?.styleProperties)?.strokeColor ?? [
|
|
353
|
-
98,
|
|
354
|
-
166,
|
|
355
|
-
255,
|
|
356
|
-
255
|
|
357
|
-
];
|
|
358
|
-
return [
|
|
359
|
-
strokeColor[0] ?? 98,
|
|
360
|
-
strokeColor[1] ?? 166,
|
|
361
|
-
strokeColor[2] ?? 255,
|
|
362
|
-
LABEL_BORDER_OPACITY
|
|
363
|
-
];
|
|
364
|
-
}
|
|
365
247
|
|
|
366
248
|
//#endregion
|
|
367
|
-
export {
|
|
249
|
+
export { getLabelPosition2d, getLabelText };
|
|
368
250
|
//# sourceMappingURL=labels.js.map
|