@tomtom-org/maps-sdk 0.36.9 → 0.38.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.
@@ -64,8 +64,9 @@ declare abstract class AbstractEventProxy {
64
64
  * @param sourceWithLayers The sources and layers to added.
65
65
  * @param handlerFn Function that will handle the event.
66
66
  * @param type Type of event to listen to.
67
+ * @param config Optional configuration for the event handler.
67
68
  */
68
- addEventHandler<T = MapGeoJSONFeature>(sourceWithLayers: SourceWithLayers, handlerFn: UserEventHandler<T>, type: EventType): void;
69
+ addEventHandler<T = MapGeoJSONFeature>(sourceWithLayers: SourceWithLayers, handlerFn: UserEventHandler<T>, type: EventType, config: EventHandlerConfig | undefined): void;
69
70
  /**
70
71
  * Removes the given sources and layers from the interactive list. When not present, nothing happens.
71
72
  * @param type The event type to be removed.
@@ -103,7 +104,7 @@ declare abstract class AbstractEventProxy {
103
104
  * handling map style changes by restoring the module's state when needed.
104
105
  *
105
106
  * @typeParam SOURCES_WITH_LAYERS - The type defining the sources and layers used by this module
106
- * @typeParam CFG - The configuration type for this module, or undefined if no configuration is needed
107
+ * @typeParam CFG - The configuration type for this module, or undefined if no configuration is needed. When defined, must extend MapModuleCommonConfig.
107
108
  *
108
109
  * @example
109
110
  * ```typescript
@@ -117,7 +118,7 @@ declare abstract class AbstractEventProxy {
117
118
  *
118
119
  * @group Shared
119
120
  */
120
- export declare abstract class AbstractMapModule<SOURCES_WITH_LAYERS extends SourcesWithLayers, CFG = undefined> {
121
+ export declare abstract class AbstractMapModule<SOURCES_WITH_LAYERS extends SourcesWithLayers, CFG extends MapModuleCommonConfig | undefined = undefined> {
121
122
  private readonly sourceType;
122
123
  /**
123
124
  * @ignore
@@ -666,6 +667,7 @@ export declare class BaseMapModule extends AbstractMapModule<BaseSourceAndLayers
666
667
  * @ignore
667
668
  */
668
669
  protected _applyConfig(config: BaseMapModuleConfig | undefined): {
670
+ events?: EventHandlerConfig;
669
671
  visible?: boolean;
670
672
  layerGroupsVisibility?: BaseMapLayerGroupsVisibility;
671
673
  } | undefined;
@@ -825,7 +827,7 @@ export declare class BaseMapModule extends AbstractMapModule<BaseSourceAndLayers
825
827
  *
826
828
  * @group Base Map
827
829
  */
828
- export declare type BaseMapModuleConfig = {
830
+ export declare type BaseMapModuleConfig = MapModuleCommonConfig & {
829
831
  /**
830
832
  * Controls the visibility of all layers associated with this module.
831
833
  *
@@ -964,7 +966,7 @@ export declare const buildRoutingLayers: (config?: RoutingModuleConfig, layerIDP
964
966
 
965
967
  /**
966
968
  * Parameters to identify a feature by its ID or index in a given features array.
967
- * @group User Events
969
+ * @group User Interaction Events
968
970
  */
969
971
  export declare type ByIdOrIndex = {
970
972
  /**
@@ -1118,7 +1120,7 @@ export declare type ChargingStopTextConfig = {
1118
1120
  * };
1119
1121
  * ```
1120
1122
  *
1121
- * @group User Events
1123
+ * @group User Interaction Events
1122
1124
  */
1123
1125
  export declare type CleanEventStateOptions = ByIdOrIndex & {
1124
1126
  /**
@@ -1156,7 +1158,7 @@ export declare type CleanEventStateOptions = ByIdOrIndex & {
1156
1158
  * };
1157
1159
  * ```
1158
1160
  *
1159
- * @group User Events
1161
+ * @group User Interaction Events
1160
1162
  */
1161
1163
  export declare type CleanEventStatesOptions = {
1162
1164
  /**
@@ -1203,7 +1205,7 @@ export declare type CleanEventStatesOptions = {
1203
1205
  * const rightClick: ClickEventType = 'contextmenu';
1204
1206
  * ```
1205
1207
  *
1206
- * @group User Events
1208
+ * @group User Interaction Events
1207
1209
  */
1208
1210
  export declare type ClickEventType = 'click' | 'contextmenu';
1209
1211
 
@@ -1226,6 +1228,13 @@ declare const colorPalettes: {
1226
1228
  pastelRainbow: string[];
1227
1229
  };
1228
1230
 
1231
+ /**
1232
+ * Allowed CSS cursor styles for map interactions.
1233
+ *
1234
+ * @group User Interaction Events
1235
+ */
1236
+ export declare type CSSCursor = 'alias' | 'all-scroll' | 'auto' | 'cell' | 'context-menu' | 'col-resize' | 'copy' | 'crosshair' | 'default' | 'e-resize' | 'ew-resize' | 'grab' | 'grabbing' | 'help' | 'move' | 'n-resize' | 'ne-resize' | 'nesw-resize' | 'ns-resize' | 'nw-resize' | 'nwse-resize' | 'no-drop' | 'none' | 'not-allowed' | 'pointer' | 'progress' | 'row-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'text' | 'vertical-text' | 'w-resize' | 'wait' | 'zoom-in' | 'zoom-out';
1237
+
1229
1238
  /**
1230
1239
  * Basic structure to define custom map icons, which end up in the map sprite.
1231
1240
  *
@@ -1919,6 +1928,47 @@ declare type DisplayTrafficSectionProps = DisplaySectionProps & TrafficSectionPr
1919
1928
  title?: string;
1920
1929
  };
1921
1930
 
1931
+ /**
1932
+ * Optional events configuration for a map module.
1933
+ *
1934
+ * @group User Interaction Events
1935
+ */
1936
+ export declare type EventHandlerConfig = EventHandlerCursorConfig;
1937
+
1938
+ /**
1939
+ * Event configuration options related to how the cursor appears during interactions.
1940
+ *
1941
+ * @group User Interaction Events
1942
+ */
1943
+ export declare type EventHandlerCursorConfig = {
1944
+ /**
1945
+ * Optional configuration to show custom cursor when hovering over interactive features.
1946
+ *
1947
+ * @remarks
1948
+ * Accepts any valid CSS cursor value.
1949
+ *
1950
+ * @default 'pointer'
1951
+ *
1952
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/cursor | MDN cursor documentation}
1953
+ *
1954
+ * @example
1955
+ * ```typescript
1956
+ * // Default pointer
1957
+ * cursorOnHover: 'pointer'
1958
+ *
1959
+ * // Crosshair for precise selection
1960
+ * cursorOnHover: 'crosshair'
1961
+ *
1962
+ * // Help cursor for info bubbles
1963
+ * cursorOnHover: 'help'
1964
+ *
1965
+ * // Custom cursor image
1966
+ * cursorOnHover: 'url(/cursors/custom.png), pointer'
1967
+ * ```
1968
+ */
1969
+ cursorOnHover?: CSSCursor;
1970
+ };
1971
+
1922
1972
  declare type EventHandlers = Record<string, SourceEventHandlers>;
1923
1973
 
1924
1974
  /**
@@ -2012,12 +2062,13 @@ declare type EventHandlers = Record<string, SourceEventHandlers>;
2012
2062
  * });
2013
2063
  * ```
2014
2064
  *
2015
- * @group User Events
2065
+ * @group User Interaction Events
2016
2066
  */
2017
2067
  export declare class EventsModule<T = MapGeoJSONFeature> {
2018
2068
  private readonly eventProxy;
2019
2069
  private readonly sourceWithLayers;
2020
- constructor(eventProxy: EventsProxy, sourceWithLayers: SourceWithLayers);
2070
+ private readonly config;
2071
+ constructor(eventProxy: EventsProxy, sourceWithLayers: SourceWithLayers, config: EventHandlerConfig | undefined);
2021
2072
  /**
2022
2073
  * Register an event handler for user interactions with map features.
2023
2074
  *
@@ -2183,7 +2234,6 @@ export declare class EventsProxy extends AbstractEventProxy {
2183
2234
  private lastClickedSourceWithLayers?;
2184
2235
  private lastCursorStyle;
2185
2236
  private readonly config;
2186
- private readonly defaultZoomLevel;
2187
2237
  constructor(map: Map_2, config?: MapEventsConfig);
2188
2238
  private listenToEvents;
2189
2239
  enable(enabled: boolean): void;
@@ -2198,7 +2248,7 @@ export declare class EventsProxy extends AbstractEventProxy {
2198
2248
  private onMouseDown;
2199
2249
  private onMouseUp;
2200
2250
  private onMouseMove;
2201
- private updateCursor;
2251
+ private updateHoverCursor;
2202
2252
  private onMapClick;
2203
2253
  }
2204
2254
 
@@ -2215,7 +2265,7 @@ export declare class EventsProxy extends AbstractEventProxy {
2215
2265
  * const hoverEvent: EventType = 'long-hover';
2216
2266
  * ```
2217
2267
  *
2218
- * @group User Events
2268
+ * @group User Interaction Events
2219
2269
  */
2220
2270
  export declare type EventType = ClickEventType | HoverEventType;
2221
2271
 
@@ -2376,7 +2426,7 @@ export declare const FINISH_INDEX = "finish";
2376
2426
  *
2377
2427
  * @group Traffic Flow
2378
2428
  */
2379
- export declare type FlowConfig = {
2429
+ export declare type FlowConfig = MapModuleCommonConfig & {
2380
2430
  /**
2381
2431
  * Controls the visibility of the traffic flow layers.
2382
2432
  *
@@ -2838,7 +2888,7 @@ export declare class GeometriesModule extends AbstractMapModule<GeometrySourcesW
2838
2888
  *
2839
2889
  * @group Geometries
2840
2890
  */
2841
- export declare type GeometriesModuleConfig = {
2891
+ export declare type GeometriesModuleConfig = MapModuleCommonConfig & {
2842
2892
  /**
2843
2893
  * Fill color and opacity configuration.
2844
2894
  *
@@ -3345,7 +3395,7 @@ export declare class HillshadeModule extends AbstractMapModule<HillshadeSourcesW
3345
3395
  *
3346
3396
  * @group Hillshade
3347
3397
  */
3348
- export declare type HillshadeModuleConfig = {
3398
+ export declare type HillshadeModuleConfig = MapModuleCommonConfig & {
3349
3399
  /**
3350
3400
  * Controls the visibility of the hillshade layers.
3351
3401
  *
@@ -3377,7 +3427,7 @@ declare type HillshadeSourcesWithLayers = {
3377
3427
  * const sustainedHover: HoverEventType = 'long-hover';
3378
3428
  * ```
3379
3429
  *
3380
- * @group User Events
3430
+ * @group User Interaction Events
3381
3431
  */
3382
3432
  export declare type HoverEventType = 'hover' | 'long-hover';
3383
3433
 
@@ -3456,7 +3506,7 @@ export declare type IncidentsCommonConfig = {
3456
3506
  *
3457
3507
  * @group Traffic Incidents
3458
3508
  */
3459
- export declare type IncidentsConfig = IncidentsCommonConfig & {
3509
+ export declare type IncidentsConfig = MapModuleCommonConfig & IncidentsCommonConfig & {
3460
3510
  /**
3461
3511
  * Configuration specific to incident icon display.
3462
3512
  *
@@ -3543,9 +3593,57 @@ export declare const mapDisplayPoiCategoryMappings: Partial<Record<POICategory,
3543
3593
  * };
3544
3594
  * ```
3545
3595
  *
3546
- * @group Map
3596
+ * @group User Interaction Events
3547
3597
  */
3548
- export declare type MapEventsConfig = {
3598
+ export declare type MapEventsConfig = EventHandlerCursorConfig & {
3599
+ /**
3600
+ * Optional configuration to show custom cursor when clicking (mouse down).
3601
+ *
3602
+ * @remarks
3603
+ * Accepts any valid CSS cursor value. Provides visual feedback during the
3604
+ * click action.
3605
+ *
3606
+ * @default 'grabbing'
3607
+ *
3608
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/cursor | MDN cursor documentation}
3609
+ *
3610
+ * @example
3611
+ * ```typescript
3612
+ * // Grabbing hand
3613
+ * cursorOnMouseDown: 'grabbing'
3614
+ *
3615
+ * // Move cursor
3616
+ * cursorOnMouseDown: 'move'
3617
+ *
3618
+ * // Custom cursor
3619
+ * cursorOnMouseDown: 'url(/cursors/drag.png), grabbing'
3620
+ * ```
3621
+ */
3622
+ cursorOnMouseDown?: CSSCursor;
3623
+ /**
3624
+ * Optional configuration to show custom cursor on the map canvas when not interacting with any handled features.
3625
+ *
3626
+ * @remarks
3627
+ * Accepts any valid CSS cursor value. This is the default cursor shown
3628
+ * when not interacting with any features.
3629
+ *
3630
+ * @default 'default'
3631
+ *
3632
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/cursor | MDN cursor documentation}
3633
+ *
3634
+ * @example
3635
+ * ```typescript
3636
+ * // Standard arrow
3637
+ * cursorOnMap: 'default'
3638
+ *
3639
+ * // Open hand for draggable map
3640
+ * cursorOnMap: 'grab'
3641
+ *
3642
+ * // Crosshair for measurement tools
3643
+ * cursorOnMap: 'crosshair'
3644
+ * ```
3645
+ */
3646
+ cursorOnMap?: CSSCursor;
3549
3647
  /**
3550
3648
  * Defines the event coordinates precision mode.
3551
3649
  *
@@ -3601,80 +3699,6 @@ export declare type MapEventsConfig = {
3601
3699
  * ```
3602
3700
  */
3603
3701
  paddingBoxPx?: number;
3604
- /**
3605
- * Optional configuration to show custom cursor when hovering over interactive features.
3606
- *
3607
- * @remarks
3608
- * Accepts any valid CSS cursor value.
3609
- *
3610
- * @default 'pointer'
3611
- *
3612
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/cursor | MDN cursor documentation}
3613
- *
3614
- * @example
3615
- * ```typescript
3616
- * // Default pointer
3617
- * cursorOnHover: 'pointer'
3618
- *
3619
- * // Crosshair for precise selection
3620
- * cursorOnHover: 'crosshair'
3621
- *
3622
- * // Help cursor for info bubbles
3623
- * cursorOnHover: 'help'
3624
- *
3625
- * // Custom cursor image
3626
- * cursorOnHover: 'url(/cursors/custom.png), pointer'
3627
- * ```
3628
- */
3629
- cursorOnHover?: string;
3630
- /**
3631
- * Optional configuration to show custom cursor when clicking (mouse down).
3632
- *
3633
- * @remarks
3634
- * Accepts any valid CSS cursor value. Provides visual feedback during the
3635
- * click action.
3636
- *
3637
- * @default 'grabbing'
3638
- *
3639
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/cursor | MDN cursor documentation}
3640
- *
3641
- * @example
3642
- * ```typescript
3643
- * // Grabbing hand
3644
- * cursorOnMouseDown: 'grabbing'
3645
- *
3646
- * // Move cursor
3647
- * cursorOnMouseDown: 'move'
3648
- *
3649
- * // Custom cursor
3650
- * cursorOnMouseDown: 'url(/cursors/drag.png), grabbing'
3651
- * ```
3652
- */
3653
- cursorOnMouseDown?: string;
3654
- /**
3655
- * Optional configuration to show custom cursor on the map canvas.
3656
- *
3657
- * @remarks
3658
- * Accepts any valid CSS cursor value. This is the default cursor shown
3659
- * when not interacting with any features.
3660
- *
3661
- * @default 'default'
3662
- *
3663
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/cursor | MDN cursor documentation}
3664
- *
3665
- * @example
3666
- * ```typescript
3667
- * // Standard arrow
3668
- * cursorOnMap: 'default'
3669
- *
3670
- * // Open hand for draggable map
3671
- * cursorOnMap: 'grab'
3672
- *
3673
- * // Crosshair for measurement tools
3674
- * cursorOnMap: 'crosshair'
3675
- * ```
3676
- */
3677
- cursorOnMap?: string;
3678
3702
  /**
3679
3703
  * Delay to trigger a long-hover event when map has just moved (milliseconds).
3680
3704
  *
@@ -3803,9 +3827,20 @@ declare const mapFonts: readonly ["Noto-Regular", "NotoSans-MediumItalic", "Noto
3803
3827
  */
3804
3828
  export declare type MapLibreOptions = Omit<MapOptions, 'style' | 'attributionControl'>;
3805
3829
 
3830
+ /**
3831
+ * Contains configuration options common to all map modules.
3832
+ *
3833
+ * @group Shared
3834
+ */
3835
+ export declare type MapModuleCommonConfig = {
3836
+ /**
3837
+ * Optional configuration for user event handling that applies to this map module only.
3838
+ */
3839
+ events?: EventHandlerConfig;
3840
+ };
3841
+
3806
3842
  /**
3807
3843
  * Whether a map module is based on a map style or on added GeoJSON data.
3808
- * @ignore
3809
3844
  */
3810
3845
  declare type MapModuleSource = 'style' | 'geojson';
3811
3846
 
@@ -4484,8 +4519,8 @@ export declare class PlacesModule extends AbstractMapModule<PlacesSourcesAndLaye
4484
4519
  * ```typescript
4485
4520
  * import { search } from '@tomtom-international/maps-sdk-js/services';
4486
4521
  *
4487
- * const results = await search.search({ query: 'coffee' });
4488
- * await placesModule.show(results.results);
4522
+ * const results = await search({ query: 'coffee' });
4523
+ * await placesModule.show(results);
4489
4524
  * ```
4490
4525
  *
4491
4526
  * @example
@@ -4616,7 +4651,7 @@ export declare class PlacesModule extends AbstractMapModule<PlacesSourcesAndLaye
4616
4651
  *
4617
4652
  * @group Places
4618
4653
  */
4619
- export declare type PlacesModuleConfig = {
4654
+ export declare type PlacesModuleConfig = MapModuleCommonConfig & {
4620
4655
  /**
4621
4656
  * Base style for all places.
4622
4657
  *
@@ -5298,7 +5333,7 @@ export declare class POIsModule extends AbstractMapModule<PoIsSourcesAndLayers,
5298
5333
  *
5299
5334
  * @group POIs
5300
5335
  */
5301
- export declare type POIsModuleConfig = {
5336
+ export declare type POIsModuleConfig = MapModuleCommonConfig & {
5302
5337
  /**
5303
5338
  * Controls the visibility of the POI layers.
5304
5339
  *
@@ -5479,7 +5514,7 @@ export declare const preparePlacesForDisplay: (placesInput: Place | Place[] | Pl
5479
5514
  * };
5480
5515
  * ```
5481
5516
  *
5482
- * @group User Events
5517
+ * @group User Interaction Events
5483
5518
  */
5484
5519
  export declare type PutEventStateOptions = ByIdOrIndex & {
5485
5520
  /**
@@ -6116,7 +6151,7 @@ export declare class RoutingModule extends AbstractMapModule<RoutingSourcesWithL
6116
6151
  /**
6117
6152
  * @ignore
6118
6153
  */
6119
- protected restoreDataAndConfigImpl(): Promise<void>;
6154
+ protected restoreDataAndConfigImpl(): void;
6120
6155
  private addImageIfNotExisting;
6121
6156
  /**
6122
6157
  * Displays the given routes on the map.
@@ -6256,7 +6291,7 @@ export declare class RoutingModule extends AbstractMapModule<RoutingSourcesWithL
6256
6291
  *
6257
6292
  * @group Routing
6258
6293
  */
6259
- export declare type RoutingModuleConfig = {
6294
+ export declare type RoutingModuleConfig = MapModuleCommonConfig & {
6260
6295
  /**
6261
6296
  * Units for displaying distances in route summaries and instructions.
6262
6297
  *
@@ -6393,6 +6428,7 @@ declare type SourceEventTypeHandler = {
6393
6428
  sourceWithLayers: SourceWithLayers;
6394
6429
  layerIDs: string[];
6395
6430
  fn: UserEventHandler<any>;
6431
+ config?: EventHandlerConfig;
6396
6432
  };
6397
6433
 
6398
6434
  /**
@@ -6807,7 +6843,7 @@ export declare class StyleSourceWithLayers<SOURCE_SPEC extends SourceSpecificati
6807
6843
  * const normalProps: SupportsEvents = {};
6808
6844
  * ```
6809
6845
  *
6810
- * @group User Events
6846
+ * @group User Interaction Events
6811
6847
  */
6812
6848
  export declare type SupportsEvents = {
6813
6849
  /**
@@ -6967,7 +7003,7 @@ export declare type ToBeAddedLayerSpecWithoutSource<L extends LayerSpecification
6967
7003
  * include: ['trafficFlow', 'trafficIncidents']
6968
7004
  * },
6969
7005
  * language: 'en-US',
6970
- * eventsConfig: {
7006
+ * events: {
6971
7007
  * precisionMode: 'point-then-box',
6972
7008
  * cursorOnHover: 'pointer'
6973
7009
  * }
@@ -7103,7 +7139,7 @@ export declare class TomTomMap {
7103
7139
  * include: ['trafficFlow', 'hillshade']
7104
7140
  * },
7105
7141
  * language: 'en-US',
7106
- * eventsConfig: {
7142
+ * events: {
7107
7143
  * precisionMode: 'point-then-box',
7108
7144
  * paddingBoxPx: 10
7109
7145
  * }
@@ -7118,7 +7154,7 @@ export declare class TomTomMap {
7118
7154
  * @see {@link https://maplibre.org/maplibre-gl-js-docs/api/map/ | MapLibre Map Parameters}
7119
7155
  * @see [Map Quickstart Guide](https://docs.tomtom.com/maps-sdk-js/guides/map/quickstart)
7120
7156
  * @see [Map Styles Guide](https://docs.tomtom.com/maps-sdk-js/guides/map/map-styles)
7121
- * @see [User Events Guide](https://docs.tomtom.com/maps-sdk-js/guides/map/user-events)
7157
+ * @see [User Interaction Events Guide](https://docs.tomtom.com/maps-sdk-js/guides/map/user-events)
7122
7158
  */
7123
7159
  constructor(mapLibreOptions: MapLibreOptions, mapParams?: Partial<TomTomMapParams>);
7124
7160
  private loadRTLTextPlugin;
@@ -7468,7 +7504,7 @@ export declare class TomTomMap {
7468
7504
  * center: [4.9041, 52.3676],
7469
7505
  * zoom: 12,
7470
7506
  * style: 'standardLight',
7471
- * eventsConfig: {
7507
+ * events: {
7472
7508
  * onClick: (event) => console.log('Map clicked', event)
7473
7509
  * }
7474
7510
  * };
@@ -7505,7 +7541,7 @@ export declare type TomTomMapParams = GlobalConfig & {
7505
7541
  *
7506
7542
  * @example
7507
7543
  * ```typescript
7508
- * eventsConfig: {
7544
+ * events: {
7509
7545
  * onClick: (event) => {
7510
7546
  * console.log('Clicked at', event.lngLat);
7511
7547
  * },
@@ -7515,7 +7551,7 @@ export declare type TomTomMapParams = GlobalConfig & {
7515
7551
  * }
7516
7552
  * ```
7517
7553
  */
7518
- eventsConfig?: MapEventsConfig;
7554
+ events?: MapEventsConfig;
7519
7555
  };
7520
7556
 
7521
7557
  /**
@@ -8352,7 +8388,7 @@ export declare const UNKNOWN_DELAY_COLOR = "#000000";
8352
8388
  *
8353
8389
  * @see {@link EventsModule.on} - For registering event handlers
8354
8390
  *
8355
- * @group User Events
8391
+ * @group User Interaction Events
8356
8392
  */
8357
8393
  export declare type UserEventHandler<T> = (topFeature: T, lngLat: LngLat, allEventFeatures: MapGeoJSONFeature[], sourceWithLayers: SourceWithLayers) => void;
8358
8394