@mapvx/web-js 3.1.0 → 3.2.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/cjs/controllers/markerLayoutController.js +359 -0
- package/dist/cjs/controllers/markerLayoutController.js.map +1 -0
- package/dist/cjs/controllers/routeController.js +13 -0
- package/dist/cjs/controllers/routeController.js.map +1 -1
- package/dist/cjs/domain/models/mapConfig.js +14 -1
- package/dist/cjs/domain/models/mapConfig.js.map +1 -1
- package/dist/cjs/domain/models/marker.js +147 -82
- package/dist/cjs/domain/models/marker.js.map +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/logger/sentry.js +1 -1
- package/dist/cjs/map/map.js +41 -3
- package/dist/cjs/map/map.js.map +1 -1
- package/dist/cjs/utils/mapvxHostname.js +4 -3
- package/dist/cjs/utils/mapvxHostname.js.map +1 -1
- package/dist/es/config/sdkConfig.d.ts +1 -1
- package/dist/es/controllers/markerLayoutController.d.ts +148 -0
- package/dist/es/controllers/markerLayoutController.d.ts.map +1 -0
- package/dist/es/controllers/markerLayoutController.js +351 -0
- package/dist/es/controllers/markerLayoutController.js.map +1 -0
- package/dist/es/controllers/routeController.d.ts +7 -0
- package/dist/es/controllers/routeController.d.ts.map +1 -1
- package/dist/es/controllers/routeController.js +13 -0
- package/dist/es/controllers/routeController.js.map +1 -1
- package/dist/es/domain/models/mapConfig.d.ts +96 -0
- package/dist/es/domain/models/mapConfig.d.ts.map +1 -1
- package/dist/es/domain/models/mapConfig.js +13 -0
- package/dist/es/domain/models/mapConfig.js.map +1 -1
- package/dist/es/domain/models/marker.d.ts +232 -1
- package/dist/es/domain/models/marker.d.ts.map +1 -1
- package/dist/es/domain/models/marker.js +146 -82
- package/dist/es/domain/models/marker.js.map +1 -1
- package/dist/es/index.d.ts +2 -2
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +1 -1
- package/dist/es/index.js.map +1 -1
- package/dist/es/logger/sentry.js +1 -1
- package/dist/es/map/map.d.ts +15 -1
- package/dist/es/map/map.d.ts.map +1 -1
- package/dist/es/map/map.js +42 -4
- package/dist/es/map/map.js.map +1 -1
- package/dist/es/utils/mapvxHostname.d.ts +3 -2
- package/dist/es/utils/mapvxHostname.d.ts.map +1 -1
- package/dist/es/utils/mapvxHostname.js +4 -3
- package/dist/es/utils/mapvxHostname.js.map +1 -1
- package/dist/umd/index.js +867 -133
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/styles.css +45 -19
- package/dist/umd/styles.css.map +1 -1
- package/package.json +1 -1
|
@@ -74,6 +74,94 @@ export declare const DEFAULT_TILE_CACHE_CONFIG: Required<MapTileCacheConfig>;
|
|
|
74
74
|
* @internal
|
|
75
75
|
*/
|
|
76
76
|
export declare const MAPLIBRE_MAX_TILE_CACHE_HARD_CAP = 100000;
|
|
77
|
+
/**
|
|
78
|
+
* Configuration for automatic marker label collision avoidance.
|
|
79
|
+
*
|
|
80
|
+
* When enabled, a marker's text label (see `MarkerConfig.textPosition`) is
|
|
81
|
+
* treated as a preferred starting side rather than a fixed placement: the
|
|
82
|
+
* SDK checks it against neighboring markers' icons and labels, moves it to
|
|
83
|
+
* a free side (right/top/left/bottom) when its preferred side is occupied,
|
|
84
|
+
* and hides it entirely when no side is collision-free. The marker's icon
|
|
85
|
+
* itself never moves.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const markerLayoutConfig: MarkerLayoutConfig = {
|
|
90
|
+
* enabled: true,
|
|
91
|
+
* minZoomForLabels: 17,
|
|
92
|
+
* gapPx: 8,
|
|
93
|
+
* maxLabelWidthPx: 160,
|
|
94
|
+
* };
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @group Configuration
|
|
98
|
+
*/
|
|
99
|
+
export interface MarkerLayoutConfig {
|
|
100
|
+
/**
|
|
101
|
+
* Enable automatic label collision avoidance.
|
|
102
|
+
* When false, labels always render at their configured `textPosition`,
|
|
103
|
+
* exactly like before this feature existed.
|
|
104
|
+
* @default true
|
|
105
|
+
*/
|
|
106
|
+
enabled?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Zoom level below which no label is rendered at all. Markers keep their
|
|
109
|
+
* icons; only the text is withheld.
|
|
110
|
+
*
|
|
111
|
+
* Motivated by dense maps: zoomed out, hundreds of pins share a few
|
|
112
|
+
* hundred pixels and nearly every label would be hidden by collision
|
|
113
|
+
* avoidance anyway, one at a time and in an order the caller cannot
|
|
114
|
+
* predict. A single threshold makes that state deliberate and uniform —
|
|
115
|
+
* pins only, then labels once the camera is close enough for them to fit.
|
|
116
|
+
*
|
|
117
|
+
* Evaluated continuously as the camera moves, so labels appear the moment
|
|
118
|
+
* the zoom crosses the threshold rather than when the gesture ends.
|
|
119
|
+
*
|
|
120
|
+
* Labels withheld by this threshold are not obstacles: they never occupy
|
|
121
|
+
* space for their neighbors, so nothing is displaced on their behalf.
|
|
122
|
+
*
|
|
123
|
+
* Requires `enabled: true`: `enabled: false` short-circuits the entire
|
|
124
|
+
* layout pass, so the threshold is never evaluated either.
|
|
125
|
+
*
|
|
126
|
+
* @default -Infinity (no threshold — labels are placed at every zoom)
|
|
127
|
+
*/
|
|
128
|
+
minZoomForLabels?: number;
|
|
129
|
+
/**
|
|
130
|
+
* Horizontal gap, in pixels, between an icon and a label placed to its
|
|
131
|
+
* left or right. Drives both the collision math and the rendered offset
|
|
132
|
+
* (published as the `--mapvx-label-gap` CSS custom property).
|
|
133
|
+
* @default 8
|
|
134
|
+
*/
|
|
135
|
+
gapPx?: number;
|
|
136
|
+
/**
|
|
137
|
+
* Vertical gap, in pixels, between an icon and a label placed above or
|
|
138
|
+
* below it. Drives both the collision math and the rendered offset
|
|
139
|
+
* (published as the `--mapvx-label-vertical-gap` CSS custom property).
|
|
140
|
+
* @default 4
|
|
141
|
+
*/
|
|
142
|
+
verticalGapPx?: number;
|
|
143
|
+
/**
|
|
144
|
+
* Extra buffer, in pixels, added around every box when testing for
|
|
145
|
+
* collisions between a marker and its *neighbors*. Higher values leave
|
|
146
|
+
* more visual breathing room between labels/icons at the cost of hiding
|
|
147
|
+
* labels sooner under crowding. A label's distance from its own icon is
|
|
148
|
+
* set by `gapPx`/`verticalGapPx` alone and is unaffected by this.
|
|
149
|
+
* @default 4
|
|
150
|
+
*/
|
|
151
|
+
paddingPx?: number;
|
|
152
|
+
/**
|
|
153
|
+
* Default maximum label width, in pixels, before truncation. Applied to
|
|
154
|
+
* every marker added through `addMarker`, and overridable per marker via
|
|
155
|
+
* `MarkerConfig.maxLabelWidthPx`.
|
|
156
|
+
* @default 200
|
|
157
|
+
*/
|
|
158
|
+
maxLabelWidthPx?: number;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Default values for marker layout configuration
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
export declare const DEFAULT_MARKER_LAYOUT_CONFIG: Required<MarkerLayoutConfig>;
|
|
77
165
|
/**
|
|
78
166
|
* Basic configuration for the map.
|
|
79
167
|
* Provides essential settings for initializing and customizing map behavior.
|
|
@@ -123,6 +211,7 @@ export declare const MAPLIBRE_MAX_TILE_CACHE_HARD_CAP = 100000;
|
|
|
123
211
|
* @property authToken - (Optional) Authentication token for accessing protected map resources. Required for loading map related data from Portal.
|
|
124
212
|
* @property apiUrl - (Optional) Injected by SDK when creating map; base API URL for map requests.
|
|
125
213
|
* @property mapvxRequestContext - (Optional) Injected by SDK when creating map; context sent as headers to public-api.mapvx.com.
|
|
214
|
+
* @property markerLayout - (Optional) Automatic marker label collision avoidance configuration.
|
|
126
215
|
*/
|
|
127
216
|
export interface MapConfig {
|
|
128
217
|
/**
|
|
@@ -350,6 +439,13 @@ export interface MapConfig {
|
|
|
350
439
|
* @see {@link MapTileCacheConfig} for available options
|
|
351
440
|
*/
|
|
352
441
|
tileCache?: MapTileCacheConfig;
|
|
442
|
+
/**
|
|
443
|
+
* Automatic marker label collision avoidance configuration.
|
|
444
|
+
* Controls how marker text labels move or hide to avoid overlapping
|
|
445
|
+
* neighboring markers.
|
|
446
|
+
* @see {@link MarkerLayoutConfig} for available options
|
|
447
|
+
*/
|
|
448
|
+
markerLayout?: MarkerLayoutConfig;
|
|
353
449
|
/**
|
|
354
450
|
* Mode of the map.
|
|
355
451
|
* Controls the mode of the map.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapConfig.d.ts","sourceRoot":"","sources":["../../../../src/domain/models/mapConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"mapConfig.d.ts","sourceRoot":"","sources":["../../../../src/domain/models/mapConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAE9C;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAEhC;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAE9B;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC;AAED;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,kBAAkB,CAOlE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,SAAU,CAAA;AAEvD;;;;;;;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B,CAAA;IAEjC;;;;;;;;;;;;OAYG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IAElB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_MAX_LABEL_WIDTH_PX } from "./marker";
|
|
1
2
|
/**
|
|
2
3
|
* Default values for tile cache configuration
|
|
3
4
|
* @internal
|
|
@@ -18,4 +19,16 @@ export const DEFAULT_TILE_CACHE_CONFIG = {
|
|
|
18
19
|
* @internal
|
|
19
20
|
*/
|
|
20
21
|
export const MAPLIBRE_MAX_TILE_CACHE_HARD_CAP = 100000;
|
|
22
|
+
/**
|
|
23
|
+
* Default values for marker layout configuration
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export const DEFAULT_MARKER_LAYOUT_CONFIG = {
|
|
27
|
+
enabled: true,
|
|
28
|
+
minZoomForLabels: Number.NEGATIVE_INFINITY,
|
|
29
|
+
gapPx: 8,
|
|
30
|
+
verticalGapPx: 4,
|
|
31
|
+
paddingPx: 4,
|
|
32
|
+
maxLabelWidthPx: DEFAULT_MAX_LABEL_WIDTH_PX,
|
|
33
|
+
};
|
|
21
34
|
//# sourceMappingURL=mapConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapConfig.js","sourceRoot":"","sources":["../../../../src/domain/models/mapConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mapConfig.js","sourceRoot":"","sources":["../../../../src/domain/models/mapConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAA;AAqErD;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAiC;IACrE,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,GAAG;IACb,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,aAAa;IACpC,sBAAsB,EAAE,IAAI;IAC5B,oBAAoB,EAAE,KAAK;IAC3B,wBAAwB,EAAE,CAAC;CAC5B,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAO,CAAA;AA2FvD;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAiC;IACxE,OAAO,EAAE,IAAI;IACb,gBAAgB,EAAE,MAAM,CAAC,iBAAiB;IAC1C,KAAK,EAAE,CAAC;IACR,aAAa,EAAE,CAAC;IAChB,SAAS,EAAE,CAAC;IACZ,eAAe,EAAE,0BAA0B;CAC5C,CAAA"}
|
|
@@ -25,6 +25,20 @@ export declare enum TextPosition {
|
|
|
25
25
|
/** Text positioned below the icon */
|
|
26
26
|
bottom = 3
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Fallback icon width/height, in pixels, used whenever a marker is created
|
|
30
|
+
* without explicit `iconProperties`.
|
|
31
|
+
*
|
|
32
|
+
* @group Markers
|
|
33
|
+
*/
|
|
34
|
+
export declare const DEFAULT_ICON_SIZE_PX = 40;
|
|
35
|
+
/**
|
|
36
|
+
* Fallback maximum label width, in pixels, used whenever neither the marker
|
|
37
|
+
* nor the map's `markerLayout` configuration specifies one.
|
|
38
|
+
*
|
|
39
|
+
* @group Markers
|
|
40
|
+
*/
|
|
41
|
+
export declare const DEFAULT_MAX_LABEL_WIDTH_PX = 200;
|
|
28
42
|
/**
|
|
29
43
|
* Alignment options for marker rotation and pitch behavior.
|
|
30
44
|
* Controls how the marker responds to map rotation and pitch changes.
|
|
@@ -69,10 +83,33 @@ export interface MarkerConfig {
|
|
|
69
83
|
*/
|
|
70
84
|
floorId?: string;
|
|
71
85
|
/**
|
|
72
|
-
* The position of the marker's text relative to its
|
|
86
|
+
* The preferred position of the marker's text relative to its icon.
|
|
87
|
+
*
|
|
88
|
+
* This is a starting preference, not a guaranteed final placement: when
|
|
89
|
+
* automatic label collision avoidance is enabled (see `markerLayout` on
|
|
90
|
+
* `MapConfig`), the SDK may move the label to a different side (or hide it)
|
|
91
|
+
* to avoid overlapping a neighboring marker's icon or label.
|
|
73
92
|
* @see {@link TextPosition} for available positioning options
|
|
74
93
|
*/
|
|
75
94
|
textPosition?: TextPosition;
|
|
95
|
+
/**
|
|
96
|
+
* Maximum width, in pixels, of the marker's text label before it is
|
|
97
|
+
* truncated with an ellipsis. Also used as the label's footprint when
|
|
98
|
+
* computing automatic collision avoidance, so the visual cap and the
|
|
99
|
+
* layout math always agree.
|
|
100
|
+
*
|
|
101
|
+
* Defaults to the map-level `markerLayout.maxLabelWidthPx`, which itself
|
|
102
|
+
* defaults to {@link DEFAULT_MAX_LABEL_WIDTH_PX}.
|
|
103
|
+
*/
|
|
104
|
+
maxLabelWidthPx?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Priority used to resolve label collisions: when two markers' labels
|
|
107
|
+
* would overlap, the one with the higher `labelPriority` keeps its
|
|
108
|
+
* preferred position (or any non-colliding position) first, and the other
|
|
109
|
+
* is displaced or hidden. Ties are broken by the order markers were added.
|
|
110
|
+
* @defaultValue 0
|
|
111
|
+
*/
|
|
112
|
+
labelPriority?: number;
|
|
76
113
|
/**
|
|
77
114
|
* The icon element to be displayed within the marker.
|
|
78
115
|
* Can be either a URL string or an HTML element.
|
|
@@ -97,6 +134,11 @@ export interface MarkerConfig {
|
|
|
97
134
|
/**
|
|
98
135
|
* The HTML element associated with the marker.
|
|
99
136
|
* If provided, this element will be used instead of the icon and text properties.
|
|
137
|
+
*
|
|
138
|
+
* Pair it with `iconProperties` when the element's footprint is known:
|
|
139
|
+
* that pins the marker's own box (and therefore its anchor point) instead
|
|
140
|
+
* of letting the element size it, and gives automatic label collision
|
|
141
|
+
* avoidance an exact rect to work with.
|
|
100
142
|
*/
|
|
101
143
|
element?: HTMLElement;
|
|
102
144
|
/**
|
|
@@ -185,6 +227,114 @@ export interface TextProperties {
|
|
|
185
227
|
*/
|
|
186
228
|
textShadow?: string;
|
|
187
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* Utility class for creating and manipulating marker elements on a map.
|
|
232
|
+
* Provides static methods for marker element creation and styling.
|
|
233
|
+
*/
|
|
234
|
+
export declare class MarkerUtils {
|
|
235
|
+
/**
|
|
236
|
+
* Creates a container element for the marker and adds the icon and text
|
|
237
|
+
* according to the properties specified in the `MarkerConfig` object.
|
|
238
|
+
*
|
|
239
|
+
* @param marker - `MarkerConfig` object containing the marker configuration
|
|
240
|
+
* @returns Marker container element ready to be added to the map
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* const markerElement = MarkerUtils.createMarkerElement(markerConfig);
|
|
245
|
+
* map.addLayer(markerElement);
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
static createMarkerElement(marker: MarkerConfig): HTMLElement;
|
|
249
|
+
/**
|
|
250
|
+
* Appends the marker's text label (if any) to the container, positioned
|
|
251
|
+
* around whichever element (icon or custom `element`) is already there.
|
|
252
|
+
*
|
|
253
|
+
* @param markerConfig - Configuration object containing text properties
|
|
254
|
+
* @param container - Container element to append the label to
|
|
255
|
+
* @returns The same container, with the label appended when text is present
|
|
256
|
+
*/
|
|
257
|
+
private static setAndCreateText;
|
|
258
|
+
/**
|
|
259
|
+
* Creates an icon element with proper styling.
|
|
260
|
+
*
|
|
261
|
+
* @param marker - Marker configuration
|
|
262
|
+
* @param iconWidth - Width of the icon
|
|
263
|
+
* @param iconHeight - Height of the icon
|
|
264
|
+
* @returns Icon element ready to be added to the container
|
|
265
|
+
*/
|
|
266
|
+
private static createIconElement;
|
|
267
|
+
/**
|
|
268
|
+
* Creates a text container, absolutely positioned around the marker's icon
|
|
269
|
+
* via CSS (see `.text-container` in styles.css), so the label never affects
|
|
270
|
+
* the container's own box.
|
|
271
|
+
*
|
|
272
|
+
* @param textElement - The text element to contain
|
|
273
|
+
* @param textPosition - Desired position relative to the icon
|
|
274
|
+
* @param maxLabelWidthPx - Maximum label width in pixels before truncation
|
|
275
|
+
* @returns Container with text positioned using CSS classes
|
|
276
|
+
*/
|
|
277
|
+
private static createTextContainer;
|
|
278
|
+
/**
|
|
279
|
+
* Resolves an optional {@link TextPosition} to its default (`right`), the
|
|
280
|
+
* same default `createTextContainer` has always applied.
|
|
281
|
+
*/
|
|
282
|
+
static resolveTextPosition(textPosition?: TextPosition): TextPosition;
|
|
283
|
+
/**
|
|
284
|
+
* Swaps a text container's position class, keeping exactly one of
|
|
285
|
+
* `top|bottom|left|right` applied at a time.
|
|
286
|
+
*/
|
|
287
|
+
private static setTextPositionClass;
|
|
288
|
+
/**
|
|
289
|
+
* Repositions (or hides) a marker's already-rendered text label at
|
|
290
|
+
* runtime, without rebuilding any DOM. Used both by automatic collision
|
|
291
|
+
* avoidance and by anything else that needs to move a label after
|
|
292
|
+
* creation.
|
|
293
|
+
*
|
|
294
|
+
* @param textContainer - The `.text-container` element to reposition
|
|
295
|
+
* @param position - Side of the icon the label should render on
|
|
296
|
+
* @param hidden - Whether the label should be hidden (kept measurable via
|
|
297
|
+
* `visibility`, never removed via `display`, so it can be measured again
|
|
298
|
+
* to decide whether it fits once something else changes)
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```typescript
|
|
302
|
+
* MarkerUtils.applyTextPosition(textEl, TextPosition.left, false);
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
static applyTextPosition(textContainer: HTMLElement, position: TextPosition, hidden: boolean): void;
|
|
306
|
+
/**
|
|
307
|
+
* Creates and returns an icon element for the marker, using the image URL
|
|
308
|
+
* specified in the `MarkerConfig` object.
|
|
309
|
+
*
|
|
310
|
+
* @param marker - `MarkerConfig` object containing the marker configuration
|
|
311
|
+
* @returns Marker icon element with proper styling and dimensions
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```typescript
|
|
315
|
+
* const iconElement = MarkerUtils.createIcon(markerConfig);
|
|
316
|
+
* container.appendChild(iconElement);
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
319
|
+
static createIcon(marker: MarkerConfig): HTMLElement;
|
|
320
|
+
/**
|
|
321
|
+
* Creates and returns a text element for the marker container, applying
|
|
322
|
+
* custom text styles if provided in the marker properties.
|
|
323
|
+
*
|
|
324
|
+
* @param text - Text content to display
|
|
325
|
+
* @param properties - Optional text styling properties
|
|
326
|
+
* @returns Text element with applied styles
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```typescript
|
|
330
|
+
* const textElement = MarkerUtils.createTextElement("Coffee Shop", {
|
|
331
|
+
* fontSize: "14px",
|
|
332
|
+
* color: "#333333"
|
|
333
|
+
* });
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
private static createTextElement;
|
|
337
|
+
}
|
|
188
338
|
/**
|
|
189
339
|
* Custom implementation of a MapLibre Marker with additional functionality.
|
|
190
340
|
* Extends the base MapLibre Marker class with MapVX-specific features.
|
|
@@ -215,6 +365,59 @@ export declare class MarkerAttribute extends Marker {
|
|
|
215
365
|
* Used for indoor navigation and floor-specific marker management.
|
|
216
366
|
*/
|
|
217
367
|
floorId?: string;
|
|
368
|
+
/**
|
|
369
|
+
* Resolved icon dimensions (defaults to {@link DEFAULT_ICON_SIZE_PX} square
|
|
370
|
+
* when unspecified), matching whatever `MarkerUtils.createMarkerElement`
|
|
371
|
+
* rendered. Used by automatic label collision avoidance to compute the
|
|
372
|
+
* icon's on-screen rect without a DOM measurement — except when
|
|
373
|
+
* {@link measureIconFromDom} is set.
|
|
374
|
+
* @internal
|
|
375
|
+
*/
|
|
376
|
+
iconSize: {
|
|
377
|
+
width: number;
|
|
378
|
+
height: number;
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* The `PositionAnchor` this marker was created with, needed by automatic
|
|
382
|
+
* label collision avoidance to translate a screen point into the icon's
|
|
383
|
+
* on-screen rect the same way MapLibre itself does.
|
|
384
|
+
* @internal
|
|
385
|
+
*/
|
|
386
|
+
anchorType: PositionAnchor;
|
|
387
|
+
/**
|
|
388
|
+
* The marker's preferred text position, used as the first candidate by
|
|
389
|
+
* automatic label collision avoidance before it tries the other sides.
|
|
390
|
+
* @internal
|
|
391
|
+
*/
|
|
392
|
+
preferredTextPosition: TextPosition;
|
|
393
|
+
/**
|
|
394
|
+
* Priority used to resolve label collisions; see
|
|
395
|
+
* {@link MarkerConfig.labelPriority}.
|
|
396
|
+
* @internal
|
|
397
|
+
*/
|
|
398
|
+
labelPriority: number;
|
|
399
|
+
/**
|
|
400
|
+
* Cached reference to this marker's `.text-container` element, if it has
|
|
401
|
+
* a text label. Avoids querying the DOM on every layout pass.
|
|
402
|
+
* @internal
|
|
403
|
+
*/
|
|
404
|
+
textContainerEl?: HTMLElement;
|
|
405
|
+
/**
|
|
406
|
+
* True when the marker renders a caller-supplied `element` and no
|
|
407
|
+
* `iconProperties` declared its footprint. In that case {@link iconSize}
|
|
408
|
+
* is only a fallback and automatic label collision avoidance measures the
|
|
409
|
+
* marker element's real box from the DOM instead.
|
|
410
|
+
* @internal
|
|
411
|
+
*/
|
|
412
|
+
measureIconFromDom: boolean;
|
|
413
|
+
/**
|
|
414
|
+
* The config this marker currently renders from. {@link updateIcon} merges
|
|
415
|
+
* its (usually partial) config on top of this one, so an update that omits
|
|
416
|
+
* `iconProperties`, `textPosition` or `labelPriority` keeps whatever the
|
|
417
|
+
* marker already had instead of silently snapping back to the SDK defaults
|
|
418
|
+
* — both in the DOM it rebuilds and in the layout state derived from it.
|
|
419
|
+
*/
|
|
420
|
+
private currentConfig;
|
|
218
421
|
/**
|
|
219
422
|
* Constructs a new `MarkerAttribute` object with the specified properties.
|
|
220
423
|
*
|
|
@@ -231,6 +434,29 @@ export declare class MarkerAttribute extends Marker {
|
|
|
231
434
|
* ```
|
|
232
435
|
*/
|
|
233
436
|
constructor(markerConfig: MarkerConfig);
|
|
437
|
+
/**
|
|
438
|
+
* Derives the state automatic label collision avoidance reads (icon box,
|
|
439
|
+
* preferred label side, priority, label element) from a fully-resolved
|
|
440
|
+
* config. It is what assigns the fields declared with `!` above — the
|
|
441
|
+
* constructor always calls it, but TypeScript can't see through the
|
|
442
|
+
* indirection. Shared by the constructor and {@link updateIcon} so the two can
|
|
443
|
+
* never drift apart.
|
|
444
|
+
*/
|
|
445
|
+
private applyLayoutState;
|
|
446
|
+
/**
|
|
447
|
+
* Merges an update on top of the marker's current config, so a partial
|
|
448
|
+
* update such as `{ id, coordinate, icon }` keeps the marker's existing
|
|
449
|
+
* icon dimensions, label side and priority.
|
|
450
|
+
*
|
|
451
|
+
* `element` is deliberately *not* carried forward: it and `icon` are
|
|
452
|
+
* mutually exclusive rendering paths, and `updateIcon` has always chosen
|
|
453
|
+
* the path named by the update itself.
|
|
454
|
+
*/
|
|
455
|
+
private mergeConfig;
|
|
456
|
+
/**
|
|
457
|
+
* Finds this marker's `.text-container` child element, if it has one.
|
|
458
|
+
*/
|
|
459
|
+
private findTextContainerEl;
|
|
234
460
|
/**
|
|
235
461
|
* Adds the marker attribute to the specified map.
|
|
236
462
|
*
|
|
@@ -246,6 +472,11 @@ export declare class MarkerAttribute extends Marker {
|
|
|
246
472
|
/**
|
|
247
473
|
* Updates the icon of the marker attribute based on the specified marker configuration.
|
|
248
474
|
*
|
|
475
|
+
* The config is merged on top of the one the marker currently renders
|
|
476
|
+
* from, so a partial update keeps every property it omits — passing only
|
|
477
|
+
* `{ icon }` no longer resets the marker's icon dimensions, preferred
|
|
478
|
+
* label side or label priority to their defaults.
|
|
479
|
+
*
|
|
249
480
|
* @param marker - `MarkerConfig` object containing the new marker configuration
|
|
250
481
|
*
|
|
251
482
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marker.d.ts","sourceRoot":"","sources":["../../../../src/domain/models/marker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,GAAG,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAA;AAEnE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtC;;;;;;;;;;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