@maptrip/map-tiles 1.2.0 → 1.2.1
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 +1 -0
- package/dist/api-extensions/google/MapTripGoogleMapType.d.ts +1 -1
- package/dist/api-extensions/leaflet/MapTripLeafletGridLayer.d.ts +22 -1
- package/dist/core/VectorTileFactory.d.ts +1 -1
- package/dist/core/VectorTileRenderer.d.ts +1 -1
- package/dist/core/rendering_config_grayscale.d.ts +34 -0
- package/dist/map-tiles.d.ts +2 -2
- package/dist/map-tiles.js +884 -861
- package/dist/map-tiles.js.map +1 -1
- package/dist/types/interfaces.d.ts +8 -9
- package/lib/api-extensions/google/MapTripGoogleMapType.ts +4 -1
- package/lib/api-extensions/leaflet/MapTripLeafletGridLayer.ts +29 -25
- package/lib/api-extensions/openlayers/MapTripOpenLayersSource.ts +1 -0
- package/lib/core/VectorTileFactory.ts +16 -12
- package/lib/core/VectorTileRenderer.ts +13 -5
- package/lib/core/rendering_config_grayscale.ts +1126 -1104
- package/lib/main.ts +0 -2
- package/lib/types/interfaces.ts +10 -10
- package/package.json +5 -5
|
@@ -35,13 +35,6 @@ export interface Renderer {
|
|
|
35
35
|
dy: number;
|
|
36
36
|
};
|
|
37
37
|
filters?: Filter[];
|
|
38
|
-
[key: string]: any;
|
|
39
|
-
}
|
|
40
|
-
export interface Filter {
|
|
41
|
-
interface: string;
|
|
42
|
-
key: string;
|
|
43
|
-
value?: any;
|
|
44
|
-
type: string;
|
|
45
38
|
}
|
|
46
39
|
export interface RENDERING_CONFIG {
|
|
47
40
|
background: {
|
|
@@ -56,6 +49,12 @@ export interface RENDERING_CONFIG {
|
|
|
56
49
|
[key: string]: Renderer[];
|
|
57
50
|
};
|
|
58
51
|
}
|
|
52
|
+
export interface Filter {
|
|
53
|
+
interface: string;
|
|
54
|
+
key: string;
|
|
55
|
+
value?: any;
|
|
56
|
+
type: string;
|
|
57
|
+
}
|
|
59
58
|
export interface PolylineTextStyle {
|
|
60
59
|
size: number;
|
|
61
60
|
color: string;
|
|
@@ -79,8 +78,8 @@ export interface PolygonStyle {
|
|
|
79
78
|
opacity?: number | undefined;
|
|
80
79
|
outlineColor?: string | undefined;
|
|
81
80
|
outlineWidth?: number | undefined;
|
|
82
|
-
url
|
|
83
|
-
font
|
|
81
|
+
url?: string | undefined;
|
|
82
|
+
font?: string | undefined;
|
|
84
83
|
fontStyle?: string | undefined;
|
|
85
84
|
fontWeight?: string | undefined;
|
|
86
85
|
size?: number | undefined;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { VectorTileFactory } from "../../core/VectorTileFactory.js";
|
|
2
2
|
import { MIN_ZOOM, MAX_ZOOM } from "../../core/constants.js";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
RENDERING_CONFIG
|
|
5
|
+
} from "../../types/interfaces.js";
|
|
6
|
+
import { PointXY } from "../../types/interfaces.js";
|
|
4
7
|
|
|
5
8
|
class MapTripGoogleMapType {
|
|
6
9
|
tileSize = new google.maps.Size(256, 256);
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import L from "leaflet";
|
|
2
|
-
|
|
3
2
|
import { VectorTileFactory } from "../../core/VectorTileFactory.js";
|
|
4
3
|
import { MIN_ZOOM, MAX_ZOOM, ATTRIBUTION } from "../../core/constants.js";
|
|
5
|
-
import type { PointXY
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
MAX_ZOOM: MAX_ZOOM,
|
|
4
|
+
import type { PointXY } from "../../types/interfaces.js";
|
|
5
|
+
import {
|
|
6
|
+
RENDERING_CONFIG
|
|
7
|
+
} from "../../types/interfaces.js";
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
class MapTripLeafletGridLayer extends L.GridLayer {
|
|
10
|
+
MIN_ZOOM = MIN_ZOOM;
|
|
11
|
+
MAX_ZOOM = MAX_ZOOM;
|
|
12
|
+
token: string;
|
|
13
|
+
factory: VectorTileFactory;
|
|
14
|
+
constructor(options: {
|
|
12
15
|
provider?: string;
|
|
13
16
|
baseMap?: boolean;
|
|
14
17
|
traffic?: boolean;
|
|
@@ -21,24 +24,25 @@ const MapTripLeafletGridLayer = L.GridLayer.extend({
|
|
|
21
24
|
minZoom?: number;
|
|
22
25
|
maxZoom?: number;
|
|
23
26
|
}) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
super(options as L.GridLayerOptions);
|
|
28
|
+
this.token = options.token!;
|
|
29
|
+
this.options.attribution = options.attribution
|
|
30
|
+
? options.attribution
|
|
31
|
+
: ATTRIBUTION;
|
|
32
|
+
//@ts-expect-error picking up LayerOptions rather than GridLayerOptions
|
|
33
|
+
this.options.minZoom = options.minZoom
|
|
34
|
+
? Math.max(this.MIN_ZOOM, options.minZoom)
|
|
35
|
+
: this.MIN_ZOOM;
|
|
36
|
+
//@ts-expect-error
|
|
37
|
+
this.options.maxZoom = options.maxZoom
|
|
38
|
+
? Math.min(this.MAX_ZOOM, options.maxZoom)
|
|
39
|
+
: this.MAX_ZOOM;
|
|
40
|
+
this.factory = VectorTileFactory.createFactory(options);
|
|
41
|
+
}
|
|
38
42
|
|
|
39
|
-
createTile
|
|
40
|
-
return this.factory.getJsonTile(coords.z
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
+
createTile(coords: PointXY) {
|
|
44
|
+
return this.factory.getJsonTile(coords.z!, coords.x, coords.y, this.token);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
43
47
|
|
|
44
48
|
export { MapTripLeafletGridLayer };
|
|
@@ -8,18 +8,18 @@ import {
|
|
|
8
8
|
PROVIDER_TRAFFIC,
|
|
9
9
|
} from "./constants.js";
|
|
10
10
|
|
|
11
|
+
import WebFont from "webfontloader";
|
|
11
12
|
import { RENDERING_CONFIG_DEFAULT } from "./rendering_config_default.js";
|
|
12
13
|
import { RENDERING_CONFIG_TRAFFIC } from "./rendering_config_traffic.js";
|
|
13
14
|
|
|
14
|
-
import WebFont from "webfontloader";
|
|
15
15
|
import {
|
|
16
16
|
Boundaries,
|
|
17
17
|
Coordinates,
|
|
18
|
-
RENDERING_CONFIG,
|
|
19
18
|
SuccessCallback,
|
|
20
19
|
MapTilesProperties,
|
|
21
20
|
} from "../types/interfaces.js";
|
|
22
21
|
|
|
22
|
+
import { RENDERING_CONFIG } from "../types/interfaces.js"
|
|
23
23
|
/**
|
|
24
24
|
* Creates a factory to create tiles from the provided URL templates.
|
|
25
25
|
*
|
|
@@ -145,17 +145,21 @@ class VectorTileFactory {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
private static getRenderingConfig(properties:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
148
|
+
private static getRenderingConfig(properties: {
|
|
149
|
+
provider?: string;
|
|
150
|
+
baseMap?: boolean;
|
|
151
|
+
traffic?: boolean;
|
|
152
|
+
timeout?: number;
|
|
153
|
+
parallelDownloads?: number;
|
|
154
|
+
detourProfile?: string;
|
|
155
|
+
renderingConfig?: RENDERING_CONFIG;
|
|
156
|
+
}) {
|
|
157
|
+
if (properties.renderingConfig) {
|
|
158
|
+
return properties.renderingConfig;
|
|
159
|
+
} else if (properties.baseMap) {
|
|
158
160
|
return RENDERING_CONFIG_DEFAULT;
|
|
161
|
+
} else {
|
|
162
|
+
return RENDERING_CONFIG_TRAFFIC;
|
|
159
163
|
}
|
|
160
164
|
}
|
|
161
165
|
|
|
@@ -15,11 +15,12 @@ import {
|
|
|
15
15
|
PolylineStyle,
|
|
16
16
|
PolylineTextStyle,
|
|
17
17
|
PositionXY,
|
|
18
|
-
RENDERING_CONFIG,
|
|
19
18
|
Renderer,
|
|
20
19
|
Vertex,
|
|
21
20
|
} from "../types/interfaces.js";
|
|
22
21
|
|
|
22
|
+
import { RENDERING_CONFIG} from "../types/interfaces.js"
|
|
23
|
+
|
|
23
24
|
class VectorTileRenderer {
|
|
24
25
|
private _styles: RENDERING_CONFIG;
|
|
25
26
|
private _images: { [key: string]: HTMLImageElement };
|
|
@@ -159,9 +160,11 @@ class VectorTileRenderer {
|
|
|
159
160
|
const geometry = layer[i].geometry;
|
|
160
161
|
|
|
161
162
|
// Look up the renderer for this kind of data
|
|
162
|
-
|
|
163
|
+
//@ts-ignore
|
|
164
|
+
const rendererName = this._styles.layers[kind];
|
|
163
165
|
const renderer = rendererName
|
|
164
|
-
?
|
|
166
|
+
? //@ts-ignore
|
|
167
|
+
this._styles?.renderers[rendererName]
|
|
165
168
|
: undefined;
|
|
166
169
|
|
|
167
170
|
if (renderer) {
|
|
@@ -426,7 +429,7 @@ class VectorTileRenderer {
|
|
|
426
429
|
texts?: { [key: string]: any }
|
|
427
430
|
): void {
|
|
428
431
|
if (style) {
|
|
429
|
-
|
|
432
|
+
let merged = { ...VectorTileRenderer.DEFAULT_STYLE.POLYGON, ...style };
|
|
430
433
|
|
|
431
434
|
for (var j = 0; j < coordinates.length; j++) {
|
|
432
435
|
var part = coordinates[j];
|
|
@@ -491,7 +494,7 @@ class VectorTileRenderer {
|
|
|
491
494
|
return;
|
|
492
495
|
}
|
|
493
496
|
|
|
494
|
-
merged = { ...VectorTileRenderer.DEFAULT_STYLE.TEXT, ...style };
|
|
497
|
+
let merged = { ...VectorTileRenderer.DEFAULT_STYLE.TEXT, ...style };
|
|
495
498
|
|
|
496
499
|
context.globalAlpha = merged.opacity;
|
|
497
500
|
context.font =
|
|
@@ -1123,8 +1126,11 @@ class VectorTileRenderer {
|
|
|
1123
1126
|
|
|
1124
1127
|
preloadImages(): void {
|
|
1125
1128
|
for (const name in this._styles?.renderers) {
|
|
1129
|
+
//@ts-ignore not allowing for bracket notation
|
|
1126
1130
|
for (let i = 0; i < this._styles.renderers[name].length; i++) {
|
|
1131
|
+
//@ts-ignore not allowing for bracket notation
|
|
1127
1132
|
for (const renderer in this._styles.renderers[name][i]) {
|
|
1133
|
+
//@ts-ignore not allowing for bracket notation
|
|
1128
1134
|
const config = this._styles.renderers[name][i][renderer];
|
|
1129
1135
|
|
|
1130
1136
|
if (config.url) {
|
|
@@ -1146,7 +1152,9 @@ class VectorTileRenderer {
|
|
|
1146
1152
|
let result = [];
|
|
1147
1153
|
|
|
1148
1154
|
for (let renderer in this._styles?.renderers) {
|
|
1155
|
+
//@ts-ignore not allowing for bracket notation
|
|
1149
1156
|
for (let i = 0; i < this._styles.renderers[renderer].length; i++) {
|
|
1157
|
+
//@ts-ignore not allowing for bracket notation
|
|
1150
1158
|
let text = this._styles.renderers[renderer][i].text;
|
|
1151
1159
|
if (text) {
|
|
1152
1160
|
let merged = { ...VectorTileRenderer.DEFAULT_STYLE.TEXT, ...text };
|