@tomtom-org/maps-sdk 0.51.5 → 0.52.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 +26 -0
- package/README.md +2 -2
- package/core/dist/core.es.js +1 -1
- package/core/dist/core.es.js.map +1 -1
- package/core/dist/index.d.ts +295 -360
- package/map/dist/index.d.ts +1315 -764
- package/map/dist/map.es.js +1 -1
- package/map/dist/map.es.js.map +1 -1
- package/package.json +7 -7
- package/services/dist/index.d.ts +238 -437
- package/services/dist/services.es.js +1 -1
- package/services/dist/services.es.js.map +1 -1
package/map/dist/index.d.ts
CHANGED
|
@@ -230,7 +230,7 @@ type MapEventsConfig = EventHandlerCursorConfig & {
|
|
|
230
230
|
*
|
|
231
231
|
* @group Map Style
|
|
232
232
|
*/
|
|
233
|
-
declare const standardStyleIDs: readonly ["standardLight", "standardDark", "drivingLight", "drivingDark", "monoLight", "monoDark", "satellite"];
|
|
233
|
+
export declare const standardStyleIDs: readonly ["standardLight", "standardDark", "drivingLight", "drivingDark", "monoLight", "monoDark", "satellite"];
|
|
234
234
|
/**
|
|
235
235
|
* Identifier for a TomTom-hosted standard map style.
|
|
236
236
|
*
|
|
@@ -254,7 +254,7 @@ declare const standardStyleIDs: readonly ["standardLight", "standardDark", "driv
|
|
|
254
254
|
*
|
|
255
255
|
* @group Map Style
|
|
256
256
|
*/
|
|
257
|
-
type StandardStyleID = (typeof standardStyleIDs)[number];
|
|
257
|
+
export type StandardStyleID = (typeof standardStyleIDs)[number];
|
|
258
258
|
/**
|
|
259
259
|
* Configuration for a TomTom standard map style.
|
|
260
260
|
*
|
|
@@ -282,7 +282,7 @@ type StandardStyleID = (typeof standardStyleIDs)[number];
|
|
|
282
282
|
*
|
|
283
283
|
* @group Map Style
|
|
284
284
|
*/
|
|
285
|
-
type StandardStyle = {
|
|
285
|
+
export type StandardStyle = {
|
|
286
286
|
/**
|
|
287
287
|
* Standard style identifier.
|
|
288
288
|
*
|
|
@@ -362,7 +362,7 @@ type StandardStyle = {
|
|
|
362
362
|
*
|
|
363
363
|
* @group Map Style
|
|
364
364
|
*/
|
|
365
|
-
type CustomStyle = {
|
|
365
|
+
export type CustomStyle = {
|
|
366
366
|
/**
|
|
367
367
|
* URL to a MapLibre/Mapbox style JSON.
|
|
368
368
|
*
|
|
@@ -403,7 +403,7 @@ type CustomStyle = {
|
|
|
403
403
|
*
|
|
404
404
|
* @group Map Style
|
|
405
405
|
*/
|
|
406
|
-
declare const styleModules: readonly ["trafficIncidents", "trafficFlow", "hillshade"];
|
|
406
|
+
export declare const styleModules: readonly ["trafficIncidents", "trafficFlow", "hillshade"];
|
|
407
407
|
/**
|
|
408
408
|
* Optional map modules that can be included with a style.
|
|
409
409
|
*
|
|
@@ -414,7 +414,7 @@ declare const styleModules: readonly ["trafficIncidents", "trafficFlow", "hillsh
|
|
|
414
414
|
*
|
|
415
415
|
* @group Map Style
|
|
416
416
|
*/
|
|
417
|
-
type StyleModule = (typeof styleModules)[number];
|
|
417
|
+
export type StyleModule = (typeof styleModules)[number];
|
|
418
418
|
/**
|
|
419
419
|
* Map style specification for initialization.
|
|
420
420
|
*
|
|
@@ -454,7 +454,7 @@ type StyleModule = (typeof styleModules)[number];
|
|
|
454
454
|
*
|
|
455
455
|
* @group Map Style
|
|
456
456
|
*/
|
|
457
|
-
type StyleInput = StandardStyleID | (StandardStyle & {
|
|
457
|
+
export type StyleInput = StandardStyleID | (StandardStyle & {
|
|
458
458
|
type: 'standard';
|
|
459
459
|
}) | (CustomStyle & {
|
|
460
460
|
type: 'custom';
|
|
@@ -476,7 +476,7 @@ type StyleInput = StandardStyleID | (StandardStyle & {
|
|
|
476
476
|
*
|
|
477
477
|
* @group Map
|
|
478
478
|
*/
|
|
479
|
-
type MapLibreOptions = Omit<MapOptions, 'style' | 'attributionControl'>;
|
|
479
|
+
export type MapLibreOptions = Omit<MapOptions, 'style' | 'attributionControl'>;
|
|
480
480
|
/**
|
|
481
481
|
* Parameters for initializing a TomTom map instance.
|
|
482
482
|
*
|
|
@@ -502,7 +502,7 @@ type MapLibreOptions = Omit<MapOptions, 'style' | 'attributionControl'>;
|
|
|
502
502
|
*
|
|
503
503
|
* @group Map
|
|
504
504
|
*/
|
|
505
|
-
type TomTomMapParams = Partial<GlobalConfig> & {
|
|
505
|
+
export type TomTomMapParams = Partial<GlobalConfig> & {
|
|
506
506
|
/**
|
|
507
507
|
* Map style to load.
|
|
508
508
|
*
|
|
@@ -569,7 +569,7 @@ type TomTomMapParams = Partial<GlobalConfig> & {
|
|
|
569
569
|
*
|
|
570
570
|
* @ignore
|
|
571
571
|
*/
|
|
572
|
-
type InternalTomTomMapParams = GlobalConfig & TomTomMapParams;
|
|
572
|
+
export type InternalTomTomMapParams = GlobalConfig & TomTomMapParams;
|
|
573
573
|
//#endregion
|
|
574
574
|
//#region src/TomTomMap.d.ts
|
|
575
575
|
/**
|
|
@@ -612,7 +612,7 @@ type InternalTomTomMapParams = GlobalConfig & TomTomMapParams;
|
|
|
612
612
|
*
|
|
613
613
|
* @group Map Style
|
|
614
614
|
*/
|
|
615
|
-
type StyleChangeHandler = {
|
|
615
|
+
export type StyleChangeHandler = {
|
|
616
616
|
/**
|
|
617
617
|
* Callback invoked immediately before a style change begins.
|
|
618
618
|
*
|
|
@@ -699,7 +699,7 @@ type StyleChangeHandler = {
|
|
|
699
699
|
*
|
|
700
700
|
* @group Map
|
|
701
701
|
*/
|
|
702
|
-
declare class TomTomMap {
|
|
702
|
+
export declare class TomTomMap {
|
|
703
703
|
/**
|
|
704
704
|
* Indicates whether the map style has been fully loaded and is ready for interaction.
|
|
705
705
|
*
|
|
@@ -1219,22 +1219,22 @@ declare class TomTomMap {
|
|
|
1219
1219
|
* **RoutingModule** - Positions route visualizations below labels for readability:
|
|
1220
1220
|
* ```typescript
|
|
1221
1221
|
* // Routes appear below labels but above the base map
|
|
1222
|
-
* const routingModule = await RoutingModule.
|
|
1222
|
+
* const routingModule = await RoutingModule.create(map);
|
|
1223
1223
|
* // Uses mapStyleLayerIDs.lowestLabel by default
|
|
1224
1224
|
* ```
|
|
1225
1225
|
*
|
|
1226
1226
|
* **GeometriesModule** - Configurable layer positioning for polygon areas:
|
|
1227
1227
|
* ```typescript
|
|
1228
1228
|
* // Default: below labels
|
|
1229
|
-
* const geometriesModule = await GeometriesModule.
|
|
1229
|
+
* const geometriesModule = await GeometriesModule.create(map);
|
|
1230
1230
|
*
|
|
1231
1231
|
* // Custom: below buildings to show at ground level
|
|
1232
|
-
* const geometriesModule = await GeometriesModule.
|
|
1232
|
+
* const geometriesModule = await GeometriesModule.create(map, {
|
|
1233
1233
|
* beforeLayerConfig: 'lowestBuilding'
|
|
1234
1234
|
* });
|
|
1235
1235
|
*
|
|
1236
1236
|
* // On top of everything
|
|
1237
|
-
* const geometriesModule = await GeometriesModule.
|
|
1237
|
+
* const geometriesModule = await GeometriesModule.create(map, {
|
|
1238
1238
|
* beforeLayerConfig: 'top'
|
|
1239
1239
|
* });
|
|
1240
1240
|
* ```
|
|
@@ -1266,7 +1266,7 @@ declare class TomTomMap {
|
|
|
1266
1266
|
*
|
|
1267
1267
|
* @group Map Style
|
|
1268
1268
|
*/
|
|
1269
|
-
declare const mapStyleLayerIDs: {
|
|
1269
|
+
export declare const mapStyleLayerIDs: {
|
|
1270
1270
|
/**
|
|
1271
1271
|
* Country name label layer.
|
|
1272
1272
|
*
|
|
@@ -1509,14 +1509,14 @@ interface FeatureCollection<G extends Geometry | null = Geometry, P = GeoJsonPro
|
|
|
1509
1509
|
* MapLibre `MapGeoJSONFeature`s, plain GeoJSON `Feature`s, and cached originals alike.
|
|
1510
1510
|
*/
|
|
1511
1511
|
/** Minimal shape needed to look a feature up by id. @ignore */
|
|
1512
|
-
type RenderedRef = {
|
|
1512
|
+
export type RenderedRef = {
|
|
1513
1513
|
id?: string | number;
|
|
1514
1514
|
properties?: {
|
|
1515
1515
|
id?: unknown;
|
|
1516
1516
|
} | null;
|
|
1517
1517
|
};
|
|
1518
1518
|
/** A feature together with its index in the array it was found in. @ignore */
|
|
1519
|
-
type IndexedFeature<F> = {
|
|
1519
|
+
export type IndexedFeature<F> = {
|
|
1520
1520
|
feature: F;
|
|
1521
1521
|
index: number;
|
|
1522
1522
|
};
|
|
@@ -1532,13 +1532,13 @@ type IndexedFeature<F> = {
|
|
|
1532
1532
|
* features that only carry a top-level id). Returns `undefined` when neither is set.
|
|
1533
1533
|
* @ignore
|
|
1534
1534
|
*/
|
|
1535
|
-
declare const renderedRefId: (rendered: RenderedRef) => string | number | undefined;
|
|
1535
|
+
export declare const renderedRefId: (rendered: RenderedRef) => string | number | undefined;
|
|
1536
1536
|
/**
|
|
1537
1537
|
* Find the first feature whose {@link renderedRefId} equals `id`, with its index, or
|
|
1538
1538
|
* `undefined` (also for a nullish `id`).
|
|
1539
1539
|
* @ignore
|
|
1540
1540
|
*/
|
|
1541
|
-
declare const findFeatureByRefId: <F extends RenderedRef>(features: readonly F[], id: string | number | undefined) => IndexedFeature<F> | undefined;
|
|
1541
|
+
export declare const findFeatureByRefId: <F extends RenderedRef>(features: readonly F[], id: string | number | undefined) => IndexedFeature<F> | undefined;
|
|
1542
1542
|
//#endregion
|
|
1543
1543
|
//#region src/shared/TomTomMapSource.d.ts
|
|
1544
1544
|
/**
|
|
@@ -1546,7 +1546,7 @@ declare const findFeatureByRefId: <F extends RenderedRef>(features: readonly F[]
|
|
|
1546
1546
|
* * The source might already be initialized from the map style, or it might be initialized here.
|
|
1547
1547
|
* @ignore
|
|
1548
1548
|
*/
|
|
1549
|
-
declare class TomTomMapSource<SOURCE_SPEC extends SourceSpecification = SourceSpecification, RUNTIME_SOURCE extends Source = Source> {
|
|
1549
|
+
export declare class TomTomMapSource<SOURCE_SPEC extends SourceSpecification = SourceSpecification, RUNTIME_SOURCE extends Source = Source> {
|
|
1550
1550
|
readonly id: string;
|
|
1551
1551
|
readonly spec?: SOURCE_SPEC | undefined;
|
|
1552
1552
|
runtimeSource?: RUNTIME_SOURCE | undefined;
|
|
@@ -1559,7 +1559,7 @@ declare class TomTomMapSource<SOURCE_SPEC extends SourceSpecification = SourceSp
|
|
|
1559
1559
|
* Contains a source and the layers to render its data.
|
|
1560
1560
|
* @ignore
|
|
1561
1561
|
*/
|
|
1562
|
-
declare abstract class AbstractSourceWithLayers<SOURCE_SPEC extends SourceSpecification = SourceSpecification, RUNTIME_SOURCE extends Source = Source, LAYER_SPEC extends LayerSpecification = LayerSpecification> {
|
|
1562
|
+
export declare abstract class AbstractSourceWithLayers<SOURCE_SPEC extends SourceSpecification = SourceSpecification, RUNTIME_SOURCE extends Source = Source, LAYER_SPEC extends LayerSpecification = LayerSpecification> {
|
|
1563
1563
|
readonly map: Map;
|
|
1564
1564
|
readonly source: TomTomMapSource<SOURCE_SPEC, RUNTIME_SOURCE>;
|
|
1565
1565
|
readonly _layerSpecs: LAYER_SPEC[];
|
|
@@ -1578,27 +1578,26 @@ declare abstract class AbstractSourceWithLayers<SOURCE_SPEC extends SourceSpecif
|
|
|
1578
1578
|
private isLayerVisible;
|
|
1579
1579
|
setLayersVisible(visible: boolean, filter?: LayerSpecFilter): void;
|
|
1580
1580
|
get sourceAndLayerIDs(): SourceWithLayerIDs;
|
|
1581
|
-
equalSourceAndLayerIDs(other: SourceWithLayers): boolean;
|
|
1582
1581
|
}
|
|
1583
1582
|
/**
|
|
1584
1583
|
* @ignore
|
|
1585
1584
|
* @param loadedMap
|
|
1586
1585
|
* @param sourceIDs
|
|
1587
1586
|
*/
|
|
1588
|
-
declare const filterLayersBySources: (loadedMap: Map, sourceIDs: string[]) => LayerSpecWithSource[];
|
|
1587
|
+
export declare const filterLayersBySources: (loadedMap: Map, sourceIDs: string[]) => LayerSpecWithSource[];
|
|
1589
1588
|
/**
|
|
1590
1589
|
* Source with layers which are coming from the downloaded TT map style.
|
|
1591
1590
|
* * Examples are parts of the base map, traffic, pois, and hillshade.
|
|
1592
1591
|
* @ignore
|
|
1593
1592
|
*/
|
|
1594
|
-
declare class StyleSourceWithLayers<SOURCE_SPEC extends SourceSpecification = SourceSpecification, RUNTIME_SOURCE extends Source = Source> extends AbstractSourceWithLayers<SourceSpecification, RUNTIME_SOURCE> {
|
|
1593
|
+
export declare class StyleSourceWithLayers<SOURCE_SPEC extends SourceSpecification = SourceSpecification, RUNTIME_SOURCE extends Source = Source> extends AbstractSourceWithLayers<SourceSpecification, RUNTIME_SOURCE> {
|
|
1595
1594
|
constructor(map: Map, runtimeSource: RUNTIME_SOURCE, filter?: LayerSpecFilter);
|
|
1596
1595
|
}
|
|
1597
1596
|
/**
|
|
1598
1597
|
* Source with layers which originally is not in the map style, but it's to be added after the map is initialized.
|
|
1599
1598
|
* @ignore
|
|
1600
1599
|
*/
|
|
1601
|
-
declare class AddedSourceWithLayers<SOURCE_SPEC extends SourceSpecification = SourceSpecification, RUNTIME_SOURCE extends Source = Source> extends AbstractSourceWithLayers<SOURCE_SPEC, RUNTIME_SOURCE, ToBeAddedLayerSpec> {
|
|
1600
|
+
export declare class AddedSourceWithLayers<SOURCE_SPEC extends SourceSpecification = SourceSpecification, RUNTIME_SOURCE extends Source = Source> extends AbstractSourceWithLayers<SOURCE_SPEC, RUNTIME_SOURCE, ToBeAddedLayerSpec> {
|
|
1602
1601
|
constructor(map: Map, sourceId: string, sourceSpec: SOURCE_SPEC, layerSpecs: ToBeAddedLayerSpecWithoutSource[]);
|
|
1603
1602
|
private ensureLayersAddedToMap;
|
|
1604
1603
|
ensureAddedToMapWithVisibility(visible: boolean, addLayersToMap: boolean): void;
|
|
@@ -1607,7 +1606,7 @@ declare class AddedSourceWithLayers<SOURCE_SPEC extends SourceSpecification = So
|
|
|
1607
1606
|
* Options for the {@link GeoJSONSourceWithLayers.show} method.
|
|
1608
1607
|
* @ignore
|
|
1609
1608
|
*/
|
|
1610
|
-
type ShowOptions = {
|
|
1609
|
+
export type ShowOptions = {
|
|
1611
1610
|
/**
|
|
1612
1611
|
* When `true` (default), layer visibility is automatically set based on whether
|
|
1613
1612
|
* the feature collection is non-empty. Pass `false` from state-update calls
|
|
@@ -1623,11 +1622,11 @@ type ShowOptions = {
|
|
|
1623
1622
|
* can be configured with at construction time. Forwarded verbatim to MapLibre.
|
|
1624
1623
|
* @ignore
|
|
1625
1624
|
*/
|
|
1626
|
-
type GeoJSONSourceClusterOptions = Pick<GeoJSONSourceSpecification, 'cluster' | 'clusterRadius' | 'clusterMaxZoom' | 'clusterMinPoints' | 'clusterProperties'>;
|
|
1625
|
+
export type GeoJSONSourceClusterOptions = Pick<GeoJSONSourceSpecification, 'cluster' | 'clusterRadius' | 'clusterMaxZoom' | 'clusterMinPoints' | 'clusterProperties'>;
|
|
1627
1626
|
/**
|
|
1628
1627
|
* @ignore
|
|
1629
1628
|
*/
|
|
1630
|
-
declare class GeoJSONSourceWithLayers<T extends FeatureCollection = FeatureCollection> extends AddedSourceWithLayers<GeoJSONSourceSpecification, GeoJSONSource> {
|
|
1629
|
+
export declare class GeoJSONSourceWithLayers<T extends FeatureCollection = FeatureCollection> extends AddedSourceWithLayers<GeoJSONSourceSpecification, GeoJSONSource> {
|
|
1631
1630
|
shownFeatures: T;
|
|
1632
1631
|
constructor(map: Map, sourceId: string, layerSpecs: ToBeAddedLayerSpecWithoutSource[], addLayersToMap?: boolean, clusterOptions?: GeoJSONSourceClusterOptions);
|
|
1633
1632
|
show(featureCollection: T, { automaticVisibility }?: ShowOptions): void;
|
|
@@ -2526,15 +2525,286 @@ type MapModuleCommonConfig = {
|
|
|
2526
2525
|
*/
|
|
2527
2526
|
type LightDark = 'light' | 'dark';
|
|
2528
2527
|
//#endregion
|
|
2528
|
+
//#region src/shared/eventScope.d.ts
|
|
2529
|
+
/**
|
|
2530
|
+
* What `where()` accepts: a predicate over the feature type this surface exposes, or — where the
|
|
2531
|
+
* module defines one — its own scope object. {@link UserEvents.where} turns either into a
|
|
2532
|
+
* {@link ResolvedEventScope}.
|
|
2533
|
+
*
|
|
2534
|
+
* @typeParam T - Feature type this surface exposes, which a predicate therefore receives.
|
|
2535
|
+
* @typeParam WHERE_SCOPE - The module's own scope object, such as {@link BaseMapEventScope}.
|
|
2536
|
+
* `never` on a module that only supports predicates, leaving just the predicate arm.
|
|
2537
|
+
*
|
|
2538
|
+
* @ignore
|
|
2539
|
+
*/
|
|
2540
|
+
export type EventScope<T, WHERE_SCOPE> = ((feature: T) => boolean) | WHERE_SCOPE;
|
|
2541
|
+
/**
|
|
2542
|
+
* A scope narrowed down to the two things the event proxy can act on.
|
|
2543
|
+
*
|
|
2544
|
+
* Every public way of expressing a scope — a feature predicate, `{ layerGroups }` on
|
|
2545
|
+
* {@link BaseMapModule}, a module's named scope — resolves to one of these before it reaches
|
|
2546
|
+
* {@link AbstractEventProxy}. Both parts are optional: an unscoped handler carries neither.
|
|
2547
|
+
*
|
|
2548
|
+
* @ignore
|
|
2549
|
+
*/
|
|
2550
|
+
export type ResolvedEventScope = {
|
|
2551
|
+
/**
|
|
2552
|
+
* Selects which of the source's layers the handler listens to. Applied fresh whenever the
|
|
2553
|
+
* layer set changes, so a scope keeps meaning the same thing across style changes.
|
|
2554
|
+
*/
|
|
2555
|
+
layerFilter?: LayerSpecFilter;
|
|
2556
|
+
/**
|
|
2557
|
+
* Decides whether a rendered feature belongs to this scope. Receives the raw MapLibre
|
|
2558
|
+
* feature — a module's `mapping` is composed into this function at `where()` time, so the
|
|
2559
|
+
* caller's predicate still sees the module's own feature type.
|
|
2560
|
+
*/
|
|
2561
|
+
featureMatches?: (feature: MapGeoJSONFeature) => boolean;
|
|
2562
|
+
};
|
|
2563
|
+
/**
|
|
2564
|
+
* Combines an existing scope with a narrower one, so `where(a).where(b)` means "a and b".
|
|
2565
|
+
* Both axes intersect independently.
|
|
2566
|
+
*
|
|
2567
|
+
* Chaining is not a feature to reach for — two predicates read better as one `a(f) && b(f)`, and
|
|
2568
|
+
* layer plus feature narrowing is a single {@link BaseMapEventScope}. It exists because `where()`
|
|
2569
|
+
* returns a `UserEvents`, which has a `where()` of its own: without intersecting here, a second
|
|
2570
|
+
* call would silently replace the first and *widen* the scope.
|
|
2571
|
+
* @ignore
|
|
2572
|
+
*/
|
|
2573
|
+
export declare const combineEventScopes: (outer: ResolvedEventScope | undefined, inner: ResolvedEventScope | undefined) => ResolvedEventScope | undefined;
|
|
2574
|
+
/**
|
|
2575
|
+
* The layer specs a scope selects out of a source, resolved against the source's *current*
|
|
2576
|
+
* layers. Called again on every style change so a scope never holds stale layer IDs.
|
|
2577
|
+
* @ignore
|
|
2578
|
+
*/
|
|
2579
|
+
export declare const scopedLayerSpecs: (sourceWithLayers: SourceWithLayers, scope: ResolvedEventScope | undefined) => LayerSpecification[];
|
|
2580
|
+
/**
|
|
2581
|
+
* Names a module cannot use for a named event scope, because a scope is attached as a property
|
|
2582
|
+
* onto the module-wide events object and would shadow one of its methods.
|
|
2583
|
+
* @ignore
|
|
2584
|
+
*/
|
|
2585
|
+
export declare const reservedScopeNames: readonly string[];
|
|
2586
|
+
/**
|
|
2587
|
+
* Guards {@link reservedScopeNames}. SDK-authored scope names are covered by a unit test, but
|
|
2588
|
+
* {@link CustomGeoJSONModule} takes its scope names from the caller's own `sources`, so this
|
|
2589
|
+
* has to hold at runtime too.
|
|
2590
|
+
* @ignore
|
|
2591
|
+
*/
|
|
2592
|
+
export declare const assertNoReservedScopeNames: (names: string[], context: string) => void;
|
|
2593
|
+
//#endregion
|
|
2594
|
+
//#region src/shared/ModuleEvents.d.ts
|
|
2595
|
+
/**
|
|
2596
|
+
* Lifecycle event module for map modules.
|
|
2597
|
+
*
|
|
2598
|
+
* Provides a unified API for subscribing to module-level events that are not tied
|
|
2599
|
+
* to user interaction with map features. Two event types are supported:
|
|
2600
|
+
*
|
|
2601
|
+
* - `config-change`: emitted whenever the module's configuration is updated
|
|
2602
|
+
* (via `applyConfig`, `resetConfig`, or any module-specific setter that mutates config).
|
|
2603
|
+
* - `shown-features`: emitted by modules that have a `show` method, immediately after
|
|
2604
|
+
* features are displayed on the map.
|
|
2605
|
+
*
|
|
2606
|
+
* Each `on()` call returns an unsubscribe function so individual handlers can be
|
|
2607
|
+
* removed without clearing the entire listener list.
|
|
2608
|
+
*
|
|
2609
|
+
* @typeParam TConfig - The module's configuration type.
|
|
2610
|
+
* @typeParam TShownFeatures - The type of data passed to `show()`. Use `never` for
|
|
2611
|
+
* modules that have no `show` method.
|
|
2612
|
+
*
|
|
2613
|
+
* @example
|
|
2614
|
+
* ```typescript
|
|
2615
|
+
* const unsubscribeConfig = trafficFlow.events.on('config-change', (config) => {
|
|
2616
|
+
* console.log('New config:', config);
|
|
2617
|
+
* });
|
|
2618
|
+
*
|
|
2619
|
+
* const unsubscribeShown = places.events.on('shown-features', (features) => {
|
|
2620
|
+
* console.log('Shown:', features);
|
|
2621
|
+
* });
|
|
2622
|
+
*
|
|
2623
|
+
* // Later:
|
|
2624
|
+
* unsubscribeConfig();
|
|
2625
|
+
* unsubscribeShown();
|
|
2626
|
+
* ```
|
|
2627
|
+
*
|
|
2628
|
+
* @group Events
|
|
2629
|
+
*/
|
|
2630
|
+
/**
|
|
2631
|
+
* `'shown-features'`, except on a module with no `show` — where `TShownFeatures` is `never` and
|
|
2632
|
+
* this collapses to `never`, making the overload uncallable. Without it a handler could be
|
|
2633
|
+
* registered for an event the module can never emit.
|
|
2634
|
+
*
|
|
2635
|
+
* @group Events
|
|
2636
|
+
*/
|
|
2637
|
+
export type ShownFeaturesType<TShownFeatures> = [TShownFeatures] extends [never] ? never : 'shown-features';
|
|
2638
|
+
export declare class ModuleEvents<TConfig, TShownFeatures = never> {
|
|
2639
|
+
private readonly configChangeHandlers;
|
|
2640
|
+
private readonly shownFeaturesHandlers;
|
|
2641
|
+
constructor(configChangeHandlers: ((config: TConfig | undefined) => void)[], shownFeaturesHandlers: ((features: TShownFeatures) => void)[]);
|
|
2642
|
+
/**
|
|
2643
|
+
* Subscribe to config-change events.
|
|
2644
|
+
*
|
|
2645
|
+
* The handler is called with the module's full current configuration immediately after
|
|
2646
|
+
* any mutation — whether through `applyConfig`, a module-specific setter, or `resetConfig`.
|
|
2647
|
+
*
|
|
2648
|
+
* @param type - `'config-change'`
|
|
2649
|
+
* @param handler - Receives the module's config (or `undefined` when config is cleared).
|
|
2650
|
+
* @returns An unsubscribe function. Call it to remove **only this handler** without
|
|
2651
|
+
* affecting other registered handlers for the same event type.
|
|
2652
|
+
*
|
|
2653
|
+
* @example
|
|
2654
|
+
* ```typescript
|
|
2655
|
+
* const unsub = trafficFlow.events.on('config-change', (config) => {
|
|
2656
|
+
* toggle.checked = config?.visible ?? false;
|
|
2657
|
+
* });
|
|
2658
|
+
*
|
|
2659
|
+
* // Later:
|
|
2660
|
+
* unsub();
|
|
2661
|
+
* ```
|
|
2662
|
+
*/
|
|
2663
|
+
on(type: 'config-change', handler: (config: TConfig | undefined) => void): () => void;
|
|
2664
|
+
/**
|
|
2665
|
+
* Subscribe to shown-features events.
|
|
2666
|
+
*
|
|
2667
|
+
* The handler is called immediately after a module's `show()` method (or equivalent)
|
|
2668
|
+
* has updated the map with new data. Only available on modules that have a `show` method.
|
|
2669
|
+
*
|
|
2670
|
+
* @param type - `'shown-features'`
|
|
2671
|
+
* @param handler - Receives the data that was passed to `show()`.
|
|
2672
|
+
* @returns An unsubscribe function. Call it to remove **only this handler** without
|
|
2673
|
+
* affecting other registered handlers for the same event type.
|
|
2674
|
+
*
|
|
2675
|
+
* @example
|
|
2676
|
+
* ```typescript
|
|
2677
|
+
* const unsub = places.events.on('shown-features', (features) => {
|
|
2678
|
+
* fitMapToResults(features);
|
|
2679
|
+
* });
|
|
2680
|
+
*
|
|
2681
|
+
* // Later:
|
|
2682
|
+
* unsub();
|
|
2683
|
+
* ```
|
|
2684
|
+
*/
|
|
2685
|
+
on(type: ShownFeaturesType<TShownFeatures>, handler: (features: TShownFeatures) => void): () => void;
|
|
2686
|
+
/**
|
|
2687
|
+
* Remove **all** handlers for the given event type at once.
|
|
2688
|
+
*
|
|
2689
|
+
* Prefer the unsubscribe function returned by {@link on} when you need to remove a
|
|
2690
|
+
* single handler. Use `off` for bulk teardown — e.g. when unmounting a component that
|
|
2691
|
+
* registered multiple handlers.
|
|
2692
|
+
*
|
|
2693
|
+
* @param type - The event type whose handlers should all be cleared.
|
|
2694
|
+
*
|
|
2695
|
+
* @example
|
|
2696
|
+
* ```typescript
|
|
2697
|
+
* // Clear all config-change listeners in one call
|
|
2698
|
+
* trafficFlow.events.off('config-change');
|
|
2699
|
+
* ```
|
|
2700
|
+
*/
|
|
2701
|
+
off(type: 'config-change' | 'shown-features'): void;
|
|
2702
|
+
}
|
|
2703
|
+
//#endregion
|
|
2529
2704
|
//#region src/shared/AbstractEventProxy.d.ts
|
|
2530
|
-
|
|
2705
|
+
/**
|
|
2706
|
+
* Any map module, whatever its sources and config. The event proxy only ever compares owners by
|
|
2707
|
+
* identity, so it needs no more than "some module" — but naming the class says who may own a
|
|
2708
|
+
* handler, which a bare `object` did not. The two type parameters are irrelevant to identity, and
|
|
2709
|
+
* pinning them would drag every module's concrete types through this file.
|
|
2710
|
+
*
|
|
2711
|
+
* @ignore
|
|
2712
|
+
*/
|
|
2713
|
+
type AnyMapModule = AbstractMapModule<any, any>;
|
|
2714
|
+
/**
|
|
2715
|
+
* One entry in the handler index: the caller's function plus everything dispatch needs to decide
|
|
2716
|
+
* whether it should fire. A caller supplies a {@link HandlerRegistration}; the proxy files this.
|
|
2717
|
+
*
|
|
2718
|
+
* Repeated `on()` calls append rather than replace, so several entries can listen to one layer and
|
|
2719
|
+
* all of them fire.
|
|
2720
|
+
*
|
|
2721
|
+
* @ignore
|
|
2722
|
+
*/
|
|
2723
|
+
type HandlerEntry = {
|
|
2724
|
+
/**
|
|
2725
|
+
* The source the handler was registered against — **all** of its layers, not just the ones
|
|
2726
|
+
* this entry listens to; `layerIDs` is that narrowing.
|
|
2727
|
+
*
|
|
2728
|
+
* Kept because the handler receives it as its last argument, because a GeoJSON source can
|
|
2729
|
+
* substitute the caller's typed original back in for the rendered feature, and because
|
|
2730
|
+
* dropping by source needs its ID. Replaced wholesale on a style change.
|
|
2731
|
+
*/
|
|
2531
2732
|
sourceWithLayers: SourceWithLayers;
|
|
2532
|
-
|
|
2733
|
+
/**
|
|
2734
|
+
* The layers this entry actually listens to: `sourceWithLayers`' layers narrowed by `scope`,
|
|
2735
|
+
* so a scoped handler holds a subset and an unscoped one holds the lot.
|
|
2736
|
+
*
|
|
2737
|
+
* It is also *where the entry is filed* — it appears in `handlers[type][layerID]` under each
|
|
2738
|
+
* of these — which is why a style change re-files the entry rather than just overwriting the
|
|
2739
|
+
* set. A Set rather than a list because a layer-scoped handler tests membership per dispatch
|
|
2740
|
+
* to narrow the features its caller sees, and the base map contributes ~90 layers to test
|
|
2741
|
+
* against.
|
|
2742
|
+
*/
|
|
2743
|
+
layerIDs: Set<string>;
|
|
2744
|
+
/**
|
|
2745
|
+
* The handler to call, already wrapped by {@link UserEvents} with the module's feature mapping
|
|
2746
|
+
* and any `where()` predicate — so by the time dispatch reaches it, it takes the module's own
|
|
2747
|
+
* feature type and has already declined features outside its scope.
|
|
2748
|
+
*/
|
|
2533
2749
|
fn: UserEventHandler<any>;
|
|
2750
|
+
/** Event configuration this entry registered with — its hover cursor, chiefly. */
|
|
2534
2751
|
config?: EventHandlerConfig;
|
|
2752
|
+
/**
|
|
2753
|
+
* The module that registered this handler. Two modules can share one MapLibre source ID —
|
|
2754
|
+
* POIs and the base map both use `vectorTiles` — so a style-change refresh has to tell their
|
|
2755
|
+
* handlers apart by owner rather than by source ID alone.
|
|
2756
|
+
*/
|
|
2757
|
+
owner: AnyMapModule;
|
|
2758
|
+
/**
|
|
2759
|
+
* How the registration was narrowed, if at all. Kept alongside `layerIDs` rather than being
|
|
2760
|
+
* spent when it is resolved: `layerFilter` has to run again over the new layer set after a
|
|
2761
|
+
* style change, and `featureMatches` decides per dispatch whether this entry claims the
|
|
2762
|
+
* hover cursor for the feature under the pointer.
|
|
2763
|
+
*/
|
|
2764
|
+
scope?: ResolvedEventScope;
|
|
2535
2765
|
};
|
|
2536
|
-
|
|
2537
|
-
|
|
2766
|
+
/**
|
|
2767
|
+
* How a handler was registered: the parts of a {@link HandlerEntry} a caller supplies, as opposed
|
|
2768
|
+
* to the layers and source the proxy resolves for it. Grouped rather than passed as three trailing
|
|
2769
|
+
* arguments, so a call site names what it means instead of positioning an `undefined` config
|
|
2770
|
+
* before an owner.
|
|
2771
|
+
*
|
|
2772
|
+
* @ignore
|
|
2773
|
+
*/
|
|
2774
|
+
type HandlerRegistration = Pick<HandlerEntry, 'config' | 'owner' | 'scope'>;
|
|
2775
|
+
/**
|
|
2776
|
+
* One event type's handlers, bucketed by the layer they listen to. Each bucket is in registration
|
|
2777
|
+
* order — `findHandlers()[0]` is the first one registered, which is what claims the hover cursor.
|
|
2778
|
+
*
|
|
2779
|
+
* @ignore
|
|
2780
|
+
*/
|
|
2781
|
+
type HandlersByLayer = Record<string, HandlerEntry[]>;
|
|
2782
|
+
/**
|
|
2783
|
+
* Every registered handler, indexed by event type and then by the layer it listens to. A handler
|
|
2784
|
+
* scoped to several layers appears under each of them, so dispatch is a lookup rather than a scan:
|
|
2785
|
+
* a hit on `layerId` fires exactly `handlers[type][layerId]`.
|
|
2786
|
+
*
|
|
2787
|
+
* Keyed this way, the interactive-layer list is local information — a layer is interactive while
|
|
2788
|
+
* some type still holds a non-empty bucket for it, so releasing one costs five lookups instead of
|
|
2789
|
+
* a walk over every registered handler.
|
|
2790
|
+
*
|
|
2791
|
+
* @example
|
|
2792
|
+
* ```typescript
|
|
2793
|
+
* const handlers = {
|
|
2794
|
+
* click: {
|
|
2795
|
+
* 'Buildings': [{ sourceWithLayers, layerIDs: Set { 'Buildings', 'Roads' }, fn, … }],
|
|
2796
|
+
* 'Roads': [ …the same handler again, plus any other listening to Roads ],
|
|
2797
|
+
* },
|
|
2798
|
+
* hover: { 'Water': [ … ] },
|
|
2799
|
+
* contextmenu: {},
|
|
2800
|
+
* 'hover-move': {},
|
|
2801
|
+
* 'long-hover': {},
|
|
2802
|
+
* };
|
|
2803
|
+
* ```
|
|
2804
|
+
*
|
|
2805
|
+
* @ignore
|
|
2806
|
+
*/
|
|
2807
|
+
type EventHandlers = Record<EventType, HandlersByLayer>;
|
|
2538
2808
|
/**
|
|
2539
2809
|
* @ignore
|
|
2540
2810
|
*/
|
|
@@ -2543,61 +2813,90 @@ declare abstract class AbstractEventProxy {
|
|
|
2543
2813
|
protected handlers: EventHandlers;
|
|
2544
2814
|
/**
|
|
2545
2815
|
* Adds the given layers as interactive, so we'll listen to them for hover and click.
|
|
2546
|
-
*
|
|
2816
|
+
*
|
|
2817
|
+
* Only the layers a handler's scope actually selects are added. Marking the whole source
|
|
2818
|
+
* interactive would let an out-of-scope feature rendered on top shadow an in-scope one, since
|
|
2819
|
+
* dispatch matches on the topmost hit.
|
|
2820
|
+
* @param layerIDs The scoped layers to listen to.
|
|
2547
2821
|
*/
|
|
2548
2822
|
private ensureInteractiveLayerIDsAdded;
|
|
2823
|
+
private releaseUnusedInteractiveLayerIDs;
|
|
2824
|
+
private indexHandler;
|
|
2825
|
+
private unindexHandlers;
|
|
2826
|
+
/**
|
|
2827
|
+
* Detaches this source's handlers that the predicate matches, then stops listening to any
|
|
2828
|
+
* layer none of the survivors still covers.
|
|
2829
|
+
*
|
|
2830
|
+
* The source has to be part of the match: `UserEvents.on` registers one handler function
|
|
2831
|
+
* across several sources and unsubscribes them one at a time, so the function alone does not
|
|
2832
|
+
* identify which registration to drop.
|
|
2833
|
+
*/
|
|
2834
|
+
private dropHandlers;
|
|
2549
2835
|
/**
|
|
2550
2836
|
* Register an event listener to the list.
|
|
2551
2837
|
* @param sourceWithLayers The sources and layers to added.
|
|
2552
2838
|
* @param handlerFn Function that will handle the event.
|
|
2553
2839
|
* @param type Type of event to listen to.
|
|
2554
|
-
* @param
|
|
2840
|
+
* @param registration How the handler was registered — see {@link HandlerRegistration}.
|
|
2555
2841
|
*/
|
|
2556
|
-
addEventHandler<T = MapGeoJSONFeature>(sourceWithLayers: SourceWithLayers, handlerFn: UserEventHandler<T>, type: EventType,
|
|
2842
|
+
addEventHandler<T = MapGeoJSONFeature>(sourceWithLayers: SourceWithLayers, handlerFn: UserEventHandler<T>, type: EventType, registration: HandlerRegistration): void;
|
|
2557
2843
|
/**
|
|
2558
2844
|
* Removes a single handler function for the given source and event type.
|
|
2559
2845
|
* Other handlers registered for the same source and type are not affected.
|
|
2560
|
-
* Unlike {@link remove}, this does not remove the source from the interactive layer list —
|
|
2561
|
-
* other handlers may still depend on it.
|
|
2562
2846
|
* @param sourceWithLayers The source whose handler should be removed.
|
|
2563
2847
|
* @param type The event type.
|
|
2564
2848
|
* @param handlerFn The exact function reference to remove.
|
|
2565
2849
|
*/
|
|
2566
2850
|
removeHandler(sourceWithLayers: SourceWithLayers, type: EventType, handlerFn: UserEventHandler<any>): void;
|
|
2567
2851
|
/**
|
|
2568
|
-
* Removes
|
|
2852
|
+
* Removes every handler this owner registered for the given source and event type — what
|
|
2853
|
+
* `events.off(type)` means. Scoped handlers go with the rest: a scope is a way of registering,
|
|
2854
|
+
* not a separate surface to tear down.
|
|
2855
|
+
*
|
|
2856
|
+
* Matching is by owner rather than by layer set, because two modules can share one MapLibre
|
|
2857
|
+
* source ID (POIs and the base map both use `vectorTiles`) and neither may drop the other's
|
|
2858
|
+
* handlers.
|
|
2859
|
+
* @param sourceWithLayers The source whose handlers should go.
|
|
2569
2860
|
* @param type The event type to be removed.
|
|
2570
|
-
* @param
|
|
2861
|
+
* @param owner The module that registered them.
|
|
2571
2862
|
*/
|
|
2572
|
-
remove(sourceWithLayers: SourceWithLayers, type: EventType): void;
|
|
2863
|
+
remove(sourceWithLayers: SourceWithLayers, type: EventType, owner: AnyMapModule): void;
|
|
2573
2864
|
/**
|
|
2574
2865
|
* Removes all interactive sources and layers.
|
|
2575
2866
|
*/
|
|
2576
2867
|
removeAll(): void;
|
|
2577
2868
|
/**
|
|
2578
|
-
*
|
|
2579
|
-
* @param
|
|
2869
|
+
* Whether any handler, of any event type, listens to this layer.
|
|
2870
|
+
* @param layerId The layer id a rendered feature was drawn from.
|
|
2580
2871
|
*/
|
|
2581
|
-
|
|
2872
|
+
hasHandlerForLayer(layerId: string): boolean;
|
|
2582
2873
|
/**
|
|
2583
|
-
* Look up the {@link SourceWithLayers}
|
|
2584
|
-
*
|
|
2585
|
-
* The SDK assumes at most one `SourceWithLayers` per MapLibre source ID — each
|
|
2586
|
-
* module creates its own source — so any non-empty handler bucket gives us the
|
|
2587
|
-
* right reference. We iterate event-type buckets defensively to skip transient
|
|
2588
|
-
* empty arrays left mid-`removeHandler` before the bucket itself is deleted.
|
|
2874
|
+
* Look up the {@link SourceWithLayers} a layer's handlers were registered against, if any.
|
|
2589
2875
|
*
|
|
2590
|
-
*
|
|
2591
|
-
*
|
|
2876
|
+
* The SDK assumes at most one `SourceWithLayers` per MapLibre source ID — each module creates
|
|
2877
|
+
* its own source — and a layer belongs to exactly one source, so any handler listening to the
|
|
2878
|
+
* layer carries the right reference.
|
|
2592
2879
|
*/
|
|
2593
|
-
protected sourceWithLayersFor(
|
|
2880
|
+
protected sourceWithLayersFor(layerId: string | undefined): SourceWithLayers | undefined;
|
|
2594
2881
|
/**
|
|
2595
2882
|
* Updates the given sourcesWithLayers, if they have any handlers.
|
|
2596
2883
|
* * (This is typically called to refresh any registered, stale sourceWithLayers references after a map style has changed).
|
|
2597
2884
|
* @param sourcesWithLayers The new sources with layers to replace existing ones.
|
|
2885
|
+
* @param owner The module whose sources these are. Only its own handlers are refreshed: two
|
|
2886
|
+
* modules can share one MapLibre source ID, so the ID alone cannot tell them apart.
|
|
2887
|
+
*/
|
|
2888
|
+
updateIfRegistered(sourcesWithLayers: SourcesWithLayers, owner: AnyMapModule): void;
|
|
2889
|
+
/**
|
|
2890
|
+
* The handlers that should fire for a hit on `layerId`.
|
|
2891
|
+
*
|
|
2892
|
+
* The bucket *is* the layer, so no layer matching is needed here: a handler is filed under
|
|
2893
|
+
* exactly the layers its scope selects, which is what keeps a click on a POI out of the base
|
|
2894
|
+
* map's handler even though both register against the `vectorTiles` source.
|
|
2895
|
+
*
|
|
2896
|
+
* When a feature is supplied, handlers whose scope rejects it are dropped too — that is what
|
|
2897
|
+
* lets a feature-scoped handler drive its own hover cursor.
|
|
2598
2898
|
*/
|
|
2599
|
-
|
|
2600
|
-
protected findHandlers: (types: EventType[], sourceId: string | undefined, layerId: string | undefined) => SourceEventTypeHandler[];
|
|
2899
|
+
protected findHandlers: (types: EventType[], layerId: string | undefined, feature?: MapGeoJSONFeature) => HandlerEntry[];
|
|
2601
2900
|
}
|
|
2602
2901
|
//#endregion
|
|
2603
2902
|
//#region src/shared/EventsProxy.d.ts
|
|
@@ -2606,7 +2905,7 @@ declare abstract class AbstractEventProxy {
|
|
|
2606
2905
|
* To have full control on hovers and clicks when multiple overlapping layers are present, that logic must be centralized here.
|
|
2607
2906
|
* @ignore
|
|
2608
2907
|
*/
|
|
2609
|
-
declare class EventsProxy extends AbstractEventProxy {
|
|
2908
|
+
export declare class EventsProxy extends AbstractEventProxy {
|
|
2610
2909
|
private readonly map;
|
|
2611
2910
|
private readonly mapCanvas;
|
|
2612
2911
|
private enabled;
|
|
@@ -2620,6 +2919,8 @@ declare class EventsProxy extends AbstractEventProxy {
|
|
|
2620
2919
|
private lastClickedFeature?;
|
|
2621
2920
|
private lastClickedSourceWithLayers?;
|
|
2622
2921
|
private lastCursorStyle;
|
|
2922
|
+
private pendingMouseMove?;
|
|
2923
|
+
private mouseMoveFrameRequested;
|
|
2623
2924
|
private readonly config;
|
|
2624
2925
|
constructor(map: Map, config?: MapEventsConfig);
|
|
2625
2926
|
private listenToEvents;
|
|
@@ -2638,6 +2939,7 @@ declare class EventsProxy extends AbstractEventProxy {
|
|
|
2638
2939
|
* extends Feature`).
|
|
2639
2940
|
*/
|
|
2640
2941
|
private toCallerFeatures;
|
|
2942
|
+
private callerFeaturesFor;
|
|
2641
2943
|
private getRenderedFeatures;
|
|
2642
2944
|
private clearLongHoverTimeout;
|
|
2643
2945
|
private restartLongHoverTimeout;
|
|
@@ -2646,372 +2948,68 @@ declare class EventsProxy extends AbstractEventProxy {
|
|
|
2646
2948
|
private onMouseOut;
|
|
2647
2949
|
private onMouseDown;
|
|
2648
2950
|
private onMouseUp;
|
|
2951
|
+
/**
|
|
2952
|
+
* Mouse movement arrives far more often than the browser paints, and each pass runs a
|
|
2953
|
+
* `queryRenderedFeatures` — by a wide margin the most expensive thing this proxy does. Only
|
|
2954
|
+
* the newest position matters by the time anything is drawn, so moves are coalesced into one
|
|
2955
|
+
* pass per animation frame and the intermediate ones are dropped.
|
|
2956
|
+
*
|
|
2957
|
+
* Hover semantics are unaffected: `detectHoverState` compares against the previously handled
|
|
2958
|
+
* position, so a coalesced move is indistinguishable from the pointer having travelled
|
|
2959
|
+
* straight there.
|
|
2960
|
+
*/
|
|
2649
2961
|
private onMouseMove;
|
|
2962
|
+
private handleMouseMove;
|
|
2963
|
+
/**
|
|
2964
|
+
* Handles the pointer arriving on a different feature: cursor, `eventState` marker, and the
|
|
2965
|
+
* `hover` handlers themselves.
|
|
2966
|
+
* @returns the caller-facing features, if they had to be built, so `hover-move` can reuse them.
|
|
2967
|
+
*/
|
|
2968
|
+
private dispatchHoverEnter;
|
|
2969
|
+
private dispatchHoverMove;
|
|
2970
|
+
private dispatchToHandlers;
|
|
2650
2971
|
private updateHoverCursor;
|
|
2651
2972
|
private onMapClick;
|
|
2652
2973
|
}
|
|
2653
2974
|
//#endregion
|
|
2654
|
-
//#region src/shared/
|
|
2655
|
-
/**
|
|
2656
|
-
* Whether a map module is based on a map style or on added GeoJSON data.
|
|
2657
|
-
*/
|
|
2658
|
-
type MapModuleSource = 'style' | 'geojson';
|
|
2975
|
+
//#region src/shared/UserEvents.d.ts
|
|
2659
2976
|
/**
|
|
2660
|
-
*
|
|
2661
|
-
*
|
|
2662
|
-
* This abstract class provides the foundation for creating map modules that can display
|
|
2663
|
-
* and manage various types of data on a TomTom map. It handles module lifecycle management,
|
|
2664
|
-
* including initialization, configuration updates, and automatic restoration after map style changes.
|
|
2665
|
-
*
|
|
2666
|
-
* @remarks
|
|
2667
|
-
* All map modules extend this class to ensure consistent behavior across the SDK.
|
|
2668
|
-
* The class manages the module's sources, layers, and configuration, automatically
|
|
2669
|
-
* handling map style changes by restoring the module's state when needed.
|
|
2670
|
-
*
|
|
2671
|
-
* @typeParam SOURCES_WITH_LAYERS - The type defining the sources and layers used by this module
|
|
2672
|
-
* @typeParam CFG - The configuration type for this module, or undefined if no configuration is needed. When defined, must extend MapModuleCommonConfig.
|
|
2673
|
-
*
|
|
2674
|
-
* @example
|
|
2675
|
-
* ```typescript
|
|
2676
|
-
* class CustomModule extends AbstractMapModule<MySourcesWithLayers, MyConfig> {
|
|
2677
|
-
* constructor(tomtomMap: TomTomMap, config?: MyConfig) {
|
|
2678
|
-
* super('geojson', tomtomMap, config);
|
|
2679
|
-
* }
|
|
2680
|
-
* // Implement abstract methods...
|
|
2681
|
-
* }
|
|
2682
|
-
* ```
|
|
2683
|
-
*
|
|
2684
|
-
* @group Shared
|
|
2977
|
+
* Everything {@link UserEvents} needs to register handlers for one scope of one module.
|
|
2978
|
+
* @ignore
|
|
2685
2979
|
*/
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
/**
|
|
2689
|
-
* @ignore
|
|
2690
|
-
*/
|
|
2691
|
-
protected readonly tomtomMap: TomTomMap;
|
|
2692
|
-
/**
|
|
2693
|
-
* @ignore
|
|
2694
|
-
*/
|
|
2695
|
-
protected readonly eventsProxy: EventsProxy;
|
|
2696
|
-
/**
|
|
2697
|
-
* @ignore
|
|
2698
|
-
*/
|
|
2699
|
-
protected readonly mapLibreMap: Map;
|
|
2700
|
-
/**
|
|
2701
|
-
* @ignore
|
|
2702
|
-
*/
|
|
2703
|
-
protected sourcesWithLayers: SOURCES_WITH_LAYERS;
|
|
2980
|
+
export type UserEventsOptions<T, WHERE_SCOPE> = {
|
|
2981
|
+
eventProxy: EventsProxy;
|
|
2704
2982
|
/**
|
|
2705
|
-
*
|
|
2983
|
+
* The source(s) whose features this scope handles events for. Several sources back one scope
|
|
2984
|
+
* when they carry the same data in different display modes — hexgrid, square and heatmap in
|
|
2985
|
+
* {@link TrafficAreaAnalyticsModule}, clustered and unclustered places in {@link PlacesModule}.
|
|
2706
2986
|
*/
|
|
2707
|
-
|
|
2987
|
+
sourcesWithLayers: SourceWithLayers[];
|
|
2708
2988
|
/**
|
|
2709
|
-
*
|
|
2989
|
+
* The module that owns these sources. Kept with every handler so a style-change restore can
|
|
2990
|
+
* tell handlers apart when two modules share one MapLibre source ID.
|
|
2710
2991
|
*/
|
|
2711
|
-
|
|
2992
|
+
owner: AnyMapModule;
|
|
2712
2993
|
/**
|
|
2713
|
-
*
|
|
2994
|
+
* Event configuration for every handler registered through this instance — the hover cursor,
|
|
2995
|
+
* chiefly. A scope built by {@link UserEvents.where} inherits the module's unless `where` is
|
|
2996
|
+
* given one of its own, which is how two parts of one module get different cursors.
|
|
2714
2997
|
*/
|
|
2715
|
-
|
|
2998
|
+
config?: EventHandlerConfig;
|
|
2716
2999
|
/**
|
|
2717
|
-
*
|
|
2718
|
-
*
|
|
2719
|
-
* @
|
|
3000
|
+
* Transforms a raw {@link MapGeoJSONFeature} into the feature type `T` this scope exposes, so
|
|
3001
|
+
* callers receive the module's own feature shape. Applied before handlers and before any
|
|
3002
|
+
* {@link UserEvents.where} predicate, so a predicate also sees `T`.
|
|
2720
3003
|
*/
|
|
2721
|
-
|
|
3004
|
+
mapping?: (feature: MapGeoJSONFeature) => T;
|
|
3005
|
+
/** The scope already applied to this instance, if it came from {@link UserEvents.where}. */
|
|
3006
|
+
scope?: ResolvedEventScope;
|
|
2722
3007
|
/**
|
|
2723
|
-
*
|
|
2724
|
-
*
|
|
2725
|
-
* has its own counter without per-subclass boilerplate. Use as a suffix on
|
|
2726
|
-
* auto-generated source and layer IDs to keep them stable across style changes and
|
|
2727
|
-
* unique across module instances.
|
|
2728
|
-
* @ignore
|
|
3008
|
+
* Turns a module-specific scope object into a {@link ResolvedEventScope}. Only modules with a
|
|
3009
|
+
* typed layer vocabulary supply one — today that is {@link BaseMapModule} and its layer groups.
|
|
2729
3010
|
*/
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
* Per-concrete-class instance counter. WeakMap-keyed so unloaded classes can be GC'd.
|
|
2733
|
-
* @ignore
|
|
2734
|
-
*/
|
|
2735
|
-
private static readonly instanceCounters;
|
|
2736
|
-
/**
|
|
2737
|
-
* Indicates that this module is currently adding its sources and layers to the map, so during this time it might not function properly.
|
|
2738
|
-
* @see waitUntilModuleReady
|
|
2739
|
-
* @private
|
|
2740
|
-
*/
|
|
2741
|
-
private moduleReady;
|
|
2742
|
-
/**
|
|
2743
|
-
* Builds this module based on a given Maps SDK map.
|
|
2744
|
-
* @param tomtomMap The map. It may or may not be initialized at this stage,
|
|
2745
|
-
* but the module ensures to initialize itself once it is.
|
|
2746
|
-
* @param sourceType Whether the module is based on a map style or on added GeoJSON data.
|
|
2747
|
-
* @param config Optional configuration to initialize directly as soon as the map is ready.
|
|
2748
|
-
*/
|
|
2749
|
-
protected constructor(sourceType: MapModuleSource, tomtomMap: TomTomMap, config?: CFG);
|
|
2750
|
-
/**
|
|
2751
|
-
* Initializes the sources with layers of this module.
|
|
2752
|
-
* @param config The optional configuration for the module.
|
|
2753
|
-
* @param restore Whether we are restoring an existing module after the map style got reloaded.
|
|
2754
|
-
* @protected
|
|
2755
|
-
* @ignore
|
|
2756
|
-
*/
|
|
2757
|
-
protected initSourcesWithLayers(config?: CFG, restore?: boolean): void;
|
|
2758
|
-
/**
|
|
2759
|
-
* Initializes the sources with layers for the specific module.
|
|
2760
|
-
* @protected
|
|
2761
|
-
* @ignore
|
|
2762
|
-
*/
|
|
2763
|
-
protected abstract _initSourcesWithLayers(config?: CFG, restore?: boolean): SOURCES_WITH_LAYERS;
|
|
2764
|
-
protected waitUntilModuleReady(): Promise<void>;
|
|
2765
|
-
/**
|
|
2766
|
-
* Applies a configuration to this module.
|
|
2767
|
-
*
|
|
2768
|
-
* This method updates the module's behavior and appearance based on the provided configuration.
|
|
2769
|
-
* The configuration is stored internally and will be automatically reapplied if the map style changes.
|
|
2770
|
-
*
|
|
2771
|
-
* @param config - The configuration object to apply to the module. Pass `undefined` to reset
|
|
2772
|
-
* the configuration to default values.
|
|
2773
|
-
*
|
|
2774
|
-
* @remarks
|
|
2775
|
-
* When a configuration is applied, the module updates its visual representation and behavior
|
|
2776
|
-
* accordingly. The configuration persists across map style changes, ensuring consistent
|
|
2777
|
-
* module behavior even when the map's base style is modified.
|
|
2778
|
-
*
|
|
2779
|
-
* @example
|
|
2780
|
-
* ```typescript
|
|
2781
|
-
* // Apply a new configuration
|
|
2782
|
-
* myModule.applyConfig({ visible: true, opacity: 0.8 });
|
|
2783
|
-
*
|
|
2784
|
-
* // Reset to default configuration
|
|
2785
|
-
* myModule.applyConfig(undefined);
|
|
2786
|
-
* ```
|
|
2787
|
-
*
|
|
2788
|
-
* @see {@link resetConfig} for a convenience method to reset configuration
|
|
2789
|
-
* @see {@link getConfig} to retrieve the current configuration
|
|
2790
|
-
*/
|
|
2791
|
-
applyConfig(config: CFG | undefined): void;
|
|
2792
|
-
/**
|
|
2793
|
-
* Emits a `config-change` event to all registered handlers.
|
|
2794
|
-
* Skipped during module initialisation to avoid spurious events.
|
|
2795
|
-
* @ignore
|
|
2796
|
-
*/
|
|
2797
|
-
protected emitConfigChange(): void;
|
|
2798
|
-
/**
|
|
2799
|
-
* Internal implementation to apply config for the specific module.
|
|
2800
|
-
* @param config The config to apply. this.config contains the previous configuration (if any).
|
|
2801
|
-
* Once the method returns config, it will be assigned to this.config.
|
|
2802
|
-
* @protected
|
|
2803
|
-
* @ignore
|
|
2804
|
-
*/
|
|
2805
|
-
protected abstract _applyConfig(config: CFG | undefined): CFG | undefined;
|
|
2806
|
-
/**
|
|
2807
|
-
* Resets the configuration of this module to its default values.
|
|
2808
|
-
*
|
|
2809
|
-
* This is a convenience method that clears any previously applied configuration
|
|
2810
|
-
* and restores the module to its initial state. This is equivalent to calling
|
|
2811
|
-
* `applyConfig(undefined)`.
|
|
2812
|
-
*
|
|
2813
|
-
* @remarks
|
|
2814
|
-
* After calling this method, the module will behave as if no configuration was ever applied.
|
|
2815
|
-
* Any custom settings, styling, or behavior modifications will be removed and replaced
|
|
2816
|
-
* with default values.
|
|
2817
|
-
*
|
|
2818
|
-
* @example
|
|
2819
|
-
* ```typescript
|
|
2820
|
-
* // Apply some configuration
|
|
2821
|
-
* myModule.applyConfig({ visible: true, opacity: 0.5 });
|
|
2822
|
-
*
|
|
2823
|
-
* // Later, reset to defaults
|
|
2824
|
-
* myModule.resetConfig();
|
|
2825
|
-
* ```
|
|
2826
|
-
*
|
|
2827
|
-
* @see {@link applyConfig} to apply a new configuration
|
|
2828
|
-
* @see {@link getConfig} to retrieve the current configuration before resetting
|
|
2829
|
-
*/
|
|
2830
|
-
resetConfig(): void;
|
|
2831
|
-
private restoreDataAndConfig;
|
|
2832
|
-
/**
|
|
2833
|
-
* implementation needed to restore the module state (data and config applied to the module).
|
|
2834
|
-
* to be used to restore module state after map style change
|
|
2835
|
-
* @protected
|
|
2836
|
-
* @ignore
|
|
2837
|
-
*/
|
|
2838
|
-
protected restoreDataAndConfigImpl(): void;
|
|
2839
|
-
/**
|
|
2840
|
-
* Retrieves a copy of the current module configuration.
|
|
2841
|
-
*
|
|
2842
|
-
* This method returns a shallow copy of the configuration object that is currently
|
|
2843
|
-
* applied to the module. If no configuration has been applied, it returns `undefined`.
|
|
2844
|
-
*
|
|
2845
|
-
* @returns A shallow copy of the current configuration object, or `undefined` if no
|
|
2846
|
-
* configuration is currently applied. The returned object is a copy to prevent
|
|
2847
|
-
* unintended modifications to the internal state.
|
|
2848
|
-
*
|
|
2849
|
-
* @remarks
|
|
2850
|
-
* The returned configuration object is a shallow copy, which means that while the
|
|
2851
|
-
* top-level properties are copied, any nested objects or arrays are still referenced
|
|
2852
|
-
* from the original configuration. This is sufficient for most use cases but should
|
|
2853
|
-
* be kept in mind when dealing with complex configurations.
|
|
2854
|
-
*
|
|
2855
|
-
* @example
|
|
2856
|
-
* ```typescript
|
|
2857
|
-
* // Apply a configuration
|
|
2858
|
-
* myModule.applyConfig({ visible: true, opacity: 0.8 });
|
|
2859
|
-
*
|
|
2860
|
-
* // Later, retrieve the current configuration
|
|
2861
|
-
* const currentConfig = myModule.getConfig();
|
|
2862
|
-
* console.log(currentConfig); // { visible: true, opacity: 0.8 }
|
|
2863
|
-
*
|
|
2864
|
-
* // When no config is applied
|
|
2865
|
-
* myModule.resetConfig();
|
|
2866
|
-
* console.log(myModule.getConfig()); // undefined
|
|
2867
|
-
* ```
|
|
2868
|
-
*
|
|
2869
|
-
* @see {@link applyConfig} to modify the configuration
|
|
2870
|
-
* @see {@link resetConfig} to clear the configuration
|
|
2871
|
-
*/
|
|
2872
|
-
getConfig(): NonNullable<CFG> | undefined;
|
|
2873
|
-
/**
|
|
2874
|
-
* Gets the source and layer identifiers for all sources managed by this module.
|
|
2875
|
-
*
|
|
2876
|
-
* This property provides access to the MapLibre source and layer IDs that were created
|
|
2877
|
-
* and are managed by this module. These IDs can be used to interact directly with
|
|
2878
|
-
* MapLibre's API or to identify which layers belong to this module.
|
|
2879
|
-
*
|
|
2880
|
-
* @returns A record mapping each source name to its corresponding source ID and layer IDs.
|
|
2881
|
-
* Each entry contains the MapLibre source identifier and an array of layer identifiers
|
|
2882
|
-
* associated with that source.
|
|
2883
|
-
*
|
|
2884
|
-
* @remarks
|
|
2885
|
-
* The returned IDs are useful when you need to:
|
|
2886
|
-
* - Directly manipulate layers using MapLibre's native API
|
|
2887
|
-
* - Identify which layers on the map belong to this module
|
|
2888
|
-
* - Set layer ordering or positioning relative to other layers
|
|
2889
|
-
* - Access source or layer properties through MapLibre methods
|
|
2890
|
-
*
|
|
2891
|
-
* @example
|
|
2892
|
-
* ```typescript
|
|
2893
|
-
* const ids = myModule.sourceAndLayerIDs;
|
|
2894
|
-
* console.log(ids);
|
|
2895
|
-
* // {
|
|
2896
|
-
* // mySource: {
|
|
2897
|
-
* // sourceID: 'my-source-id',
|
|
2898
|
-
* // layerIDs: ['layer-1', 'layer-2']
|
|
2899
|
-
* // }
|
|
2900
|
-
* // }
|
|
2901
|
-
*
|
|
2902
|
-
* // Use with MapLibre API
|
|
2903
|
-
* const map = myModule.mapLibreMap;
|
|
2904
|
-
* ids.mySource.layerIDs.forEach(layerId => {
|
|
2905
|
-
* map.setLayoutProperty(layerId, 'visibility', 'visible');
|
|
2906
|
-
* });
|
|
2907
|
-
* ```
|
|
2908
|
-
*/
|
|
2909
|
-
get sourceAndLayerIDs(): Record<keyof SOURCES_WITH_LAYERS, SourceWithLayerIDs>;
|
|
2910
|
-
}
|
|
2911
|
-
//#endregion
|
|
2912
|
-
//#region src/shared/ModuleEvents.d.ts
|
|
2913
|
-
/**
|
|
2914
|
-
* Lifecycle event module for map modules.
|
|
2915
|
-
*
|
|
2916
|
-
* Provides a unified API for subscribing to module-level events that are not tied
|
|
2917
|
-
* to user interaction with map features. Two event types are supported:
|
|
2918
|
-
*
|
|
2919
|
-
* - `config-change`: emitted whenever the module's configuration is updated
|
|
2920
|
-
* (via `applyConfig`, `resetConfig`, or any module-specific setter that mutates config).
|
|
2921
|
-
* - `shown-features`: emitted by modules that have a `show` method, immediately after
|
|
2922
|
-
* features are displayed on the map.
|
|
2923
|
-
*
|
|
2924
|
-
* Each `on()` call returns an unsubscribe function so individual handlers can be
|
|
2925
|
-
* removed without clearing the entire listener list.
|
|
2926
|
-
*
|
|
2927
|
-
* @typeParam TConfig - The module's configuration type.
|
|
2928
|
-
* @typeParam TShownFeatures - The type of data passed to `show()`. Use `never` for
|
|
2929
|
-
* modules that have no `show` method.
|
|
2930
|
-
*
|
|
2931
|
-
* @example
|
|
2932
|
-
* ```typescript
|
|
2933
|
-
* const unsubscribeConfig = trafficFlow.events.on('config-change', (config) => {
|
|
2934
|
-
* console.log('New config:', config);
|
|
2935
|
-
* });
|
|
2936
|
-
*
|
|
2937
|
-
* const unsubscribeShown = places.events.on('shown-features', (features) => {
|
|
2938
|
-
* console.log('Shown:', features);
|
|
2939
|
-
* });
|
|
2940
|
-
*
|
|
2941
|
-
* // Later:
|
|
2942
|
-
* unsubscribeConfig();
|
|
2943
|
-
* unsubscribeShown();
|
|
2944
|
-
* ```
|
|
2945
|
-
*
|
|
2946
|
-
* @group Events
|
|
2947
|
-
*/
|
|
2948
|
-
declare class ModuleEvents<TConfig, TShownFeatures = never> {
|
|
2949
|
-
private readonly configChangeHandlers;
|
|
2950
|
-
private readonly shownFeaturesHandlers;
|
|
2951
|
-
constructor(configChangeHandlers: ((config: TConfig | undefined) => void)[], shownFeaturesHandlers: ((features: TShownFeatures) => void)[]);
|
|
2952
|
-
/**
|
|
2953
|
-
* Subscribe to config-change events.
|
|
2954
|
-
*
|
|
2955
|
-
* The handler is called with the module's full current configuration immediately after
|
|
2956
|
-
* any mutation — whether through `applyConfig`, a module-specific setter, or `resetConfig`.
|
|
2957
|
-
*
|
|
2958
|
-
* @param type - `'config-change'`
|
|
2959
|
-
* @param handler - Receives the module's config (or `undefined` when config is cleared).
|
|
2960
|
-
* @returns An unsubscribe function. Call it to remove **only this handler** without
|
|
2961
|
-
* affecting other registered handlers for the same event type.
|
|
2962
|
-
*
|
|
2963
|
-
* @example
|
|
2964
|
-
* ```typescript
|
|
2965
|
-
* const unsub = trafficFlow.events.on('config-change', (config) => {
|
|
2966
|
-
* toggle.checked = config?.visible ?? false;
|
|
2967
|
-
* });
|
|
2968
|
-
*
|
|
2969
|
-
* // Later:
|
|
2970
|
-
* unsub();
|
|
2971
|
-
* ```
|
|
2972
|
-
*/
|
|
2973
|
-
on(type: 'config-change', handler: (config: TConfig | undefined) => void): () => void;
|
|
2974
|
-
/**
|
|
2975
|
-
* Subscribe to shown-features events.
|
|
2976
|
-
*
|
|
2977
|
-
* The handler is called immediately after a module's `show()` method (or equivalent)
|
|
2978
|
-
* has updated the map with new data. Only available on modules that have a `show` method.
|
|
2979
|
-
*
|
|
2980
|
-
* @param type - `'shown-features'`
|
|
2981
|
-
* @param handler - Receives the data that was passed to `show()`.
|
|
2982
|
-
* @returns An unsubscribe function. Call it to remove **only this handler** without
|
|
2983
|
-
* affecting other registered handlers for the same event type.
|
|
2984
|
-
*
|
|
2985
|
-
* @example
|
|
2986
|
-
* ```typescript
|
|
2987
|
-
* const unsub = places.events.on('shown-features', (features) => {
|
|
2988
|
-
* fitMapToResults(features);
|
|
2989
|
-
* });
|
|
2990
|
-
*
|
|
2991
|
-
* // Later:
|
|
2992
|
-
* unsub();
|
|
2993
|
-
* ```
|
|
2994
|
-
*/
|
|
2995
|
-
on(type: 'shown-features', handler: (features: TShownFeatures) => void): () => void;
|
|
2996
|
-
/**
|
|
2997
|
-
* Remove **all** handlers for the given event type at once.
|
|
2998
|
-
*
|
|
2999
|
-
* Prefer the unsubscribe function returned by {@link on} when you need to remove a
|
|
3000
|
-
* single handler. Use `off` for bulk teardown — e.g. when unmounting a component that
|
|
3001
|
-
* registered multiple handlers.
|
|
3002
|
-
*
|
|
3003
|
-
* @param type - The event type whose handlers should all be cleared.
|
|
3004
|
-
*
|
|
3005
|
-
* @example
|
|
3006
|
-
* ```typescript
|
|
3007
|
-
* // Clear all config-change listeners in one call
|
|
3008
|
-
* trafficFlow.events.off('config-change');
|
|
3009
|
-
* ```
|
|
3010
|
-
*/
|
|
3011
|
-
off(type: 'config-change' | 'shown-features'): void;
|
|
3012
|
-
}
|
|
3013
|
-
//#endregion
|
|
3014
|
-
//#region src/shared/UserEvents.d.ts
|
|
3011
|
+
scopeResolver?: (scope: WHERE_SCOPE) => ResolvedEventScope;
|
|
3012
|
+
};
|
|
3015
3013
|
/**
|
|
3016
3014
|
* Event handling interface for map features.
|
|
3017
3015
|
*
|
|
@@ -3105,38 +3103,52 @@ declare class ModuleEvents<TConfig, TShownFeatures = never> {
|
|
|
3105
3103
|
*
|
|
3106
3104
|
* @group Events
|
|
3107
3105
|
*/
|
|
3108
|
-
declare class UserEvents<T = MapGeoJSONFeature> {
|
|
3109
|
-
private readonly eventProxy;
|
|
3110
|
-
private readonly config;
|
|
3111
|
-
/**
|
|
3112
|
-
* Optional function that transforms a raw {@link MapGeoJSONFeature} into the
|
|
3113
|
-
* feature type `T` exposed by the module. When provided, every feature passed (fired)
|
|
3114
|
-
* to event handlers is first run through this function, so callers receive the
|
|
3115
|
-
* module's own feature shape instead of the underlying MapLibre feature.
|
|
3116
|
-
*
|
|
3117
|
-
* When omitted, `T` defaults to `MapGeoJSONFeature` and features are forwarded
|
|
3118
|
-
* as-is.
|
|
3119
|
-
*/
|
|
3120
|
-
private readonly mapping?;
|
|
3106
|
+
export declare class UserEvents<T = MapGeoJSONFeature, WHERE_SCOPE = never> {
|
|
3121
3107
|
private readonly sources;
|
|
3122
|
-
|
|
3108
|
+
private readonly options;
|
|
3109
|
+
constructor(options: UserEventsOptions<T, WHERE_SCOPE>);
|
|
3123
3110
|
/**
|
|
3124
|
-
*
|
|
3125
|
-
*
|
|
3126
|
-
*
|
|
3127
|
-
*
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
*
|
|
3132
|
-
* feature type `T` exposed by the module. When provided, every feature passed (fired)
|
|
3133
|
-
* to event handlers is first run through this function, so callers receive the
|
|
3134
|
-
* module's own feature shape instead of the underlying MapLibre feature.
|
|
3111
|
+
* Narrows these events to part of what they cover, returning a {@link UserEvents} over just
|
|
3112
|
+
* that part.
|
|
3113
|
+
*
|
|
3114
|
+
* Two things can be narrowed. A **feature predicate** keeps only the features you care about —
|
|
3115
|
+
* available on every module, since only the module's own data can tell a major incident from a
|
|
3116
|
+
* minor one. A **layer scope** keeps only part of the map's layers; the SDK offers this where
|
|
3117
|
+
* a stable, typed vocabulary for those layers exists, which today means
|
|
3118
|
+
* {@link BaseMapModule}'s layer groups.
|
|
3135
3119
|
*
|
|
3136
|
-
*
|
|
3137
|
-
*
|
|
3120
|
+
* A new instance, rather than this one narrowed in place: callers hold `events` and narrow it
|
|
3121
|
+
* more than once, and mutating would make the second `where()` mean "first AND second" while
|
|
3122
|
+
* leaving the surface it came from silently scoped — and its `config` overridden.
|
|
3123
|
+
*
|
|
3124
|
+
* Narrowing on both axes is one call, not two — {@link BaseMapModule}'s scope object takes a
|
|
3125
|
+
* `features` predicate alongside its `layerGroups`. A further `where()` does intersect with
|
|
3126
|
+
* this one, but two feature predicates read better as a single `a(f) && b(f)`.
|
|
3127
|
+
*
|
|
3128
|
+
* @param scope See {@link EventScope} — a predicate over this scope's feature type, or, where
|
|
3129
|
+
* the module supports one, a scope object such as `{ layerGroups }`.
|
|
3130
|
+
* @param config Event configuration for handlers registered through the returned instance.
|
|
3131
|
+
* Each scope can carry its own, which is how two parts of one module get different hover
|
|
3132
|
+
* cursors. Defaults to the configuration this instance already uses.
|
|
3133
|
+
*
|
|
3134
|
+
* @example
|
|
3135
|
+
* ```typescript
|
|
3136
|
+
* // Feature scope: only major incidents are clickable.
|
|
3137
|
+
* trafficIncidents.events.where((incident) => incident.properties.magnitude === 'major')
|
|
3138
|
+
* .on('click', showIncidentDetails);
|
|
3139
|
+
*
|
|
3140
|
+
* // Layer scope with its own cursor, on the base map.
|
|
3141
|
+
* baseMap.events
|
|
3142
|
+
* .where({ layerGroups: { mode: 'include', names: ['roadLabels'] } }, { cursorOnHover: 'pointer' })
|
|
3143
|
+
* .on('click', showRoadName);
|
|
3144
|
+
*
|
|
3145
|
+
* // A named scope, narrowed by a predicate.
|
|
3146
|
+
* routing.events.tunnels.where((section) => section.properties.lengthInMeters > 500)
|
|
3147
|
+
* .on('click', showLongTunnel);
|
|
3148
|
+
* ```
|
|
3138
3149
|
*/
|
|
3139
|
-
|
|
3150
|
+
where(scope: EventScope<T, WHERE_SCOPE>, config?: EventHandlerConfig): UserEvents<T, WHERE_SCOPE>;
|
|
3151
|
+
private resolveScope;
|
|
3140
3152
|
/**
|
|
3141
3153
|
* Register an event handler for user interactions with map features.
|
|
3142
3154
|
*
|
|
@@ -3216,6 +3228,7 @@ declare class UserEvents<T = MapGeoJSONFeature> {
|
|
|
3216
3228
|
* ```
|
|
3217
3229
|
*/
|
|
3218
3230
|
on(type: EventType, handler: UserEventHandler<T>): () => void;
|
|
3231
|
+
private toRegisteredHandler;
|
|
3219
3232
|
/**
|
|
3220
3233
|
* Remove all event handlers for a specific event type.
|
|
3221
3234
|
*
|
|
@@ -3302,10 +3315,18 @@ declare class UserEvents<T = MapGeoJSONFeature> {
|
|
|
3302
3315
|
* underlying {@link ModuleEvents} instance. Each `on` call returns an unsubscribe function.
|
|
3303
3316
|
* Both user and module event types are also removable in bulk via {@link off}.
|
|
3304
3317
|
*
|
|
3318
|
+
* Named scopes, where a module has them, hang off this object as properties and are themselves
|
|
3319
|
+
* `CombinedEvents` — so a scope carries the lifecycle events that module actually scopes.
|
|
3320
|
+
* {@link where} narrows ad hoc instead, and returns a plain {@link UserEvents}: a filter you build
|
|
3321
|
+
* on the spot has no lifecycle of its own.
|
|
3322
|
+
*
|
|
3305
3323
|
* @typeParam T - Feature type surfaced by user interaction handlers.
|
|
3306
3324
|
* @typeParam CFG - Module configuration type passed to `config-change` handlers.
|
|
3307
3325
|
* @typeParam TShown - Data type passed to `shown-features` handlers. Use `never` for
|
|
3308
3326
|
* modules that have no `show` method.
|
|
3327
|
+
* @typeParam WHERE_SCOPE - Module-specific scope object accepted by {@link where}, in addition to a
|
|
3328
|
+
* feature predicate. `never` for modules that only support predicates. Unrelated to a module's
|
|
3329
|
+
* *named* scopes, which are properties on this object rather than an argument to it.
|
|
3309
3330
|
*
|
|
3310
3331
|
* @example
|
|
3311
3332
|
* ```typescript
|
|
@@ -3332,10 +3353,27 @@ declare class UserEvents<T = MapGeoJSONFeature> {
|
|
|
3332
3353
|
*
|
|
3333
3354
|
* @group Events
|
|
3334
3355
|
*/
|
|
3335
|
-
declare class CombinedEvents<T, CFG, TShown = never> {
|
|
3356
|
+
export declare class CombinedEvents<T, CFG, TShown = never, WHERE_SCOPE = never> {
|
|
3336
3357
|
private readonly userEventsInstance;
|
|
3337
3358
|
private readonly moduleEventsInstance;
|
|
3338
|
-
constructor(userEventsInstance: UserEvents<T>, moduleEventsInstance: ModuleEvents<CFG, TShown>);
|
|
3359
|
+
constructor(userEventsInstance: UserEvents<T, WHERE_SCOPE>, moduleEventsInstance: ModuleEvents<CFG, TShown>);
|
|
3360
|
+
/**
|
|
3361
|
+
* Narrows these events to part of what they cover — see {@link UserEvents.where}.
|
|
3362
|
+
*
|
|
3363
|
+
* @param scope See {@link EventScope} — a predicate over this module's feature type, or, where
|
|
3364
|
+
* the module supports one, a scope object such as `{ layerGroups }` on {@link BaseMapModule}.
|
|
3365
|
+
* @param config Event configuration for handlers registered through the returned instance, so
|
|
3366
|
+
* each scope can have its own hover cursor.
|
|
3367
|
+
* @returns A {@link UserEvents} covering only the narrowed set. Lifecycle events stay on the
|
|
3368
|
+
* module (or named scope) they belong to.
|
|
3369
|
+
*
|
|
3370
|
+
* @example
|
|
3371
|
+
* ```typescript
|
|
3372
|
+
* trafficIncidents.events.where((incident) => incident.properties.magnitude === 'major')
|
|
3373
|
+
* .on('click', showIncidentDetails);
|
|
3374
|
+
* ```
|
|
3375
|
+
*/
|
|
3376
|
+
where(scope: EventScope<T, WHERE_SCOPE>, config?: EventHandlerConfig): UserEvents<T, WHERE_SCOPE>;
|
|
3339
3377
|
/**
|
|
3340
3378
|
* Subscribe to a user interaction event (`click`, `contextmenu`, `hover`, `long-hover`).
|
|
3341
3379
|
*
|
|
@@ -3371,45 +3409,365 @@ declare class CombinedEvents<T, CFG, TShown = never> {
|
|
|
3371
3409
|
* unsub();
|
|
3372
3410
|
* ```
|
|
3373
3411
|
*/
|
|
3374
|
-
on(type: 'config-change', handler: (config: CFG | undefined) => void): () => void;
|
|
3412
|
+
on(type: 'config-change', handler: (config: CFG | undefined) => void): () => void;
|
|
3413
|
+
/**
|
|
3414
|
+
* Subscribe to shown-features events.
|
|
3415
|
+
*
|
|
3416
|
+
* Fires immediately after the module's `show()` method (or equivalent) has rendered
|
|
3417
|
+
* new data on the map. Only available on modules that have a `show` method.
|
|
3418
|
+
*
|
|
3419
|
+
* @param type - `'shown-features'`
|
|
3420
|
+
* @param handler - Receives the data that was passed to `show()`.
|
|
3421
|
+
* @returns An unsubscribe function. Call it to remove **only this handler**.
|
|
3422
|
+
*
|
|
3423
|
+
* @example
|
|
3424
|
+
* ```typescript
|
|
3425
|
+
* const unsub = places.events.on('shown-features', (features) => {
|
|
3426
|
+
* fitMapToResults(features);
|
|
3427
|
+
* });
|
|
3428
|
+
* unsub();
|
|
3429
|
+
* ```
|
|
3430
|
+
*/
|
|
3431
|
+
on(type: ShownFeaturesType<TShown>, handler: (features: TShown) => void): () => void;
|
|
3432
|
+
/**
|
|
3433
|
+
* Remove **all** handlers for the given event type at once.
|
|
3434
|
+
*
|
|
3435
|
+
* Accepts both user interaction types (`click`, `contextmenu`, `hover`, `long-hover`) and
|
|
3436
|
+
* module lifecycle types (`config-change`, `shown-features`).
|
|
3437
|
+
*
|
|
3438
|
+
* Prefer the unsubscribe function returned by {@link on} when you need to remove a single
|
|
3439
|
+
* handler. Use `off` for bulk teardown — e.g. when unmounting a component that registered
|
|
3440
|
+
* multiple handlers of the same type.
|
|
3441
|
+
*
|
|
3442
|
+
* @param type - The event type whose handlers should all be cleared.
|
|
3443
|
+
*
|
|
3444
|
+
* @example
|
|
3445
|
+
* ```typescript
|
|
3446
|
+
* places.events.off('click'); // clear all click handlers
|
|
3447
|
+
* places.events.off('config-change'); // clear all config-change handlers
|
|
3448
|
+
* ```
|
|
3449
|
+
*/
|
|
3450
|
+
off(type: EventType | 'config-change' | 'shown-features'): void;
|
|
3451
|
+
}
|
|
3452
|
+
//#endregion
|
|
3453
|
+
//#region src/shared/AbstractMapModule.d.ts
|
|
3454
|
+
/**
|
|
3455
|
+
* How a module builds user events over some of its sources.
|
|
3456
|
+
* @ignore
|
|
3457
|
+
*/
|
|
3458
|
+
type EventScopeOptions<T, WHERE_SCOPE> = {
|
|
3459
|
+
/** Turns a raw MapLibre feature into the feature type this scope exposes. */
|
|
3460
|
+
mapping?: (feature: MapGeoJSONFeature) => T;
|
|
3461
|
+
/** Resolves a module-specific scope object, such as BaseMapModule's `{ layerGroups }`. */
|
|
3462
|
+
scopeResolver?: (scope: WHERE_SCOPE) => ResolvedEventScope;
|
|
3463
|
+
};
|
|
3464
|
+
/**
|
|
3465
|
+
* Whether a map module is based on a map style or on added GeoJSON data.
|
|
3466
|
+
*/
|
|
3467
|
+
type MapModuleSource = 'style' | 'geojson';
|
|
3468
|
+
/**
|
|
3469
|
+
* Base class for all Maps SDK map modules.
|
|
3470
|
+
*
|
|
3471
|
+
* This abstract class provides the foundation for creating map modules that can display
|
|
3472
|
+
* and manage various types of data on a TomTom map. It handles module lifecycle management,
|
|
3473
|
+
* including initialization, configuration updates, and automatic restoration after map style changes.
|
|
3474
|
+
*
|
|
3475
|
+
* @remarks
|
|
3476
|
+
* All map modules extend this class to ensure consistent behavior across the SDK.
|
|
3477
|
+
* The class manages the module's sources, layers, and configuration, automatically
|
|
3478
|
+
* handling map style changes by restoring the module's state when needed.
|
|
3479
|
+
*
|
|
3480
|
+
* The `sourceType` a module passes up says who owns the sources and layers it controls, and
|
|
3481
|
+
* therefore how its instances behave:
|
|
3482
|
+
*
|
|
3483
|
+
* - `'geojson'` — the module adds and owns its own sources, layers and images, suffixed per
|
|
3484
|
+
* instance. Multi-instance, built with `create(map, config?)`.
|
|
3485
|
+
* - `'style'` — the module controls sources and layers the map style already provides, under fixed
|
|
3486
|
+
* global IDs. A shared controller, obtained with `get(map, config?)`.
|
|
3487
|
+
*
|
|
3488
|
+
* @typeParam SOURCES_WITH_LAYERS - The type defining the sources and layers used by this module
|
|
3489
|
+
* @typeParam CFG - The configuration type for this module, or undefined if no configuration is needed. When defined, must extend MapModuleCommonConfig.
|
|
3490
|
+
*
|
|
3491
|
+
* @example
|
|
3492
|
+
* ```typescript
|
|
3493
|
+
* class CustomModule extends AbstractMapModule<MySourcesWithLayers, MyConfig> {
|
|
3494
|
+
* constructor(tomtomMap: TomTomMap, config?: MyConfig) {
|
|
3495
|
+
* super('geojson', tomtomMap, config);
|
|
3496
|
+
* }
|
|
3497
|
+
* // Implement abstract methods...
|
|
3498
|
+
* }
|
|
3499
|
+
* ```
|
|
3500
|
+
*
|
|
3501
|
+
* @group Shared
|
|
3502
|
+
*/
|
|
3503
|
+
export declare abstract class AbstractMapModule<SOURCES_WITH_LAYERS extends SourcesWithLayers, CFG extends MapModuleCommonConfig | undefined = undefined> {
|
|
3504
|
+
private readonly sourceType;
|
|
3505
|
+
/**
|
|
3506
|
+
* @ignore
|
|
3507
|
+
*/
|
|
3508
|
+
protected readonly tomtomMap: TomTomMap;
|
|
3509
|
+
/**
|
|
3510
|
+
* @ignore
|
|
3511
|
+
*/
|
|
3512
|
+
protected readonly eventsProxy: EventsProxy;
|
|
3513
|
+
/**
|
|
3514
|
+
* @ignore
|
|
3515
|
+
*/
|
|
3516
|
+
protected readonly mapLibreMap: Map;
|
|
3517
|
+
/**
|
|
3518
|
+
* @ignore
|
|
3519
|
+
*/
|
|
3520
|
+
protected sourcesWithLayers: SOURCES_WITH_LAYERS;
|
|
3521
|
+
/**
|
|
3522
|
+
* @ignore
|
|
3523
|
+
*/
|
|
3524
|
+
protected _sourceAndLayerIDs: Record<keyof SOURCES_WITH_LAYERS, SourceWithLayerIDs>;
|
|
3525
|
+
/**
|
|
3526
|
+
* @ignore
|
|
3527
|
+
*/
|
|
3528
|
+
protected config?: CFG;
|
|
3529
|
+
/**
|
|
3530
|
+
* @ignore
|
|
3531
|
+
*/
|
|
3532
|
+
protected _initializing: boolean;
|
|
3533
|
+
/**
|
|
3534
|
+
* Handlers registered via events.on('config-change', …).
|
|
3535
|
+
* Stored here so the array reference stays stable across multiple events getter calls.
|
|
3536
|
+
* @ignore
|
|
3537
|
+
*/
|
|
3538
|
+
protected readonly configChangeHandlers: ((config: CFG | undefined) => void)[];
|
|
3539
|
+
/**
|
|
3540
|
+
* Monotonically increasing index unique to this instance within its concrete module
|
|
3541
|
+
* class. Auto-assigned in the constructor based on `new.target`, so each subclass
|
|
3542
|
+
* has its own counter without per-subclass boilerplate. Use as a suffix on
|
|
3543
|
+
* auto-generated source and layer IDs to keep them stable across style changes and
|
|
3544
|
+
* unique across module instances.
|
|
3545
|
+
* @ignore
|
|
3546
|
+
*/
|
|
3547
|
+
protected readonly instanceIndex: number;
|
|
3548
|
+
/**
|
|
3549
|
+
* Per-concrete-class instance counter. WeakMap-keyed so unloaded classes can be GC'd.
|
|
3550
|
+
* @ignore
|
|
3551
|
+
*/
|
|
3552
|
+
private static readonly instanceCounters;
|
|
3553
|
+
/**
|
|
3554
|
+
* Indicates that this module is currently adding its sources and layers to the map, so during this time it might not function properly.
|
|
3555
|
+
* @see waitUntilModuleReady
|
|
3556
|
+
* @private
|
|
3557
|
+
*/
|
|
3558
|
+
private moduleReady;
|
|
3559
|
+
/**
|
|
3560
|
+
* Builds this module based on a given Maps SDK map.
|
|
3561
|
+
* @param tomtomMap The map. It may or may not be initialized at this stage,
|
|
3562
|
+
* but the module ensures to initialize itself once it is.
|
|
3563
|
+
* @param sourceType Whether the module is based on a map style or on added GeoJSON data.
|
|
3564
|
+
* @param config Optional configuration to initialize directly as soon as the map is ready.
|
|
3565
|
+
*/
|
|
3566
|
+
protected constructor(sourceType: MapModuleSource, tomtomMap: TomTomMap, config?: CFG);
|
|
3567
|
+
/**
|
|
3568
|
+
* Initializes the sources with layers of this module.
|
|
3569
|
+
* @param config The optional configuration for the module.
|
|
3570
|
+
* @param restore Whether we are restoring an existing module after the map style got reloaded.
|
|
3571
|
+
* @protected
|
|
3572
|
+
* @ignore
|
|
3573
|
+
*/
|
|
3574
|
+
protected initSourcesWithLayers(config?: CFG, restore?: boolean): void;
|
|
3575
|
+
/**
|
|
3576
|
+
* Initializes the sources with layers for the specific module.
|
|
3577
|
+
* @protected
|
|
3578
|
+
* @ignore
|
|
3579
|
+
*/
|
|
3580
|
+
protected abstract _initSourcesWithLayers(config?: CFG, restore?: boolean): SOURCES_WITH_LAYERS;
|
|
3581
|
+
protected waitUntilModuleReady(): Promise<void>;
|
|
3582
|
+
/**
|
|
3583
|
+
* Applies a configuration to this module.
|
|
3584
|
+
*
|
|
3585
|
+
* This method updates the module's behavior and appearance based on the provided configuration.
|
|
3586
|
+
* The configuration is stored internally and will be automatically reapplied if the map style changes.
|
|
3587
|
+
*
|
|
3588
|
+
* @param config - The configuration object to apply to the module. Pass `undefined` to reset
|
|
3589
|
+
* the configuration to default values.
|
|
3590
|
+
*
|
|
3591
|
+
* @remarks
|
|
3592
|
+
* When a configuration is applied, the module updates its visual representation and behavior
|
|
3593
|
+
* accordingly. The configuration persists across map style changes, ensuring consistent
|
|
3594
|
+
* module behavior even when the map's base style is modified.
|
|
3595
|
+
*
|
|
3596
|
+
* Unless a module documents otherwise, the given configuration **replaces** the current one
|
|
3597
|
+
* rather than being merged into it. To change one part of it, spread the current
|
|
3598
|
+
* configuration into the new one: `myModule.applyConfig({ ...myModule.getConfig(), theme })`.
|
|
3599
|
+
*
|
|
3600
|
+
* @example
|
|
3601
|
+
* ```typescript
|
|
3602
|
+
* // Apply a new configuration
|
|
3603
|
+
* myModule.applyConfig({ visible: true, opacity: 0.8 });
|
|
3604
|
+
*
|
|
3605
|
+
* // Reset to default configuration
|
|
3606
|
+
* myModule.applyConfig(undefined);
|
|
3607
|
+
* ```
|
|
3608
|
+
*
|
|
3609
|
+
* @see {@link resetConfig} for a convenience method to reset configuration
|
|
3610
|
+
* @see {@link getConfig} to retrieve the current configuration
|
|
3611
|
+
*/
|
|
3612
|
+
applyConfig(config: CFG | undefined): void;
|
|
3613
|
+
/**
|
|
3614
|
+
* Emits a `config-change` event to all registered handlers.
|
|
3615
|
+
* Skipped during module initialisation to avoid spurious events.
|
|
3616
|
+
* @ignore
|
|
3617
|
+
*/
|
|
3618
|
+
protected emitConfigChange(): void;
|
|
3619
|
+
/**
|
|
3620
|
+
* Internal implementation to apply config for the specific module.
|
|
3621
|
+
* @param config The config to apply. this.config contains the previous configuration (if any).
|
|
3622
|
+
* Once the method returns config, it will be assigned to this.config.
|
|
3623
|
+
* @protected
|
|
3624
|
+
* @ignore
|
|
3625
|
+
*/
|
|
3626
|
+
protected abstract _applyConfig(config: CFG | undefined): CFG | undefined;
|
|
3627
|
+
/**
|
|
3628
|
+
* Resets the configuration of this module to its default values.
|
|
3629
|
+
*
|
|
3630
|
+
* This is a convenience method that clears any previously applied configuration
|
|
3631
|
+
* and restores the module to its initial state. This is equivalent to calling
|
|
3632
|
+
* `applyConfig(undefined)`.
|
|
3633
|
+
*
|
|
3634
|
+
* @remarks
|
|
3635
|
+
* After calling this method, the module will behave as if no configuration was ever applied.
|
|
3636
|
+
* Any custom settings, styling, or behavior modifications will be removed and replaced
|
|
3637
|
+
* with default values.
|
|
3638
|
+
*
|
|
3639
|
+
* @example
|
|
3640
|
+
* ```typescript
|
|
3641
|
+
* // Apply some configuration
|
|
3642
|
+
* myModule.applyConfig({ visible: true, opacity: 0.5 });
|
|
3643
|
+
*
|
|
3644
|
+
* // Later, reset to defaults
|
|
3645
|
+
* myModule.resetConfig();
|
|
3646
|
+
* ```
|
|
3647
|
+
*
|
|
3648
|
+
* @see {@link applyConfig} to apply a new configuration
|
|
3649
|
+
* @see {@link getConfig} to retrieve the current configuration before resetting
|
|
3650
|
+
*/
|
|
3651
|
+
resetConfig(): void;
|
|
3652
|
+
private restoreDataAndConfig;
|
|
3653
|
+
/**
|
|
3654
|
+
* implementation needed to restore the module state (data and config applied to the module).
|
|
3655
|
+
* to be used to restore module state after map style change
|
|
3656
|
+
* @protected
|
|
3657
|
+
* @ignore
|
|
3658
|
+
*/
|
|
3659
|
+
protected restoreDataAndConfigImpl(): void;
|
|
3660
|
+
/**
|
|
3661
|
+
* Retrieves a copy of the current module configuration.
|
|
3662
|
+
*
|
|
3663
|
+
* This method returns a shallow copy of the configuration object that is currently
|
|
3664
|
+
* applied to the module. If no configuration has been applied, it returns `undefined`.
|
|
3665
|
+
*
|
|
3666
|
+
* @returns A shallow copy of the current configuration object, or `undefined` if no
|
|
3667
|
+
* configuration is currently applied. The returned object is a copy to prevent
|
|
3668
|
+
* unintended modifications to the internal state.
|
|
3669
|
+
*
|
|
3670
|
+
* @remarks
|
|
3671
|
+
* The returned configuration object is a shallow copy, which means that while the
|
|
3672
|
+
* top-level properties are copied, any nested objects or arrays are still referenced
|
|
3673
|
+
* from the original configuration. This is sufficient for most use cases but should
|
|
3674
|
+
* be kept in mind when dealing with complex configurations.
|
|
3675
|
+
*
|
|
3676
|
+
* @example
|
|
3677
|
+
* ```typescript
|
|
3678
|
+
* // Apply a configuration
|
|
3679
|
+
* myModule.applyConfig({ visible: true, opacity: 0.8 });
|
|
3680
|
+
*
|
|
3681
|
+
* // Later, retrieve the current configuration
|
|
3682
|
+
* const currentConfig = myModule.getConfig();
|
|
3683
|
+
* console.log(currentConfig); // { visible: true, opacity: 0.8 }
|
|
3684
|
+
*
|
|
3685
|
+
* // When no config is applied
|
|
3686
|
+
* myModule.resetConfig();
|
|
3687
|
+
* console.log(myModule.getConfig()); // undefined
|
|
3688
|
+
* ```
|
|
3689
|
+
*
|
|
3690
|
+
* @see {@link applyConfig} to modify the configuration
|
|
3691
|
+
* @see {@link resetConfig} to clear the configuration
|
|
3692
|
+
*/
|
|
3693
|
+
getConfig(): NonNullable<CFG> | undefined;
|
|
3375
3694
|
/**
|
|
3376
|
-
*
|
|
3695
|
+
* Gets the source and layer identifiers for all sources managed by this module.
|
|
3377
3696
|
*
|
|
3378
|
-
*
|
|
3379
|
-
*
|
|
3697
|
+
* This property provides access to the MapLibre source and layer IDs that were created
|
|
3698
|
+
* and are managed by this module. These IDs can be used to interact directly with
|
|
3699
|
+
* MapLibre's API or to identify which layers belong to this module.
|
|
3380
3700
|
*
|
|
3381
|
-
* @
|
|
3382
|
-
*
|
|
3383
|
-
*
|
|
3701
|
+
* @returns A record mapping each source name to its corresponding source ID and layer IDs.
|
|
3702
|
+
* Each entry contains the MapLibre source identifier and an array of layer identifiers
|
|
3703
|
+
* associated with that source.
|
|
3704
|
+
*
|
|
3705
|
+
* @remarks
|
|
3706
|
+
* The returned IDs are useful when you need to:
|
|
3707
|
+
* - Directly manipulate layers using MapLibre's native API
|
|
3708
|
+
* - Identify which layers on the map belong to this module
|
|
3709
|
+
* - Set layer ordering or positioning relative to other layers
|
|
3710
|
+
* - Access source or layer properties through MapLibre methods
|
|
3384
3711
|
*
|
|
3385
3712
|
* @example
|
|
3386
3713
|
* ```typescript
|
|
3387
|
-
* const
|
|
3388
|
-
*
|
|
3714
|
+
* const ids = myModule.sourceAndLayerIDs;
|
|
3715
|
+
* console.log(ids);
|
|
3716
|
+
* // {
|
|
3717
|
+
* // mySource: {
|
|
3718
|
+
* // sourceID: 'my-source-id',
|
|
3719
|
+
* // layerIDs: ['layer-1', 'layer-2']
|
|
3720
|
+
* // }
|
|
3721
|
+
* // }
|
|
3722
|
+
*
|
|
3723
|
+
* // Use with MapLibre API
|
|
3724
|
+
* const map = myModule.mapLibreMap;
|
|
3725
|
+
* ids.mySource.layerIDs.forEach(layerId => {
|
|
3726
|
+
* map.setLayoutProperty(layerId, 'visibility', 'visible');
|
|
3389
3727
|
* });
|
|
3390
|
-
* unsub();
|
|
3391
3728
|
* ```
|
|
3392
3729
|
*/
|
|
3393
|
-
|
|
3730
|
+
get sourceAndLayerIDs(): Record<keyof SOURCES_WITH_LAYERS, SourceWithLayerIDs>;
|
|
3394
3731
|
/**
|
|
3395
|
-
*
|
|
3732
|
+
* User events over the named sources of this module — what every named scope is.
|
|
3396
3733
|
*
|
|
3397
|
-
*
|
|
3398
|
-
*
|
|
3734
|
+
* `sourceNames` may list several sources when they carry the same data in different display
|
|
3735
|
+
* modes — clustered and unclustered places, or the hexgrid/square/heatmap trio — and missing
|
|
3736
|
+
* ones are skipped, so an optional source costs the caller nothing.
|
|
3399
3737
|
*
|
|
3400
|
-
*
|
|
3401
|
-
*
|
|
3402
|
-
*
|
|
3738
|
+
* A scope carries no lifecycle events: a module has one configuration and one `show` stream,
|
|
3739
|
+
* neither of which a scope narrows. Both live on the module's own `events`.
|
|
3740
|
+
* @ignore
|
|
3741
|
+
*/
|
|
3742
|
+
protected userEvents<T = MapGeoJSONFeature, WHERE_SCOPE = never>(sourceNames: (keyof SOURCES_WITH_LAYERS)[], options?: EventScopeOptions<T, WHERE_SCOPE>): UserEvents<T, WHERE_SCOPE>;
|
|
3743
|
+
/**
|
|
3744
|
+
* The event surface of a module with no `show`: user events over the named sources, plus
|
|
3745
|
+
* `config-change`. `shown-features` is not subscribable here — `TShown` is `never`, which
|
|
3746
|
+
* makes the overload uncallable.
|
|
3747
|
+
* @ignore
|
|
3748
|
+
*/
|
|
3749
|
+
protected moduleEvents<T = MapGeoJSONFeature, WHERE_SCOPE = never>(sourceNames: (keyof SOURCES_WITH_LAYERS)[], options?: EventScopeOptions<T, WHERE_SCOPE>): CombinedEvents<T, CFG, never, WHERE_SCOPE>;
|
|
3750
|
+
/**
|
|
3751
|
+
* The event surface of a module that has a `show`. `shownFeaturesHandlers` is passed
|
|
3752
|
+
* positionally, and must be the very array `show` iterates: handing over a throwaway would
|
|
3753
|
+
* accept subscriptions that can never fire.
|
|
3754
|
+
* @ignore
|
|
3755
|
+
*/
|
|
3756
|
+
protected moduleEventsWithShown<T, TShown, WHERE_SCOPE = never>(sourceNames: (keyof SOURCES_WITH_LAYERS)[], shownFeaturesHandlers: ((features: TShown) => void)[], options?: EventScopeOptions<T, WHERE_SCOPE>): CombinedEvents<T, CFG, TShown, WHERE_SCOPE>;
|
|
3757
|
+
/**
|
|
3758
|
+
* Attaches named scopes to the module's event surface, so `events.on(...)` and
|
|
3759
|
+
* `events.<scope>.on(...)` live on one object.
|
|
3403
3760
|
*
|
|
3404
|
-
*
|
|
3761
|
+
* A module only declares scopes where it manages more than one surface; with a single source,
|
|
3762
|
+
* `events` already is that scope and a named alias would just duplicate it.
|
|
3405
3763
|
*
|
|
3406
|
-
*
|
|
3407
|
-
*
|
|
3408
|
-
*
|
|
3409
|
-
*
|
|
3410
|
-
*
|
|
3764
|
+
* The two scope type parameters are unrelated, and a module typically has one or the other:
|
|
3765
|
+
* `NAMED_SCOPES` is the object of scopes hung off `events` as properties (RoutingModule's
|
|
3766
|
+
* `mainLines`, `waypoints`, …), while `WHERE_SCOPE` is the scope object `events.where(…)`
|
|
3767
|
+
* accepts as an argument (BaseMapModule's `{ layerGroups }`).
|
|
3768
|
+
* @ignore
|
|
3411
3769
|
*/
|
|
3412
|
-
|
|
3770
|
+
protected buildEvents<T, TShown, WHERE_SCOPE, NAMED_SCOPES extends object>(moduleWide: CombinedEvents<T, CFG, TShown, WHERE_SCOPE>, scopes: NAMED_SCOPES): CombinedEvents<T, CFG, TShown, WHERE_SCOPE> & NAMED_SCOPES;
|
|
3413
3771
|
}
|
|
3414
3772
|
//#endregion
|
|
3415
3773
|
//#region src/shared/layers/commonLayerProps.d.ts
|
|
@@ -3480,7 +3838,7 @@ type MapFont = (typeof mapFonts)[number];
|
|
|
3480
3838
|
*
|
|
3481
3839
|
* @group POIs
|
|
3482
3840
|
*/
|
|
3483
|
-
declare const POI_SOURCE_ID = "vectorTiles";
|
|
3841
|
+
export declare const POI_SOURCE_ID = "vectorTiles";
|
|
3484
3842
|
/**
|
|
3485
3843
|
* Source identifier for hillshade terrain visualization.
|
|
3486
3844
|
*
|
|
@@ -3490,7 +3848,7 @@ declare const POI_SOURCE_ID = "vectorTiles";
|
|
|
3490
3848
|
*
|
|
3491
3849
|
* @group Hillshade
|
|
3492
3850
|
*/
|
|
3493
|
-
declare const HILLSHADE_SOURCE_ID = "hillshade";
|
|
3851
|
+
export declare const HILLSHADE_SOURCE_ID = "hillshade";
|
|
3494
3852
|
/**
|
|
3495
3853
|
* Source identifier for base map vector tiles.
|
|
3496
3854
|
*
|
|
@@ -3500,7 +3858,7 @@ declare const HILLSHADE_SOURCE_ID = "hillshade";
|
|
|
3500
3858
|
*
|
|
3501
3859
|
* @group Base Map
|
|
3502
3860
|
*/
|
|
3503
|
-
declare const BASE_MAP_SOURCE_ID = "vectorTiles";
|
|
3861
|
+
export declare const BASE_MAP_SOURCE_ID = "vectorTiles";
|
|
3504
3862
|
/**
|
|
3505
3863
|
* Source identifier for traffic incidents vector tiles.
|
|
3506
3864
|
*
|
|
@@ -3510,7 +3868,7 @@ declare const BASE_MAP_SOURCE_ID = "vectorTiles";
|
|
|
3510
3868
|
*
|
|
3511
3869
|
* @group Traffic Incidents
|
|
3512
3870
|
*/
|
|
3513
|
-
declare const TRAFFIC_INCIDENTS_SOURCE_ID = "vectorTilesIncidents";
|
|
3871
|
+
export declare const TRAFFIC_INCIDENTS_SOURCE_ID = "vectorTilesIncidents";
|
|
3514
3872
|
/**
|
|
3515
3873
|
* Source identifier for traffic flow vector tiles.
|
|
3516
3874
|
*
|
|
@@ -3520,7 +3878,27 @@ declare const TRAFFIC_INCIDENTS_SOURCE_ID = "vectorTilesIncidents";
|
|
|
3520
3878
|
*
|
|
3521
3879
|
* @group Traffic Flow
|
|
3522
3880
|
*/
|
|
3523
|
-
declare const TRAFFIC_FLOW_SOURCE_ID = "vectorTilesFlow";
|
|
3881
|
+
export declare const TRAFFIC_FLOW_SOURCE_ID = "vectorTilesFlow";
|
|
3882
|
+
//#endregion
|
|
3883
|
+
//#region src/shared/sharedInstance.d.ts
|
|
3884
|
+
/**
|
|
3885
|
+
* Returns the shared instance of a style-owned module for this map, building it on first use.
|
|
3886
|
+
*
|
|
3887
|
+
* Style-owned modules control sources and layers the map style already provides, under fixed
|
|
3888
|
+
* global IDs, so a second instance would be a second controller over one piece of shared state.
|
|
3889
|
+
* Callers get the same instance instead — two components each asking for hillshade is reasonable
|
|
3890
|
+
* code, and making them hoist a shared reference would be work pushed onto them for no benefit.
|
|
3891
|
+
*
|
|
3892
|
+
* @param map The map the module belongs to.
|
|
3893
|
+
* @param moduleClass The concrete module class, which together with the map identifies the instance.
|
|
3894
|
+
* @param construct Builds the instance. Called at most once per map and class.
|
|
3895
|
+
* @param applyToExisting Applies the caller's configuration to an instance that already exists.
|
|
3896
|
+
* Omit it when the caller passed no configuration: `get(map)` is a plain accessor and must not
|
|
3897
|
+
* re-apply defaults over settings someone else already made.
|
|
3898
|
+
*
|
|
3899
|
+
* @ignore
|
|
3900
|
+
*/
|
|
3901
|
+
export declare const sharedInstance: <MODULE>(map: TomTomMap, moduleClass: Function, construct: () => MODULE, applyToExisting?: (existing: MODULE) => void) => Promise<MODULE>;
|
|
3524
3902
|
//#endregion
|
|
3525
3903
|
//#region src/base/types/baseMapModuleConfig.d.ts
|
|
3526
3904
|
/**
|
|
@@ -3534,11 +3912,10 @@ declare const TRAFFIC_FLOW_SOURCE_ID = "vectorTilesFlow";
|
|
|
3534
3912
|
* style's own draw order rather than the settlement hierarchy.
|
|
3535
3913
|
*
|
|
3536
3914
|
* @see {@link BaseMapLayerGroupName}
|
|
3537
|
-
* @see {@link BaseMapModuleInitConfig.layerGroupsFilter}
|
|
3538
3915
|
*
|
|
3539
3916
|
* @group Base Map
|
|
3540
3917
|
*/
|
|
3541
|
-
declare const baseMapLayerGroupNames: readonly ["land", "water", "buildings2D", "roads", "railways", "ferries", "borders", "buildings3D", "natureLabels", "roadLabels", "roadShields", "houseNumbers", "smallerTownLabels", "stateLabels", "cityLabels", "allPlaceLabels", "capitalLabels", "countryLabels"];
|
|
3918
|
+
export declare const baseMapLayerGroupNames: readonly ["land", "water", "buildings2D", "roads", "railways", "ferries", "borders", "buildings3D", "natureLabels", "roadLabels", "roadShields", "houseNumbers", "smallerTownLabels", "stateLabels", "cityLabels", "allPlaceLabels", "capitalLabels", "countryLabels"];
|
|
3542
3919
|
/**
|
|
3543
3920
|
* Name of a base map layer group.
|
|
3544
3921
|
*
|
|
@@ -3587,7 +3964,7 @@ declare const baseMapLayerGroupNames: readonly ["land", "water", "buildings2D",
|
|
|
3587
3964
|
*
|
|
3588
3965
|
* @group Base Map
|
|
3589
3966
|
*/
|
|
3590
|
-
type BaseMapLayerGroupName = (typeof baseMapLayerGroupNames)[number];
|
|
3967
|
+
export type BaseMapLayerGroupName = (typeof baseMapLayerGroupNames)[number];
|
|
3591
3968
|
/**
|
|
3592
3969
|
* Layer group visibility configuration with explicit visible state.
|
|
3593
3970
|
*
|
|
@@ -3613,7 +3990,7 @@ type BaseMapLayerGroupName = (typeof baseMapLayerGroupNames)[number];
|
|
|
3613
3990
|
*
|
|
3614
3991
|
* @group Base Map
|
|
3615
3992
|
*/
|
|
3616
|
-
type BaseMapLayerGroupsVisibility = BaseMapLayerGroups & {
|
|
3993
|
+
export type BaseMapLayerGroupsVisibility = BaseMapLayerGroups & {
|
|
3617
3994
|
visible: boolean;
|
|
3618
3995
|
};
|
|
3619
3996
|
/**
|
|
@@ -3657,7 +4034,7 @@ type BaseMapLayerGroupsVisibility = BaseMapLayerGroups & {
|
|
|
3657
4034
|
*
|
|
3658
4035
|
* @group Base Map
|
|
3659
4036
|
*/
|
|
3660
|
-
type BaseMapLayerGroups = {
|
|
4037
|
+
export type BaseMapLayerGroups = {
|
|
3661
4038
|
/**
|
|
3662
4039
|
* Filter mode determining whether groups are included or excluded.
|
|
3663
4040
|
*
|
|
@@ -3726,7 +4103,7 @@ type BaseMapLayerGroups = {
|
|
|
3726
4103
|
*
|
|
3727
4104
|
* @group Base Map
|
|
3728
4105
|
*/
|
|
3729
|
-
type BaseMapModuleConfig = MapModuleCommonConfig & {
|
|
4106
|
+
export type BaseMapModuleConfig = MapModuleCommonConfig & {
|
|
3730
4107
|
/**
|
|
3731
4108
|
* Controls the visibility of all layers associated with this module.
|
|
3732
4109
|
*
|
|
@@ -3737,9 +4114,6 @@ type BaseMapModuleConfig = MapModuleCommonConfig & {
|
|
|
3737
4114
|
* Optional visibility configuration for specific layer groups.
|
|
3738
4115
|
*
|
|
3739
4116
|
* @remarks
|
|
3740
|
-
* **Important:** The layer groups specified here must be included in the
|
|
3741
|
-
* module (not excluded by `layerGroupsFilter` during initialization).
|
|
3742
|
-
*
|
|
3743
4117
|
* Use this to control visibility of layer groups at runtime without
|
|
3744
4118
|
* reinitializing the module.
|
|
3745
4119
|
*
|
|
@@ -3762,90 +4136,41 @@ type BaseMapModuleConfig = MapModuleCommonConfig & {
|
|
|
3762
4136
|
*/
|
|
3763
4137
|
layerGroupsVisibility?: BaseMapLayerGroupsVisibility;
|
|
3764
4138
|
};
|
|
4139
|
+
//#endregion
|
|
4140
|
+
//#region src/base/BaseMapModule.d.ts
|
|
4141
|
+
type BaseSourceAndLayers = {
|
|
4142
|
+
vectorTiles: StyleSourceWithLayers;
|
|
4143
|
+
};
|
|
3765
4144
|
/**
|
|
3766
|
-
*
|
|
3767
|
-
*
|
|
3768
|
-
* Extends {@link BaseMapModuleConfig} with additional options available only
|
|
3769
|
-
* during module initialization.
|
|
3770
|
-
*
|
|
3771
|
-
* @remarks
|
|
3772
|
-
* **Initialization vs Runtime:**
|
|
3773
|
-
* - `layerGroupsFilter`: Only available at init - determines which groups to load
|
|
3774
|
-
* - `layerGroupsVisibility`: Available at init and runtime - controls visibility
|
|
4145
|
+
* Scope accepted by `baseMap.events.where(...)`, in addition to a plain feature predicate.
|
|
3775
4146
|
*
|
|
3776
|
-
*
|
|
3777
|
-
*
|
|
3778
|
-
*
|
|
3779
|
-
* - Optimize performance by not loading unnecessary layers
|
|
4147
|
+
* `layerGroups` narrows to part of the map — road labels, water, buildings — using the same
|
|
4148
|
+
* {@link BaseMapLayerGroupName} vocabulary as `setVisible`. `features` narrows within those
|
|
4149
|
+
* layers, and the two combine.
|
|
3780
4150
|
*
|
|
3781
4151
|
* @example
|
|
3782
4152
|
* ```typescript
|
|
3783
|
-
*
|
|
3784
|
-
*
|
|
3785
|
-
*
|
|
3786
|
-
*
|
|
3787
|
-
* names: ['roads', 'roadLabels', 'water', 'land']
|
|
3788
|
-
* },
|
|
3789
|
-
* visible: true
|
|
3790
|
-
* };
|
|
3791
|
-
*
|
|
3792
|
-
* // Exclude buildings from initialization
|
|
3793
|
-
* const noBuildingsConfig: BaseMapModuleInitConfig = {
|
|
3794
|
-
* layerGroupsFilter: {
|
|
3795
|
-
* mode: 'exclude',
|
|
3796
|
-
* names: ['buildings2D', 'buildings3D', 'houseNumbers']
|
|
3797
|
-
* }
|
|
3798
|
-
* };
|
|
3799
|
-
*
|
|
3800
|
-
* // Minimal map for data overlay
|
|
3801
|
-
* const overlayBaseConfig: BaseMapModuleInitConfig = {
|
|
3802
|
-
* layerGroupsFilter: {
|
|
3803
|
-
* mode: 'include',
|
|
3804
|
-
* names: ['water', 'land', 'borders']
|
|
3805
|
-
* },
|
|
3806
|
-
* visible: true
|
|
3807
|
-
* };
|
|
4153
|
+
* baseMap.events
|
|
4154
|
+
* .where({ layerGroups: { mode: 'include', names: ['roadLabels', 'roadShields'] } },
|
|
4155
|
+
* { cursorOnHover: 'pointer' })
|
|
4156
|
+
* .on('click', (feature) => showRoadName(feature.properties.name));
|
|
3808
4157
|
* ```
|
|
3809
4158
|
*
|
|
3810
4159
|
* @group Base Map
|
|
3811
4160
|
*/
|
|
3812
|
-
type
|
|
3813
|
-
/**
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
* **One-time configuration:** This can only be set during initialization.
|
|
3818
|
-
* Once the module is created, you cannot change which groups are loaded,
|
|
3819
|
-
* only their visibility via `layerGroupsVisibility`.
|
|
3820
|
-
*
|
|
3821
|
-
* @example
|
|
3822
|
-
* ```typescript
|
|
3823
|
-
* // Load only essential layers
|
|
3824
|
-
* layerGroupsFilter: {
|
|
3825
|
-
* mode: 'include',
|
|
3826
|
-
* names: ['land', 'water', 'roads', 'borders']
|
|
3827
|
-
* }
|
|
3828
|
-
*
|
|
3829
|
-
* // Load everything except 3D buildings
|
|
3830
|
-
* layerGroupsFilter: {
|
|
3831
|
-
* mode: 'exclude',
|
|
3832
|
-
* names: ['buildings3D']
|
|
3833
|
-
* }
|
|
3834
|
-
*
|
|
3835
|
-
* // Minimal overlay map
|
|
3836
|
-
* layerGroupsFilter: {
|
|
3837
|
-
* mode: 'include',
|
|
3838
|
-
* names: ['water', 'land']
|
|
3839
|
-
* }
|
|
3840
|
-
* ```
|
|
3841
|
-
*/
|
|
3842
|
-
layerGroupsFilter?: BaseMapLayerGroups;
|
|
3843
|
-
};
|
|
3844
|
-
//#endregion
|
|
3845
|
-
//#region src/base/BaseMapModule.d.ts
|
|
3846
|
-
type BaseSourceAndLayers = {
|
|
3847
|
-
vectorTiles: StyleSourceWithLayers;
|
|
4161
|
+
export type BaseMapEventScope = {
|
|
4162
|
+
/** Which layer groups this scope covers. */
|
|
4163
|
+
layerGroups: BaseMapLayerGroups;
|
|
4164
|
+
/** Optional further narrowing to particular features within those layers. */
|
|
4165
|
+
features?: (feature: MapGeoJSONFeature) => boolean;
|
|
3848
4166
|
};
|
|
4167
|
+
/**
|
|
4168
|
+
* Event surface of {@link BaseMapModule}. The base map manages one source, so it has no named
|
|
4169
|
+
* scopes — `events` is that scope, narrowed on demand with `where()`.
|
|
4170
|
+
*
|
|
4171
|
+
* @group Base Map
|
|
4172
|
+
*/
|
|
4173
|
+
export type BaseMapEvents = CombinedEvents<MapGeoJSONFeature, BaseMapModuleConfig, never, BaseMapEventScope>;
|
|
3849
4174
|
/**
|
|
3850
4175
|
* Base Map Module for controlling standard map layers and their visibility.
|
|
3851
4176
|
*
|
|
@@ -3892,13 +4217,7 @@ type BaseSourceAndLayers = {
|
|
|
3892
4217
|
* @example
|
|
3893
4218
|
* Working with layer groups:
|
|
3894
4219
|
* ```typescript
|
|
3895
|
-
*
|
|
3896
|
-
* const baseMap = await BaseMapModule.get(map, {
|
|
3897
|
-
* layerGroupsFilter: {
|
|
3898
|
-
* mode: 'include',
|
|
3899
|
-
* names: ['roads', 'roadLabels', 'borders']
|
|
3900
|
-
* }
|
|
3901
|
-
* });
|
|
4220
|
+
* const baseMap = await BaseMapModule.get(map);
|
|
3902
4221
|
*
|
|
3903
4222
|
* // Hide buildings and labels
|
|
3904
4223
|
* baseMap.setVisible(false, {
|
|
@@ -3936,7 +4255,7 @@ type BaseSourceAndLayers = {
|
|
|
3936
4255
|
*
|
|
3937
4256
|
* @group Base Map
|
|
3938
4257
|
*/
|
|
3939
|
-
declare class BaseMapModule extends AbstractMapModule<BaseSourceAndLayers, BaseMapModuleConfig> {
|
|
4258
|
+
export declare class BaseMapModule extends AbstractMapModule<BaseSourceAndLayers, BaseMapModuleConfig> {
|
|
3940
4259
|
private layersByGroup?;
|
|
3941
4260
|
/**
|
|
3942
4261
|
* Asynchronously retrieves a BaseMapModule instance for the given map.
|
|
@@ -3950,6 +4269,12 @@ declare class BaseMapModule extends AbstractMapModule<BaseSourceAndLayers, BaseM
|
|
|
3950
4269
|
* @returns A promise that resolves to the initialized BaseMapModule.
|
|
3951
4270
|
*
|
|
3952
4271
|
* @remarks
|
|
4272
|
+
* **Instances:**
|
|
4273
|
+
* `BaseMapModule` controls the base-map source and layers the map style already provides, under
|
|
4274
|
+
* fixed global IDs, so every map has exactly one — a second `get()` returns the same instance.
|
|
4275
|
+
* To work with part of the map, name the layer groups per call: `setVisible(false, {
|
|
4276
|
+
* layerGroups })` for visibility, `events.where({ layerGroups })` for events.
|
|
4277
|
+
*
|
|
3953
4278
|
* **Initialization:**
|
|
3954
4279
|
* - Waits for map to be ready before creating module
|
|
3955
4280
|
* - Validates that required sources exist in the map style
|
|
@@ -3957,7 +4282,6 @@ declare class BaseMapModule extends AbstractMapModule<BaseSourceAndLayers, BaseM
|
|
|
3957
4282
|
*
|
|
3958
4283
|
* **Configuration Options:**
|
|
3959
4284
|
* - `visible`: Initial visibility state
|
|
3960
|
-
* - `layerGroupsFilter`: Which layer groups to include/exclude
|
|
3961
4285
|
* - `layerGroupsVisibility`: Fine-grained visibility per group
|
|
3962
4286
|
*
|
|
3963
4287
|
* @throws Error if the base map source is not found in the style
|
|
@@ -3973,31 +4297,20 @@ declare class BaseMapModule extends AbstractMapModule<BaseSourceAndLayers, BaseM
|
|
|
3973
4297
|
* ```typescript
|
|
3974
4298
|
* const baseMap = await BaseMapModule.get(map, {
|
|
3975
4299
|
* visible: true,
|
|
3976
|
-
*
|
|
3977
|
-
* mode: 'exclude',
|
|
3978
|
-
* names: ['buildings3D', 'houseNumbers']
|
|
3979
|
-
* }
|
|
3980
|
-
* });
|
|
3981
|
-
* ```
|
|
3982
|
-
*
|
|
3983
|
-
* @example
|
|
3984
|
-
* Show only specific groups:
|
|
3985
|
-
* ```typescript
|
|
3986
|
-
* const baseMap = await BaseMapModule.get(map, {
|
|
3987
|
-
* layerGroupsFilter: {
|
|
4300
|
+
* layerGroupsVisibility: {
|
|
3988
4301
|
* mode: 'include',
|
|
3989
|
-
* names: ['
|
|
3990
|
-
*
|
|
3991
|
-
*
|
|
4302
|
+
* names: ['buildings3D', 'houseNumbers'],
|
|
4303
|
+
* visible: false
|
|
4304
|
+
* }
|
|
3992
4305
|
* });
|
|
3993
4306
|
* ```
|
|
3994
4307
|
*/
|
|
3995
|
-
static get(tomtomMap: TomTomMap, config?:
|
|
4308
|
+
static get(tomtomMap: TomTomMap, config?: BaseMapModuleConfig): Promise<BaseMapModule>;
|
|
3996
4309
|
private constructor();
|
|
3997
4310
|
/**
|
|
3998
4311
|
* @ignore
|
|
3999
4312
|
*/
|
|
4000
|
-
protected _initSourcesWithLayers(
|
|
4313
|
+
protected _initSourcesWithLayers(): {
|
|
4001
4314
|
vectorTiles: StyleSourceWithLayers<import("maplibre-gl").SourceSpecification, import("maplibre-gl").Source>;
|
|
4002
4315
|
};
|
|
4003
4316
|
/**
|
|
@@ -4011,12 +4324,19 @@ declare class BaseMapModule extends AbstractMapModule<BaseSourceAndLayers, BaseM
|
|
|
4011
4324
|
/**
|
|
4012
4325
|
* Checks if any base map layers are currently visible.
|
|
4013
4326
|
*
|
|
4014
|
-
* @
|
|
4327
|
+
* @param options - Optional settings for fine-grained control.
|
|
4328
|
+
* @param options.layerGroups - Ask about specific layer groups instead of all layers.
|
|
4329
|
+
*
|
|
4330
|
+
* @returns `true` if at least one of the layers asked about is visible, `false` if all are
|
|
4331
|
+
* hidden.
|
|
4015
4332
|
*
|
|
4016
4333
|
* @remarks
|
|
4017
4334
|
* This checks the actual visibility state of layers in the map, not just the
|
|
4018
4335
|
* module's configuration setting.
|
|
4019
4336
|
*
|
|
4337
|
+
* Mirrors {@link setVisible}, so a group toggled through one can be read back through the
|
|
4338
|
+
* other — which is how a per-group control reflects the state the style actually starts in.
|
|
4339
|
+
*
|
|
4020
4340
|
* @example
|
|
4021
4341
|
* ```typescript
|
|
4022
4342
|
* if (baseMap.isVisible()) {
|
|
@@ -4025,8 +4345,17 @@ declare class BaseMapModule extends AbstractMapModule<BaseSourceAndLayers, BaseM
|
|
|
4025
4345
|
* console.log('Base map is hidden');
|
|
4026
4346
|
* }
|
|
4027
4347
|
* ```
|
|
4348
|
+
*
|
|
4349
|
+
* @example
|
|
4350
|
+
* Ask about one group:
|
|
4351
|
+
* ```typescript
|
|
4352
|
+
* // buildings3D ships hidden in most styles
|
|
4353
|
+
* const shown = baseMap.isVisible({ layerGroups: { mode: 'include', names: ['buildings3D'] } });
|
|
4354
|
+
* ```
|
|
4028
4355
|
*/
|
|
4029
|
-
isVisible(
|
|
4356
|
+
isVisible(options?: {
|
|
4357
|
+
layerGroups?: BaseMapLayerGroups;
|
|
4358
|
+
}): boolean;
|
|
4030
4359
|
/**
|
|
4031
4360
|
* Sets the visibility of base map layers.
|
|
4032
4361
|
*
|
|
@@ -4142,7 +4471,7 @@ declare class BaseMapModule extends AbstractMapModule<BaseSourceAndLayers, BaseM
|
|
|
4142
4471
|
* unsub(); // remove by returned function
|
|
4143
4472
|
* ```
|
|
4144
4473
|
*/
|
|
4145
|
-
get events():
|
|
4474
|
+
get events(): BaseMapEvents;
|
|
4146
4475
|
}
|
|
4147
4476
|
//#endregion
|
|
4148
4477
|
//#region src/custom/types/customGeoJSONModuleConfig.d.ts
|
|
@@ -4153,7 +4482,7 @@ type DistributiveOmit<T, K extends string> = T extends unknown ? Omit<T, K> : ne
|
|
|
4153
4482
|
*
|
|
4154
4483
|
* @group Custom
|
|
4155
4484
|
*/
|
|
4156
|
-
type CustomGeoJSONImageData = HTMLImageElement | ImageBitmap | ImageData | StyleImageInterface | {
|
|
4485
|
+
export type CustomGeoJSONImageData = HTMLImageElement | ImageBitmap | ImageData | StyleImageInterface | {
|
|
4157
4486
|
width: number;
|
|
4158
4487
|
height: number;
|
|
4159
4488
|
data: Uint8Array | Uint8ClampedArray;
|
|
@@ -4166,7 +4495,7 @@ type CustomGeoJSONImageData = HTMLImageElement | ImageBitmap | ImageData | Style
|
|
|
4166
4495
|
*
|
|
4167
4496
|
* @group Custom
|
|
4168
4497
|
*/
|
|
4169
|
-
type CustomGeoJSONImageSpec = {
|
|
4498
|
+
export type CustomGeoJSONImageSpec = {
|
|
4170
4499
|
/**
|
|
4171
4500
|
* The image data, in any format accepted by MapLibre's `addImage`. Asynchronous
|
|
4172
4501
|
* sources (URLs, SVG strings) are not supported here — pre-load them and pass an
|
|
@@ -4197,7 +4526,7 @@ type CustomGeoJSONImageSpec = {
|
|
|
4197
4526
|
*
|
|
4198
4527
|
* @group Custom
|
|
4199
4528
|
*/
|
|
4200
|
-
type CustomGeoJSONLayerSpec = DistributiveOmit<LayerSpecWithSource, 'source' | 'id'> & {
|
|
4529
|
+
export type CustomGeoJSONLayerSpec = DistributiveOmit<LayerSpecWithSource, 'source' | 'id'> & {
|
|
4201
4530
|
id?: string;
|
|
4202
4531
|
beforeID?: string;
|
|
4203
4532
|
};
|
|
@@ -4208,7 +4537,7 @@ type CustomGeoJSONLayerSpec = DistributiveOmit<LayerSpecWithSource, 'source' | '
|
|
|
4208
4537
|
*
|
|
4209
4538
|
* @group Custom
|
|
4210
4539
|
*/
|
|
4211
|
-
type CustomGeoJSONSourceSpec = {
|
|
4540
|
+
export type CustomGeoJSONSourceSpec = {
|
|
4212
4541
|
/**
|
|
4213
4542
|
* Optional MapLibre source ID. Auto-generated as
|
|
4214
4543
|
* `custom-geojson-${instanceIndex}-${sourceName}` when absent.
|
|
@@ -4252,7 +4581,7 @@ type CustomGeoJSONSourceSpec = {
|
|
|
4252
4581
|
*
|
|
4253
4582
|
* @group Custom
|
|
4254
4583
|
*/
|
|
4255
|
-
type CustomGeoJSONModuleConfig<TSources extends Record<string, FeatureCollection> = Record<string, FeatureCollection>> = MapModuleCommonConfig & {
|
|
4584
|
+
export type CustomGeoJSONModuleConfig<TSources extends Record<string, FeatureCollection> = Record<string, FeatureCollection>> = MapModuleCommonConfig & {
|
|
4256
4585
|
/**
|
|
4257
4586
|
* The sources, keyed by an arbitrary user-defined name, that this module manages.
|
|
4258
4587
|
*
|
|
@@ -4311,7 +4640,17 @@ type CustomGeoJSONSourcesWithLayers<TSources extends Record<string, FeatureColle
|
|
|
4311
4640
|
*
|
|
4312
4641
|
* @group Custom
|
|
4313
4642
|
*/
|
|
4314
|
-
|
|
4643
|
+
/**
|
|
4644
|
+
* What `module.events.on('shown-features', ...)` receives. This module's `show` names the source
|
|
4645
|
+
* it writes, so the event names it too — the one module whose shown data is per source.
|
|
4646
|
+
*
|
|
4647
|
+
* @group Custom
|
|
4648
|
+
*/
|
|
4649
|
+
export type CustomGeoJSONShownFeatures<TSources extends Record<string, FeatureCollection>> = { [K in keyof TSources]: {
|
|
4650
|
+
sourceName: K;
|
|
4651
|
+
data: TSources[K];
|
|
4652
|
+
}; }[keyof TSources];
|
|
4653
|
+
export type CustomGeoJSONEvents<TSources extends Record<string, FeatureCollection>> = CombinedEvents<MapGeoJSONFeature, CustomGeoJSONModuleConfig<TSources>, CustomGeoJSONShownFeatures<TSources>> & { [K in keyof TSources]: UserEvents<MapGeoJSONFeature>; };
|
|
4315
4654
|
/**
|
|
4316
4655
|
* Module for displaying customer-owned GeoJSON data with TomTom SDK support.
|
|
4317
4656
|
*
|
|
@@ -4324,6 +4663,11 @@ type CustomGeoJSONEvents<TSources extends Record<string, FeatureCollection>> = {
|
|
|
4324
4663
|
* this module makes no assumptions about how data is rendered — the caller passes raw
|
|
4325
4664
|
* MapLibre layer specs (`circle`, `heatmap`, `fill`, `line`, `symbol`, …).
|
|
4326
4665
|
*
|
|
4666
|
+
* @remarks
|
|
4667
|
+
* Because the sources and layers are caller-supplied, the module has no built-in defaults:
|
|
4668
|
+
* `resetConfig()` (or `applyConfig(undefined)`) returns to the configuration passed to
|
|
4669
|
+
* {@link CustomGeoJSONModule.create | create}, and `getConfig()` never becomes `undefined`.
|
|
4670
|
+
*
|
|
4327
4671
|
* @typeParam TSources - A record mapping source names to the {@link FeatureCollection}
|
|
4328
4672
|
* type each source carries. Pass this generic when you want type-safe `show` /
|
|
4329
4673
|
* `getShown` per source.
|
|
@@ -4331,7 +4675,7 @@ type CustomGeoJSONEvents<TSources extends Record<string, FeatureCollection>> = {
|
|
|
4331
4675
|
* @example
|
|
4332
4676
|
* Single source, default generic:
|
|
4333
4677
|
* ```typescript
|
|
4334
|
-
* const module = await CustomGeoJSONModule.
|
|
4678
|
+
* const module = await CustomGeoJSONModule.create(map, {
|
|
4335
4679
|
* sources: {
|
|
4336
4680
|
* points: {
|
|
4337
4681
|
* layers: [{ type: 'circle', paint: { 'circle-radius': 4, 'circle-color': '#0a3653' } }],
|
|
@@ -4351,7 +4695,7 @@ type CustomGeoJSONEvents<TSources extends Record<string, FeatureCollection>> = {
|
|
|
4351
4695
|
* buildings: FeatureCollection<Polygon, { name: string }>;
|
|
4352
4696
|
* };
|
|
4353
4697
|
*
|
|
4354
|
-
* const module = await CustomGeoJSONModule.
|
|
4698
|
+
* const module = await CustomGeoJSONModule.create<Sources>(map, {
|
|
4355
4699
|
* sources: {
|
|
4356
4700
|
* heatmap: { layers: [{ type: 'heatmap', paint: { 'heatmap-radius': 12 } }] },
|
|
4357
4701
|
* buildings: { layers: [{ type: 'fill', paint: { 'fill-color': '#5a5' } }] },
|
|
@@ -4367,7 +4711,7 @@ type CustomGeoJSONEvents<TSources extends Record<string, FeatureCollection>> = {
|
|
|
4367
4711
|
* ```typescript
|
|
4368
4712
|
* type Buildings = FeatureCollection<Point, { Name: string }>;
|
|
4369
4713
|
*
|
|
4370
|
-
* const module = await CustomGeoJSONModule.
|
|
4714
|
+
* const module = await CustomGeoJSONModule.create<{ heatmap: Buildings; markers: Buildings }>(map, {
|
|
4371
4715
|
* sources: {
|
|
4372
4716
|
* heatmap: { layers: heatmapLayers },
|
|
4373
4717
|
* markers: { layers: markerLayers },
|
|
@@ -4379,19 +4723,24 @@ type CustomGeoJSONEvents<TSources extends Record<string, FeatureCollection>> = {
|
|
|
4379
4723
|
*
|
|
4380
4724
|
* @group Custom
|
|
4381
4725
|
*/
|
|
4382
|
-
declare class CustomGeoJSONModule<TSources extends Record<string, FeatureCollection> = Record<string, FeatureCollection>> extends AbstractMapModule<CustomGeoJSONSourcesWithLayers<TSources>, CustomGeoJSONModuleConfig<TSources>> {
|
|
4726
|
+
export declare class CustomGeoJSONModule<TSources extends Record<string, FeatureCollection> = Record<string, FeatureCollection>> extends AbstractMapModule<CustomGeoJSONSourcesWithLayers<TSources>, CustomGeoJSONModuleConfig<TSources>> {
|
|
4383
4727
|
private resolvedSourceIDs;
|
|
4384
4728
|
private resolvedLayerSpecs;
|
|
4385
4729
|
private lastShown;
|
|
4386
|
-
private
|
|
4730
|
+
private initialConfig;
|
|
4731
|
+
private readonly shownFeaturesHandlers;
|
|
4387
4732
|
/**
|
|
4388
4733
|
* Creates a new {@link CustomGeoJSONModule} once the map is ready.
|
|
4389
4734
|
*
|
|
4735
|
+
* `CustomGeoJSONModule` owns the sources, layers and images it adds, all suffixed per instance.
|
|
4736
|
+
* Every call therefore returns a **new, independent** instance, and stacking several of them on
|
|
4737
|
+
* one map is a supported thing to do.
|
|
4738
|
+
*
|
|
4390
4739
|
* @param tomtomMap The TomTomMap instance.
|
|
4391
4740
|
* @param config Module configuration. `sources` is required and must contain at
|
|
4392
4741
|
* least one entry; each entry must have at least one layer.
|
|
4393
4742
|
*/
|
|
4394
|
-
static
|
|
4743
|
+
static create<TSources extends Record<string, FeatureCollection> = Record<string, FeatureCollection>>(tomtomMap: TomTomMap, config: CustomGeoJSONModuleConfig<TSources>): Promise<CustomGeoJSONModule<TSources>>;
|
|
4395
4744
|
private constructor();
|
|
4396
4745
|
/**
|
|
4397
4746
|
* @ignore
|
|
@@ -4459,15 +4808,15 @@ declare class CustomGeoJSONModule<TSources extends Record<string, FeatureCollect
|
|
|
4459
4808
|
* @example
|
|
4460
4809
|
* ```typescript
|
|
4461
4810
|
* module.events.buildings.on('click', (feature, lngLat) => { ... });
|
|
4462
|
-
* module.events.
|
|
4463
|
-
* module.events.
|
|
4811
|
+
* module.events.on('shown-features', ({ sourceName, data }) => { ... });
|
|
4812
|
+
* module.events.on('config-change', (config) => { ... });
|
|
4464
4813
|
* ```
|
|
4465
4814
|
*/
|
|
4466
4815
|
get events(): CustomGeoJSONEvents<TSources>;
|
|
4467
4816
|
}
|
|
4468
4817
|
//#endregion
|
|
4469
4818
|
//#region src/geometry/layers/colorPalettes.d.ts
|
|
4470
|
-
declare const colorPalettes: {
|
|
4819
|
+
export declare const colorPalettes: {
|
|
4471
4820
|
warm: string[];
|
|
4472
4821
|
browns: string[];
|
|
4473
4822
|
cold: string[];
|
|
@@ -4483,8 +4832,8 @@ declare const colorPalettes: {
|
|
|
4483
4832
|
fadedRainbow: string[];
|
|
4484
4833
|
pastelRainbow: string[];
|
|
4485
4834
|
};
|
|
4486
|
-
type ColorPaletteOptions = keyof typeof colorPalettes;
|
|
4487
|
-
declare const colorPaletteIDs: ColorPaletteOptions[];
|
|
4835
|
+
export type ColorPaletteOptions = keyof typeof colorPalettes;
|
|
4836
|
+
export declare const colorPaletteIDs: ColorPaletteOptions[];
|
|
4488
4837
|
//#endregion
|
|
4489
4838
|
//#region src/geometry/types/geometryTheme.d.ts
|
|
4490
4839
|
/**
|
|
@@ -4499,13 +4848,13 @@ declare const colorPaletteIDs: ColorPaletteOptions[];
|
|
|
4499
4848
|
*
|
|
4500
4849
|
* @group Geometries
|
|
4501
4850
|
*/
|
|
4502
|
-
type GeometryTheme = 'filled' | 'outline' | 'inverted';
|
|
4851
|
+
export type GeometryTheme = 'filled' | 'outline' | 'inverted';
|
|
4503
4852
|
/**
|
|
4504
4853
|
* All valid {@link GeometryTheme} values.
|
|
4505
4854
|
*
|
|
4506
4855
|
* @group Geometries
|
|
4507
4856
|
*/
|
|
4508
|
-
declare const geometryThemes: readonly ["filled", "outline", "inverted"];
|
|
4857
|
+
export declare const geometryThemes: readonly ["filled", "outline", "inverted"];
|
|
4509
4858
|
//#endregion
|
|
4510
4859
|
//#region src/geometry/types/geometriesModuleConfig.d.ts
|
|
4511
4860
|
/**
|
|
@@ -4518,7 +4867,7 @@ declare const geometryThemes: readonly ["filled", "outline", "inverted"];
|
|
|
4518
4867
|
* const fill: GeometryFillConfig = { color: '#FF5733', opacity: 0.3 };
|
|
4519
4868
|
*
|
|
4520
4869
|
* // Palette name
|
|
4521
|
-
* const fill: GeometryFillConfig = { color: '
|
|
4870
|
+
* const fill: GeometryFillConfig = { color: 'blues', opacity: 0.25 };
|
|
4522
4871
|
*
|
|
4523
4872
|
* // Data-driven color based on properties
|
|
4524
4873
|
* const fill: GeometryFillConfig = {
|
|
@@ -4529,9 +4878,9 @@ declare const geometryThemes: readonly ["filled", "outline", "inverted"];
|
|
|
4529
4878
|
*
|
|
4530
4879
|
* @group Geometries
|
|
4531
4880
|
*/
|
|
4532
|
-
type GeometryFillConfig = {
|
|
4881
|
+
export type GeometryFillConfig = {
|
|
4533
4882
|
/**
|
|
4534
|
-
* Fill color: a hex string (`'#FF5733'`), a palette name (`'
|
|
4883
|
+
* Fill color: a hex string (`'#FF5733'`), a palette name (`'blues'`, see {@link colorPaletteIDs}), or a MapLibre expression
|
|
4535
4884
|
* for data-driven styling (e.g. `['get', 'color']`).
|
|
4536
4885
|
*
|
|
4537
4886
|
* @default '#0A3653'
|
|
@@ -4573,7 +4922,7 @@ type GeometryFillConfig = {
|
|
|
4573
4922
|
*
|
|
4574
4923
|
* @group Geometries
|
|
4575
4924
|
*/
|
|
4576
|
-
type GeometryTextConfig = {
|
|
4925
|
+
export type GeometryTextConfig = {
|
|
4577
4926
|
/**
|
|
4578
4927
|
* Text content to display as label.
|
|
4579
4928
|
*
|
|
@@ -4619,7 +4968,7 @@ type GeometryTextConfig = {
|
|
|
4619
4968
|
*
|
|
4620
4969
|
* @group Geometries
|
|
4621
4970
|
*/
|
|
4622
|
-
type GeometryLineConfig = {
|
|
4971
|
+
export type GeometryLineConfig = {
|
|
4623
4972
|
/**
|
|
4624
4973
|
* Border/outline color: a hex string or a MapLibre expression (e.g. `['get', 'borderColor']`).
|
|
4625
4974
|
*
|
|
@@ -4692,7 +5041,7 @@ type GeometryLineConfig = {
|
|
|
4692
5041
|
*
|
|
4693
5042
|
* @group Geometries
|
|
4694
5043
|
*/
|
|
4695
|
-
type GeometryLineLabelConfig = {
|
|
5044
|
+
export type GeometryLineLabelConfig = {
|
|
4696
5045
|
/**
|
|
4697
5046
|
* Minimum zoom level at which border labels are visible.
|
|
4698
5047
|
*
|
|
@@ -4810,7 +5159,7 @@ type GeometryLineLabelConfig = {
|
|
|
4810
5159
|
*
|
|
4811
5160
|
* @group Geometries
|
|
4812
5161
|
*/
|
|
4813
|
-
type GeometryBeforeLayerConfig = BeforeLayerConfig | GeometryBeforeLayerTargets;
|
|
5162
|
+
export type GeometryBeforeLayerConfig = BeforeLayerConfig | GeometryBeforeLayerTargets;
|
|
4814
5163
|
/**
|
|
4815
5164
|
* Per-layer positioning targets for the object form of {@link GeometryBeforeLayerConfig}.
|
|
4816
5165
|
*
|
|
@@ -4820,7 +5169,7 @@ type GeometryBeforeLayerConfig = BeforeLayerConfig | GeometryBeforeLayerTargets;
|
|
|
4820
5169
|
*
|
|
4821
5170
|
* @group Geometries
|
|
4822
5171
|
*/
|
|
4823
|
-
type GeometryBeforeLayerTargets = {
|
|
5172
|
+
export type GeometryBeforeLayerTargets = {
|
|
4824
5173
|
/** Fallback position for any layer not named by `fill` / `line`. */
|
|
4825
5174
|
all?: BeforeLayerConfig;
|
|
4826
5175
|
/** Position for the fill layer. */
|
|
@@ -4868,7 +5217,7 @@ type GeometryBeforeLayerTargets = {
|
|
|
4868
5217
|
*
|
|
4869
5218
|
* @group Geometries
|
|
4870
5219
|
*/
|
|
4871
|
-
type GeometriesModuleConfig = MapModuleCommonConfig & {
|
|
5220
|
+
export type GeometriesModuleConfig = MapModuleCommonConfig & {
|
|
4872
5221
|
/**
|
|
4873
5222
|
* Fill color, opacity, and (optional) fill-layer positioning.
|
|
4874
5223
|
*
|
|
@@ -4925,7 +5274,7 @@ type GeometriesModuleConfig = MapModuleCommonConfig & {
|
|
|
4925
5274
|
* @example
|
|
4926
5275
|
* ```typescript
|
|
4927
5276
|
* // Show the "rest of the world" outside a country
|
|
4928
|
-
* const module = await GeometriesModule.
|
|
5277
|
+
* const module = await GeometriesModule.create(map, {
|
|
4929
5278
|
* theme: 'inverted',
|
|
4930
5279
|
* fill: { color: 'black', opacity: 0.5 }
|
|
4931
5280
|
* });
|
|
@@ -4970,6 +5319,18 @@ type GeometrySourcesWithLayers = {
|
|
|
4970
5319
|
geometry: GeoJSONSourceWithLayers<PolygonFeatures>;
|
|
4971
5320
|
geometryLabel: GeoJSONSourceWithLayers<FeatureCollection<Point>>;
|
|
4972
5321
|
};
|
|
5322
|
+
/**
|
|
5323
|
+
* Event surface of {@link GeometriesModule}: the module's own events, plus one named scope per
|
|
5324
|
+
* surface it manages.
|
|
5325
|
+
*
|
|
5326
|
+
* @group Geometries
|
|
5327
|
+
*/
|
|
5328
|
+
export type GeometriesEvents = CombinedEvents<MapGeoJSONFeature, GeometriesModuleConfig, PolygonFeatures> & {
|
|
5329
|
+
/** The geometry fills and outlines. */
|
|
5330
|
+
geometry: UserEvents<MapGeoJSONFeature>;
|
|
5331
|
+
/** The labels rendered on top of the geometries. */
|
|
5332
|
+
geometryLabel: UserEvents<MapGeoJSONFeature>;
|
|
5333
|
+
};
|
|
4973
5334
|
/**
|
|
4974
5335
|
* Geometries Module for displaying polygon areas with custom styling on the map.
|
|
4975
5336
|
*
|
|
@@ -5003,7 +5364,7 @@ type GeometrySourcesWithLayers = {
|
|
|
5003
5364
|
* import { GeometriesModule } from '@tomtom-org/maps-sdk/map';
|
|
5004
5365
|
*
|
|
5005
5366
|
* // Initialize module
|
|
5006
|
-
* const geometriesModule = await GeometriesModule.
|
|
5367
|
+
* const geometriesModule = await GeometriesModule.create(map);
|
|
5007
5368
|
*
|
|
5008
5369
|
* // Display a polygon
|
|
5009
5370
|
* await geometriesModule.show({
|
|
@@ -5021,7 +5382,7 @@ type GeometrySourcesWithLayers = {
|
|
|
5021
5382
|
* @example
|
|
5022
5383
|
* Custom styling:
|
|
5023
5384
|
* ```typescript
|
|
5024
|
-
* const geometriesModule = await GeometriesModule.
|
|
5385
|
+
* const geometriesModule = await GeometriesModule.create(map, {
|
|
5025
5386
|
* fill: { color: '#FF5733', opacity: 0.3 },
|
|
5026
5387
|
* line: { color: '#C70039', width: 3 },
|
|
5027
5388
|
* textConfig: {
|
|
@@ -5069,7 +5430,7 @@ type GeometrySourcesWithLayers = {
|
|
|
5069
5430
|
*
|
|
5070
5431
|
* @group Geometries
|
|
5071
5432
|
*/
|
|
5072
|
-
declare class GeometriesModule extends AbstractMapModule<GeometrySourcesWithLayers, GeometriesModuleConfig> {
|
|
5433
|
+
export declare class GeometriesModule extends AbstractMapModule<GeometrySourcesWithLayers, GeometriesModuleConfig> {
|
|
5073
5434
|
private titleLayerSpecs;
|
|
5074
5435
|
private geometryFillLayerSpecs;
|
|
5075
5436
|
private geometryOutlineLayerSpecs;
|
|
@@ -5096,19 +5457,20 @@ declare class GeometriesModule extends AbstractMapModule<GeometrySourcesWithLaye
|
|
|
5096
5457
|
* - `beforeLayerConfig`: Layer ordering — a single target, or `{ all, fill, line }` to split them
|
|
5097
5458
|
*
|
|
5098
5459
|
* **Multiple Instances:**
|
|
5099
|
-
*
|
|
5100
|
-
*
|
|
5460
|
+
* `GeometriesModule` owns the sources, layers and images it adds, all suffixed per instance.
|
|
5461
|
+
* Every call therefore returns a **new, independent** instance, so you can put several on the
|
|
5462
|
+
* same map, each managing a different set of geometries with different styles.
|
|
5101
5463
|
*
|
|
5102
5464
|
* @example
|
|
5103
5465
|
* Default initialization:
|
|
5104
5466
|
* ```typescript
|
|
5105
|
-
* const geometriesModule = await GeometriesModule.
|
|
5467
|
+
* const geometriesModule = await GeometriesModule.create(map);
|
|
5106
5468
|
* ```
|
|
5107
5469
|
*
|
|
5108
5470
|
* @example
|
|
5109
5471
|
* With custom styling:
|
|
5110
5472
|
* ```typescript
|
|
5111
|
-
* const geometriesModule = await GeometriesModule.
|
|
5473
|
+
* const geometriesModule = await GeometriesModule.create(map, {
|
|
5112
5474
|
* fill: { color: 'blue', opacity: 0.25 },
|
|
5113
5475
|
* line: { color: 'darkblue', width: 2, opacity: 0.8 },
|
|
5114
5476
|
* textConfig: {
|
|
@@ -5121,7 +5483,7 @@ declare class GeometriesModule extends AbstractMapModule<GeometrySourcesWithLaye
|
|
|
5121
5483
|
* @example
|
|
5122
5484
|
* Data-driven styling:
|
|
5123
5485
|
* ```typescript
|
|
5124
|
-
* const geometriesModule = await GeometriesModule.
|
|
5486
|
+
* const geometriesModule = await GeometriesModule.create(map, {
|
|
5125
5487
|
* fill: {
|
|
5126
5488
|
* // Color based on feature properties
|
|
5127
5489
|
* color: [
|
|
@@ -5137,7 +5499,7 @@ declare class GeometriesModule extends AbstractMapModule<GeometrySourcesWithLaye
|
|
|
5137
5499
|
* });
|
|
5138
5500
|
* ```
|
|
5139
5501
|
*/
|
|
5140
|
-
static
|
|
5502
|
+
static create(tomtomMap: TomTomMap, config?: GeometriesModuleConfig): Promise<GeometriesModule>;
|
|
5141
5503
|
private constructor();
|
|
5142
5504
|
/**
|
|
5143
5505
|
* @ignore
|
|
@@ -5314,7 +5676,7 @@ declare class GeometriesModule extends AbstractMapModule<GeometrySourcesWithLaye
|
|
|
5314
5676
|
/**
|
|
5315
5677
|
* Gets the events interface for handling user interactions with geometries.
|
|
5316
5678
|
*
|
|
5317
|
-
* @returns
|
|
5679
|
+
* @returns The module's events, with `on` / `off` for handlers and `where` for scoping.
|
|
5318
5680
|
*
|
|
5319
5681
|
* @remarks
|
|
5320
5682
|
* **Supported Events:**
|
|
@@ -5356,12 +5718,12 @@ declare class GeometriesModule extends AbstractMapModule<GeometrySourcesWithLaye
|
|
|
5356
5718
|
* });
|
|
5357
5719
|
* ```
|
|
5358
5720
|
*/
|
|
5359
|
-
get events():
|
|
5721
|
+
get events(): GeometriesEvents;
|
|
5360
5722
|
}
|
|
5361
5723
|
//#endregion
|
|
5362
5724
|
//#region src/geometry/prepareReachableRangesForDisplay.d.ts
|
|
5363
5725
|
/** Custom label generator for reachable range features. */
|
|
5364
|
-
type ReachableRangeLabelFn = (feature: PolygonFeature, index: number) => string;
|
|
5726
|
+
export type ReachableRangeLabelFn = (feature: PolygonFeature, index: number) => string;
|
|
5365
5727
|
/**
|
|
5366
5728
|
* Attaches labels and applies theme-specific geometry to reachable range polygon features.
|
|
5367
5729
|
*
|
|
@@ -5385,7 +5747,7 @@ type ReachableRangeLabelFn = (feature: PolygonFeature, index: number) => string;
|
|
|
5385
5747
|
*
|
|
5386
5748
|
* @group Geometries
|
|
5387
5749
|
*/
|
|
5388
|
-
declare const buildReachableRangeFeatures: (features: PolygonFeature[], labels: string[], theme?: GeometryTheme) => PolygonFeature[];
|
|
5750
|
+
export declare const buildReachableRangeFeatures: (features: PolygonFeature[], labels: string[], theme?: GeometryTheme) => PolygonFeature[];
|
|
5389
5751
|
/**
|
|
5390
5752
|
* Prepares the output of `calculateReachableRanges` for display with {@link GeometriesModule}.
|
|
5391
5753
|
*
|
|
@@ -5410,7 +5772,7 @@ declare const buildReachableRangeFeatures: (features: PolygonFeature[], labels:
|
|
|
5410
5772
|
*
|
|
5411
5773
|
* @group Geometries
|
|
5412
5774
|
*/
|
|
5413
|
-
declare const prepareReachableRangesForDisplay: (result: PolygonFeatures, theme?: GeometryTheme, label?: ReachableRangeLabelFn) => PolygonFeatures;
|
|
5775
|
+
export declare const prepareReachableRangesForDisplay: (result: PolygonFeatures, theme?: GeometryTheme, label?: ReachableRangeLabelFn) => PolygonFeatures;
|
|
5414
5776
|
//#endregion
|
|
5415
5777
|
//#region src/geometry/geometryConfigs.d.ts
|
|
5416
5778
|
/**
|
|
@@ -5427,7 +5789,7 @@ declare const prepareReachableRangesForDisplay: (result: PolygonFeatures, theme?
|
|
|
5427
5789
|
*
|
|
5428
5790
|
* @group Geometries
|
|
5429
5791
|
*/
|
|
5430
|
-
declare const themedGeometryConfig: (palette?: ColorPaletteOptions, beforeLayerConfig?: GeometryBeforeLayerConfig) => GeometriesModuleConfig;
|
|
5792
|
+
export declare const themedGeometryConfig: (palette?: ColorPaletteOptions, beforeLayerConfig?: GeometryBeforeLayerConfig) => GeometriesModuleConfig;
|
|
5431
5793
|
/**
|
|
5432
5794
|
* Returns a {@link GeometriesModuleConfig} for reachable ranges.
|
|
5433
5795
|
*
|
|
@@ -5442,14 +5804,14 @@ declare const themedGeometryConfig: (palette?: ColorPaletteOptions, beforeLayerC
|
|
|
5442
5804
|
*
|
|
5443
5805
|
* @example
|
|
5444
5806
|
* ```typescript
|
|
5445
|
-
* const module = await GeometriesModule.
|
|
5807
|
+
* const module = await GeometriesModule.create(map, reachableRangeGeometryConfig());
|
|
5446
5808
|
* const result = await calculateReachableRanges([...]);
|
|
5447
5809
|
* module.show(result); // labels and theme applied automatically
|
|
5448
5810
|
* ```
|
|
5449
5811
|
*
|
|
5450
5812
|
* @group Geometries
|
|
5451
5813
|
*/
|
|
5452
|
-
declare const reachableRangeGeometryConfig: (palette?: ColorPaletteOptions, theme?: GeometryTheme, beforeLayerConfig?: GeometryBeforeLayerConfig, label?: ReachableRangeLabelFn) => GeometriesModuleConfig;
|
|
5814
|
+
export declare const reachableRangeGeometryConfig: (palette?: ColorPaletteOptions, theme?: GeometryTheme, beforeLayerConfig?: GeometryBeforeLayerConfig, label?: ReachableRangeLabelFn) => GeometriesModuleConfig;
|
|
5453
5815
|
//#endregion
|
|
5454
5816
|
//#region src/geometry/types/geometryDisplayProps.d.ts
|
|
5455
5817
|
/**
|
|
@@ -5486,7 +5848,7 @@ declare const reachableRangeGeometryConfig: (palette?: ColorPaletteOptions, them
|
|
|
5486
5848
|
*
|
|
5487
5849
|
* @group Geometries
|
|
5488
5850
|
*/
|
|
5489
|
-
type ExtraGeometryDisplayProps = {
|
|
5851
|
+
export type ExtraGeometryDisplayProps = {
|
|
5490
5852
|
/**
|
|
5491
5853
|
* Display title for the geometry.
|
|
5492
5854
|
*
|
|
@@ -5562,7 +5924,7 @@ type ExtraGeometryDisplayProps = {
|
|
|
5562
5924
|
*
|
|
5563
5925
|
* @group Geometries
|
|
5564
5926
|
*/
|
|
5565
|
-
type DisplayGeometryProps = CommonPlaceProps & ExtraGeometryDisplayProps;
|
|
5927
|
+
export type DisplayGeometryProps = CommonPlaceProps & ExtraGeometryDisplayProps;
|
|
5566
5928
|
//#endregion
|
|
5567
5929
|
//#region src/hillshade/HillshadeModule.d.ts
|
|
5568
5930
|
/**
|
|
@@ -5612,7 +5974,7 @@ type HillshadeSourcesWithLayers = {
|
|
|
5612
5974
|
*
|
|
5613
5975
|
* @group Hillshade
|
|
5614
5976
|
*/
|
|
5615
|
-
declare class HillshadeModule extends AbstractMapModule<HillshadeSourcesWithLayers, HillshadeModuleConfig> {
|
|
5977
|
+
export declare class HillshadeModule extends AbstractMapModule<HillshadeSourcesWithLayers, HillshadeModuleConfig> {
|
|
5616
5978
|
/**
|
|
5617
5979
|
* Retrieves a HillshadeModule instance for the given map.
|
|
5618
5980
|
*
|
|
@@ -5653,6 +6015,12 @@ declare class HillshadeModule extends AbstractMapModule<HillshadeSourcesWithLaye
|
|
|
5653
6015
|
* visible: false
|
|
5654
6016
|
* });
|
|
5655
6017
|
* ```
|
|
6018
|
+
*
|
|
6019
|
+
* @remarks
|
|
6020
|
+
* **Instances:**
|
|
6021
|
+
* `HillshadeModule` controls the hillshade source and layers the map style already provides,
|
|
6022
|
+
* under fixed global IDs. Every instance is another handle on that same shared state, so
|
|
6023
|
+
* visibility applied through one is visible through all of them.
|
|
5656
6024
|
*/
|
|
5657
6025
|
static get(map: TomTomMap, config?: HillshadeModuleConfig): Promise<HillshadeModule>;
|
|
5658
6026
|
private constructor();
|
|
@@ -5764,7 +6132,7 @@ type HillshadeModuleConfig = MapModuleCommonConfig & {
|
|
|
5764
6132
|
* POI category mappings that have a direct equivalent in Map Display POI categories.
|
|
5765
6133
|
* @ignore
|
|
5766
6134
|
*/
|
|
5767
|
-
declare const mapDisplayPoiCategoryMappings: Partial<Record<POICategory, string>>;
|
|
6135
|
+
export declare const mapDisplayPoiCategoryMappings: Partial<Record<POICategory, string>>;
|
|
5768
6136
|
/**
|
|
5769
6137
|
* Map style POI category type.
|
|
5770
6138
|
*
|
|
@@ -5784,11 +6152,11 @@ declare const mapDisplayPoiCategoryMappings: Partial<Record<POICategory, string>
|
|
|
5784
6152
|
*
|
|
5785
6153
|
* @group POIs
|
|
5786
6154
|
*/
|
|
5787
|
-
type MapStylePOICategory = keyof typeof mapDisplayPoiCategoryMappings;
|
|
6155
|
+
export type MapStylePOICategory = keyof typeof mapDisplayPoiCategoryMappings;
|
|
5788
6156
|
/**
|
|
5789
6157
|
* @ignore
|
|
5790
6158
|
*/
|
|
5791
|
-
declare const toBaseMapPOICategory: (category: POICategory) => string;
|
|
6159
|
+
export declare const toBaseMapPOICategory: (category: POICategory) => string;
|
|
5792
6160
|
/**
|
|
5793
6161
|
* The deduplicated set of base-map POI categories — the right-hand side of
|
|
5794
6162
|
* {@link completeMapDisplayPoiCategoryMappings}. Each value names the
|
|
@@ -5799,11 +6167,11 @@ declare const toBaseMapPOICategory: (category: POICategory) => string;
|
|
|
5799
6167
|
*
|
|
5800
6168
|
* @ignore
|
|
5801
6169
|
*/
|
|
5802
|
-
declare const baseMapPOICategoryValues: readonly string[];
|
|
6170
|
+
export declare const baseMapPOICategoryValues: readonly string[];
|
|
5803
6171
|
/**
|
|
5804
6172
|
* @ignore
|
|
5805
6173
|
*/
|
|
5806
|
-
declare const toBaseMapPOIGroup: (category: POICategory) => string | undefined;
|
|
6174
|
+
export declare const toBaseMapPOIGroup: (category: POICategory) => string | undefined;
|
|
5807
6175
|
//#endregion
|
|
5808
6176
|
//#region src/places/types/placeDisplayProps.d.ts
|
|
5809
6177
|
/**
|
|
@@ -5844,7 +6212,7 @@ declare const toBaseMapPOIGroup: (category: POICategory) => string | undefined;
|
|
|
5844
6212
|
*
|
|
5845
6213
|
* @group Places
|
|
5846
6214
|
*/
|
|
5847
|
-
type PlaceDisplayProps = {
|
|
6215
|
+
export type PlaceDisplayProps = {
|
|
5848
6216
|
/**
|
|
5849
6217
|
* Unique identifier for the place feature.
|
|
5850
6218
|
*
|
|
@@ -5954,7 +6322,7 @@ type PlaceDisplayProps = {
|
|
|
5954
6322
|
*
|
|
5955
6323
|
* @group Places
|
|
5956
6324
|
*/
|
|
5957
|
-
type DisplayPlaceProps = CommonPlaceProps & PlaceDisplayProps;
|
|
6325
|
+
export type DisplayPlaceProps = CommonPlaceProps & PlaceDisplayProps;
|
|
5958
6326
|
//#endregion
|
|
5959
6327
|
//#region src/places/types/placesModuleConfig.d.ts
|
|
5960
6328
|
/**
|
|
@@ -5973,7 +6341,13 @@ type DisplayPlaceProps = CommonPlaceProps & PlaceDisplayProps;
|
|
|
5973
6341
|
*
|
|
5974
6342
|
* @group Places
|
|
5975
6343
|
*/
|
|
5976
|
-
type PlacesTheme =
|
|
6344
|
+
type PlacesTheme = (typeof placesThemes)[number];
|
|
6345
|
+
/**
|
|
6346
|
+
* All valid {@link PlacesTheme} values.
|
|
6347
|
+
*
|
|
6348
|
+
* @group Places
|
|
6349
|
+
*/
|
|
6350
|
+
export declare const placesThemes: readonly ["pin", "circle-icon", "base-map", "pin-clustered"];
|
|
5977
6351
|
/**
|
|
5978
6352
|
* Configuration for EV charging station availability display.
|
|
5979
6353
|
*
|
|
@@ -5989,14 +6363,14 @@ type PlacesTheme = 'pin' | 'circle-icon' | 'base-map' | 'pin-clustered';
|
|
|
5989
6363
|
* @example
|
|
5990
6364
|
* ```typescript
|
|
5991
6365
|
* // Enable with defaults
|
|
5992
|
-
* const places = await PlacesModule.
|
|
6366
|
+
* const places = await PlacesModule.create(map, {
|
|
5993
6367
|
* evAvailability: { enabled: true }
|
|
5994
6368
|
* });
|
|
5995
6369
|
* const stations = await search({ poiCategories: ['ELECTRIC_VEHICLE_STATION'] });
|
|
5996
6370
|
* places.show(await getPlacesWithEVAvailability(stations));
|
|
5997
6371
|
*
|
|
5998
6372
|
* // Custom threshold and format
|
|
5999
|
-
* const places = await PlacesModule.
|
|
6373
|
+
* const places = await PlacesModule.create(map, {
|
|
6000
6374
|
* evAvailability: {
|
|
6001
6375
|
* enabled: true,
|
|
6002
6376
|
* threshold: 0.5,
|
|
@@ -6005,7 +6379,7 @@ type PlacesTheme = 'pin' | 'circle-icon' | 'base-map' | 'pin-clustered';
|
|
|
6005
6379
|
* });
|
|
6006
6380
|
*
|
|
6007
6381
|
* // Combine with custom icon
|
|
6008
|
-
* const places = await PlacesModule.
|
|
6382
|
+
* const places = await PlacesModule.create(map, {
|
|
6009
6383
|
* icon: {
|
|
6010
6384
|
* categoryIcons: [{
|
|
6011
6385
|
* id: 'ELECTRIC_VEHICLE_STATION',
|
|
@@ -6675,7 +7049,119 @@ type PlacesSourcesAndLayers = {
|
|
|
6675
7049
|
*/
|
|
6676
7050
|
connections: GeoJSONSourceWithLayers<ConnectionFeatureCollection>;
|
|
6677
7051
|
};
|
|
6678
|
-
|
|
7052
|
+
/**
|
|
7053
|
+
* What {@link PlacesModule.show} accepts, and what `shown-features` handlers receive back.
|
|
7054
|
+
*
|
|
7055
|
+
* @group Places
|
|
7056
|
+
*/
|
|
7057
|
+
export type ShownPlaces = Place | Place[] | Places;
|
|
7058
|
+
/**
|
|
7059
|
+
* What `places.events.on('shown-features', ...)` receives: whichever of places or connections was
|
|
7060
|
+
* just rendered.
|
|
7061
|
+
*
|
|
7062
|
+
* @group Places
|
|
7063
|
+
*/
|
|
7064
|
+
export type PlacesShownFeatures = {
|
|
7065
|
+
places: ShownPlaces;
|
|
7066
|
+
} | {
|
|
7067
|
+
connections: PlaceConnectionDisplay[];
|
|
7068
|
+
};
|
|
7069
|
+
/**
|
|
7070
|
+
* Event surface of {@link PlacesModule}: the module's own events, plus one named scope per
|
|
7071
|
+
* surface it manages.
|
|
7072
|
+
*
|
|
7073
|
+
* @group Places
|
|
7074
|
+
*/
|
|
7075
|
+
export type PlacesEvents = CombinedEvents<MapGeoJSONFeature, PlacesModuleConfig, PlacesShownFeatures> & {
|
|
7076
|
+
/** The place pins themselves, clustered or not. */
|
|
7077
|
+
places: UserEvents<Place<DisplayPlaceProps>>;
|
|
7078
|
+
/** The lines and labels connecting places to their parent, when connections are shown. */
|
|
7079
|
+
connections: UserEvents<MapGeoJSONFeature>;
|
|
7080
|
+
};
|
|
7081
|
+
/**
|
|
7082
|
+
* Map module for displaying and managing place markers.
|
|
7083
|
+
*
|
|
7084
|
+
* The PlacesModule provides functionality to display location markers (pins) on the map
|
|
7085
|
+
* for points of interest, search results, or custom locations. It supports various marker
|
|
7086
|
+
* styles, custom icons, text labels, and interactive events.
|
|
7087
|
+
*
|
|
7088
|
+
* @remarks
|
|
7089
|
+
* **Features:**
|
|
7090
|
+
* - Multiple marker styles (pin, circle-icon, base-map POI-like)
|
|
7091
|
+
* - Custom icons per POI category
|
|
7092
|
+
* - Text labels with styling options
|
|
7093
|
+
* - Data-driven styling via MapLibre expressions
|
|
7094
|
+
* - Interactive events (click, hover, etc.)
|
|
7095
|
+
* - Support for custom feature properties
|
|
7096
|
+
* - EV charging station availability display (opt-in)
|
|
7097
|
+
*
|
|
7098
|
+
* **Marker Styles:**
|
|
7099
|
+
* - `pin`: Traditional teardrop-shaped map pins
|
|
7100
|
+
* - `circle-icon`: Simple circular markers (previously named `circle`)
|
|
7101
|
+
* - `base-map`: Mimics the map's built-in POI layer styling (combines `main`, `selected`, and `micro` layers). For micro-only rendering, hide the `main` layer via `layers.main.layout.visibility = 'none'`.
|
|
7102
|
+
*
|
|
7103
|
+
* **EV Charging Station Availability:**
|
|
7104
|
+
* When displaying EV charging stations with availability data from
|
|
7105
|
+
* {@link getPlacesWithEVAvailability}, the module can:
|
|
7106
|
+
* - Show available/total charging points (e.g., "3/10")
|
|
7107
|
+
* - Color-code availability (green = good, orange = limited, red = none/low)
|
|
7108
|
+
* - Display as formatted text within the station's label
|
|
7109
|
+
*
|
|
7110
|
+
* This feature is disabled by default. To enable it, set `evAvailability.enabled` to `true`
|
|
7111
|
+
* in the configuration.
|
|
7112
|
+
*
|
|
7113
|
+
* **Common Use Cases:**
|
|
7114
|
+
* - Search result visualization
|
|
7115
|
+
* - Custom location markers
|
|
7116
|
+
* - Store locators
|
|
7117
|
+
* - EV charging station maps with real-time availability
|
|
7118
|
+
* - Delivery/pickup points
|
|
7119
|
+
* - Saved locations display
|
|
7120
|
+
*
|
|
7121
|
+
* @example
|
|
7122
|
+
* ```typescript
|
|
7123
|
+
* // Create places module with pin markers
|
|
7124
|
+
* const placesModule = await PlacesModule.create(map, {
|
|
7125
|
+
* icon: {
|
|
7126
|
+
* categoryIcons: []
|
|
7127
|
+
* },
|
|
7128
|
+
* text: {
|
|
7129
|
+
* field: (place) => place.properties.poi?.name || 'Unknown'
|
|
7130
|
+
* },
|
|
7131
|
+
* theme: 'pin'
|
|
7132
|
+
* });
|
|
7133
|
+
*
|
|
7134
|
+
* // Display places from search
|
|
7135
|
+
* await placesModule.show(searchResults);
|
|
7136
|
+
*
|
|
7137
|
+
* // EV Charging Stations - Opt-in to availability display
|
|
7138
|
+
* const evStations = await PlacesModule.create(map, {
|
|
7139
|
+
* evAvailability: { enabled: true }
|
|
7140
|
+
* });
|
|
7141
|
+
* const results = await search({ poiCategories: ['ELECTRIC_VEHICLE_STATION'] });
|
|
7142
|
+
* evStations.show(await getPlacesWithEVAvailability(results)); // Shows availability
|
|
7143
|
+
*
|
|
7144
|
+
* // Granular control: Enable for searched stations only, background stations without
|
|
7145
|
+
* const bgStations = await PlacesModule.create(map); // EV availability disabled
|
|
7146
|
+
* const searched = await PlacesModule.create(map, {
|
|
7147
|
+
* evAvailability: { enabled: true }
|
|
7148
|
+
* });
|
|
7149
|
+
*
|
|
7150
|
+
* // Handle clicks
|
|
7151
|
+
* placesModule.events.on('click', (feature) => {
|
|
7152
|
+
* console.log('Clicked:', feature.properties);
|
|
7153
|
+
* });
|
|
7154
|
+
*
|
|
7155
|
+
* placesModule.events.on('hover', (feature) => {
|
|
7156
|
+
* showTooltip(feature.properties.poi?.name);
|
|
7157
|
+
* });
|
|
7158
|
+
* ```
|
|
7159
|
+
*
|
|
7160
|
+
* @see [Places Guide](https://docs.tomtom.com/maps-sdk-js/guides/map/places)
|
|
7161
|
+
*
|
|
7162
|
+
* @group Places
|
|
7163
|
+
*/
|
|
7164
|
+
export declare class PlacesModule extends AbstractMapModule<PlacesSourcesAndLayers, PlacesModuleConfig> {
|
|
6679
7165
|
private layerSpecs;
|
|
6680
7166
|
private connectionLayerSpecs;
|
|
6681
7167
|
private currentClusterMode;
|
|
@@ -6687,12 +7173,17 @@ declare class PlacesModule extends AbstractMapModule<PlacesSourcesAndLayers, Pla
|
|
|
6687
7173
|
private shownConnections;
|
|
6688
7174
|
private readonly shownFeaturesHandlers;
|
|
6689
7175
|
/**
|
|
6690
|
-
*
|
|
7176
|
+
* Creates a new module instance on the given map, waiting until the map is ready first.
|
|
7177
|
+
*
|
|
7178
|
+
* `PlacesModule` owns the sources, layers and images it adds, all suffixed per instance. Every
|
|
7179
|
+
* call therefore returns a **new, independent** instance, and stacking several of them on one
|
|
7180
|
+
* map is a supported thing to do.
|
|
7181
|
+
*
|
|
6691
7182
|
* @param tomtomMap The TomTomMap instance.
|
|
6692
7183
|
* @param config The module optional configuration
|
|
6693
7184
|
* @returns {Promise} Returns a promise with a new instance of this module
|
|
6694
7185
|
*/
|
|
6695
|
-
static
|
|
7186
|
+
static create(tomtomMap: TomTomMap, config?: PlacesModuleConfig): Promise<PlacesModule>;
|
|
6696
7187
|
private constructor();
|
|
6697
7188
|
/**
|
|
6698
7189
|
* @ignore
|
|
@@ -6855,7 +7346,7 @@ declare class PlacesModule extends AbstractMapModule<PlacesSourcesAndLayers, Pla
|
|
|
6855
7346
|
* await placesModule.show([place1, place2, place3]);
|
|
6856
7347
|
* ```
|
|
6857
7348
|
*/
|
|
6858
|
-
show(places:
|
|
7349
|
+
show(places: ShownPlaces): Promise<void>;
|
|
6859
7350
|
/**
|
|
6860
7351
|
* Removes all places from the map.
|
|
6861
7352
|
*
|
|
@@ -6890,7 +7381,7 @@ declare class PlacesModule extends AbstractMapModule<PlacesSourcesAndLayers, Pla
|
|
|
6890
7381
|
*
|
|
6891
7382
|
* @example
|
|
6892
7383
|
* ```typescript
|
|
6893
|
-
* const places = await PlacesModule.
|
|
7384
|
+
* const places = await PlacesModule.create(map, {
|
|
6894
7385
|
* connections: {
|
|
6895
7386
|
* label: (c) => `${c.distanceMeters} m`
|
|
6896
7387
|
* }
|
|
@@ -6979,7 +7470,7 @@ declare class PlacesModule extends AbstractMapModule<PlacesSourcesAndLayers, Pla
|
|
|
6979
7470
|
* ```
|
|
6980
7471
|
*/
|
|
6981
7472
|
cleanEventStates(options?: CleanEventStatesOptions): void;
|
|
6982
|
-
get events():
|
|
7473
|
+
get events(): PlacesEvents;
|
|
6983
7474
|
}
|
|
6984
7475
|
//#endregion
|
|
6985
7476
|
//#region src/places/utils/preparePlacesForDisplay.d.ts
|
|
@@ -6988,40 +7479,40 @@ declare class PlacesModule extends AbstractMapModule<PlacesSourcesAndLayers, Pla
|
|
|
6988
7479
|
* @param place The place to display.
|
|
6989
7480
|
* @ignore
|
|
6990
7481
|
*/
|
|
6991
|
-
declare const buildPlaceTitle: (place: Place) => string;
|
|
7482
|
+
export declare const buildPlaceTitle: (place: Place) => string;
|
|
6992
7483
|
/**
|
|
6993
7484
|
* Gets the map style sprite image ID to display on the map for the give place.
|
|
6994
7485
|
* @ignore
|
|
6995
7486
|
*/
|
|
6996
|
-
declare const getIconIDForPlace: (place: Place, instanceIndex: number, config?: PlacesModuleConfig) => string;
|
|
7487
|
+
export declare const getIconIDForPlace: (place: Place, instanceIndex: number, config?: PlacesModuleConfig) => string;
|
|
6997
7488
|
/**
|
|
6998
7489
|
* Maps a Place category to the poi layer one, so the latter's style can apply it.
|
|
6999
7490
|
* @ignore
|
|
7000
7491
|
*/
|
|
7001
|
-
declare const getPOILayerCategoryForPlace: (place: Place, config?: PlacesModuleConfig) => string | undefined;
|
|
7492
|
+
export declare const getPOILayerCategoryForPlace: (place: Place, config?: PlacesModuleConfig) => string | undefined;
|
|
7002
7493
|
/**
|
|
7003
7494
|
* Maps a Place to the base map POI group used by the style's `text-color` and
|
|
7004
7495
|
* `POI - Micro` icon expressions (e.g., `eat_and_drink`, `lodging`, `driving`).
|
|
7005
7496
|
* @ignore
|
|
7006
7497
|
*/
|
|
7007
|
-
declare const getPOIGroupForPlace: (place: Place, config?: PlacesModuleConfig) => string | undefined;
|
|
7498
|
+
export declare const getPOIGroupForPlace: (place: Place, config?: PlacesModuleConfig) => string | undefined;
|
|
7008
7499
|
/**
|
|
7009
7500
|
* Transforms the input of a "show" call to FeatureCollection "Places".
|
|
7010
7501
|
* @ignore
|
|
7011
7502
|
*/
|
|
7012
|
-
declare const toPlaces: (places: Place | Place[] | Places) => Places;
|
|
7503
|
+
export declare const toPlaces: (places: Place | Place[] | Places) => Places;
|
|
7013
7504
|
/**
|
|
7014
7505
|
* prepare places features to be displayed on map by adding needed properties for title, icon and style
|
|
7015
7506
|
* @ignore
|
|
7016
7507
|
*/
|
|
7017
|
-
declare const preparePlacesForDisplay: (placesInput: Place | Place[] | Places, instanceIndex: number, config?: PlacesModuleConfig) => Places<DisplayPlaceProps>;
|
|
7508
|
+
export declare const preparePlacesForDisplay: (placesInput: Place | Place[] | Places, instanceIndex: number, config?: PlacesModuleConfig) => Places<DisplayPlaceProps>;
|
|
7018
7509
|
//#endregion
|
|
7019
7510
|
//#region src/pois/layers/poisLayers.d.ts
|
|
7020
7511
|
/**
|
|
7021
7512
|
* Layer IDs for POIs on the map.
|
|
7022
7513
|
* @ignore
|
|
7023
7514
|
*/
|
|
7024
|
-
declare const poiLayerIDs: string[];
|
|
7515
|
+
export declare const poiLayerIDs: string[];
|
|
7025
7516
|
//#endregion
|
|
7026
7517
|
//#region src/pois/types/poiCategoryGroups.d.ts
|
|
7027
7518
|
/**
|
|
@@ -7073,7 +7564,7 @@ declare const poiLayerIDs: string[];
|
|
|
7073
7564
|
*
|
|
7074
7565
|
* @group POIs
|
|
7075
7566
|
*/
|
|
7076
|
-
declare const poiCategoryGroups: Record<string, MapStylePOICategory[]>;
|
|
7567
|
+
export declare const poiCategoryGroups: Record<string, MapStylePOICategory[]>;
|
|
7077
7568
|
/**
|
|
7078
7569
|
* POI category group type.
|
|
7079
7570
|
*
|
|
@@ -7140,7 +7631,7 @@ declare const poiCategoryGroups: Record<string, MapStylePOICategory[]>;
|
|
|
7140
7631
|
*
|
|
7141
7632
|
* @group POIs
|
|
7142
7633
|
*/
|
|
7143
|
-
type POICategoryGroup = keyof typeof poiCategoryGroups;
|
|
7634
|
+
export type POICategoryGroup = keyof typeof poiCategoryGroups;
|
|
7144
7635
|
//#endregion
|
|
7145
7636
|
//#region src/pois/types/poisModuleConfig.d.ts
|
|
7146
7637
|
/**
|
|
@@ -7347,7 +7838,7 @@ type POIsModuleFeature = Feature<Point, {
|
|
|
7347
7838
|
* @param categories list of filtered categories.
|
|
7348
7839
|
* @ignore
|
|
7349
7840
|
*/
|
|
7350
|
-
declare const getStyleCategories: (categories: FilterablePOICategory[]) => string[];
|
|
7841
|
+
export declare const getStyleCategories: (categories: FilterablePOICategory[]) => string[];
|
|
7351
7842
|
/**
|
|
7352
7843
|
* IDs of sources and layers for places of interest module.
|
|
7353
7844
|
*/
|
|
@@ -7438,7 +7929,7 @@ type PoIsSourcesAndLayers = {
|
|
|
7438
7929
|
*
|
|
7439
7930
|
* @group POIs
|
|
7440
7931
|
*/
|
|
7441
|
-
declare class POIsModule extends AbstractMapModule<PoIsSourcesAndLayers, POIsModuleConfig> {
|
|
7932
|
+
export declare class POIsModule extends AbstractMapModule<PoIsSourcesAndLayers, POIsModuleConfig> {
|
|
7442
7933
|
private categoriesFilter?;
|
|
7443
7934
|
private originalFilter?;
|
|
7444
7935
|
/**
|
|
@@ -7475,6 +7966,12 @@ declare class POIsModule extends AbstractMapModule<PoIsSourcesAndLayers, POIsMod
|
|
|
7475
7966
|
* }
|
|
7476
7967
|
* });
|
|
7477
7968
|
* ```
|
|
7969
|
+
*
|
|
7970
|
+
* @remarks
|
|
7971
|
+
* **Instances:**
|
|
7972
|
+
* `POIsModule` controls the POI sources and layers the map style already provides, under fixed
|
|
7973
|
+
* global IDs. Every instance is another handle on that same shared state, so visibility and
|
|
7974
|
+
* filters applied through one are visible through all of them.
|
|
7478
7975
|
*/
|
|
7479
7976
|
static get(map: TomTomMap, config?: POIsModuleConfig): Promise<POIsModule>;
|
|
7480
7977
|
private constructor();
|
|
@@ -7593,7 +8090,7 @@ declare class POIsModule extends AbstractMapModule<PoIsSourcesAndLayers, POIsMod
|
|
|
7593
8090
|
/**
|
|
7594
8091
|
* Gets the events interface for handling user interactions with POIs.
|
|
7595
8092
|
*
|
|
7596
|
-
* @returns
|
|
8093
|
+
* @returns The module's events, with `on` / `off` for handlers and `where` for scoping.
|
|
7597
8094
|
*
|
|
7598
8095
|
* @remarks
|
|
7599
8096
|
* **Supported Events:**
|
|
@@ -8215,7 +8712,7 @@ type RoutingModuleConfig = MapModuleCommonConfig & {
|
|
|
8215
8712
|
* @param instanceIndex - Optional instance index for image ID suffixes.
|
|
8216
8713
|
* @ignore
|
|
8217
8714
|
*/
|
|
8218
|
-
declare const buildRoutingLayers: (config?: RoutingModuleConfig, layerIDPrefix?: string, instanceIndex?: number) => Required<RouteLayersConfig>;
|
|
8715
|
+
export declare const buildRoutingLayers: (config?: RoutingModuleConfig, layerIDPrefix?: string, instanceIndex?: number) => Required<RouteLayersConfig>;
|
|
8219
8716
|
/**
|
|
8220
8717
|
* Default routing layers configuration. Calls routingLayers with no parameters.
|
|
8221
8718
|
*
|
|
@@ -8237,38 +8734,38 @@ declare const buildRoutingLayers: (config?: RoutingModuleConfig, layerIDPrefix?:
|
|
|
8237
8734
|
*
|
|
8238
8735
|
* @group Routing
|
|
8239
8736
|
*/
|
|
8240
|
-
declare const defaultRoutingLayers: Required<RouteLayersConfig>;
|
|
8737
|
+
export declare const defaultRoutingLayers: Required<RouteLayersConfig>;
|
|
8241
8738
|
//#endregion
|
|
8242
8739
|
//#region src/routing/layers/shared.d.ts
|
|
8243
8740
|
/**
|
|
8244
8741
|
* Main route line foreground color.
|
|
8245
8742
|
* @ignore
|
|
8246
8743
|
*/
|
|
8247
|
-
declare const ROUTE_LINE_FOREGROUND_COLOR = "#36A8F0";
|
|
8744
|
+
export declare const ROUTE_LINE_FOREGROUND_COLOR = "#36A8F0";
|
|
8248
8745
|
/**
|
|
8249
8746
|
* Main route outline color.
|
|
8250
8747
|
* @ignore
|
|
8251
8748
|
*/
|
|
8252
|
-
declare const ROUTE_LINE_OUTLINE_COLOR = "#105287";
|
|
8749
|
+
export declare const ROUTE_LINE_OUTLINE_COLOR = "#105287";
|
|
8253
8750
|
/**
|
|
8254
8751
|
* Deselected route line foreground color.
|
|
8255
8752
|
* @ignore
|
|
8256
8753
|
*/
|
|
8257
|
-
declare const DESELECTED_FOREGROUND_COLOR = "#ABAFB3";
|
|
8754
|
+
export declare const DESELECTED_FOREGROUND_COLOR = "#ABAFB3";
|
|
8258
8755
|
/**
|
|
8259
8756
|
* Deselected route line outline color.
|
|
8260
8757
|
* @ignore
|
|
8261
8758
|
*/
|
|
8262
|
-
declare const DESELECTED_OUTLINE_COLOR = "#3C4956";
|
|
8759
|
+
export declare const DESELECTED_OUTLINE_COLOR = "#3C4956";
|
|
8263
8760
|
/**
|
|
8264
8761
|
* @ignore
|
|
8265
8762
|
*/
|
|
8266
|
-
declare const DESELECTED_SECONDARY_COLOR = "#727C85";
|
|
8763
|
+
export declare const DESELECTED_SECONDARY_COLOR = "#727C85";
|
|
8267
8764
|
/**
|
|
8268
8765
|
* Main route line width based on zoom level.
|
|
8269
8766
|
* @ignore
|
|
8270
8767
|
*/
|
|
8271
|
-
declare const ROUTE_LINE_FOREGROUND_WIDTH: ExpressionSpecification;
|
|
8768
|
+
export declare const ROUTE_LINE_FOREGROUND_WIDTH: ExpressionSpecification;
|
|
8272
8769
|
/**
|
|
8273
8770
|
* Used for showing/hiding layer depending on layer being part of selected route or not.
|
|
8274
8771
|
*
|
|
@@ -8279,7 +8776,7 @@ declare const ROUTE_LINE_FOREGROUND_WIDTH: ExpressionSpecification;
|
|
|
8279
8776
|
* filter: SELECTED_ROUTE_FILTER
|
|
8280
8777
|
* @group Routing
|
|
8281
8778
|
*/
|
|
8282
|
-
declare const SELECTED_ROUTE_FILTER: ExpressionSpecification;
|
|
8779
|
+
export declare const SELECTED_ROUTE_FILTER: ExpressionSpecification;
|
|
8283
8780
|
/**
|
|
8284
8781
|
* Used for showing/hiding layer depending on layer being part of deselected route or not.
|
|
8285
8782
|
*
|
|
@@ -8290,76 +8787,76 @@ declare const SELECTED_ROUTE_FILTER: ExpressionSpecification;
|
|
|
8290
8787
|
* filter: DESELECTED_ROUTE_FILTER
|
|
8291
8788
|
* @group Routing
|
|
8292
8789
|
*/
|
|
8293
|
-
declare const DESELECTED_ROUTE_FILTER: ExpressionSpecification;
|
|
8790
|
+
export declare const DESELECTED_ROUTE_FILTER: ExpressionSpecification;
|
|
8294
8791
|
/**
|
|
8295
8792
|
* Main route line outline width (medium) based on zoom level.
|
|
8296
8793
|
* @ignore
|
|
8297
8794
|
*/
|
|
8298
|
-
declare const ROUTE_LINE_OUTLINE_WIDTH: ExpressionSpecification;
|
|
8795
|
+
export declare const ROUTE_LINE_OUTLINE_WIDTH: ExpressionSpecification;
|
|
8299
8796
|
/**
|
|
8300
8797
|
* Returns the foreground line width expression for the given size preset.
|
|
8301
8798
|
* @ignore
|
|
8302
8799
|
*/
|
|
8303
|
-
declare const getLineForegroundWidth: (size?: RouteWidth) => ExpressionSpecification;
|
|
8800
|
+
export declare const getLineForegroundWidth: (size?: RouteWidth) => ExpressionSpecification;
|
|
8304
8801
|
/**
|
|
8305
8802
|
* Returns the outline line width expression for the given size preset.
|
|
8306
8803
|
* @ignore
|
|
8307
8804
|
*/
|
|
8308
|
-
declare const getLineOutlineWidth: (size?: RouteWidth) => ExpressionSpecification;
|
|
8805
|
+
export declare const getLineOutlineWidth: (size?: RouteWidth) => ExpressionSpecification;
|
|
8309
8806
|
/**
|
|
8310
8807
|
* Returns the waypoint icon size expression for the given size preset.
|
|
8311
8808
|
* @ignore
|
|
8312
8809
|
*/
|
|
8313
|
-
declare const getWaypointIconSize: (size?: RouteWaypointSize) => ExpressionSpecification;
|
|
8810
|
+
export declare const getWaypointIconSize: (size?: RouteWaypointSize) => ExpressionSpecification;
|
|
8314
8811
|
/**
|
|
8315
8812
|
* Returns the toll road outline width expression for the given size preset.
|
|
8316
8813
|
* @ignore
|
|
8317
8814
|
*/
|
|
8318
|
-
declare const getTollRoadOutlineWidth: (size?: RouteWidth) => ExpressionSpecification;
|
|
8815
|
+
export declare const getTollRoadOutlineWidth: (size?: RouteWidth) => ExpressionSpecification;
|
|
8319
8816
|
/**
|
|
8320
8817
|
* Returns the instruction line width expression for the given size preset.
|
|
8321
8818
|
* @ignore
|
|
8322
8819
|
*/
|
|
8323
|
-
declare const getInstructionLineWidth: (size?: RouteWidth) => ExpressionSpecification;
|
|
8820
|
+
export declare const getInstructionLineWidth: (size?: RouteWidth) => ExpressionSpecification;
|
|
8324
8821
|
/**
|
|
8325
8822
|
* Returns the instruction outline width expression for the given size preset.
|
|
8326
8823
|
* @ignore
|
|
8327
8824
|
*/
|
|
8328
|
-
declare const getInstructionOutlineWidth: (size?: RouteWidth) => ExpressionSpecification;
|
|
8825
|
+
export declare const getInstructionOutlineWidth: (size?: RouteWidth) => ExpressionSpecification;
|
|
8329
8826
|
/**
|
|
8330
8827
|
* @ignore
|
|
8331
8828
|
*/
|
|
8332
|
-
declare const MAJOR_DELAY_COLOR = "#AD0000";
|
|
8829
|
+
export declare const MAJOR_DELAY_COLOR = "#AD0000";
|
|
8333
8830
|
/**
|
|
8334
8831
|
* @ignore
|
|
8335
8832
|
*/
|
|
8336
|
-
declare const MODERATE_DELAY_COLOR = "#FB2D09";
|
|
8833
|
+
export declare const MODERATE_DELAY_COLOR = "#FB2D09";
|
|
8337
8834
|
/**
|
|
8338
8835
|
* @ignore
|
|
8339
8836
|
*/
|
|
8340
|
-
declare const MINOR_DELAY_COLOR = "#FFC105";
|
|
8837
|
+
export declare const MINOR_DELAY_COLOR = "#FFC105";
|
|
8341
8838
|
/**
|
|
8342
8839
|
* @ignore
|
|
8343
8840
|
*/
|
|
8344
|
-
declare const MINOR_DELAY_LABEL_COLOR = "#f58240";
|
|
8841
|
+
export declare const MINOR_DELAY_LABEL_COLOR = "#f58240";
|
|
8345
8842
|
/**
|
|
8346
8843
|
* @ignore
|
|
8347
8844
|
*/
|
|
8348
|
-
declare const UNKNOWN_DELAY_COLOR = "#000000";
|
|
8845
|
+
export declare const UNKNOWN_DELAY_COLOR = "#000000";
|
|
8349
8846
|
/**
|
|
8350
8847
|
* @ignore
|
|
8351
8848
|
*/
|
|
8352
|
-
declare const UNKNOWN_DELAY_BG_COLOR = "#C7D2D8";
|
|
8849
|
+
export declare const UNKNOWN_DELAY_BG_COLOR = "#C7D2D8";
|
|
8353
8850
|
/**
|
|
8354
8851
|
* Dashed-line color for `magnitudeOfDelay === 'unknown'` (rendered as a red dashed overlay).
|
|
8355
8852
|
* @ignore
|
|
8356
8853
|
*/
|
|
8357
|
-
declare const UNKNOWN_DELAY_DASH_COLOR = "rgba(190, 39, 27, 1)";
|
|
8854
|
+
export declare const UNKNOWN_DELAY_DASH_COLOR = "rgba(190, 39, 27, 1)";
|
|
8358
8855
|
/**
|
|
8359
8856
|
* Dashed-line color for `magnitudeOfDelay === 'indefinite'` (rendered as a gray dashed overlay).
|
|
8360
8857
|
* @ignore
|
|
8361
8858
|
*/
|
|
8362
|
-
declare const INDEFINITE_DELAY_DASH_COLOR = "rgba(137, 150, 168, 1)";
|
|
8859
|
+
export declare const INDEFINITE_DELAY_DASH_COLOR = "rgba(137, 150, 168, 1)";
|
|
8363
8860
|
//#endregion
|
|
8364
8861
|
//#region src/routing/types/displayRoutes.d.ts
|
|
8365
8862
|
/**
|
|
@@ -8853,19 +9350,19 @@ type PlanningWaypoint = WaypointLike | null;
|
|
|
8853
9350
|
/**
|
|
8854
9351
|
* @group Routing
|
|
8855
9352
|
*/
|
|
8856
|
-
declare const START_INDEX = "start";
|
|
9353
|
+
export declare const START_INDEX = "start";
|
|
8857
9354
|
/**
|
|
8858
9355
|
* @group Routing
|
|
8859
9356
|
*/
|
|
8860
|
-
declare const MIDDLE_INDEX = "middle";
|
|
9357
|
+
export declare const MIDDLE_INDEX = "middle";
|
|
8861
9358
|
/**
|
|
8862
9359
|
* @group Routing
|
|
8863
9360
|
*/
|
|
8864
|
-
declare const FINISH_INDEX = "finish";
|
|
9361
|
+
export declare const FINISH_INDEX = "finish";
|
|
8865
9362
|
/**
|
|
8866
9363
|
* @group Routing
|
|
8867
9364
|
*/
|
|
8868
|
-
type WaypointIndexType = typeof START_INDEX | typeof MIDDLE_INDEX | typeof FINISH_INDEX;
|
|
9365
|
+
export type WaypointIndexType = typeof START_INDEX | typeof MIDDLE_INDEX | typeof FINISH_INDEX;
|
|
8869
9366
|
/**
|
|
8870
9367
|
* Display properties for a waypoint marker on the map.
|
|
8871
9368
|
*
|
|
@@ -8911,7 +9408,7 @@ type WaypointIndexType = typeof START_INDEX | typeof MIDDLE_INDEX | typeof FINIS
|
|
|
8911
9408
|
*
|
|
8912
9409
|
* @group Routing
|
|
8913
9410
|
*/
|
|
8914
|
-
type WaypointDisplayProps = PlaceDisplayProps & {
|
|
9411
|
+
export type WaypointDisplayProps = PlaceDisplayProps & {
|
|
8915
9412
|
/**
|
|
8916
9413
|
* The index of the waypoint in relation to the other waypoints.
|
|
8917
9414
|
*
|
|
@@ -8943,8 +9440,8 @@ type WaypointDisplayProps = PlaceDisplayProps & {
|
|
|
8943
9440
|
* The stop index to be displayed.
|
|
8944
9441
|
*
|
|
8945
9442
|
* @remarks
|
|
8946
|
-
* Stops are the
|
|
8947
|
-
*
|
|
9443
|
+
* Stops are the waypoints between origin and destination, numbered starting from 1.
|
|
9444
|
+
* Only present for middle waypoints.
|
|
8948
9445
|
*
|
|
8949
9446
|
* **Display Behavior:**
|
|
8950
9447
|
* - Start waypoint: undefined
|
|
@@ -8966,11 +9463,7 @@ type WaypointDisplayProps = PlaceDisplayProps & {
|
|
|
8966
9463
|
/**
|
|
8967
9464
|
* @ignore
|
|
8968
9465
|
*/
|
|
8969
|
-
declare const
|
|
8970
|
-
/**
|
|
8971
|
-
* @ignore
|
|
8972
|
-
*/
|
|
8973
|
-
declare const STOP_DISPLAY_INDEX = "stopDisplayIndex";
|
|
9466
|
+
export declare const STOP_DISPLAY_INDEX = "stopDisplayIndex";
|
|
8974
9467
|
//#endregion
|
|
8975
9468
|
//#region src/routing/types/routingSourcesAndLayers.d.ts
|
|
8976
9469
|
/**
|
|
@@ -9042,6 +9535,45 @@ type ShowRoutesOptions = {
|
|
|
9042
9535
|
};
|
|
9043
9536
|
//#endregion
|
|
9044
9537
|
//#region src/routing/RoutingModule.d.ts
|
|
9538
|
+
/**
|
|
9539
|
+
* What `routing.events.on('shown-features', ...)` receives: whichever of routes or waypoints was
|
|
9540
|
+
* just rendered.
|
|
9541
|
+
*
|
|
9542
|
+
* @group Routing
|
|
9543
|
+
*/
|
|
9544
|
+
export type RoutingShownFeatures = {
|
|
9545
|
+
routes: Route | Routes;
|
|
9546
|
+
} | {
|
|
9547
|
+
waypoints: PlanningWaypoint[] | Waypoints;
|
|
9548
|
+
};
|
|
9549
|
+
/**
|
|
9550
|
+
* Event surface of {@link RoutingModule}: the module's own events, plus one named scope per part
|
|
9551
|
+
* of a route it draws.
|
|
9552
|
+
*
|
|
9553
|
+
* @group Routing
|
|
9554
|
+
*/
|
|
9555
|
+
export type RoutingEvents = CombinedEvents<MapGeoJSONFeature, RoutingModuleConfig, RoutingShownFeatures> & {
|
|
9556
|
+
/** The route lines themselves. */
|
|
9557
|
+
mainLines: UserEvents<Route<DisplayRouteProps>>;
|
|
9558
|
+
/** Origin, destination and intermediate stops. */
|
|
9559
|
+
waypoints: UserEvents<Waypoint<WaypointDisplayProps>>;
|
|
9560
|
+
/** Charging stops along an EV route. */
|
|
9561
|
+
chargingStops: UserEvents<RouteSection>;
|
|
9562
|
+
/** The summary bubbles shown against each alternative. */
|
|
9563
|
+
summaryBubbles: UserEvents<DisplayRouteSummary>;
|
|
9564
|
+
/** Traffic incidents on the route. */
|
|
9565
|
+
incidents: UserEvents<RouteSection<DisplayTrafficSectionProps>>;
|
|
9566
|
+
/** Sections the vehicle is restricted from. */
|
|
9567
|
+
vehicleRestricted: UserEvents<RouteSection>;
|
|
9568
|
+
/** Ferry sections. */
|
|
9569
|
+
ferries: UserEvents<RouteSection>;
|
|
9570
|
+
/** Toll road sections. */
|
|
9571
|
+
tollRoads: UserEvents<RouteSection>;
|
|
9572
|
+
/** Tunnel sections. */
|
|
9573
|
+
tunnels: UserEvents<RouteSection>;
|
|
9574
|
+
/** The guidance instruction lines. */
|
|
9575
|
+
instructionLines: UserEvents<DisplayInstruction>;
|
|
9576
|
+
};
|
|
9045
9577
|
/**
|
|
9046
9578
|
* Map module for displaying and managing route visualizations.
|
|
9047
9579
|
*
|
|
@@ -9069,7 +9601,7 @@ type ShowRoutesOptions = {
|
|
|
9069
9601
|
* @example
|
|
9070
9602
|
* ```typescript
|
|
9071
9603
|
* // Create the module
|
|
9072
|
-
* const routingModule = await RoutingModule.
|
|
9604
|
+
* const routingModule = await RoutingModule.create(map, {
|
|
9073
9605
|
* displayUnits: {
|
|
9074
9606
|
* distance: { type: 'metric' }
|
|
9075
9607
|
* }
|
|
@@ -9095,7 +9627,7 @@ type ShowRoutesOptions = {
|
|
|
9095
9627
|
*
|
|
9096
9628
|
* @group Routing
|
|
9097
9629
|
*/
|
|
9098
|
-
declare class RoutingModule extends AbstractMapModule<RoutingSourcesWithLayers, RoutingModuleConfig> {
|
|
9630
|
+
export declare class RoutingModule extends AbstractMapModule<RoutingSourcesWithLayers, RoutingModuleConfig> {
|
|
9099
9631
|
private layersSpecs;
|
|
9100
9632
|
private layerIDPrefix;
|
|
9101
9633
|
private readonly shownFeaturesHandlers;
|
|
@@ -9106,6 +9638,11 @@ declare class RoutingModule extends AbstractMapModule<RoutingSourcesWithLayers,
|
|
|
9106
9638
|
* @returns {Promise} Returns a promise with a new instance of this module
|
|
9107
9639
|
*
|
|
9108
9640
|
* @remarks
|
|
9641
|
+
* **Instances:**
|
|
9642
|
+
* `RoutingModule` owns the sources, layers and images it adds, all suffixed per instance. Every
|
|
9643
|
+
* call therefore returns a **new, independent** instance, and stacking several of them on one
|
|
9644
|
+
* map is a supported thing to do.
|
|
9645
|
+
*
|
|
9109
9646
|
* **Configuration Options:**
|
|
9110
9647
|
* - `displayUnits`: Distance units (metric/imperial)
|
|
9111
9648
|
* - `waypointsSource`: Waypoint entry point options
|
|
@@ -9117,13 +9654,13 @@ declare class RoutingModule extends AbstractMapModule<RoutingSourcesWithLayers,
|
|
|
9117
9654
|
* @example
|
|
9118
9655
|
* Default initialization:
|
|
9119
9656
|
* ```typescript
|
|
9120
|
-
* const routingModule = await RoutingModule.
|
|
9657
|
+
* const routingModule = await RoutingModule.create(map);
|
|
9121
9658
|
* ```
|
|
9122
9659
|
*
|
|
9123
9660
|
* @example
|
|
9124
9661
|
* With custom configuration:
|
|
9125
9662
|
* ```typescript
|
|
9126
|
-
* const routingModule = await RoutingModule.
|
|
9663
|
+
* const routingModule = await RoutingModule.create(map, {
|
|
9127
9664
|
* displayUnits: 'imperial',
|
|
9128
9665
|
* waypointsSource: {
|
|
9129
9666
|
* entryPoints: 'main-when-available'
|
|
@@ -9131,7 +9668,7 @@ declare class RoutingModule extends AbstractMapModule<RoutingSourcesWithLayers,
|
|
|
9131
9668
|
* });
|
|
9132
9669
|
* ```
|
|
9133
9670
|
*/
|
|
9134
|
-
static
|
|
9671
|
+
static create(tomtomMap: TomTomMap, config?: RoutingModuleConfig): Promise<RoutingModule>;
|
|
9135
9672
|
private constructor();
|
|
9136
9673
|
private createSourcesWithLayers;
|
|
9137
9674
|
/**
|
|
@@ -9317,42 +9854,29 @@ declare class RoutingModule extends AbstractMapModule<RoutingSourcesWithLayers,
|
|
|
9317
9854
|
summaryBubbles: DisplayRouteSummaries;
|
|
9318
9855
|
};
|
|
9319
9856
|
/**
|
|
9320
|
-
* Unified events interface for the routing module
|
|
9857
|
+
* Unified events interface for the routing module.
|
|
9321
9858
|
*
|
|
9322
|
-
*
|
|
9323
|
-
*
|
|
9324
|
-
*
|
|
9325
|
-
* routing.events.user.waypoints.on('hover', (waypoint) => { ... });
|
|
9326
|
-
* ```
|
|
9859
|
+
* `events` itself covers every route feature and the module's lifecycle events; the named
|
|
9860
|
+
* scopes below cover one part of a route each, and every one of them can be narrowed further
|
|
9861
|
+
* with `where()`.
|
|
9327
9862
|
*
|
|
9328
|
-
* **`events.module`** — module lifecycle events:
|
|
9329
9863
|
* ```typescript
|
|
9330
|
-
*
|
|
9331
|
-
*
|
|
9864
|
+
* routing.events.mainLines.on('click', (route) => { ... });
|
|
9865
|
+
* routing.events.waypoints.on('hover', (waypoint) => { ... });
|
|
9866
|
+
*
|
|
9867
|
+
* // Only the long tunnels, with their own hover cursor:
|
|
9868
|
+
* routing.events.tunnels
|
|
9869
|
+
* .where((section) => section.properties.lengthInMeters > 500, { cursorOnHover: 'help' })
|
|
9870
|
+
* .on('click', showTunnel);
|
|
9871
|
+
*
|
|
9872
|
+
* const unsub = routing.events.on('config-change', (config) => { ... });
|
|
9873
|
+
* routing.events.on('shown-features', (features) => {
|
|
9332
9874
|
* if ('routes' in features) { ... }
|
|
9333
9875
|
* });
|
|
9334
9876
|
* unsub();
|
|
9335
9877
|
* ```
|
|
9336
9878
|
*/
|
|
9337
|
-
get events():
|
|
9338
|
-
user: {
|
|
9339
|
-
mainLines: UserEvents<Route<DisplayRouteProps>>;
|
|
9340
|
-
waypoints: UserEvents<Waypoint<WaypointDisplayProps>>;
|
|
9341
|
-
chargingStops: UserEvents<RouteSection>;
|
|
9342
|
-
summaryBubbles: UserEvents<DisplayRouteSummary>;
|
|
9343
|
-
incidents: UserEvents<RouteSection<DisplayTrafficSectionProps>>;
|
|
9344
|
-
vehicleRestricted: UserEvents<RouteSection>;
|
|
9345
|
-
ferries: UserEvents<RouteSection>;
|
|
9346
|
-
tollRoads: UserEvents<RouteSection>;
|
|
9347
|
-
tunnels: UserEvents<RouteSection>;
|
|
9348
|
-
instructionLines: UserEvents<DisplayInstruction>;
|
|
9349
|
-
};
|
|
9350
|
-
module: ModuleEvents<RoutingModuleConfig, {
|
|
9351
|
-
routes: Route | Routes;
|
|
9352
|
-
} | {
|
|
9353
|
-
waypoints: PlanningWaypoint[] | Waypoints;
|
|
9354
|
-
}>;
|
|
9355
|
-
};
|
|
9879
|
+
get events(): RoutingEvents;
|
|
9356
9880
|
/**
|
|
9357
9881
|
* Returns the map style layer under which route lines are rendered.
|
|
9358
9882
|
* * Useful if you want to render extra layers just above the route ones but not on top of everything else.
|
|
@@ -9808,7 +10332,7 @@ type TrafficAreaAnalyticsConfig = MapModuleCommonConfig & {
|
|
|
9808
10332
|
* Resolves the effective color stops for a given color configuration.
|
|
9809
10333
|
* @ignore
|
|
9810
10334
|
*/
|
|
9811
|
-
declare const resolveColorStops: (colorConfig: AreaAnalyticsColorTheme | AreaAnalyticsColorStopsConfig) => AreaAnalyticsColorStop[];
|
|
10335
|
+
export declare const resolveColorStops: (colorConfig: AreaAnalyticsColorTheme | AreaAnalyticsColorStopsConfig) => AreaAnalyticsColorStop[];
|
|
9812
10336
|
//#endregion
|
|
9813
10337
|
//#region src/traffic/types/trafficAreaAnalyticsFeature.d.ts
|
|
9814
10338
|
/**
|
|
@@ -9821,7 +10345,7 @@ declare const resolveColorStops: (colorConfig: AreaAnalyticsColorTheme | AreaAna
|
|
|
9821
10345
|
*
|
|
9822
10346
|
* @group Traffic Area Analytics
|
|
9823
10347
|
*/
|
|
9824
|
-
type AreaAnalyticsDisplayProperties = AreaAnalyticsMetrics & SupportsEvents & {
|
|
10348
|
+
export type AreaAnalyticsDisplayProperties = AreaAnalyticsMetrics & SupportsEvents & {
|
|
9825
10349
|
/**
|
|
9826
10350
|
* Stable feature identifier (typically the tile centre coordinates stringified
|
|
9827
10351
|
* or the H3 cell index).
|
|
@@ -9833,7 +10357,7 @@ type AreaAnalyticsDisplayProperties = AreaAnalyticsMetrics & SupportsEvents & {
|
|
|
9833
10357
|
*
|
|
9834
10358
|
* @group Traffic Area Analytics
|
|
9835
10359
|
*/
|
|
9836
|
-
type AreaAnalyticsTileFeature = Feature<Point | Polygon, AreaAnalyticsDisplayProperties>;
|
|
10360
|
+
export type AreaAnalyticsTileFeature = Feature<Point | Polygon, AreaAnalyticsDisplayProperties>;
|
|
9837
10361
|
//#endregion
|
|
9838
10362
|
//#region src/traffic/TrafficAreaAnalyticsModule.d.ts
|
|
9839
10363
|
/**
|
|
@@ -9864,7 +10388,7 @@ type AreaAnalyticsSourcesWithLayers = {
|
|
|
9864
10388
|
* import { TrafficAreaAnalyticsModule } from '@tomtom-org/maps-sdk/map';
|
|
9865
10389
|
* import { trafficAreaAnalytics } from '@tomtom-org/maps-sdk/services';
|
|
9866
10390
|
*
|
|
9867
|
-
* const module = await TrafficAreaAnalyticsModule.
|
|
10391
|
+
* const module = await TrafficAreaAnalyticsModule.create(map, {
|
|
9868
10392
|
* displayMode: 'hexgrid-3d',
|
|
9869
10393
|
* metric: { active: 'congestionLevel' },
|
|
9870
10394
|
* });
|
|
@@ -9874,7 +10398,7 @@ type AreaAnalyticsSourcesWithLayers = {
|
|
|
9874
10398
|
*
|
|
9875
10399
|
* @group Traffic Area Analytics
|
|
9876
10400
|
*/
|
|
9877
|
-
declare class TrafficAreaAnalyticsModule extends AbstractMapModule<AreaAnalyticsSourcesWithLayers, TrafficAreaAnalyticsConfig> {
|
|
10401
|
+
export declare class TrafficAreaAnalyticsModule extends AbstractMapModule<AreaAnalyticsSourcesWithLayers, TrafficAreaAnalyticsConfig> {
|
|
9878
10402
|
private heatmapLayerSpec;
|
|
9879
10403
|
private hexFillLayerSpec;
|
|
9880
10404
|
private hexExtrusionLayerSpec;
|
|
@@ -9893,10 +10417,14 @@ declare class TrafficAreaAnalyticsModule extends AbstractMapModule<AreaAnalytics
|
|
|
9893
10417
|
*
|
|
9894
10418
|
* All configuration properties are optional. When `config` is omitted (or only
|
|
9895
10419
|
* partially supplied), built-in defaults are applied for every missing field.
|
|
9896
|
-
* After `
|
|
10420
|
+
* After `create()` resolves, {@link TrafficAreaAnalyticsModule.getConfig} always returns a
|
|
9897
10421
|
* fully-populated configuration — there is no need to reference any default
|
|
9898
10422
|
* values yourself.
|
|
9899
10423
|
*
|
|
10424
|
+
* `TrafficAreaAnalyticsModule` owns the sources, layers and images it adds, all suffixed per
|
|
10425
|
+
* instance. Every call therefore returns a **new, independent** instance, and stacking several
|
|
10426
|
+
* of them on one map is a supported thing to do.
|
|
10427
|
+
*
|
|
9900
10428
|
* @param tomtomMap - The TomTomMap instance.
|
|
9901
10429
|
* @param config - Optional initial configuration. Omit to use all defaults.
|
|
9902
10430
|
* @returns A promise that resolves with the initialised module.
|
|
@@ -9904,11 +10432,11 @@ declare class TrafficAreaAnalyticsModule extends AbstractMapModule<AreaAnalytics
|
|
|
9904
10432
|
* @example
|
|
9905
10433
|
* ```typescript
|
|
9906
10434
|
* // No config needed — defaults are applied automatically.
|
|
9907
|
-
* const module = await TrafficAreaAnalyticsModule.
|
|
10435
|
+
* const module = await TrafficAreaAnalyticsModule.create(map);
|
|
9908
10436
|
* await module.show(analytics);
|
|
9909
10437
|
*
|
|
9910
10438
|
* // Or override specific properties while keeping everything else at default:
|
|
9911
|
-
* const module = await TrafficAreaAnalyticsModule.
|
|
10439
|
+
* const module = await TrafficAreaAnalyticsModule.create(map, {
|
|
9912
10440
|
* displayMode: 'heatmap',
|
|
9913
10441
|
* metricConfig: {
|
|
9914
10442
|
* congestionLevel: { color: 'heat' },
|
|
@@ -9916,7 +10444,7 @@ declare class TrafficAreaAnalyticsModule extends AbstractMapModule<AreaAnalytics
|
|
|
9916
10444
|
* });
|
|
9917
10445
|
* ```
|
|
9918
10446
|
*/
|
|
9919
|
-
static
|
|
10447
|
+
static create(tomtomMap: TomTomMap, config?: TrafficAreaAnalyticsConfig): Promise<TrafficAreaAnalyticsModule>;
|
|
9920
10448
|
private constructor();
|
|
9921
10449
|
/** @ignore */
|
|
9922
10450
|
protected _initSourcesWithLayers(config?: TrafficAreaAnalyticsConfig, _restore?: boolean): AreaAnalyticsSourcesWithLayers;
|
|
@@ -10104,7 +10632,7 @@ declare class TrafficAreaAnalyticsModule extends AbstractMapModule<AreaAnalytics
|
|
|
10104
10632
|
*
|
|
10105
10633
|
* @group Traffic
|
|
10106
10634
|
*/
|
|
10107
|
-
declare const roadCategories: readonly ["motorway", "motorway_link", "trunk", "trunk_link", "primary", "primary_link", "secondary", "secondary_link", "tertiary", "tertiary_link", "street", "service", "track"];
|
|
10635
|
+
export declare const roadCategories: readonly ["motorway", "motorway_link", "trunk", "trunk_link", "primary", "primary_link", "secondary", "secondary_link", "tertiary", "tertiary_link", "street", "service", "track"];
|
|
10108
10636
|
/**
|
|
10109
10637
|
* Road hierarchy category type.
|
|
10110
10638
|
*
|
|
@@ -10124,7 +10652,7 @@ declare const roadCategories: readonly ["motorway", "motorway_link", "trunk", "t
|
|
|
10124
10652
|
*
|
|
10125
10653
|
* @group Traffic
|
|
10126
10654
|
*/
|
|
10127
|
-
type RoadCategory = (typeof roadCategories)[number];
|
|
10655
|
+
export type RoadCategory = (typeof roadCategories)[number];
|
|
10128
10656
|
/**
|
|
10129
10657
|
* Available street road sub-category identifiers.
|
|
10130
10658
|
*
|
|
@@ -10133,7 +10661,7 @@ type RoadCategory = (typeof roadCategories)[number];
|
|
|
10133
10661
|
*
|
|
10134
10662
|
* @group Traffic
|
|
10135
10663
|
*/
|
|
10136
|
-
declare const streetRoadSubCategories: readonly ["unclassified", "residential", "living_street"];
|
|
10664
|
+
export declare const streetRoadSubCategories: readonly ["unclassified", "residential", "living_street"];
|
|
10137
10665
|
/**
|
|
10138
10666
|
* Street road sub-category type.
|
|
10139
10667
|
*
|
|
@@ -10147,7 +10675,7 @@ declare const streetRoadSubCategories: readonly ["unclassified", "residential",
|
|
|
10147
10675
|
*
|
|
10148
10676
|
* @group Traffic
|
|
10149
10677
|
*/
|
|
10150
|
-
type StreetRoadSubCategory = (typeof streetRoadSubCategories)[number];
|
|
10678
|
+
export type StreetRoadSubCategory = (typeof streetRoadSubCategories)[number];
|
|
10151
10679
|
/**
|
|
10152
10680
|
* Available service road sub-category identifiers.
|
|
10153
10681
|
*
|
|
@@ -10156,7 +10684,7 @@ type StreetRoadSubCategory = (typeof streetRoadSubCategories)[number];
|
|
|
10156
10684
|
*
|
|
10157
10685
|
* @group Traffic
|
|
10158
10686
|
*/
|
|
10159
|
-
declare const serviceRoadSubCategories: readonly ["parking", "driveway", "alley"];
|
|
10687
|
+
export declare const serviceRoadSubCategories: readonly ["parking", "driveway", "alley"];
|
|
10160
10688
|
/**
|
|
10161
10689
|
* Service road sub-category type.
|
|
10162
10690
|
*
|
|
@@ -10170,7 +10698,7 @@ declare const serviceRoadSubCategories: readonly ["parking", "driveway", "alley"
|
|
|
10170
10698
|
*
|
|
10171
10699
|
* @group Traffic
|
|
10172
10700
|
*/
|
|
10173
|
-
type ServiceRoadSubCategory = (typeof serviceRoadSubCategories)[number];
|
|
10701
|
+
export type ServiceRoadSubCategory = (typeof serviceRoadSubCategories)[number];
|
|
10174
10702
|
/**
|
|
10175
10703
|
* Road sub-category type.
|
|
10176
10704
|
*
|
|
@@ -10179,7 +10707,7 @@ type ServiceRoadSubCategory = (typeof serviceRoadSubCategories)[number];
|
|
|
10179
10707
|
*
|
|
10180
10708
|
* @group Traffic
|
|
10181
10709
|
*/
|
|
10182
|
-
type RoadSubCategory = StreetRoadSubCategory | ServiceRoadSubCategory;
|
|
10710
|
+
export type RoadSubCategory = StreetRoadSubCategory | ServiceRoadSubCategory;
|
|
10183
10711
|
/**
|
|
10184
10712
|
* Common filter configuration shared between traffic incidents and flow visualization.
|
|
10185
10713
|
*
|
|
@@ -10188,7 +10716,7 @@ type RoadSubCategory = StreetRoadSubCategory | ServiceRoadSubCategory;
|
|
|
10188
10716
|
*
|
|
10189
10717
|
* @group Traffic
|
|
10190
10718
|
*/
|
|
10191
|
-
type TrafficCommonFilter = {
|
|
10719
|
+
export type TrafficCommonFilter = {
|
|
10192
10720
|
/**
|
|
10193
10721
|
* Filters traffic data by road hierarchy categories.
|
|
10194
10722
|
*
|
|
@@ -10229,7 +10757,7 @@ type TrafficCommonFilter = {
|
|
|
10229
10757
|
*
|
|
10230
10758
|
* @group Traffic Flow
|
|
10231
10759
|
*/
|
|
10232
|
-
type TrafficFlowFilter = TrafficCommonFilter & {
|
|
10760
|
+
export type TrafficFlowFilter = TrafficCommonFilter & {
|
|
10233
10761
|
/**
|
|
10234
10762
|
* Controls road closure display in the traffic flow layer.
|
|
10235
10763
|
*
|
|
@@ -10267,7 +10795,7 @@ type TrafficFlowFilter = TrafficCommonFilter & {
|
|
|
10267
10795
|
*
|
|
10268
10796
|
* @group Traffic Flow
|
|
10269
10797
|
*/
|
|
10270
|
-
type TrafficFlowFilters = {
|
|
10798
|
+
export type TrafficFlowFilters = {
|
|
10271
10799
|
/**
|
|
10272
10800
|
* Array of flow filters combined with OR logic.
|
|
10273
10801
|
*
|
|
@@ -10285,7 +10813,7 @@ type TrafficFlowFilters = {
|
|
|
10285
10813
|
*
|
|
10286
10814
|
* @group Traffic Flow
|
|
10287
10815
|
*/
|
|
10288
|
-
type FlowConfig = MapModuleCommonConfig & {
|
|
10816
|
+
export type FlowConfig = MapModuleCommonConfig & {
|
|
10289
10817
|
/**
|
|
10290
10818
|
* Controls the visibility of the traffic flow layers.
|
|
10291
10819
|
*
|
|
@@ -10309,7 +10837,7 @@ type FlowConfig = MapModuleCommonConfig & {
|
|
|
10309
10837
|
*
|
|
10310
10838
|
* @group Traffic Flow
|
|
10311
10839
|
*/
|
|
10312
|
-
type TrafficFlowModuleFeature = Feature<LineString, {
|
|
10840
|
+
export type TrafficFlowModuleFeature = Feature<LineString, {
|
|
10313
10841
|
/**
|
|
10314
10842
|
* Road hierarchy category type.
|
|
10315
10843
|
*/
|
|
@@ -10429,7 +10957,7 @@ type TrafficFlowSourcesWithLayers = {
|
|
|
10429
10957
|
*
|
|
10430
10958
|
* @group Traffic Flow
|
|
10431
10959
|
*/
|
|
10432
|
-
declare class TrafficFlowModule extends AbstractMapModule<TrafficFlowSourcesWithLayers, FlowConfig> {
|
|
10960
|
+
export declare class TrafficFlowModule extends AbstractMapModule<TrafficFlowSourcesWithLayers, FlowConfig> {
|
|
10433
10961
|
private originalFilters;
|
|
10434
10962
|
/**
|
|
10435
10963
|
* Retrieves a TrafficFlowModule instance for the given map.
|
|
@@ -10471,6 +10999,12 @@ declare class TrafficFlowModule extends AbstractMapModule<TrafficFlowSourcesWith
|
|
|
10471
10999
|
* }
|
|
10472
11000
|
* });
|
|
10473
11001
|
* ```
|
|
11002
|
+
*
|
|
11003
|
+
* @remarks
|
|
11004
|
+
* **Instances:**
|
|
11005
|
+
* `TrafficFlowModule` controls the traffic-flow source and layers the map style already
|
|
11006
|
+
* provides, under fixed global IDs. Every instance is another handle on that same shared state,
|
|
11007
|
+
* so visibility and filters applied through one are visible through all of them.
|
|
10474
11008
|
*/
|
|
10475
11009
|
static get(map: TomTomMap, config?: FlowConfig): Promise<TrafficFlowModule>;
|
|
10476
11010
|
private constructor();
|
|
@@ -10745,7 +11279,7 @@ type Sources = {
|
|
|
10745
11279
|
*
|
|
10746
11280
|
* const map = new TomTomMap({ mapLibre: { container: 'map', center: [4.9, 52.37], zoom: 13 } });
|
|
10747
11281
|
*
|
|
10748
|
-
* const overlay = await TrafficIncidentOverlayModule.
|
|
11282
|
+
* const overlay = await TrafficIncidentOverlayModule.create(map);
|
|
10749
11283
|
* const result = await trafficIncidentDetails({
|
|
10750
11284
|
* bbox: [4.85, 52.34, 4.95, 52.40],
|
|
10751
11285
|
* timeValidityFilter: ['present'],
|
|
@@ -10764,12 +11298,23 @@ type Sources = {
|
|
|
10764
11298
|
*
|
|
10765
11299
|
* @group Traffic
|
|
10766
11300
|
*/
|
|
10767
|
-
declare class TrafficIncidentOverlayModule extends AbstractMapModule<Sources, TrafficIncidentOverlayConfig> {
|
|
11301
|
+
export declare class TrafficIncidentOverlayModule extends AbstractMapModule<Sources, TrafficIncidentOverlayConfig> {
|
|
10768
11302
|
private lastResult;
|
|
10769
11303
|
private lastFeatureIds;
|
|
10770
11304
|
private lastFocusIds;
|
|
10771
11305
|
private readonly shownFeaturesHandlers;
|
|
10772
|
-
|
|
11306
|
+
/**
|
|
11307
|
+
* Creates a new module instance on the given map, waiting until the map is ready first.
|
|
11308
|
+
*
|
|
11309
|
+
* `TrafficIncidentOverlayModule` owns the sources, layers and images it adds, all suffixed per
|
|
11310
|
+
* instance. Every call therefore returns a **new, independent** instance, and stacking several
|
|
11311
|
+
* of them on one map is a supported thing to do.
|
|
11312
|
+
*
|
|
11313
|
+
* @param tomtomMap The TomTomMap instance.
|
|
11314
|
+
* @param config The module optional configuration.
|
|
11315
|
+
* @returns {Promise} Returns a promise with a new instance of this module.
|
|
11316
|
+
*/
|
|
11317
|
+
static create(tomtomMap: TomTomMap, config?: TrafficIncidentOverlayConfig): Promise<TrafficIncidentOverlayModule>;
|
|
10773
11318
|
private constructor();
|
|
10774
11319
|
/** @ignore */
|
|
10775
11320
|
protected _initSourcesWithLayers(config?: TrafficIncidentOverlayConfig, _restore?: boolean): Sources;
|
|
@@ -10834,7 +11379,7 @@ declare class TrafficIncidentOverlayModule extends AbstractMapModule<Sources, Tr
|
|
|
10834
11379
|
*
|
|
10835
11380
|
* @group Traffic Incidents
|
|
10836
11381
|
*/
|
|
10837
|
-
type DelayFilter = {
|
|
11382
|
+
export type DelayFilter = {
|
|
10838
11383
|
/**
|
|
10839
11384
|
* Requires incidents to have an associated delay.
|
|
10840
11385
|
*
|
|
@@ -10872,7 +11417,7 @@ type DelayFilter = {
|
|
|
10872
11417
|
*
|
|
10873
11418
|
* @group Traffic Incidents
|
|
10874
11419
|
*/
|
|
10875
|
-
type TrafficIncidentsFilter = TrafficCommonFilter & {
|
|
11420
|
+
export type TrafficIncidentsFilter = TrafficCommonFilter & {
|
|
10876
11421
|
/**
|
|
10877
11422
|
* Filters incidents by category type.
|
|
10878
11423
|
*
|
|
@@ -10943,7 +11488,7 @@ type TrafficIncidentsFilter = TrafficCommonFilter & {
|
|
|
10943
11488
|
*
|
|
10944
11489
|
* @group Traffic Incidents
|
|
10945
11490
|
*/
|
|
10946
|
-
type TrafficIncidentsFilters = {
|
|
11491
|
+
export type TrafficIncidentsFilters = {
|
|
10947
11492
|
/**
|
|
10948
11493
|
* Array of incident filters combined with OR logic.
|
|
10949
11494
|
*
|
|
@@ -10961,7 +11506,7 @@ type TrafficIncidentsFilters = {
|
|
|
10961
11506
|
*
|
|
10962
11507
|
* @group Traffic Incidents
|
|
10963
11508
|
*/
|
|
10964
|
-
type IncidentsCommonConfig = {
|
|
11509
|
+
export type IncidentsCommonConfig = {
|
|
10965
11510
|
/**
|
|
10966
11511
|
* Controls the visibility of the traffic incident layers.
|
|
10967
11512
|
*
|
|
@@ -10985,7 +11530,7 @@ type IncidentsCommonConfig = {
|
|
|
10985
11530
|
*
|
|
10986
11531
|
* @group Traffic Incidents
|
|
10987
11532
|
*/
|
|
10988
|
-
type IncidentsConfig = MapModuleCommonConfig & IncidentsCommonConfig & {
|
|
11533
|
+
export type IncidentsConfig = MapModuleCommonConfig & IncidentsCommonConfig & {
|
|
10989
11534
|
/**
|
|
10990
11535
|
* Configuration specific to incident icon display.
|
|
10991
11536
|
*
|
|
@@ -11000,7 +11545,7 @@ type IncidentsConfig = MapModuleCommonConfig & IncidentsCommonConfig & {
|
|
|
11000
11545
|
/**
|
|
11001
11546
|
* Defines the structure of a traffic incident feature, which extends the basic GeoJSON feature with specific properties related to traffic incidents. This type is used to represent individual traffic incidents on the map, providing details such as the description of the incident, its severity, and the road category where it is occurring.
|
|
11002
11547
|
*/
|
|
11003
|
-
type TrafficIncidentsModuleFeature = Feature<Geometry, TrafficIncidentBaseProperties & {
|
|
11548
|
+
export type TrafficIncidentsModuleFeature = Feature<Geometry, TrafficIncidentBaseProperties & {
|
|
11004
11549
|
/**
|
|
11005
11550
|
* Description of the traffic incident, providing details about the nature of the incident.
|
|
11006
11551
|
*/
|
|
@@ -11161,7 +11706,7 @@ type TrafficIncidentsSourcesWithLayers = {
|
|
|
11161
11706
|
*
|
|
11162
11707
|
* @group Traffic Incidents
|
|
11163
11708
|
*/
|
|
11164
|
-
declare class TrafficIncidentsModule extends AbstractMapModule<TrafficIncidentsSourcesWithLayers, IncidentsConfig> {
|
|
11709
|
+
export declare class TrafficIncidentsModule extends AbstractMapModule<TrafficIncidentsSourcesWithLayers, IncidentsConfig> {
|
|
11165
11710
|
private originalFilters;
|
|
11166
11711
|
/**
|
|
11167
11712
|
* Retrieves a TrafficIncidentsModule instance for the given map.
|
|
@@ -11203,6 +11748,12 @@ declare class TrafficIncidentsModule extends AbstractMapModule<TrafficIncidentsS
|
|
|
11203
11748
|
* }
|
|
11204
11749
|
* });
|
|
11205
11750
|
* ```
|
|
11751
|
+
*
|
|
11752
|
+
* @remarks
|
|
11753
|
+
* **Instances:**
|
|
11754
|
+
* `TrafficIncidentsModule` controls the traffic-incident source and layers the map style already
|
|
11755
|
+
* provides, under fixed global IDs. Every instance is another handle on that same shared state,
|
|
11756
|
+
* so visibility and filters applied through one are visible through all of them.
|
|
11206
11757
|
*/
|
|
11207
11758
|
static get(map: TomTomMap, config?: IncidentsConfig): Promise<TrafficIncidentsModule>;
|
|
11208
11759
|
private constructor();
|
|
@@ -11406,7 +11957,7 @@ declare class TrafficIncidentsModule extends AbstractMapModule<TrafficIncidentsS
|
|
|
11406
11957
|
*
|
|
11407
11958
|
* @group Utils
|
|
11408
11959
|
*/
|
|
11409
|
-
type CalculateMapCenterOptions = {
|
|
11960
|
+
export type CalculateMapCenterOptions = {
|
|
11410
11961
|
/** The TomTomMap instance or MapLibre map instance */
|
|
11411
11962
|
map: TomTomMap | Map;
|
|
11412
11963
|
/** Array of HTML elements or DOM selector strings that are positioned over the map */
|
|
@@ -11417,7 +11968,7 @@ type CalculateMapCenterOptions = {
|
|
|
11417
11968
|
*
|
|
11418
11969
|
* @group Utils
|
|
11419
11970
|
*/
|
|
11420
|
-
type CalculateMapBoundsOptions = CalculateMapCenterOptions & {
|
|
11971
|
+
export type CalculateMapBoundsOptions = CalculateMapCenterOptions & {
|
|
11421
11972
|
/**
|
|
11422
11973
|
* Additional padding in pixels to apply around the UI elements or map edges. Default is 0.
|
|
11423
11974
|
*/
|
|
@@ -11428,7 +11979,7 @@ type CalculateMapBoundsOptions = CalculateMapCenterOptions & {
|
|
|
11428
11979
|
*
|
|
11429
11980
|
* @group Utils
|
|
11430
11981
|
*/
|
|
11431
|
-
type CalculateFittingBBoxOptions = CalculateMapBoundsOptions & {
|
|
11982
|
+
export type CalculateFittingBBoxOptions = CalculateMapBoundsOptions & {
|
|
11432
11983
|
/**
|
|
11433
11984
|
* The target bounding box [west, south, east, north] that should be contained in the unobscured area
|
|
11434
11985
|
*/
|
|
@@ -11448,7 +11999,7 @@ type CalculateFittingBBoxOptions = CalculateMapBoundsOptions & {
|
|
|
11448
11999
|
*
|
|
11449
12000
|
* @group Utils
|
|
11450
12001
|
*/
|
|
11451
|
-
declare const calculatePaddedBBox: (options: CalculateMapBoundsOptions) => BBox | null;
|
|
12002
|
+
export declare const calculatePaddedBBox: (options: CalculateMapBoundsOptions) => BBox | null;
|
|
11452
12003
|
/**
|
|
11453
12004
|
* Calculates the center point in lng-lat coordinates of the visible map area
|
|
11454
12005
|
* that does not overlap with the given UI HTML elements.
|
|
@@ -11462,7 +12013,7 @@ declare const calculatePaddedBBox: (options: CalculateMapBoundsOptions) => BBox
|
|
|
11462
12013
|
*
|
|
11463
12014
|
* @group Utils
|
|
11464
12015
|
*/
|
|
11465
|
-
declare const calculatePaddedCenter: (options: CalculateMapCenterOptions) => Position | null;
|
|
12016
|
+
export declare const calculatePaddedCenter: (options: CalculateMapCenterOptions) => Position | null;
|
|
11466
12017
|
/**
|
|
11467
12018
|
* Calculates an expanded bounding box that, when the map is zoomed to it, ensures that the given to-be-contained bounding box
|
|
11468
12019
|
* is visible within the area not obscured by surrounding UI elements, including optional padding.
|
|
@@ -11478,6 +12029,6 @@ declare const calculatePaddedCenter: (options: CalculateMapCenterOptions) => Pos
|
|
|
11478
12029
|
*
|
|
11479
12030
|
* @group Utils
|
|
11480
12031
|
*/
|
|
11481
|
-
declare const calculateFittingBBox: (options: CalculateFittingBBoxOptions) => BBox | null;
|
|
12032
|
+
export declare const calculateFittingBBox: (options: CalculateFittingBBoxOptions) => BBox | null;
|
|
11482
12033
|
//#endregion
|
|
11483
|
-
export {
|
|
12034
|
+
export type { AREA_ANALYTICS_DEFAULTS, AreaAnalyticsBeforeLayerConfig, AreaAnalyticsColorStop, AreaAnalyticsColorStopsConfig, AreaAnalyticsColorTheme, AreaAnalyticsDisplayMode, AreaAnalyticsHeightConfig, AreaAnalyticsMetricConfig, AreaAnalyticsMetricFilter, AreaAnalyticsRegionPolygonConfig, AreaAnalyticsValueType, AvailabilityLevel, BeforeLayerConfig, ByIdOrIndex, CSSCursor, ChargingSpeedIconMapping, ChargingStopIconConfig, ChargingStopIconMapping, ChargingStopTextConfig, ChargingStopsConfig, CleanEventStateOptions, CleanEventStatesOptions, ClickEventType, CustomImage, DefaultPlaceIconConfig, DisplayRouteProps, DisplayRouteRelatedProps, DisplayRouteSummaries, DisplayRouteSummary, DisplayRouteSummaryProps, EVAvailabilityConfig, EventHandlerConfig, EventHandlerCursorConfig, EventType, FilterShowMode, FilterSyntaxVersion, FilterablePOICategory, HasAdditionalLayersConfig, HasBeforeID, HillshadeModuleConfig, HoverEventType, IncidentFocusStyle, LayerSpecFilter, LayerSpecTemplate, LayerSpecWithSource, LightDark, MapEventsConfig, MapFont, MapModuleCommonConfig, MapStyleLayerID, MultiSyntaxFilter, POIsModuleConfig, POIsModuleFeature, PlaceConnectionDisplay, PlaceConnectionLayerName, PlaceConnectionsConfig, PlaceConnectionsLayersConfig, PlaceIconConfig, PlaceLayerName, PlaceLayersConfig, PlaceTextConfig, PlacesModuleConfig, PlacesTheme, PlanningWaypoint, PutEventStateOptions, RouteLayersConfig, RouteStateProps, RouteTheme, RouteWaypointSize, RouteWidth, RoutingModuleConfig, SVGIconStyleOptions, SourceWithLayerIDs, SourceWithLayers, SourcesWithLayers, SupportsEvents, SymbolLayerSpecWithoutSource, ToBeAddedLayerSpec, ToBeAddedLayerSpecTemplate, ToBeAddedLayerSpecWithoutSource, TrafficAreaAnalyticsConfig, TrafficIncidentOverlayConfig, UserEventHandler, ValuesFilter, WaypointsConfig };
|