@maptrip/map-tiles 1.4.0 → 1.6.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/README.md CHANGED
@@ -68,7 +68,44 @@ L.map("map", {
68
68
  `MapTripLeafletGridLayer` can be configured with all properties listed in the section _Properties_, and also with these:
69
69
 
70
70
  - `token`: A valid and non-expired token for your account, see section _Authorization_ (**required**)
71
- - `attribution`: The copyright notes to show in the map
71
+ - `attribution`: Custom copyright notes to show in the map; default is empty
72
+ - `releaseDate`: Boolean value stating whether to append the map release data to the attribution; default is false.
73
+ - `minZoom`: The minimum zoom level for the map (must not be smaller than 2)
74
+ - `maxZoom`: The maximum zoom level for the map (must not be larger than 18)
75
+
76
+ ### MapLibre GL JS
77
+
78
+ Supported versions: MapLibre GL JS 6.16 and newer
79
+
80
+ Install [MapLibre](https://maplibre.org/projects/gl-js/) with `npm install maplibre-gl@~6.x`. To use MapTrip map tiles in MapLibre GL JS,
81
+ you create an instance of `MapLibreStyleFactory` and use it to create a map style:
82
+
83
+ ```js
84
+ import * as maplibregl from 'maplibre-gl';
85
+ import 'maplibre-gl/dist/maplibre-gl.css';
86
+ import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url';
87
+
88
+ import { MapLibreStyleFactory } from "@maptrip/map-tiles";
89
+
90
+ maplibregl.setWorkerUrl(workerUrl);
91
+
92
+ const factory = new MapLibreStyleFactory();
93
+
94
+ const map = new maplibregl.Map({
95
+ container: "map",
96
+ center: [6.95988, 50.94017],
97
+ zoom: 13,
98
+ style: factory.createMapTripStyle({
99
+ provider: "TomTom",
100
+ token: "Insert your MapTrip token here"
101
+ })
102
+ });
103
+ ```
104
+
105
+ `MapLibreStyleFactory` can be configured with all properties listed in the section _Properties_, and also with these:
106
+
107
+ - `token`: A valid and non-expired token for your account, see section _Authorization_ (**required**)
108
+ - `attribution`: Custom copyright notes to show in the map; default is empty
72
109
  - `releaseDate`: Boolean value stating whether to append the map release data to the attribution; default is false.
73
110
  - `minZoom`: The minimum zoom level for the map (must not be smaller than 2)
74
111
  - `maxZoom`: The maximum zoom level for the map (must not be larger than 18)
@@ -238,18 +275,21 @@ You can specify a third parameter with properties when creating the factory. The
238
275
  | ----------------- | ------------------------------------------------------------------------------------------------- | ------------------------ |
239
276
  | provider | The map data provider (`TomTom`, `Orbis`, `HERE` or `OpenStreetmap`) | OpenStreetmap |
240
277
  | baseMap | Set to `false` for a traffic overlay which can be used on top of e.g. an aerial view | true |
241
- | traffic | Add traffic flows to the map tiles (only available for TomTom and HERE maps) | false |
278
+ | traffic | Add traffic flows to the map tiles. Use RENDERING_CONFIG_GRAYSCALE for better contrast | false |
242
279
  | timeout | Load timeout for tiles in milliseconds. Increase this if you have a very slow internet connection | 5000 |
243
280
  | parallelDownloads | The number of tiles that are loaded in parallel | 12 |
244
281
  | detourProfile | The name of a MapTrip Detour Profile, see _MapTrip Detour_ | |
245
282
  | renderingConfig | Set a custom rendering configuration to customize layers, colors, line widths etc. | RENDERING_CONFIG_DEFAULT |
246
283
 
247
- This factory initializes a factory with TomTom data and traffic flows:
284
+ This code initializes a factory with TomTom data and traffic flows, rendered on a grayscale map for better contrast:
248
285
 
249
286
  ```js
287
+ import { VectorTileFactory, RENDERING_CONFIG_GRAYSCALE } from "@maptrip/map-tiles";
288
+
250
289
  const factory = VectorTileFactory.createFactory({
251
290
  provider: "TomTom",
252
291
  traffic: true,
292
+ renderingConfig: RENDERING_CONFIG_GRAYSCALE
253
293
  });
254
294
  ```
255
295
 
@@ -278,6 +318,20 @@ To use them, you mapping API has to be able to use both base layers and overlays
278
318
 
279
319
  ## History
280
320
 
321
+ - 1.6.0
322
+ - Traffic flows now rendered on both sides of roads to show the situation in both directions of travel
323
+ - Added traffic flows for OpenStreetmap and Orbis
324
+ - Added MapLibre integration
325
+ - Increased maximum zoom level
326
+ - Improved rendering of minor roads and foot pathes on medium zoom levels
327
+ - 1.5.0
328
+ - Fixed rendering of urban green spaces
329
+ - Improved rendering of outlines
330
+ - Improved arrows of one way streets
331
+ - Minor roads: Added outline, standardized width for regular streets and one-way streets
332
+ - Residential roads: Added outline, standardized width for regular streets and one-way streets
333
+ - Improved rendering of railways
334
+ - Updated dependencies with security vulnerabilities
281
335
  - 1.4.0:
282
336
  - Added map data provider `Orbis`
283
337
  - Added map data provider name to attribution
@@ -287,7 +341,7 @@ To use them, you mapping API has to be able to use both base layers and overlays
287
341
  - 1.3.2: Updated dependencies with security vulnerabilities
288
342
  - 1.3.1: Updated all all providers to use the latest build of the project
289
343
  - 1.3.0: Added map release data for Leaflet and OpenLayers map attributions
290
- - 1.2.1: Fixed a bug in MapTripLeafletGridLayer type implementation
344
+ - 1.2.1: Fixed a bug in `MapTripLeafletGridLayer` type implementation
291
345
  - 1.2.0: Added TypeScript declaration file
292
346
  - 1.1.1: Added rendering config for foot_path layer
293
347
  - 1.1.0: Added MapTrip detour profiles
@@ -1,17 +1,15 @@
1
1
  import { default as L } from 'leaflet';
2
2
  import { VectorTileFactory } from '../../core/VectorTileFactory.js';
3
- import { MapReleaseFetcher } from '../../util/MapReleaseFetcher.js';
4
3
  import { PointXY, RENDERING_CONFIG } from '../../types/interfaces.js';
5
4
  declare class MapTripLeafletGridLayer extends L.GridLayer {
6
- MIN_ZOOM: number;
7
- MAX_ZOOM: number;
5
+ static attributions: string[];
8
6
  token: string;
9
7
  factory: VectorTileFactory;
10
- releaseFetcher: MapReleaseFetcher;
11
- provider: string;
12
- attribution: string;
13
- release: string;
14
- releaseDate: boolean;
8
+ provider?: string;
9
+ releaseDate?: boolean;
10
+ currentAttribution?: string;
11
+ private attachedMap?;
12
+ private customAttribution?;
15
13
  constructor(options: {
16
14
  provider?: string;
17
15
  baseMap?: boolean;
@@ -26,10 +24,9 @@ declare class MapTripLeafletGridLayer extends L.GridLayer {
26
24
  maxZoom?: number;
27
25
  releaseDate?: boolean;
28
26
  });
27
+ onAdd(map: L.Map): this;
28
+ onRemove(map: L.Map): this;
29
29
  createTile(coords: PointXY): HTMLCanvasElement;
30
- private initializeAttribution;
31
- private setRelease;
32
- private setAttribution;
33
- private onBaseLayerChange;
30
+ private updateAttribution;
34
31
  }
35
32
  export { MapTripLeafletGridLayer };
@@ -0,0 +1,21 @@
1
+ import { StyleSpecification } from 'maplibre-gl';
2
+ import { RENDERING_CONFIG } from '../../types/interfaces.js';
3
+ declare class MapLibreStyleFactory {
4
+ private protocolId;
5
+ createMapTripStyle(options: {
6
+ provider?: string;
7
+ baseMap?: boolean;
8
+ traffic?: boolean;
9
+ timeout?: number;
10
+ parallelDownloads?: number;
11
+ detourProfile?: string;
12
+ renderingConfig?: RENDERING_CONFIG;
13
+ token?: string;
14
+ attribution?: string;
15
+ minZoom?: number;
16
+ maxZoom?: number;
17
+ releaseDate?: boolean;
18
+ }): StyleSpecification;
19
+ private getTileCanvasAsync;
20
+ }
21
+ export { MapLibreStyleFactory };
@@ -41,6 +41,13 @@ declare class VectorTileRenderer {
41
41
  x: number;
42
42
  y: number;
43
43
  }[];
44
+ /**
45
+ * @private
46
+ */
47
+ translatePolyline(points: {
48
+ x: number;
49
+ y: number;
50
+ }[], delta: number): void;
44
51
  /**
45
52
  * @private
46
53
  */
@@ -99,6 +106,7 @@ declare class VectorTileRenderer {
99
106
  dashColor: undefined;
100
107
  dashLength: number;
101
108
  opacity: number;
109
+ delta: number;
102
110
  };
103
111
  IMAGE: {
104
112
  url: undefined;
@@ -1,4 +1,4 @@
1
- export declare const URL_TEMPLATE = "https://v${index}.maptrip.de/?tilex=${x}&tiley=${y}&acao=true&context=tomtom${z}&project=${project}&projection=wgs84";
1
+ export declare const URL_TEMPLATE = "https://v${index}.maptrip.de/?tilex=${x}&tiley=${y}&acao=true&context=level${z}&project=${project}&projection=wgs84";
2
2
  export declare const PROVIDER_PROJECTS: {
3
3
  [key: string]: string;
4
4
  };
@@ -8,8 +8,9 @@ export declare const PROVIDER_NAMES: {
8
8
  export declare const PROVIDER_TRAFFIC: {
9
9
  [key: string]: string | null;
10
10
  };
11
+ export declare const DEFAULT_PROVIDER = "OpenStreetmap";
11
12
  export declare const MIN_ZOOM = 2;
12
- export declare const MAX_ZOOM = 18;
13
+ export declare const MAX_ZOOM = 21;
13
14
  export declare const ATTRIBUTION = "&#169;&nbsp;<a href=\"https://maptrip.de/\" target=\"_blank\">infoware GmbH</a>";
14
15
  export declare const VECTOR_TILE_SIZE = 256;
15
16
  export declare const VECTOR_TILE_RENDER_PADDING = 32;
@@ -33,9 +33,15 @@ declare const RENDERING_CONFIG_DEFAULT: {
33
33
  interstateNumbers: string;
34
34
  expresswayNumbers: string;
35
35
  expresswayintersections: string;
36
- trafficFlowFast: string;
37
- trafficFlowMedium: string;
38
- trafficFlowSlow: string;
36
+ trafficFlowFastHighway: string;
37
+ trafficFlowFastInterstate: string;
38
+ trafficFlowFastMinor: string;
39
+ trafficFlowMediumHighway: string;
40
+ trafficFlowMediumInterstate: string;
41
+ trafficFlowMediumMinor: string;
42
+ trafficFlowSlowHighway: string;
43
+ trafficFlowSlowInterstate: string;
44
+ trafficFlowSlowMinor: string;
39
45
  trafficJam: string;
40
46
  roadworks: string;
41
47
  dangerousSituation: string;
@@ -105,13 +111,6 @@ declare const RENDERING_CONFIG_DEFAULT: {
105
111
  };
106
112
  }[];
107
113
  forest: ({
108
- from: number;
109
- to: number;
110
- polygon: {
111
- color: string;
112
- };
113
- text?: undefined;
114
- } | {
115
114
  from: number;
116
115
  to: number;
117
116
  polygon: {
@@ -123,15 +122,15 @@ declare const RENDERING_CONFIG_DEFAULT: {
123
122
  font: string;
124
123
  fontStyle: string;
125
124
  };
126
- })[];
127
- natural_park: ({
125
+ } | {
128
126
  from: number;
129
127
  to: number;
130
128
  polygon: {
131
129
  color: string;
132
130
  };
133
131
  text?: undefined;
134
- } | {
132
+ })[];
133
+ natural_park: ({
135
134
  from: number;
136
135
  to: number;
137
136
  polygon: {
@@ -143,6 +142,13 @@ declare const RENDERING_CONFIG_DEFAULT: {
143
142
  font: string;
144
143
  fontStyle: string;
145
144
  };
145
+ } | {
146
+ from: number;
147
+ to: number;
148
+ polygon: {
149
+ color: string;
150
+ };
151
+ text?: undefined;
146
152
  })[];
147
153
  water: {
148
154
  from: number;
@@ -177,28 +183,85 @@ declare const RENDERING_CONFIG_DEFAULT: {
177
183
  outlineWidth: number;
178
184
  };
179
185
  }[];
180
- trafficFlowFast: {
186
+ trafficFlowFastHighway: {
187
+ from: number;
188
+ to: number;
189
+ line: {
190
+ color: string;
191
+ width: number;
192
+ delta: number;
193
+ };
194
+ }[];
195
+ trafficFlowFastInterstate: {
196
+ from: number;
197
+ to: number;
198
+ line: {
199
+ color: string;
200
+ width: number;
201
+ delta: number;
202
+ };
203
+ }[];
204
+ trafficFlowFastMinor: {
205
+ from: number;
206
+ to: number;
207
+ line: {
208
+ color: string;
209
+ width: number;
210
+ delta: number;
211
+ };
212
+ }[];
213
+ trafficFlowMediumHighway: {
214
+ from: number;
215
+ to: number;
216
+ line: {
217
+ color: string;
218
+ width: number;
219
+ delta: number;
220
+ };
221
+ }[];
222
+ trafficFlowMediumInterstate: {
223
+ from: number;
224
+ to: number;
225
+ line: {
226
+ color: string;
227
+ width: number;
228
+ delta: number;
229
+ };
230
+ }[];
231
+ trafficFlowMediumMinor: {
232
+ from: number;
233
+ to: number;
234
+ line: {
235
+ color: string;
236
+ width: number;
237
+ delta: number;
238
+ };
239
+ }[];
240
+ trafficFlowSlowHighway: {
181
241
  from: number;
182
242
  to: number;
183
243
  line: {
184
244
  color: string;
185
245
  width: number;
246
+ delta: number;
186
247
  };
187
248
  }[];
188
- trafficFlowMedium: {
249
+ trafficFlowSlowInterstate: {
189
250
  from: number;
190
251
  to: number;
191
252
  line: {
192
253
  color: string;
193
254
  width: number;
255
+ delta: number;
194
256
  };
195
257
  }[];
196
- trafficFlowSlow: {
258
+ trafficFlowSlowMinor: {
197
259
  from: number;
198
260
  to: number;
199
261
  line: {
200
262
  color: string;
201
263
  width: number;
264
+ delta: number;
202
265
  };
203
266
  }[];
204
267
  trafficJam: {
@@ -352,6 +415,8 @@ declare const RENDERING_CONFIG_DEFAULT: {
352
415
  line: {
353
416
  width: number;
354
417
  color: string;
418
+ outlineColor: string;
419
+ outlineWidth: number;
355
420
  };
356
421
  text: {
357
422
  size: number;
@@ -366,6 +431,8 @@ declare const RENDERING_CONFIG_DEFAULT: {
366
431
  line: {
367
432
  width: number;
368
433
  color: string;
434
+ outlineColor?: undefined;
435
+ outlineWidth?: undefined;
369
436
  };
370
437
  text?: undefined;
371
438
  })[];
@@ -376,10 +443,9 @@ declare const RENDERING_CONFIG_DEFAULT: {
376
443
  width: number;
377
444
  color: string;
378
445
  url: string;
379
- height: number;
380
- dx: number;
381
- dy: number;
382
446
  direction: string;
447
+ outlineColor: string;
448
+ outlineWidth: number;
383
449
  };
384
450
  text: {
385
451
  size: number;
@@ -394,10 +460,9 @@ declare const RENDERING_CONFIG_DEFAULT: {
394
460
  line: {
395
461
  width: number;
396
462
  color: string;
463
+ outlineColor: string;
464
+ outlineWidth: number;
397
465
  url?: undefined;
398
- height?: undefined;
399
- dx?: undefined;
400
- dy?: undefined;
401
466
  direction?: undefined;
402
467
  };
403
468
  text: {
@@ -414,10 +479,9 @@ declare const RENDERING_CONFIG_DEFAULT: {
414
479
  width: number;
415
480
  color: string;
416
481
  url?: undefined;
417
- height?: undefined;
418
- dx?: undefined;
419
- dy?: undefined;
420
482
  direction?: undefined;
483
+ outlineColor?: undefined;
484
+ outlineWidth?: undefined;
421
485
  };
422
486
  text?: undefined;
423
487
  })[];
@@ -428,10 +492,9 @@ declare const RENDERING_CONFIG_DEFAULT: {
428
492
  width: number;
429
493
  color: string;
430
494
  url: string;
431
- height: number;
432
- dx: number;
433
- dy: number;
434
495
  direction: string;
496
+ outlineColor: string;
497
+ outlineWidth: number;
435
498
  };
436
499
  text: {
437
500
  size: number;
@@ -446,10 +509,9 @@ declare const RENDERING_CONFIG_DEFAULT: {
446
509
  line: {
447
510
  width: number;
448
511
  color: string;
512
+ outlineColor: string;
513
+ outlineWidth: number;
449
514
  url?: undefined;
450
- height?: undefined;
451
- dx?: undefined;
452
- dy?: undefined;
453
515
  direction?: undefined;
454
516
  };
455
517
  text: {
@@ -466,10 +528,9 @@ declare const RENDERING_CONFIG_DEFAULT: {
466
528
  width: number;
467
529
  color: string;
468
530
  url?: undefined;
469
- height?: undefined;
470
- dx?: undefined;
471
- dy?: undefined;
472
531
  direction?: undefined;
532
+ outlineColor?: undefined;
533
+ outlineWidth?: undefined;
473
534
  };
474
535
  text?: undefined;
475
536
  })[];
@@ -518,9 +579,6 @@ declare const RENDERING_CONFIG_DEFAULT: {
518
579
  width: number;
519
580
  color: string;
520
581
  url: string;
521
- height: number;
522
- dx: number;
523
- dy: number;
524
582
  direction: string;
525
583
  };
526
584
  text: {
@@ -537,9 +595,6 @@ declare const RENDERING_CONFIG_DEFAULT: {
537
595
  width: number;
538
596
  color: string;
539
597
  url?: undefined;
540
- height?: undefined;
541
- dx?: undefined;
542
- dy?: undefined;
543
598
  direction?: undefined;
544
599
  };
545
600
  text: {
@@ -557,9 +612,6 @@ declare const RENDERING_CONFIG_DEFAULT: {
557
612
  width: number;
558
613
  color: string;
559
614
  url: string;
560
- height: number;
561
- dx: number;
562
- dy: number;
563
615
  direction: string;
564
616
  };
565
617
  text: {
@@ -576,9 +628,6 @@ declare const RENDERING_CONFIG_DEFAULT: {
576
628
  width: number;
577
629
  color: string;
578
630
  url?: undefined;
579
- height?: undefined;
580
- dx?: undefined;
581
- dy?: undefined;
582
631
  direction?: undefined;
583
632
  };
584
633
  text: {
@@ -589,7 +638,7 @@ declare const RENDERING_CONFIG_DEFAULT: {
589
638
  outlineWidth: number;
590
639
  };
591
640
  })[];
592
- foot_path: {
641
+ foot_path: ({
593
642
  from: number;
594
643
  to: number;
595
644
  line: {
@@ -605,15 +654,36 @@ declare const RENDERING_CONFIG_DEFAULT: {
605
654
  outlineColor: string;
606
655
  outlineWidth: number;
607
656
  };
608
- }[];
609
- rail: {
657
+ } | {
610
658
  from: number;
611
659
  to: number;
612
660
  line: {
613
661
  width: number;
614
662
  color: string;
663
+ dashColor: string;
664
+ dashLength: number;
615
665
  };
616
- }[];
666
+ text?: undefined;
667
+ })[];
668
+ rail: ({
669
+ from: number;
670
+ to: number;
671
+ line: {
672
+ width: number;
673
+ color: string;
674
+ dashColor: string;
675
+ dashLength: number;
676
+ };
677
+ } | {
678
+ from: number;
679
+ to: number;
680
+ line: {
681
+ width: number;
682
+ color: string;
683
+ dashLength: number;
684
+ dashColor?: undefined;
685
+ };
686
+ })[];
617
687
  ferry: ({
618
688
  from: number;
619
689
  to: number;