@maptrip/map-tiles 1.5.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,12 @@ 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
281
327
  - 1.5.0
282
328
  - Fixed rendering of urban green spaces
283
329
  - Improved rendering of outlines
@@ -295,7 +341,7 @@ To use them, you mapping API has to be able to use both base layers and overlays
295
341
  - 1.3.2: Updated dependencies with security vulnerabilities
296
342
  - 1.3.1: Updated all all providers to use the latest build of the project
297
343
  - 1.3.0: Added map release data for Leaflet and OpenLayers map attributions
298
- - 1.2.1: Fixed a bug in MapTripLeafletGridLayer type implementation
344
+ - 1.2.1: Fixed a bug in `MapTripLeafletGridLayer` type implementation
299
345
  - 1.2.0: Added TypeScript declaration file
300
346
  - 1.1.1: Added rendering config for foot_path layer
301
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: {
@@ -362,22 +425,6 @@ declare const RENDERING_CONFIG_DEFAULT: {
362
425
  outlineColor: string;
363
426
  outlineWidth: number;
364
427
  };
365
- } | {
366
- from: number;
367
- to: number;
368
- line: {
369
- width: number;
370
- color: string;
371
- outlineColor?: undefined;
372
- outlineWidth?: undefined;
373
- };
374
- text: {
375
- size: number;
376
- color: string;
377
- font: string;
378
- outlineColor: string;
379
- outlineWidth: number;
380
- };
381
428
  } | {
382
429
  from: number;
383
430
  to: number;
@@ -413,10 +460,10 @@ declare const RENDERING_CONFIG_DEFAULT: {
413
460
  line: {
414
461
  width: number;
415
462
  color: string;
463
+ outlineColor: string;
464
+ outlineWidth: number;
416
465
  url?: undefined;
417
466
  direction?: undefined;
418
- outlineColor?: undefined;
419
- outlineWidth?: undefined;
420
467
  };
421
468
  text: {
422
469
  size: number;
@@ -462,10 +509,10 @@ declare const RENDERING_CONFIG_DEFAULT: {
462
509
  line: {
463
510
  width: number;
464
511
  color: string;
512
+ outlineColor: string;
513
+ outlineWidth: number;
465
514
  url?: undefined;
466
515
  direction?: undefined;
467
- outlineColor?: undefined;
468
- outlineWidth?: undefined;
469
516
  };
470
517
  text: {
471
518
  size: number;
@@ -591,7 +638,7 @@ declare const RENDERING_CONFIG_DEFAULT: {
591
638
  outlineWidth: number;
592
639
  };
593
640
  })[];
594
- foot_path: {
641
+ foot_path: ({
595
642
  from: number;
596
643
  to: number;
597
644
  line: {
@@ -607,7 +654,17 @@ declare const RENDERING_CONFIG_DEFAULT: {
607
654
  outlineColor: string;
608
655
  outlineWidth: number;
609
656
  };
610
- }[];
657
+ } | {
658
+ from: number;
659
+ to: number;
660
+ line: {
661
+ width: number;
662
+ color: string;
663
+ dashColor: string;
664
+ dashLength: number;
665
+ };
666
+ text?: undefined;
667
+ })[];
611
668
  rail: ({
612
669
  from: number;
613
670
  to: number;
@@ -33,9 +33,15 @@ declare const RENDERING_CONFIG_GRAYSCALE: {
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_GRAYSCALE: {
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_GRAYSCALE: {
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_GRAYSCALE: {
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_GRAYSCALE: {
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: {
@@ -362,22 +425,6 @@ declare const RENDERING_CONFIG_GRAYSCALE: {
362
425
  outlineColor: string;
363
426
  outlineWidth: number;
364
427
  };
365
- } | {
366
- from: number;
367
- to: number;
368
- line: {
369
- width: number;
370
- color: string;
371
- outlineColor?: undefined;
372
- outlineWidth?: undefined;
373
- };
374
- text: {
375
- size: number;
376
- color: string;
377
- font: string;
378
- outlineColor: string;
379
- outlineWidth: number;
380
- };
381
428
  } | {
382
429
  from: number;
383
430
  to: number;
@@ -413,10 +460,10 @@ declare const RENDERING_CONFIG_GRAYSCALE: {
413
460
  line: {
414
461
  width: number;
415
462
  color: string;
463
+ outlineColor: string;
464
+ outlineWidth: number;
416
465
  url?: undefined;
417
466
  direction?: undefined;
418
- outlineColor?: undefined;
419
- outlineWidth?: undefined;
420
467
  };
421
468
  text: {
422
469
  size: number;
@@ -462,10 +509,10 @@ declare const RENDERING_CONFIG_GRAYSCALE: {
462
509
  line: {
463
510
  width: number;
464
511
  color: string;
512
+ outlineColor: string;
513
+ outlineWidth: number;
465
514
  url?: undefined;
466
515
  direction?: undefined;
467
- outlineColor?: undefined;
468
- outlineWidth?: undefined;
469
516
  };
470
517
  text: {
471
518
  size: number;
@@ -605,7 +652,7 @@ declare const RENDERING_CONFIG_GRAYSCALE: {
605
652
  outlineWidth: number;
606
653
  };
607
654
  })[];
608
- foot_path: {
655
+ foot_path: ({
609
656
  from: number;
610
657
  to: number;
611
658
  line: {
@@ -621,7 +668,17 @@ declare const RENDERING_CONFIG_GRAYSCALE: {
621
668
  outlineColor: string;
622
669
  outlineWidth: number;
623
670
  };
624
- }[];
671
+ } | {
672
+ from: number;
673
+ to: number;
674
+ line: {
675
+ width: number;
676
+ color: string;
677
+ dashColor: string;
678
+ dashLength: number;
679
+ };
680
+ text?: undefined;
681
+ })[];
625
682
  rail: ({
626
683
  from: number;
627
684
  to: number;