@maptrip/map-tiles 1.1.1 → 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 +2 -0
- package/dist/api-extensions/google/MapTripGoogleMapType.d.ts +28 -0
- package/dist/api-extensions/leaflet/MapTripLeafletGridLayer.d.ts +25 -0
- package/dist/api-extensions/openlayers/MapTripOpenLayersSource.d.ts +19 -0
- package/dist/core/CollisionDetector.d.ts +14 -0
- package/dist/core/VectorTileFactory.d.ts +64 -0
- package/dist/core/VectorTileLoader.d.ts +40 -0
- package/dist/core/VectorTileRenderer.d.ts +123 -0
- package/dist/core/constants.d.ts +10 -0
- package/dist/core/rendering_config_default.d.ts +658 -0
- package/dist/core/rendering_config_grayscale.d.ts +672 -0
- package/dist/core/rendering_config_traffic.d.ts +39 -0
- package/dist/map-tiles.d.ts +9 -0
- package/dist/map-tiles.js +22856 -9398
- package/dist/map-tiles.js.map +1 -0
- package/dist/types/interfaces.d.ts +134 -0
- package/lib/api-extensions/google/MapTripGoogleMapType.ts +43 -0
- package/lib/api-extensions/leaflet/MapTripLeafletGridLayer.ts +48 -0
- package/lib/api-extensions/openlayers/MapTripOpenLayersSource.ts +62 -0
- package/lib/core/CollisionDetector.ts +95 -0
- package/lib/core/VectorTileFactory.ts +331 -0
- package/lib/core/VectorTileLoader.ts +165 -0
- package/lib/core/VectorTileRenderer.ts +1220 -0
- package/lib/core/constants.ts +21 -0
- package/lib/core/rendering_config_grayscale.ts +1129 -0
- package/lib/types/interfaces.ts +147 -0
- package/package.json +22 -17
- package/lib/api-extensions/google/MapTripGoogleMapType.js +0 -25
- package/lib/api-extensions/leaflet/MapTripLeafletGridLayer.js +0 -24
- package/lib/api-extensions/openlayers/MapTripOpenLayersSource.js +0 -43
- package/lib/core/CollisionDetector.js +0 -65
- package/lib/core/VectorTileFactory.js +0 -245
- package/lib/core/VectorTileLoader.js +0 -132
- package/lib/core/VectorTileRenderer.js +0 -826
- package/lib/core/constants.js +0 -18
- package/lib/core/rendering_config_grayscale.js +0 -1107
- /package/lib/core/{rendering_config_default.js → rendering_config_default.ts} +0 -0
- /package/lib/core/{rendering_config_traffic.js → rendering_config_traffic.ts} +0 -0
- /package/lib/{main.js → main.ts} +0 -0
package/README.md
CHANGED
|
@@ -274,6 +274,8 @@ To use them, you mapping API has to be able to use both base layers and overlays
|
|
|
274
274
|
|
|
275
275
|
## History
|
|
276
276
|
|
|
277
|
+
- 1.2.1: Fixed a bug in MapTripLeafletGridLayer type implementation
|
|
278
|
+
- 1.2.0: Added TypeScript declaration file
|
|
277
279
|
- 1.1.1: Added rendering config for foot_path layer
|
|
278
280
|
- 1.1.0: Added MapTrip detour profiles
|
|
279
281
|
- 1.0.8: First public version
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RENDERING_CONFIG, PointXY } from '../../types/interfaces.js';
|
|
2
|
+
import { VectorTileFactory } from '../../core/VectorTileFactory.js';
|
|
3
|
+
|
|
4
|
+
declare class MapTripGoogleMapType {
|
|
5
|
+
tileSize: google.maps.Size;
|
|
6
|
+
alt: null;
|
|
7
|
+
maxZoom: number;
|
|
8
|
+
minZoom: number;
|
|
9
|
+
projection: null;
|
|
10
|
+
radius: number;
|
|
11
|
+
name: string;
|
|
12
|
+
token: string;
|
|
13
|
+
factory: VectorTileFactory;
|
|
14
|
+
constructor(properties: {
|
|
15
|
+
provider?: string;
|
|
16
|
+
baseMap?: boolean;
|
|
17
|
+
traffic?: boolean;
|
|
18
|
+
timeout?: number;
|
|
19
|
+
parallelDownloads?: number;
|
|
20
|
+
detourProfile?: string;
|
|
21
|
+
renderingConfig?: RENDERING_CONFIG;
|
|
22
|
+
token?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
});
|
|
25
|
+
getTile(coord: PointXY, zoom: number): HTMLCanvasElement;
|
|
26
|
+
releaseTile(): void;
|
|
27
|
+
}
|
|
28
|
+
export { MapTripGoogleMapType };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PointXY, RENDERING_CONFIG } from '../../types/interfaces.js';
|
|
2
|
+
import { VectorTileFactory } from '../../core/VectorTileFactory.js';
|
|
3
|
+
import { default as L } from 'leaflet';
|
|
4
|
+
|
|
5
|
+
declare class MapTripLeafletGridLayer extends L.GridLayer {
|
|
6
|
+
MIN_ZOOM: number;
|
|
7
|
+
MAX_ZOOM: number;
|
|
8
|
+
token: string;
|
|
9
|
+
factory: VectorTileFactory;
|
|
10
|
+
constructor(options: {
|
|
11
|
+
provider?: string;
|
|
12
|
+
baseMap?: boolean;
|
|
13
|
+
traffic?: boolean;
|
|
14
|
+
timeout?: number;
|
|
15
|
+
parallelDownloads?: number;
|
|
16
|
+
detourProfile?: string;
|
|
17
|
+
renderingConfig?: RENDERING_CONFIG;
|
|
18
|
+
token?: string;
|
|
19
|
+
attribution?: string;
|
|
20
|
+
minZoom?: number;
|
|
21
|
+
maxZoom?: number;
|
|
22
|
+
});
|
|
23
|
+
createTile(coords: PointXY): HTMLCanvasElement;
|
|
24
|
+
}
|
|
25
|
+
export { MapTripLeafletGridLayer };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RENDERING_CONFIG } from '../../types/interfaces.js';
|
|
2
|
+
import { VectorTileFactory } from '../../core/VectorTileFactory.js';
|
|
3
|
+
import { default as XYZ } from 'ol/source/XYZ.js';
|
|
4
|
+
|
|
5
|
+
declare class MapTripOpenLayersSource extends XYZ {
|
|
6
|
+
token: string;
|
|
7
|
+
factory: VectorTileFactory;
|
|
8
|
+
constructor(properties: {
|
|
9
|
+
provider?: string;
|
|
10
|
+
baseMap?: boolean;
|
|
11
|
+
traffic?: boolean;
|
|
12
|
+
timeout?: number;
|
|
13
|
+
parallelDownloads?: number;
|
|
14
|
+
detourProfile?: string;
|
|
15
|
+
renderingConfig?: RENDERING_CONFIG;
|
|
16
|
+
token?: string;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export { MapTripOpenLayersSource };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PositionXY } from '../types/interfaces.js';
|
|
2
|
+
|
|
3
|
+
declare class CollisionDetector {
|
|
4
|
+
private _tree;
|
|
5
|
+
constructor();
|
|
6
|
+
insert(x: number, y: number, w: number, h: number): void;
|
|
7
|
+
insertPolylineText(context: CanvasRenderingContext2D, text: string, position: PositionXY): void;
|
|
8
|
+
isCollision(x: number, y: number, w: number, h: number): boolean;
|
|
9
|
+
isPolylineTextCollision(context: CanvasRenderingContext2D, text: string, position: PositionXY): boolean;
|
|
10
|
+
getCollisionParams(context: CanvasRenderingContext2D, text: string, position: PositionXY, widthUsed: number): {
|
|
11
|
+
[key: string]: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export { CollisionDetector };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { SuccessCallback, MapTilesProperties, RENDERING_CONFIG } from '../types/interfaces.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a factory to create tiles from the provided URL templates.
|
|
5
|
+
*
|
|
6
|
+
* The templates must have variables ${x}, ${y} and ${z} for the tile index.
|
|
7
|
+
* When multiple URLs are specified, they are used round robin.
|
|
8
|
+
*/
|
|
9
|
+
declare class VectorTileFactory {
|
|
10
|
+
private _layers;
|
|
11
|
+
private _tileLoader;
|
|
12
|
+
private _renderer;
|
|
13
|
+
private _urls;
|
|
14
|
+
private _additionalUrls;
|
|
15
|
+
static _fonts: string | undefined;
|
|
16
|
+
static _properties: typeof VectorTileFactory.DEFAULT_PROPERTIES;
|
|
17
|
+
constructor(urls: string[], additionalUrls: string[], renderingConfig: RENDERING_CONFIG, properties: MapTilesProperties);
|
|
18
|
+
static createFactory(properties: {
|
|
19
|
+
provider?: string;
|
|
20
|
+
baseMap?: boolean;
|
|
21
|
+
traffic?: boolean;
|
|
22
|
+
timeout?: number;
|
|
23
|
+
parallelDownloads?: number;
|
|
24
|
+
detourProfile?: string;
|
|
25
|
+
renderingConfig?: RENDERING_CONFIG;
|
|
26
|
+
}): VectorTileFactory;
|
|
27
|
+
private static getUrlTemplatesForBaseLayer;
|
|
28
|
+
private static getUrlTemplatesForTrafficLayer;
|
|
29
|
+
private static getRenderingConfig;
|
|
30
|
+
getJsonTile(z: number, x: number, y: number, token: string, callback?: SuccessCallback): HTMLCanvasElement;
|
|
31
|
+
/**
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
private resolveTileUrl;
|
|
35
|
+
/**
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
private tileIndexToLatLong;
|
|
39
|
+
/**
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
private getTileBoundaries;
|
|
43
|
+
/**
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
private drawTile;
|
|
47
|
+
/**
|
|
48
|
+
* Draws an error message on the tile.
|
|
49
|
+
* @private
|
|
50
|
+
*
|
|
51
|
+
* @param canvas
|
|
52
|
+
*/
|
|
53
|
+
private drawErroredTile;
|
|
54
|
+
/**
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
private getFeatures;
|
|
58
|
+
static DEFAULT_PROPERTIES: {
|
|
59
|
+
provider: string;
|
|
60
|
+
baseMap: boolean;
|
|
61
|
+
traffic: boolean;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export { VectorTileFactory };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SuccessCallback, TileQueueItem, Tile, MapTilesProperties } from '../types/interfaces.js';
|
|
2
|
+
|
|
3
|
+
declare class VectorTileLoader {
|
|
4
|
+
private _properties;
|
|
5
|
+
private _tiles;
|
|
6
|
+
private _numLoading;
|
|
7
|
+
constructor(properties: MapTilesProperties);
|
|
8
|
+
queue(tile: Tile, successCallback: SuccessCallback, errorCallback: ErrorCallback): void;
|
|
9
|
+
loadNext(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a HTTP Request is successful
|
|
12
|
+
*
|
|
13
|
+
* @param {XMLHttpRequest} httpRequest
|
|
14
|
+
*
|
|
15
|
+
* @return {boolean}
|
|
16
|
+
*/
|
|
17
|
+
isHttpRequestSuccessful(httpRequest: XMLHttpRequest): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if a HTTP Request has failed (there was a timeout or the status code is an error)
|
|
20
|
+
*
|
|
21
|
+
* @param {XMLHttpRequest} httpRequest
|
|
22
|
+
*
|
|
23
|
+
* @return {boolean}
|
|
24
|
+
*/
|
|
25
|
+
isHttpRequestFailed(httpRequest: XMLHttpRequest): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a HTTP Request has timed out
|
|
28
|
+
*
|
|
29
|
+
* @param {XMLHttpRequest} httpRequest
|
|
30
|
+
*
|
|
31
|
+
* @return {boolean}
|
|
32
|
+
*/
|
|
33
|
+
isHttpRequestTimeout(httpRequest: XMLHttpRequest): boolean;
|
|
34
|
+
loadAllUrls(tile: TileQueueItem, urls: string[]): void;
|
|
35
|
+
static DEFAULT_PROPERTIES: {
|
|
36
|
+
timeout: number;
|
|
37
|
+
parallelDownloads: number;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export { VectorTileLoader };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Boundaries, PointXY, PolygonStyle, PolylineStyle, PolylineTextStyle, PositionXY, Renderer, Vertex, RENDERING_CONFIG } from '../types/interfaces.js';
|
|
2
|
+
import { CollisionDetector } from './CollisionDetector.js';
|
|
3
|
+
import { GeoJsonProperties } from 'geojson';
|
|
4
|
+
|
|
5
|
+
declare class VectorTileRenderer {
|
|
6
|
+
private _styles;
|
|
7
|
+
private _images;
|
|
8
|
+
constructor(styles: RENDERING_CONFIG);
|
|
9
|
+
drawTile(layer: GeoJSON.Feature<GeoJSON.Geometry, GeoJSON.GeoJsonProperties>[], z: number, boundaries: Boundaries, context: CanvasRenderingContext2D): void;
|
|
10
|
+
drawPolylineLayers(lines: GeoJSON.Feature<GeoJSON.Geometry, GeoJSON.GeoJsonProperties>[], z: number, boundaries: Boundaries, context: CanvasRenderingContext2D, phase: string, collisions: CollisionDetector): void;
|
|
11
|
+
drawErroredTile(canvas: HTMLCanvasElement): void;
|
|
12
|
+
drawTilePhase(layer: GeoJSON.Feature<GeoJSON.Geometry, GeoJSON.GeoJsonProperties>[], z: number, boundaries: Boundaries, context: CanvasRenderingContext2D, phase: string, collisions: CollisionDetector): void;
|
|
13
|
+
/**
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
getBackgroundColor(z: number): string;
|
|
17
|
+
/**
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
accept(style: Renderer, layer: GeoJSON.Feature<GeoJSON.Geometry, GeoJSON.GeoJsonProperties>): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
drawPolygon(coordinates: GeoJSON.Position[][], geoJsonProperties: GeoJsonProperties, z: number, boundaries: Boundaries, style: PolygonStyle, context: CanvasRenderingContext2D, phase: string, collisions?: CollisionDetector, texts?: {
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
}): void;
|
|
27
|
+
getCentroid(vertices: Vertex[]): Vertex;
|
|
28
|
+
getBBox(coordinates: PointXY[]): {
|
|
29
|
+
min: {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
};
|
|
33
|
+
max: {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
projectCoordinates(coordinates: GeoJSON.Position[], boundaries: Boundaries): {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
}[];
|
|
45
|
+
/**
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
48
|
+
drawPolyline(coordinates: GeoJSON.Position[], geoJsonProperties: GeoJsonProperties, boundaries: Boundaries, style: PolylineStyle, context: CanvasRenderingContext2D, phase: "linesOutline" | "lines"): void;
|
|
49
|
+
drawPolylineText(coordinates: GeoJSON.Position[], geoJsonProperties: GeoJsonProperties, boundaries: Boundaries, style: PolylineTextStyle | undefined, context: CanvasRenderingContext2D, collisions: CollisionDetector, texts: {
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
}): void;
|
|
52
|
+
getPolylineLength(points: PointXY[]): number;
|
|
53
|
+
getAngleAndCoordsAtLength(points: PointXY[], dist: number, width: number): {
|
|
54
|
+
angle: number;
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
} | undefined;
|
|
58
|
+
getLetterPositions(points: PointXY[], text: string, context: CanvasRenderingContext2D, collisions: CollisionDetector): {
|
|
59
|
+
angle: number;
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
}[] | null;
|
|
63
|
+
/**
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
drawLetter(letter: string, position: PositionXY, outline: number, context: CanvasRenderingContext2D): void;
|
|
67
|
+
/**
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
drawPath(points: PointXY[], color: string, width: number, context: CanvasRenderingContext2D): void;
|
|
71
|
+
drawImage(coordinate: number[], boundaries: Boundaries, style: PolylineStyle, context: CanvasRenderingContext2D): void;
|
|
72
|
+
/**
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
isTextCollision(coordinate: GeoJSON.Position, name: string, boundaries: Boundaries, style: PolylineTextStyle, context: CanvasRenderingContext2D, collisions: CollisionDetector): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* @private
|
|
78
|
+
*/
|
|
79
|
+
drawText(coordinate: GeoJSON.Position, name: string, boundaries: Boundaries, style: PolylineTextStyle, context: CanvasRenderingContext2D, collisions: CollisionDetector): void;
|
|
80
|
+
preloadImages(): void;
|
|
81
|
+
findConfiguredFonts(): string[];
|
|
82
|
+
static DEFAULT_STYLE: {
|
|
83
|
+
POLYGON: {
|
|
84
|
+
color: string;
|
|
85
|
+
url: undefined;
|
|
86
|
+
outlineColor: undefined;
|
|
87
|
+
outlineWidth: number;
|
|
88
|
+
opacity: number;
|
|
89
|
+
};
|
|
90
|
+
LINE: {
|
|
91
|
+
color: string;
|
|
92
|
+
url: undefined;
|
|
93
|
+
height: number;
|
|
94
|
+
dx: number;
|
|
95
|
+
dy: number;
|
|
96
|
+
direction: string;
|
|
97
|
+
width: number;
|
|
98
|
+
outlineColor: undefined;
|
|
99
|
+
outlineWidth: number;
|
|
100
|
+
dashColor: undefined;
|
|
101
|
+
dashLength: number;
|
|
102
|
+
opacity: number;
|
|
103
|
+
};
|
|
104
|
+
IMAGE: {
|
|
105
|
+
url: undefined;
|
|
106
|
+
width: number;
|
|
107
|
+
height: number;
|
|
108
|
+
dx: number;
|
|
109
|
+
dy: number;
|
|
110
|
+
};
|
|
111
|
+
TEXT: {
|
|
112
|
+
color: string;
|
|
113
|
+
outlineColor: undefined;
|
|
114
|
+
outlineWidth: number;
|
|
115
|
+
font: string;
|
|
116
|
+
fontWeight: string;
|
|
117
|
+
fontStyle: string;
|
|
118
|
+
size: number;
|
|
119
|
+
opacity: number;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export { VectorTileRenderer };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const URL_TEMPLATE = "https://v${index}.maptrip.de/?tilex=${x}&tiley=${y}&acao=true&context=tomtom${z}&project=${project}&projection=wgs84";
|
|
2
|
+
export declare const PROVIDER_PROJECTS: {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const PROVIDER_TRAFFIC: {
|
|
6
|
+
[key: string]: string | null;
|
|
7
|
+
};
|
|
8
|
+
export declare const MIN_ZOOM = 2;
|
|
9
|
+
export declare const MAX_ZOOM = 18;
|
|
10
|
+
export declare const ATTRIBUTION = "© <a href=\"https://maptrip.de/\" target=\"_blank\">infoware GmbH</a>";
|