@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 +58 -4
- package/dist/api-extensions/leaflet/MapTripLeafletGridLayer.d.ts +9 -12
- package/dist/api-extensions/maplibre/MapLibreStyleFactory.d.ts +21 -0
- package/dist/core/VectorTileRenderer.d.ts +8 -0
- package/dist/core/constants.d.ts +3 -2
- package/dist/core/rendering_config_default.d.ts +120 -50
- package/dist/core/rendering_config_grayscale.d.ts +120 -50
- package/dist/core/rendering_config_traffic.d.ts +141 -6
- package/dist/map-tiles.js +1450 -576
- package/dist/map-tiles.js.map +1 -1
- package/dist/util/MapReleaseFetcher.d.ts +3 -2
- package/dist/util/VectorTileUtils.d.ts +4 -0
- package/lib/api-extensions/leaflet/MapTripLeafletGridLayer.ts +48 -95
- package/lib/api-extensions/maplibre/MapLibreStyleFactory.ts +114 -0
- package/lib/core/VectorTileFactory.ts +3 -2
- package/lib/core/VectorTileRenderer.ts +110 -37
- package/lib/core/constants.ts +8 -5
- package/lib/core/rendering_config_default.ts +384 -90
- package/lib/core/rendering_config_grayscale.ts +399 -105
- package/lib/core/rendering_config_traffic.ts +344 -104
- package/lib/util/MapReleaseFetcher.ts +38 -24
- package/lib/util/VectorTileUtils.ts +33 -0
- package/package.json +8 -7
|
@@ -2,118 +2,358 @@ const RENDERING_CONFIG_TRAFFIC = {
|
|
|
2
2
|
"background": [
|
|
3
3
|
{
|
|
4
4
|
"from": 1,
|
|
5
|
-
"to":
|
|
5
|
+
"to": 21,
|
|
6
6
|
"color": "rgba(0, 0, 0, 0)"
|
|
7
7
|
}
|
|
8
8
|
],
|
|
9
9
|
"layers": {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
trafficFlowFastHighway: "trafficFlowFastHighway",
|
|
11
|
+
trafficFlowFastInterstate: "trafficFlowFastInterstate",
|
|
12
|
+
trafficFlowFastMinor: "trafficFlowFastMinor",
|
|
13
|
+
trafficFlowMediumHighway: "trafficFlowMediumHighway",
|
|
14
|
+
trafficFlowMediumInterstate: "trafficFlowMediumInterstate",
|
|
15
|
+
trafficFlowMediumMinor: "trafficFlowMediumMinor",
|
|
16
|
+
trafficFlowSlowHighway: "trafficFlowSlowHighway",
|
|
17
|
+
trafficFlowSlowInterstate: "trafficFlowSlowInterstate",
|
|
18
|
+
trafficFlowSlowMinor: "trafficFlowSlowMinor",
|
|
13
19
|
},
|
|
14
20
|
"renderers": {
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
21
|
+
trafficFlowFastHighway: [
|
|
22
|
+
{
|
|
23
|
+
from: 1,
|
|
24
|
+
to: 5,
|
|
25
|
+
line: {
|
|
26
|
+
color: "#6EDB9C",
|
|
27
|
+
width: 1,
|
|
28
|
+
delta: 1,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
from: 6,
|
|
33
|
+
to: 9,
|
|
34
|
+
line: {
|
|
35
|
+
color: "#6EDB9C",
|
|
36
|
+
width: 1,
|
|
37
|
+
delta: 1,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
from: 10,
|
|
42
|
+
to: 12,
|
|
43
|
+
line: {
|
|
44
|
+
color: "#6EDB9C",
|
|
45
|
+
width: 2,
|
|
46
|
+
outlineColor: "#4B9869",
|
|
47
|
+
outlineWidth: 1,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
from: 13,
|
|
52
|
+
to: 15,
|
|
53
|
+
line: {
|
|
54
|
+
color: "#6EDB9C",
|
|
55
|
+
width: 3,
|
|
56
|
+
outlineColor: "#4B9869",
|
|
57
|
+
outlineWidth: 1,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
from: 16,
|
|
62
|
+
to: 21,
|
|
63
|
+
line: {
|
|
64
|
+
color: "#6EDB9C",
|
|
65
|
+
width: 4,
|
|
66
|
+
outlineColor: "#4B9869",
|
|
67
|
+
outlineWidth: 1,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
trafficFlowFastInterstate: [
|
|
72
|
+
{
|
|
73
|
+
from: 9,
|
|
74
|
+
to: 12,
|
|
75
|
+
line: {
|
|
76
|
+
color: "#6EDB9C",
|
|
77
|
+
width: 1,
|
|
78
|
+
delta: 1,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
from: 13,
|
|
83
|
+
to: 14,
|
|
84
|
+
line: {
|
|
85
|
+
color: "#6EDB9C",
|
|
86
|
+
width: 2,
|
|
87
|
+
delta: 2,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
from: 15,
|
|
92
|
+
to: 16,
|
|
93
|
+
line: {
|
|
94
|
+
color: "#6EDB9C",
|
|
95
|
+
width: 2,
|
|
96
|
+
delta: 2,
|
|
97
|
+
outlineColor: "#4B9869",
|
|
98
|
+
outlineWidth: 1,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
from: 17,
|
|
103
|
+
to: 21,
|
|
104
|
+
line: {
|
|
105
|
+
color: "#6EDB9C",
|
|
106
|
+
width: 3,
|
|
107
|
+
delta: 3,
|
|
108
|
+
outlineColor: "#4B9869",
|
|
109
|
+
outlineWidth: 1,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
trafficFlowFastMinor: [
|
|
114
|
+
{
|
|
115
|
+
from: 15,
|
|
116
|
+
to: 16,
|
|
117
|
+
line: {
|
|
118
|
+
color: "#6EDB9C",
|
|
119
|
+
width: 1,
|
|
120
|
+
delta: 1,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
from: 17,
|
|
125
|
+
to: 21,
|
|
126
|
+
line: {
|
|
127
|
+
color: "#6EDB9C",
|
|
128
|
+
width: 2,
|
|
129
|
+
delta: 2,
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
trafficFlowMediumHighway: [
|
|
134
|
+
{
|
|
135
|
+
from: 1,
|
|
136
|
+
to: 5,
|
|
137
|
+
line: {
|
|
138
|
+
color: "#ffce42",
|
|
139
|
+
width: 1,
|
|
140
|
+
delta: 1,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
from: 6,
|
|
145
|
+
to: 9,
|
|
146
|
+
line: {
|
|
147
|
+
color: "#ffce42",
|
|
148
|
+
width: 1,
|
|
149
|
+
delta: 1,
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
from: 10,
|
|
154
|
+
to: 12,
|
|
155
|
+
line: {
|
|
156
|
+
color: "#ffce42",
|
|
157
|
+
width: 2,
|
|
158
|
+
outlineColor: "#f4bf22",
|
|
159
|
+
outlineWidth: 1,
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
from: 13,
|
|
164
|
+
to: 15,
|
|
165
|
+
line: {
|
|
166
|
+
color: "#ffce42",
|
|
167
|
+
width: 3,
|
|
168
|
+
outlineColor: "#f4bf22",
|
|
169
|
+
outlineWidth: 1,
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
from: 16,
|
|
174
|
+
to: 21,
|
|
175
|
+
line: {
|
|
176
|
+
color: "#ffce42",
|
|
177
|
+
width: 4,
|
|
178
|
+
outlineColor: "#f4bf22",
|
|
179
|
+
outlineWidth: 1,
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
trafficFlowMediumInterstate: [
|
|
184
|
+
{
|
|
185
|
+
from: 9,
|
|
186
|
+
to: 12,
|
|
187
|
+
line: {
|
|
188
|
+
color: "#ffce42",
|
|
189
|
+
width: 1,
|
|
190
|
+
delta: 1,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
from: 13,
|
|
195
|
+
to: 14,
|
|
196
|
+
line: {
|
|
197
|
+
color: "#ffce42",
|
|
198
|
+
width: 2,
|
|
199
|
+
delta: 2,
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
from: 15,
|
|
204
|
+
to: 16,
|
|
205
|
+
line: {
|
|
206
|
+
color: "#ffce42",
|
|
207
|
+
width: 2,
|
|
208
|
+
delta: 2,
|
|
209
|
+
outlineColor: "#f4bf22",
|
|
210
|
+
outlineWidth: 1,
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
from: 17,
|
|
215
|
+
to: 21,
|
|
216
|
+
line: {
|
|
217
|
+
color: "#ffce42",
|
|
218
|
+
width: 3,
|
|
219
|
+
delta: 3,
|
|
220
|
+
outlineColor: "#f4bf22",
|
|
221
|
+
outlineWidth: 1,
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
trafficFlowMediumMinor: [
|
|
226
|
+
{
|
|
227
|
+
from: 15,
|
|
228
|
+
to: 16,
|
|
229
|
+
line: {
|
|
230
|
+
color: "#ffce42",
|
|
231
|
+
width: 1,
|
|
232
|
+
delta: 1,
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
from: 17,
|
|
237
|
+
to: 21,
|
|
238
|
+
line: {
|
|
239
|
+
color: "#ffce42",
|
|
240
|
+
width: 2,
|
|
241
|
+
delta: 2,
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
trafficFlowSlowHighway: [
|
|
246
|
+
{
|
|
247
|
+
from: 1,
|
|
248
|
+
to: 5,
|
|
249
|
+
line: {
|
|
250
|
+
color: "#f14d40",
|
|
251
|
+
width: 1,
|
|
252
|
+
delta: 1,
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
from: 6,
|
|
257
|
+
to: 9,
|
|
258
|
+
line: {
|
|
259
|
+
color: "#f14d40",
|
|
260
|
+
width: 1,
|
|
261
|
+
delta: 1,
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
from: 10,
|
|
266
|
+
to: 12,
|
|
267
|
+
line: {
|
|
268
|
+
color: "#f14d40",
|
|
269
|
+
width: 2,
|
|
270
|
+
outlineColor: "#96403a",
|
|
271
|
+
outlineWidth: 1,
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
from: 13,
|
|
276
|
+
to: 15,
|
|
277
|
+
line: {
|
|
278
|
+
color: "#f14d40",
|
|
279
|
+
width: 3,
|
|
280
|
+
outlineColor: "#96403a",
|
|
281
|
+
outlineWidth: 1,
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
from: 16,
|
|
286
|
+
to: 21,
|
|
287
|
+
line: {
|
|
288
|
+
color: "#f14d40",
|
|
289
|
+
width: 4,
|
|
290
|
+
outlineColor: "#96403a",
|
|
291
|
+
outlineWidth: 1,
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
],
|
|
295
|
+
trafficFlowSlowInterstate: [
|
|
296
|
+
{
|
|
297
|
+
from: 9,
|
|
298
|
+
to: 12,
|
|
299
|
+
line: {
|
|
300
|
+
color: "#f14d40",
|
|
301
|
+
width: 1,
|
|
302
|
+
delta: 1,
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
from: 13,
|
|
307
|
+
to: 14,
|
|
308
|
+
line: {
|
|
309
|
+
color: "#f14d40",
|
|
310
|
+
width: 2,
|
|
311
|
+
delta: 2,
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
from: 15,
|
|
316
|
+
to: 16,
|
|
317
|
+
line: {
|
|
318
|
+
color: "#f14d40",
|
|
319
|
+
width: 2,
|
|
320
|
+
delta: 2,
|
|
321
|
+
outlineColor: "#96403a",
|
|
322
|
+
outlineWidth: 1,
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
from: 17,
|
|
327
|
+
to: 21,
|
|
328
|
+
line: {
|
|
329
|
+
color: "#f14d40",
|
|
330
|
+
width: 3,
|
|
331
|
+
delta: 3,
|
|
332
|
+
outlineColor: "#96403a",
|
|
333
|
+
outlineWidth: 1,
|
|
334
|
+
},
|
|
335
|
+
},
|
|
48
336
|
],
|
|
49
|
-
|
|
50
|
-
{
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"to": 15,
|
|
69
|
-
"line": {
|
|
70
|
-
"color": "rgba(255, 165, 0, 0.5)",
|
|
71
|
-
"width": 4
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"from": 16,
|
|
76
|
-
"to": 19,
|
|
77
|
-
"line": {
|
|
78
|
-
"color": "rgba(255, 165, 0, 0.5)",
|
|
79
|
-
"width": 6
|
|
80
|
-
}
|
|
81
|
-
}
|
|
337
|
+
trafficFlowSlowMinor: [
|
|
338
|
+
{
|
|
339
|
+
from: 15,
|
|
340
|
+
to: 16,
|
|
341
|
+
line: {
|
|
342
|
+
color: "#f14d40",
|
|
343
|
+
width: 1,
|
|
344
|
+
delta: 1,
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
from: 17,
|
|
349
|
+
to: 21,
|
|
350
|
+
line: {
|
|
351
|
+
color: "#f14d40",
|
|
352
|
+
width: 2,
|
|
353
|
+
delta: 2,
|
|
354
|
+
},
|
|
355
|
+
},
|
|
82
356
|
],
|
|
83
|
-
"trafficFlowSlow": [
|
|
84
|
-
{
|
|
85
|
-
"from": 1,
|
|
86
|
-
"to": 8,
|
|
87
|
-
"line": {
|
|
88
|
-
"color": "rgba(200, 0, 0, 0.5)",
|
|
89
|
-
"width": 1
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
"from": 9,
|
|
94
|
-
"to": 12,
|
|
95
|
-
"line": {
|
|
96
|
-
"color": "rgba(200, 0, 0, 0.5)",
|
|
97
|
-
"width": 2
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
"from": 13,
|
|
102
|
-
"to": 15,
|
|
103
|
-
"line": {
|
|
104
|
-
"color": "rgba(200, 0, 0, 0.5)",
|
|
105
|
-
"width": 4
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
"from": 16,
|
|
110
|
-
"to": 19,
|
|
111
|
-
"line": {
|
|
112
|
-
"color": "rgba(200, 0, 0, 0.5)",
|
|
113
|
-
"width": 6
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
]
|
|
117
357
|
}
|
|
118
358
|
};
|
|
119
359
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PROVIDER_NAMES } from "../core/constants.js"
|
|
1
|
+
import { PROVIDER_NAMES, PROVIDER_PROJECTS, DEFAULT_PROVIDER } from "../core/constants.js"
|
|
2
2
|
|
|
3
3
|
export class MapReleaseFetcher {
|
|
4
4
|
private _token: string;
|
|
@@ -12,55 +12,69 @@ export class MapReleaseFetcher {
|
|
|
12
12
|
this._token = token;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
async getRelease(provider
|
|
15
|
+
async getRelease(provider?: string): Promise<string | null> {
|
|
16
|
+
|
|
17
|
+
if (!provider) {
|
|
18
|
+
provider = DEFAULT_PROVIDER;
|
|
19
|
+
}
|
|
20
|
+
|
|
16
21
|
if (provider === "tomtom") {
|
|
17
22
|
if (!this._tomtom) {
|
|
18
|
-
|
|
19
|
-
"https://v1.maptrip.de/?CMD=GETFILE&PROJECT=TomTom_latest&RELATIVEPATH=/data/mapset/data/routing_geocoder/admin.bin&acao=true";
|
|
20
|
-
this._tomtom = this.fetchAndExtractRelease(provider, url);
|
|
23
|
+
this._tomtom = this.fetchAndExtractRelease(provider);
|
|
21
24
|
}
|
|
22
25
|
return this._tomtom;
|
|
23
|
-
} if (provider === "orbis") {
|
|
26
|
+
} else if (provider === "orbis") {
|
|
24
27
|
if (!this._orbis) {
|
|
25
|
-
|
|
26
|
-
"https://v1.maptrip.de/?CMD=GETFILE&PROJECT=Orbis_latest&RELATIVEPATH=/data/mapset/data/routing_geocoder/admin.bin&acao=true";
|
|
27
|
-
this._orbis = this.fetchAndExtractRelease(provider, url);
|
|
28
|
+
this._orbis = this.fetchAndExtractRelease(provider);
|
|
28
29
|
}
|
|
29
30
|
return this._orbis;
|
|
30
31
|
} else if (provider === "here") {
|
|
31
32
|
if (!this._here) {
|
|
32
|
-
|
|
33
|
-
"https://v1.maptrip.de/?CMD=GETFILE&PROJECT=HERE_latest&RELATIVEPATH=/data/mapset/data/routing_geocoder/admin.bin&acao=true";
|
|
34
|
-
this._here = this.fetchAndExtractRelease(provider, url);
|
|
33
|
+
this._here = this.fetchAndExtractRelease(provider);
|
|
35
34
|
}
|
|
36
35
|
return this._here;
|
|
37
36
|
} else if (provider === "openstreetmap") {
|
|
38
37
|
if (!this._osm) {
|
|
39
|
-
|
|
40
|
-
"https://v1.maptrip.de/?CMD=GETFILE&PROJECT=OSM_latest&RELATIVEPATH=/data/mapset/data/routing_geocoder/admin.bin&acao=true";
|
|
41
|
-
this._osm = this.fetchAndExtractRelease(provider, url);
|
|
38
|
+
this._osm = this.fetchAndExtractRelease(provider);
|
|
42
39
|
}
|
|
43
40
|
return this._osm;
|
|
44
41
|
}
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private getUrl(provider: string): string {
|
|
47
|
+
const project = PROVIDER_PROJECTS[provider.toLowerCase()];
|
|
48
|
+
return `https://v0.maptrip.de/?CMD=GETFILE&PROJECT=${project}&RELATIVEPATH=/data/mapset/data/routing_geocoder/admin.bin&acao=true`;
|
|
45
49
|
}
|
|
46
50
|
|
|
47
|
-
async fetchAndExtractRelease(provider: string
|
|
51
|
+
async fetchAndExtractRelease(provider: string): Promise<string | null> {
|
|
52
|
+
|
|
53
|
+
const project = PROVIDER_PROJECTS[provider.toLowerCase()];
|
|
54
|
+
const url = `https://v0.maptrip.de/?CMD=GETFILE&PROJECT=${project}&RELATIVEPATH=/data/mapset/data/routing_geocoder/admin.bin&acao=true`;
|
|
55
|
+
|
|
48
56
|
return new Promise((resolve, reject) => {
|
|
49
57
|
var xhr = new XMLHttpRequest();
|
|
50
58
|
xhr.onreadystatechange = () => {
|
|
51
59
|
if (xhr.readyState !== XMLHttpRequest.DONE) return;
|
|
52
60
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
try {
|
|
62
|
+
if (xhr.status === 200) {
|
|
63
|
+
const text = new TextDecoder("latin1").decode(xhr.response);
|
|
64
|
+
const textString = this.extractTargetString(text);
|
|
65
|
+
const formattedString = textString!.split("Q").join(" Q");
|
|
66
|
+
const release = ` ${PROVIDER_NAMES[provider]} ${formattedString}`;
|
|
58
67
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
resolve(release);
|
|
69
|
+
} else {
|
|
70
|
+
reject(`Error fetching: ${xhr.status}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
reject(`Error fetching: ${e}`);
|
|
62
75
|
}
|
|
63
76
|
};
|
|
77
|
+
|
|
64
78
|
xhr.open("GET", url, true);
|
|
65
79
|
xhr.setRequestHeader("Authorization", `Bearer ${this._token}`);
|
|
66
80
|
xhr.setRequestHeader("Accept", "*/*");
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ATTRIBUTION } from "../core/constants.js";
|
|
2
|
+
import { MapReleaseFetcher } from "./MapReleaseFetcher.js";
|
|
3
|
+
|
|
4
|
+
class VectorTileUtils {
|
|
5
|
+
|
|
6
|
+
public static async getAttribution(token: string, provider?: string, attribution?: string, releaseDate?: boolean): Promise<string> {
|
|
7
|
+
|
|
8
|
+
let result: string[] = [ATTRIBUTION];
|
|
9
|
+
|
|
10
|
+
if (releaseDate ? releaseDate : false) {
|
|
11
|
+
const releaseFetcher = new MapReleaseFetcher(token);
|
|
12
|
+
|
|
13
|
+
const release = await releaseFetcher.getRelease(provider)
|
|
14
|
+
.catch(error => {
|
|
15
|
+
console.error('Failed to fetch release:', error);
|
|
16
|
+
return undefined;
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (release) {
|
|
20
|
+
result.push(release);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (attribution) {
|
|
25
|
+
result.push(attribution);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return result.join(", ");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { VectorTileUtils }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maptrip/map-tiles",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "API to use MapTrip map tiles in other map APIs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"map",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"types": "dist/map-tiles.d.ts",
|
|
20
20
|
"scripts": {
|
|
21
21
|
"dev": "vite src",
|
|
22
|
-
"prepublish": "tsc",
|
|
23
22
|
"build": "tsc && vite build",
|
|
24
|
-
"check-updates": "npm outdated
|
|
25
|
-
"
|
|
23
|
+
"check-updates": "npm outdated",
|
|
24
|
+
"prepublishOnly": "npm run build && npm login --scope=@maptrip",
|
|
25
|
+
"release": "npm publish --access public"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@googlemaps/js-api-loader": "^1.16.2",
|
|
@@ -31,20 +31,21 @@
|
|
|
31
31
|
"eslint": "^8.52.0",
|
|
32
32
|
"ol": "~8.2.x",
|
|
33
33
|
"typescript": "^5.4.5",
|
|
34
|
-
"vite": "^6.2.2"
|
|
34
|
+
"vite": "^6.2.2",
|
|
35
|
+
"vite-plugin-dts": "^4.5.3"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
38
|
"@types/geojson": "^7946.0.14",
|
|
38
39
|
"@types/webfontloader": "^1.6.38",
|
|
39
40
|
"rtree": "^1.4.2",
|
|
40
|
-
"vite-plugin-dts": "^4.5.3",
|
|
41
41
|
"webfontloader": "^1.6.28"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@googlemaps/js-api-loader": "^1.16.2",
|
|
45
45
|
"@types/leaflet": "^1.9.12",
|
|
46
46
|
"leaflet": "^1.9.x",
|
|
47
|
-
"ol": "~8.2.x"
|
|
47
|
+
"ol": "~8.2.x",
|
|
48
|
+
"maplibre-gl": "^6.16.0"
|
|
48
49
|
},
|
|
49
50
|
"directories": {
|
|
50
51
|
"lib": "lib"
|