@superrouteca/smap 0.0.0-stage → 1.0.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/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +92 -2
- package/dist/SOURCE.json +18 -0
- package/dist/smap-client.cjs +301 -0
- package/dist/smap-client.d.cts +43 -0
- package/dist/smap-client.d.mts +44 -0
- package/dist/smap-client.mjs +308 -0
- package/dist/smap.cjs +635 -0
- package/dist/smap.css +1 -0
- package/dist/smap.mjs +631 -0
- package/dist/vendor-licenses.txt +116 -0
- package/package.json +55 -4
- package/types/smap.d.cts +182 -0
- package/types/smap.d.mts +182 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
Copyright (c) 2023, MapLibre contributors
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
6
|
+
are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright notice,
|
|
9
|
+
this list of conditions and the following disclaimer.
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
and/or other materials provided with the distribution.
|
|
13
|
+
* Neither the name of MapLibre GL JS nor the names of its contributors
|
|
14
|
+
may be used to endorse or promote products derived from this software
|
|
15
|
+
without specific prior written permission.
|
|
16
|
+
|
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
18
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
19
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
20
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
21
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
22
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
23
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
24
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
25
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
26
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
27
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
-------------------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
Contains code from mapbox-gl-js v1.13 and earlier
|
|
33
|
+
|
|
34
|
+
Version v1.13 of mapbox-gl-js and earlier are licensed under a BSD-3-Clause license
|
|
35
|
+
|
|
36
|
+
Copyright (c) 2020, Mapbox
|
|
37
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
38
|
+
are permitted provided that the following conditions are met:
|
|
39
|
+
|
|
40
|
+
* Redistributions of source code must retain the above copyright notice,
|
|
41
|
+
this list of conditions and the following disclaimer.
|
|
42
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
43
|
+
this list of conditions and the following disclaimer in the documentation
|
|
44
|
+
and/or other materials provided with the distribution.
|
|
45
|
+
* Neither the name of Mapbox GL JS nor the names of its contributors
|
|
46
|
+
may be used to endorse or promote products derived from this software
|
|
47
|
+
without specific prior written permission.
|
|
48
|
+
|
|
49
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
50
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
51
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
52
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
53
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
54
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
55
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
56
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
57
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
58
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
59
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
-------------------------------------------------------------------------------
|
|
63
|
+
|
|
64
|
+
Contains code from glfx.js
|
|
65
|
+
|
|
66
|
+
Copyright (C) 2011 by Evan Wallace
|
|
67
|
+
|
|
68
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
69
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
70
|
+
in the Software without restriction, including without limitation the rights
|
|
71
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
72
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
73
|
+
furnished to do so, subject to the following conditions:
|
|
74
|
+
|
|
75
|
+
The above copyright notice and this permission notice shall be included in
|
|
76
|
+
all copies or substantial portions of the Software.
|
|
77
|
+
|
|
78
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
79
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
80
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
81
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
82
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
83
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
84
|
+
THE SOFTWARE.
|
|
85
|
+
|
|
86
|
+
--------------------------------------------------------------------------------
|
|
87
|
+
|
|
88
|
+
Contains a portion of d3-color https://github.com/d3/d3-color
|
|
89
|
+
|
|
90
|
+
Copyright 2010-2016 Mike Bostock
|
|
91
|
+
All rights reserved.
|
|
92
|
+
|
|
93
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
94
|
+
are permitted provided that the following conditions are met:
|
|
95
|
+
|
|
96
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
97
|
+
list of conditions and the following disclaimer.
|
|
98
|
+
|
|
99
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
100
|
+
this list of conditions and the following disclaimer in the documentation
|
|
101
|
+
and/or other materials provided with the distribution.
|
|
102
|
+
|
|
103
|
+
* Neither the name of the author nor the names of contributors may be used to
|
|
104
|
+
endorse or promote products derived from this software without specific prior
|
|
105
|
+
written permission.
|
|
106
|
+
|
|
107
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
108
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
109
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
110
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
111
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
112
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
113
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
114
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
115
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
116
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superrouteca/smap",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Maps from Superroute's sMap service: the Web SDK (map view) and the JS client (tokens, nearest node, styles, tiles).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Goodneo Solutions",
|
|
7
|
+
"homepage": "https://github.com/Goodneo-Solutions/smap-sdk/tree/main/js#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Goodneo-Solutions/smap-sdk.git",
|
|
11
|
+
"directory": "js"
|
|
12
|
+
},
|
|
13
|
+
"keywords": ["map", "maps", "vector-tiles", "smap", "superroute"],
|
|
14
|
+
"sideEffects": ["*.css"],
|
|
15
|
+
"main": "./dist/smap.cjs",
|
|
16
|
+
"module": "./dist/smap.mjs",
|
|
17
|
+
"types": "./types/smap.d.cts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./types/smap.d.mts",
|
|
22
|
+
"default": "./dist/smap.mjs"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./types/smap.d.cts",
|
|
26
|
+
"default": "./dist/smap.cjs"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"./client": {
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./dist/smap-client.d.mts",
|
|
32
|
+
"default": "./dist/smap-client.mjs"
|
|
33
|
+
},
|
|
34
|
+
"require": {
|
|
35
|
+
"types": "./dist/smap-client.d.cts",
|
|
36
|
+
"default": "./dist/smap-client.cjs"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"./smap.css": "./dist/smap.css",
|
|
40
|
+
"./package.json": "./package.json"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"types",
|
|
45
|
+
"README.md",
|
|
46
|
+
"CHANGELOG.md",
|
|
47
|
+
"LICENSE"
|
|
48
|
+
],
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=18"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"sync": "../tools/sync-js.sh",
|
|
54
|
+
"prepack": "cp ../LICENSE LICENSE",
|
|
55
|
+
"test": "node --test test/*.test.mjs"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/types/smap.d.cts
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// Types of the sMap Web SDK (`@superrouteca/smap`). Kept by hand beside the generated code in dist/; smap.d.mts and
|
|
2
|
+
// smap.d.cts hold the same text (test/types.test.mjs checks).
|
|
3
|
+
|
|
4
|
+
export type StyleFlavor = 'light' | 'white' | 'grayscale' | 'dark' | 'black';
|
|
5
|
+
|
|
6
|
+
/** A position as [longitude, latitude]. */
|
|
7
|
+
export type LngLatLike = [number, number] | { lng: number; lat: number } | { lon: number; lat: number };
|
|
8
|
+
|
|
9
|
+
export type GeoJSONGeometry = { type: string; coordinates?: unknown; geometries?: unknown[] };
|
|
10
|
+
export interface GeoJSONFeature<P = Record<string, unknown>> {
|
|
11
|
+
type: 'Feature';
|
|
12
|
+
id?: string | number;
|
|
13
|
+
properties: P | null;
|
|
14
|
+
geometry: GeoJSONGeometry;
|
|
15
|
+
}
|
|
16
|
+
export interface GeoJSONFeatureCollection<P = Record<string, unknown>> {
|
|
17
|
+
type: 'FeatureCollection';
|
|
18
|
+
features: GeoJSONFeature<P>[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** A point given as an object: `{lng, lat}` (or `lon` / `longitude` / `latitude`, or `coordinates`) plus properties. */
|
|
22
|
+
export interface PointInput {
|
|
23
|
+
lat?: number;
|
|
24
|
+
lng?: number;
|
|
25
|
+
lon?: number;
|
|
26
|
+
latitude?: number;
|
|
27
|
+
longitude?: number;
|
|
28
|
+
coordinates?: [number, number];
|
|
29
|
+
id?: string | number;
|
|
30
|
+
[property: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Layer data: GeoJSON (a FeatureCollection or a Feature) or an array of points or features. */
|
|
34
|
+
export type LayerData = GeoJSONFeatureCollection | GeoJSONFeature | Array<PointInput | GeoJSONFeature> | null | undefined;
|
|
35
|
+
|
|
36
|
+
/** The event of a click on a layer's feature (the engine's map mouse event). */
|
|
37
|
+
export interface LayerClickEvent {
|
|
38
|
+
lngLat: { lng: number; lat: number };
|
|
39
|
+
point: { x: number; y: number };
|
|
40
|
+
features?: GeoJSONFeature[];
|
|
41
|
+
originalEvent?: Event;
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface CommonLayerOptions {
|
|
46
|
+
/** Higher draws on top; equal values keep the order added. */
|
|
47
|
+
zIndex?: number;
|
|
48
|
+
minzoom?: number;
|
|
49
|
+
maxzoom?: number;
|
|
50
|
+
/** A feature property used as the feature id. */
|
|
51
|
+
idProperty?: string;
|
|
52
|
+
/** HTML for a popup opened on click, from the clicked feature's properties. */
|
|
53
|
+
popup?: (properties: Record<string, unknown>, feature: GeoJSONFeature) => string | null | undefined | false;
|
|
54
|
+
onClick?: (feature: GeoJSONFeature, event: LayerClickEvent) => void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface PointOptions extends CommonLayerOptions {
|
|
58
|
+
/** Groups nearby points into circles sized by their count; a click zooms in to split them. */
|
|
59
|
+
cluster?: boolean | { radius?: number; maxZoom?: number };
|
|
60
|
+
clusterColor?: string;
|
|
61
|
+
color?: string;
|
|
62
|
+
radius?: number;
|
|
63
|
+
strokeColor?: string;
|
|
64
|
+
strokeWidth?: number;
|
|
65
|
+
/** An image URL drawn instead of a circle. */
|
|
66
|
+
icon?: string;
|
|
67
|
+
iconSize?: number;
|
|
68
|
+
iconAnchor?: string;
|
|
69
|
+
/** The property written under each point. */
|
|
70
|
+
label?: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface LineOptions extends CommonLayerOptions {
|
|
74
|
+
color?: string;
|
|
75
|
+
width?: number;
|
|
76
|
+
/** Dash and gap lengths in line widths, e.g. [2, 2]. */
|
|
77
|
+
dash?: number[];
|
|
78
|
+
opacity?: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface PolygonOptions extends CommonLayerOptions {
|
|
82
|
+
fill?: string;
|
|
83
|
+
color?: string;
|
|
84
|
+
opacity?: number;
|
|
85
|
+
outline?: string;
|
|
86
|
+
outlineWidth?: number;
|
|
87
|
+
/** Draws the areas in 3D: a height and a base in metres, each a number or the name of a property. */
|
|
88
|
+
extrude?: { height?: number | string; base?: number | string };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface BuildingsOptions {
|
|
92
|
+
color?: string;
|
|
93
|
+
opacity?: number;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface MapOptions {
|
|
97
|
+
/** The element (or its id) the map is drawn in. */
|
|
98
|
+
container: string | HTMLElement;
|
|
99
|
+
/** A map token; or */
|
|
100
|
+
token?: string;
|
|
101
|
+
/** Called at start and again two minutes before each token expires. */
|
|
102
|
+
getToken?: () => string | Promise<string>;
|
|
103
|
+
/** A map key (`smk_…`) whose allowlist names this site; with a token both are sent and the token is checked first. */
|
|
104
|
+
apiKey?: string;
|
|
105
|
+
/** A colour scheme, or a style URL or object of your own. */
|
|
106
|
+
style?: StyleFlavor | string | Record<string, unknown>;
|
|
107
|
+
/** Label language as a BCP-47 tag (`en`, `fr`, `zh-Hans`, …); the browser language by default. */
|
|
108
|
+
language?: string;
|
|
109
|
+
/** The map service, `https://tile.srsr.ca` by default. */
|
|
110
|
+
baseUrl?: string;
|
|
111
|
+
/** Read from the nearest service node (default true). */
|
|
112
|
+
nearest?: boolean;
|
|
113
|
+
/** Node URLs known in advance, used while `baseUrl` is down. */
|
|
114
|
+
nodes?: string[];
|
|
115
|
+
projection?: 'mercator' | 'globe';
|
|
116
|
+
center?: LngLatLike;
|
|
117
|
+
zoom?: number;
|
|
118
|
+
bearing?: number;
|
|
119
|
+
pitch?: number;
|
|
120
|
+
minZoom?: number;
|
|
121
|
+
maxZoom?: number;
|
|
122
|
+
/** Every other option goes to the rendering engine. */
|
|
123
|
+
[engineOption: string]: unknown;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface FlyToOptions {
|
|
127
|
+
center?: LngLatLike;
|
|
128
|
+
zoom?: number;
|
|
129
|
+
bearing?: number;
|
|
130
|
+
pitch?: number;
|
|
131
|
+
duration?: number;
|
|
132
|
+
[engineOption: string]: unknown;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface FitOptions {
|
|
136
|
+
padding?: number | { top?: number; bottom?: number; left?: number; right?: number };
|
|
137
|
+
maxZoom?: number;
|
|
138
|
+
duration?: number;
|
|
139
|
+
[engineOption: string]: unknown;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** A map. Create it in a browser only (the constructor throws elsewhere). */
|
|
143
|
+
export declare class Map {
|
|
144
|
+
constructor(options: MapOptions);
|
|
145
|
+
/** Resolves once the first style has loaded. */
|
|
146
|
+
readonly ready: Promise<Map>;
|
|
147
|
+
/** The rendering engine's map, for anything the SDK does not wrap (set once `ready` resolves). */
|
|
148
|
+
readonly engine: any;
|
|
149
|
+
setStyle(style: StyleFlavor | string | Record<string, unknown>): this;
|
|
150
|
+
setLanguage(language: string): this;
|
|
151
|
+
setProjection(projection: 'mercator' | 'globe'): this;
|
|
152
|
+
setBuildings3D(on: boolean, options?: BuildingsOptions): this;
|
|
153
|
+
addPoints(id: string, data: LayerData, options?: PointOptions): this;
|
|
154
|
+
addLines(id: string, data: LayerData, options?: LineOptions): this;
|
|
155
|
+
addPolygons(id: string, data: LayerData, options?: PolygonOptions): this;
|
|
156
|
+
setData(id: string, data: LayerData): this;
|
|
157
|
+
setVisible(id: string, visible: boolean): this;
|
|
158
|
+
removeLayer(id: string): this;
|
|
159
|
+
/** Layer ids in draw order, bottom first. */
|
|
160
|
+
layers(): string[];
|
|
161
|
+
fitLayer(id: string, options?: FitOptions): this;
|
|
162
|
+
flyTo(options: FlyToOptions): this;
|
|
163
|
+
on(type: string, ...args: any[]): this;
|
|
164
|
+
off(type: string, ...args: any[]): this;
|
|
165
|
+
once(type: string, ...args: any[]): any;
|
|
166
|
+
remove(): void;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** The SDK version. */
|
|
170
|
+
export declare const version: string;
|
|
171
|
+
/** The colour schemes. */
|
|
172
|
+
export declare const styles: StyleFlavor[];
|
|
173
|
+
/** The bundled rendering engine, for anything the SDK does not wrap (loaded on the first call). */
|
|
174
|
+
export declare function getEngine(): any;
|
|
175
|
+
|
|
176
|
+
declare const sMap: {
|
|
177
|
+
Map: typeof Map;
|
|
178
|
+
version: string;
|
|
179
|
+
styles: StyleFlavor[];
|
|
180
|
+
getEngine: typeof getEngine;
|
|
181
|
+
};
|
|
182
|
+
export default sMap;
|
package/types/smap.d.mts
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// Types of the sMap Web SDK (`@superrouteca/smap`). Kept by hand beside the generated code in dist/; smap.d.mts and
|
|
2
|
+
// smap.d.cts hold the same text (test/types.test.mjs checks).
|
|
3
|
+
|
|
4
|
+
export type StyleFlavor = 'light' | 'white' | 'grayscale' | 'dark' | 'black';
|
|
5
|
+
|
|
6
|
+
/** A position as [longitude, latitude]. */
|
|
7
|
+
export type LngLatLike = [number, number] | { lng: number; lat: number } | { lon: number; lat: number };
|
|
8
|
+
|
|
9
|
+
export type GeoJSONGeometry = { type: string; coordinates?: unknown; geometries?: unknown[] };
|
|
10
|
+
export interface GeoJSONFeature<P = Record<string, unknown>> {
|
|
11
|
+
type: 'Feature';
|
|
12
|
+
id?: string | number;
|
|
13
|
+
properties: P | null;
|
|
14
|
+
geometry: GeoJSONGeometry;
|
|
15
|
+
}
|
|
16
|
+
export interface GeoJSONFeatureCollection<P = Record<string, unknown>> {
|
|
17
|
+
type: 'FeatureCollection';
|
|
18
|
+
features: GeoJSONFeature<P>[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** A point given as an object: `{lng, lat}` (or `lon` / `longitude` / `latitude`, or `coordinates`) plus properties. */
|
|
22
|
+
export interface PointInput {
|
|
23
|
+
lat?: number;
|
|
24
|
+
lng?: number;
|
|
25
|
+
lon?: number;
|
|
26
|
+
latitude?: number;
|
|
27
|
+
longitude?: number;
|
|
28
|
+
coordinates?: [number, number];
|
|
29
|
+
id?: string | number;
|
|
30
|
+
[property: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Layer data: GeoJSON (a FeatureCollection or a Feature) or an array of points or features. */
|
|
34
|
+
export type LayerData = GeoJSONFeatureCollection | GeoJSONFeature | Array<PointInput | GeoJSONFeature> | null | undefined;
|
|
35
|
+
|
|
36
|
+
/** The event of a click on a layer's feature (the engine's map mouse event). */
|
|
37
|
+
export interface LayerClickEvent {
|
|
38
|
+
lngLat: { lng: number; lat: number };
|
|
39
|
+
point: { x: number; y: number };
|
|
40
|
+
features?: GeoJSONFeature[];
|
|
41
|
+
originalEvent?: Event;
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface CommonLayerOptions {
|
|
46
|
+
/** Higher draws on top; equal values keep the order added. */
|
|
47
|
+
zIndex?: number;
|
|
48
|
+
minzoom?: number;
|
|
49
|
+
maxzoom?: number;
|
|
50
|
+
/** A feature property used as the feature id. */
|
|
51
|
+
idProperty?: string;
|
|
52
|
+
/** HTML for a popup opened on click, from the clicked feature's properties. */
|
|
53
|
+
popup?: (properties: Record<string, unknown>, feature: GeoJSONFeature) => string | null | undefined | false;
|
|
54
|
+
onClick?: (feature: GeoJSONFeature, event: LayerClickEvent) => void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface PointOptions extends CommonLayerOptions {
|
|
58
|
+
/** Groups nearby points into circles sized by their count; a click zooms in to split them. */
|
|
59
|
+
cluster?: boolean | { radius?: number; maxZoom?: number };
|
|
60
|
+
clusterColor?: string;
|
|
61
|
+
color?: string;
|
|
62
|
+
radius?: number;
|
|
63
|
+
strokeColor?: string;
|
|
64
|
+
strokeWidth?: number;
|
|
65
|
+
/** An image URL drawn instead of a circle. */
|
|
66
|
+
icon?: string;
|
|
67
|
+
iconSize?: number;
|
|
68
|
+
iconAnchor?: string;
|
|
69
|
+
/** The property written under each point. */
|
|
70
|
+
label?: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface LineOptions extends CommonLayerOptions {
|
|
74
|
+
color?: string;
|
|
75
|
+
width?: number;
|
|
76
|
+
/** Dash and gap lengths in line widths, e.g. [2, 2]. */
|
|
77
|
+
dash?: number[];
|
|
78
|
+
opacity?: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface PolygonOptions extends CommonLayerOptions {
|
|
82
|
+
fill?: string;
|
|
83
|
+
color?: string;
|
|
84
|
+
opacity?: number;
|
|
85
|
+
outline?: string;
|
|
86
|
+
outlineWidth?: number;
|
|
87
|
+
/** Draws the areas in 3D: a height and a base in metres, each a number or the name of a property. */
|
|
88
|
+
extrude?: { height?: number | string; base?: number | string };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface BuildingsOptions {
|
|
92
|
+
color?: string;
|
|
93
|
+
opacity?: number;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface MapOptions {
|
|
97
|
+
/** The element (or its id) the map is drawn in. */
|
|
98
|
+
container: string | HTMLElement;
|
|
99
|
+
/** A map token; or */
|
|
100
|
+
token?: string;
|
|
101
|
+
/** Called at start and again two minutes before each token expires. */
|
|
102
|
+
getToken?: () => string | Promise<string>;
|
|
103
|
+
/** A map key (`smk_…`) whose allowlist names this site; with a token both are sent and the token is checked first. */
|
|
104
|
+
apiKey?: string;
|
|
105
|
+
/** A colour scheme, or a style URL or object of your own. */
|
|
106
|
+
style?: StyleFlavor | string | Record<string, unknown>;
|
|
107
|
+
/** Label language as a BCP-47 tag (`en`, `fr`, `zh-Hans`, …); the browser language by default. */
|
|
108
|
+
language?: string;
|
|
109
|
+
/** The map service, `https://tile.srsr.ca` by default. */
|
|
110
|
+
baseUrl?: string;
|
|
111
|
+
/** Read from the nearest service node (default true). */
|
|
112
|
+
nearest?: boolean;
|
|
113
|
+
/** Node URLs known in advance, used while `baseUrl` is down. */
|
|
114
|
+
nodes?: string[];
|
|
115
|
+
projection?: 'mercator' | 'globe';
|
|
116
|
+
center?: LngLatLike;
|
|
117
|
+
zoom?: number;
|
|
118
|
+
bearing?: number;
|
|
119
|
+
pitch?: number;
|
|
120
|
+
minZoom?: number;
|
|
121
|
+
maxZoom?: number;
|
|
122
|
+
/** Every other option goes to the rendering engine. */
|
|
123
|
+
[engineOption: string]: unknown;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface FlyToOptions {
|
|
127
|
+
center?: LngLatLike;
|
|
128
|
+
zoom?: number;
|
|
129
|
+
bearing?: number;
|
|
130
|
+
pitch?: number;
|
|
131
|
+
duration?: number;
|
|
132
|
+
[engineOption: string]: unknown;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface FitOptions {
|
|
136
|
+
padding?: number | { top?: number; bottom?: number; left?: number; right?: number };
|
|
137
|
+
maxZoom?: number;
|
|
138
|
+
duration?: number;
|
|
139
|
+
[engineOption: string]: unknown;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** A map. Create it in a browser only (the constructor throws elsewhere). */
|
|
143
|
+
export declare class Map {
|
|
144
|
+
constructor(options: MapOptions);
|
|
145
|
+
/** Resolves once the first style has loaded. */
|
|
146
|
+
readonly ready: Promise<Map>;
|
|
147
|
+
/** The rendering engine's map, for anything the SDK does not wrap (set once `ready` resolves). */
|
|
148
|
+
readonly engine: any;
|
|
149
|
+
setStyle(style: StyleFlavor | string | Record<string, unknown>): this;
|
|
150
|
+
setLanguage(language: string): this;
|
|
151
|
+
setProjection(projection: 'mercator' | 'globe'): this;
|
|
152
|
+
setBuildings3D(on: boolean, options?: BuildingsOptions): this;
|
|
153
|
+
addPoints(id: string, data: LayerData, options?: PointOptions): this;
|
|
154
|
+
addLines(id: string, data: LayerData, options?: LineOptions): this;
|
|
155
|
+
addPolygons(id: string, data: LayerData, options?: PolygonOptions): this;
|
|
156
|
+
setData(id: string, data: LayerData): this;
|
|
157
|
+
setVisible(id: string, visible: boolean): this;
|
|
158
|
+
removeLayer(id: string): this;
|
|
159
|
+
/** Layer ids in draw order, bottom first. */
|
|
160
|
+
layers(): string[];
|
|
161
|
+
fitLayer(id: string, options?: FitOptions): this;
|
|
162
|
+
flyTo(options: FlyToOptions): this;
|
|
163
|
+
on(type: string, ...args: any[]): this;
|
|
164
|
+
off(type: string, ...args: any[]): this;
|
|
165
|
+
once(type: string, ...args: any[]): any;
|
|
166
|
+
remove(): void;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** The SDK version. */
|
|
170
|
+
export declare const version: string;
|
|
171
|
+
/** The colour schemes. */
|
|
172
|
+
export declare const styles: StyleFlavor[];
|
|
173
|
+
/** The bundled rendering engine, for anything the SDK does not wrap (loaded on the first call). */
|
|
174
|
+
export declare function getEngine(): any;
|
|
175
|
+
|
|
176
|
+
declare const sMap: {
|
|
177
|
+
Map: typeof Map;
|
|
178
|
+
version: string;
|
|
179
|
+
styles: StyleFlavor[];
|
|
180
|
+
getEngine: typeof getEngine;
|
|
181
|
+
};
|
|
182
|
+
export default sMap;
|