@superrouteca/smap 1.0.2 → 1.0.6
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 +32 -0
- package/README.md +137 -4
- package/dist/SOURCE.json +8 -8
- package/dist/smap-client.cjs +2 -2
- package/dist/smap-client.js +2 -2
- package/dist/smap-client.mjs +2 -2
- package/dist/smap.cjs +697 -32
- package/dist/smap.css +54 -0
- package/dist/smap.js +688 -30
- package/dist/smap.mjs +697 -33
- package/package.json +1 -1
- package/types/smap.d.cts +115 -6
- package/types/smap.d.mts +115 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superrouteca/smap",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "sMap for the web: maps from Superroute's sMap service, the Web SDK (map view) and the JS client (tokens, nearest node, styles, tiles).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Goodneo Solutions",
|
package/types/smap.d.cts
CHANGED
|
@@ -30,8 +30,38 @@ export interface PointInput {
|
|
|
30
30
|
[property: string]: unknown;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
/** Layer data: GeoJSON (a FeatureCollection or a
|
|
34
|
-
export type LayerData = GeoJSONFeatureCollection | GeoJSONFeature | Array<PointInput | GeoJSONFeature> | null | undefined;
|
|
33
|
+
/** Layer data: GeoJSON (a FeatureCollection, a Feature or a bare geometry) or an array of points or features. */
|
|
34
|
+
export type LayerData = GeoJSONFeatureCollection | GeoJSONFeature | GeoJSONGeometry | Array<PointInput | GeoJSONFeature> | null | undefined;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* What a popup shows: an HTML string (inserted as it is and never sanitized, so it must be trusted: escape any feature
|
|
38
|
+
* data you put in it, or use `popupTemplate`), a DOM node, or a promise of either (the loading state shows meanwhile;
|
|
39
|
+
* a rejection closes the popup and is reported as the map's `error` event). Nothing (null, undefined, false, '')
|
|
40
|
+
* opens no popup.
|
|
41
|
+
*/
|
|
42
|
+
export type PopupContent = string | Node | null | undefined | false;
|
|
43
|
+
|
|
44
|
+
/** How a popup looks and behaves. Layer options are merged over the map's `popup` defaults. */
|
|
45
|
+
export interface PopupOptions {
|
|
46
|
+
/** Classes added to the popup's element, beside `smap-popup`. */
|
|
47
|
+
className?: string;
|
|
48
|
+
/** Largest width: pixels or a CSS length (default 240px). */
|
|
49
|
+
maxWidth?: number | string;
|
|
50
|
+
/** Smallest width: pixels or a CSS length. */
|
|
51
|
+
minWidth?: number | string;
|
|
52
|
+
/** Distance from the anchor in pixels, or per anchor (default 12). */
|
|
53
|
+
offset?: number | [number, number] | Record<string, [number, number]>;
|
|
54
|
+
/** Which side of the popup points at the position; chosen to fit by default. */
|
|
55
|
+
anchor?: 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
56
|
+
/** A close button in the corner (default true). */
|
|
57
|
+
closeButton?: boolean;
|
|
58
|
+
/** A click on the map closes it (default true). */
|
|
59
|
+
closeOnClick?: boolean;
|
|
60
|
+
/** Focus moves into the popup when it opens (default true). */
|
|
61
|
+
focusAfterOpen?: boolean;
|
|
62
|
+
/** Pan the map so the popup is fully visible (default true). */
|
|
63
|
+
autoPan?: boolean;
|
|
64
|
+
}
|
|
35
65
|
|
|
36
66
|
/** The event of a click on a layer's feature (the engine's map mouse event). */
|
|
37
67
|
export interface LayerClickEvent {
|
|
@@ -50,14 +80,68 @@ interface CommonLayerOptions {
|
|
|
50
80
|
/** A feature property used as the feature id. */
|
|
51
81
|
idProperty?: string;
|
|
52
82
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
83
|
+
* The popup opened when the top feature at a click is this layer's; called only then. A point's popup opens at the
|
|
84
|
+
* point, a line's or area's where it was clicked. `popupTemplate('<b>{name}</b>')` gives a fast, escaped one.
|
|
55
85
|
*/
|
|
56
|
-
popup?: (properties: Record<string, unknown>, feature: GeoJSONFeature) =>
|
|
86
|
+
popup?: (properties: Record<string, unknown>, feature: GeoJSONFeature) => PopupContent | Promise<PopupContent>;
|
|
87
|
+
/** This layer's popup options, over the map's `popup` defaults. */
|
|
88
|
+
popupOptions?: PopupOptions;
|
|
89
|
+
/** Shown while this layer's popup content is a pending promise (HTML string or DOM node; default pulsing dots). */
|
|
90
|
+
popupLoading?: string | Node;
|
|
91
|
+
/** Auto Zoom: a click on pins piled up zooms in around it, or lists them close up (default true). */
|
|
92
|
+
autoZoom?: boolean;
|
|
93
|
+
/** In 3D, W / S tilt and A / D turn the view while the map has focus (default true). */
|
|
94
|
+
keyboard3D?: boolean;
|
|
57
95
|
onClick?: (feature: GeoJSONFeature, event: LayerClickEvent) => void;
|
|
58
96
|
}
|
|
59
97
|
|
|
98
|
+
/**
|
|
99
|
+
* A value drawn per feature: a constant (`'#e6194b'`, `3`), a feature property (`{ property: 'status_color' }`, with
|
|
100
|
+
* `default` for features without it), or an engine expression (an array, e.g. `['get', 'color']`).
|
|
101
|
+
*/
|
|
102
|
+
export type StyleValue<T = string> = T | { property: string; default?: T } | unknown[];
|
|
103
|
+
|
|
104
|
+
/** Pins like Superroute's route map, drawn on the GPU (one image per colour pair, made when first shown). */
|
|
105
|
+
export interface MarkerOptions {
|
|
106
|
+
/** `pin` (default: a teardrop whose tip is at the position) or `circle` (centred on it). */
|
|
107
|
+
shape?: 'pin' | 'circle' | 'vehicle';
|
|
108
|
+
/** Inside colour (default white). */
|
|
109
|
+
fill?: StyleValue;
|
|
110
|
+
/** Border colour (default the layer's `color`). */
|
|
111
|
+
border?: StyleValue;
|
|
112
|
+
/** Border width in pixels (default 3). */
|
|
113
|
+
borderWidth?: number;
|
|
114
|
+
/** Width of the pin in pixels (default 32). */
|
|
115
|
+
size?: number;
|
|
116
|
+
/** The text in the pin, e.g. the stop number; none when empty. */
|
|
117
|
+
text?: StyleValue<string | number>;
|
|
118
|
+
/** Text colour (default white). */
|
|
119
|
+
textColor?: StyleValue;
|
|
120
|
+
/** A red count badge at the pin's upper right, shown when the value is more than 1. */
|
|
121
|
+
badge?: StyleValue<number>;
|
|
122
|
+
/** Numbers from this zoom on (pins without numbers below it, so a crowded overview stays readable). */
|
|
123
|
+
/** Size factor of the pin, its number and its badge together: a number or an engine expression, e.g. of the zoom. Default 1. */
|
|
124
|
+
scale?: number | unknown[];
|
|
125
|
+
/** The pin under the pointer comes to the front (default true). */
|
|
126
|
+
hoverRaise?: boolean;
|
|
127
|
+
/** From this zoom on (default 13) the number is drawn into the pin, so an upper pin covers a lower one completely; false keeps it a separate layer. */
|
|
128
|
+
bakeZoom?: number | false;
|
|
129
|
+
/**
|
|
130
|
+
* Pins piled up under a click (default on): with `threshold` (4) or more within `radius` (12 px) the map zooms in by
|
|
131
|
+
* `zoomBy` (2) up to `maxZoom` (17); close up, or for pins at one spot, a chooser lists them (`label(properties)`).
|
|
132
|
+
* `false` turns it off.
|
|
133
|
+
*/
|
|
134
|
+
overlap?: false | { threshold?: number; radius?: number; zoomBy?: number; maxZoom?: number; label?: (properties: Record<string, unknown>, feature: GeoJSONFeature) => string };
|
|
135
|
+
/** Opacity of the pin, its number and its badge (default 1). */
|
|
136
|
+
opacity?: StyleValue<number>;
|
|
137
|
+
textMinzoom?: number;
|
|
138
|
+
/** Badges from this zoom on. */
|
|
139
|
+
badgeMinzoom?: number;
|
|
140
|
+
}
|
|
141
|
+
|
|
60
142
|
export interface PointOptions extends CommonLayerOptions {
|
|
143
|
+
/** Route-map pins instead of circles or an icon. */
|
|
144
|
+
marker?: MarkerOptions;
|
|
61
145
|
/** Groups nearby points into circles sized by their count; a click zooms in to split them. */
|
|
62
146
|
cluster?: boolean | { radius?: number; maxZoom?: number };
|
|
63
147
|
clusterColor?: string;
|
|
@@ -71,14 +155,23 @@ export interface PointOptions extends CommonLayerOptions {
|
|
|
71
155
|
iconAnchor?: string;
|
|
72
156
|
/** The property written under each point. */
|
|
73
157
|
label?: string;
|
|
158
|
+
/** Where the label sits: below the point (default) or 'right' of it. */
|
|
159
|
+
labelPosition?: 'below' | 'right';
|
|
74
160
|
}
|
|
75
161
|
|
|
76
162
|
export interface LineOptions extends CommonLayerOptions {
|
|
77
|
-
color
|
|
163
|
+
/** A colour, or one per feature (`{ property: 'color' }` or an expression): one layer for many routes. */
|
|
164
|
+
color?: StyleValue;
|
|
78
165
|
width?: number;
|
|
79
166
|
/** Dash and gap lengths in line widths, e.g. [2, 2]. */
|
|
80
167
|
dash?: number[];
|
|
81
168
|
opacity?: number;
|
|
169
|
+
/** A wider line under the line (true: white, 9 px). */
|
|
170
|
+
casing?: boolean | { color?: StyleValue; width?: number; opacity?: number };
|
|
171
|
+
/** A shadow line between the casing and the line (true: black, 7 px, opacity 0.3). */
|
|
172
|
+
shadow?: boolean | { color?: StyleValue; width?: number; opacity?: number };
|
|
173
|
+
/** Arrowheads along the line in its direction (true: every 80 px, 14 px, the line's colour, opacity 0.8). */
|
|
174
|
+
arrows?: boolean | { spacing?: number; size?: number; color?: StyleValue; opacity?: number };
|
|
82
175
|
}
|
|
83
176
|
|
|
84
177
|
export interface PolygonOptions extends CommonLayerOptions {
|
|
@@ -122,6 +215,10 @@ export interface MapOptions {
|
|
|
122
215
|
pitch?: number;
|
|
123
216
|
minZoom?: number;
|
|
124
217
|
maxZoom?: number;
|
|
218
|
+
/** Default popup options of every layer and of `openPopup`. */
|
|
219
|
+
popup?: PopupOptions;
|
|
220
|
+
/** Shown while a popup's content is a pending promise (HTML string or DOM node; default pulsing dots). */
|
|
221
|
+
popupLoading?: string | Node;
|
|
125
222
|
/** Every other option goes to the rendering engine. */
|
|
126
223
|
[engineOption: string]: unknown;
|
|
127
224
|
}
|
|
@@ -163,6 +260,12 @@ export declare class Map {
|
|
|
163
260
|
layers(): string[];
|
|
164
261
|
fitLayer(id: string, options?: FitOptions): this;
|
|
165
262
|
flyTo(options: FlyToOptions): this;
|
|
263
|
+
/** Opens the map's popup at a position, closing the one open before (one popup per map). */
|
|
264
|
+
openPopup(lngLat: LngLatLike, content: PopupContent | Promise<PopupContent>, options?: PopupOptions & { loading?: string | Node }): this;
|
|
265
|
+
/** Closes the map's popup, if one is open. */
|
|
266
|
+
closePopup(): this;
|
|
267
|
+
setAutoZoom(on: boolean): this;
|
|
268
|
+
autoZoom(): boolean;
|
|
166
269
|
on(type: string, ...args: any[]): this;
|
|
167
270
|
off(type: string, ...args: any[]): this;
|
|
168
271
|
once(type: string, ...args: any[]): any;
|
|
@@ -175,11 +278,17 @@ export declare const version: string;
|
|
|
175
278
|
export declare const styles: StyleFlavor[];
|
|
176
279
|
/** The bundled rendering engine, for anything the SDK does not wrap (loaded on the first call). */
|
|
177
280
|
export declare function getEngine(): any;
|
|
281
|
+
/**
|
|
282
|
+
* A popup function from a template: every `{name}` becomes the feature's property of that name, HTML-escaped (empty
|
|
283
|
+
* when missing). The template itself is trusted HTML. Compiled once; it runs only when a popup opens.
|
|
284
|
+
*/
|
|
285
|
+
export declare function popupTemplate(template: string): (properties: Record<string, unknown> | null | undefined, feature?: GeoJSONFeature) => string;
|
|
178
286
|
|
|
179
287
|
declare const sMap: {
|
|
180
288
|
Map: typeof Map;
|
|
181
289
|
version: string;
|
|
182
290
|
styles: StyleFlavor[];
|
|
183
291
|
getEngine: typeof getEngine;
|
|
292
|
+
popupTemplate: typeof popupTemplate;
|
|
184
293
|
};
|
|
185
294
|
export default sMap;
|
package/types/smap.d.mts
CHANGED
|
@@ -30,8 +30,38 @@ export interface PointInput {
|
|
|
30
30
|
[property: string]: unknown;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
/** Layer data: GeoJSON (a FeatureCollection or a
|
|
34
|
-
export type LayerData = GeoJSONFeatureCollection | GeoJSONFeature | Array<PointInput | GeoJSONFeature> | null | undefined;
|
|
33
|
+
/** Layer data: GeoJSON (a FeatureCollection, a Feature or a bare geometry) or an array of points or features. */
|
|
34
|
+
export type LayerData = GeoJSONFeatureCollection | GeoJSONFeature | GeoJSONGeometry | Array<PointInput | GeoJSONFeature> | null | undefined;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* What a popup shows: an HTML string (inserted as it is and never sanitized, so it must be trusted: escape any feature
|
|
38
|
+
* data you put in it, or use `popupTemplate`), a DOM node, or a promise of either (the loading state shows meanwhile;
|
|
39
|
+
* a rejection closes the popup and is reported as the map's `error` event). Nothing (null, undefined, false, '')
|
|
40
|
+
* opens no popup.
|
|
41
|
+
*/
|
|
42
|
+
export type PopupContent = string | Node | null | undefined | false;
|
|
43
|
+
|
|
44
|
+
/** How a popup looks and behaves. Layer options are merged over the map's `popup` defaults. */
|
|
45
|
+
export interface PopupOptions {
|
|
46
|
+
/** Classes added to the popup's element, beside `smap-popup`. */
|
|
47
|
+
className?: string;
|
|
48
|
+
/** Largest width: pixels or a CSS length (default 240px). */
|
|
49
|
+
maxWidth?: number | string;
|
|
50
|
+
/** Smallest width: pixels or a CSS length. */
|
|
51
|
+
minWidth?: number | string;
|
|
52
|
+
/** Distance from the anchor in pixels, or per anchor (default 12). */
|
|
53
|
+
offset?: number | [number, number] | Record<string, [number, number]>;
|
|
54
|
+
/** Which side of the popup points at the position; chosen to fit by default. */
|
|
55
|
+
anchor?: 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
56
|
+
/** A close button in the corner (default true). */
|
|
57
|
+
closeButton?: boolean;
|
|
58
|
+
/** A click on the map closes it (default true). */
|
|
59
|
+
closeOnClick?: boolean;
|
|
60
|
+
/** Focus moves into the popup when it opens (default true). */
|
|
61
|
+
focusAfterOpen?: boolean;
|
|
62
|
+
/** Pan the map so the popup is fully visible (default true). */
|
|
63
|
+
autoPan?: boolean;
|
|
64
|
+
}
|
|
35
65
|
|
|
36
66
|
/** The event of a click on a layer's feature (the engine's map mouse event). */
|
|
37
67
|
export interface LayerClickEvent {
|
|
@@ -50,14 +80,68 @@ interface CommonLayerOptions {
|
|
|
50
80
|
/** A feature property used as the feature id. */
|
|
51
81
|
idProperty?: string;
|
|
52
82
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
83
|
+
* The popup opened when the top feature at a click is this layer's; called only then. A point's popup opens at the
|
|
84
|
+
* point, a line's or area's where it was clicked. `popupTemplate('<b>{name}</b>')` gives a fast, escaped one.
|
|
55
85
|
*/
|
|
56
|
-
popup?: (properties: Record<string, unknown>, feature: GeoJSONFeature) =>
|
|
86
|
+
popup?: (properties: Record<string, unknown>, feature: GeoJSONFeature) => PopupContent | Promise<PopupContent>;
|
|
87
|
+
/** This layer's popup options, over the map's `popup` defaults. */
|
|
88
|
+
popupOptions?: PopupOptions;
|
|
89
|
+
/** Shown while this layer's popup content is a pending promise (HTML string or DOM node; default pulsing dots). */
|
|
90
|
+
popupLoading?: string | Node;
|
|
91
|
+
/** Auto Zoom: a click on pins piled up zooms in around it, or lists them close up (default true). */
|
|
92
|
+
autoZoom?: boolean;
|
|
93
|
+
/** In 3D, W / S tilt and A / D turn the view while the map has focus (default true). */
|
|
94
|
+
keyboard3D?: boolean;
|
|
57
95
|
onClick?: (feature: GeoJSONFeature, event: LayerClickEvent) => void;
|
|
58
96
|
}
|
|
59
97
|
|
|
98
|
+
/**
|
|
99
|
+
* A value drawn per feature: a constant (`'#e6194b'`, `3`), a feature property (`{ property: 'status_color' }`, with
|
|
100
|
+
* `default` for features without it), or an engine expression (an array, e.g. `['get', 'color']`).
|
|
101
|
+
*/
|
|
102
|
+
export type StyleValue<T = string> = T | { property: string; default?: T } | unknown[];
|
|
103
|
+
|
|
104
|
+
/** Pins like Superroute's route map, drawn on the GPU (one image per colour pair, made when first shown). */
|
|
105
|
+
export interface MarkerOptions {
|
|
106
|
+
/** `pin` (default: a teardrop whose tip is at the position) or `circle` (centred on it). */
|
|
107
|
+
shape?: 'pin' | 'circle' | 'vehicle';
|
|
108
|
+
/** Inside colour (default white). */
|
|
109
|
+
fill?: StyleValue;
|
|
110
|
+
/** Border colour (default the layer's `color`). */
|
|
111
|
+
border?: StyleValue;
|
|
112
|
+
/** Border width in pixels (default 3). */
|
|
113
|
+
borderWidth?: number;
|
|
114
|
+
/** Width of the pin in pixels (default 32). */
|
|
115
|
+
size?: number;
|
|
116
|
+
/** The text in the pin, e.g. the stop number; none when empty. */
|
|
117
|
+
text?: StyleValue<string | number>;
|
|
118
|
+
/** Text colour (default white). */
|
|
119
|
+
textColor?: StyleValue;
|
|
120
|
+
/** A red count badge at the pin's upper right, shown when the value is more than 1. */
|
|
121
|
+
badge?: StyleValue<number>;
|
|
122
|
+
/** Numbers from this zoom on (pins without numbers below it, so a crowded overview stays readable). */
|
|
123
|
+
/** Size factor of the pin, its number and its badge together: a number or an engine expression, e.g. of the zoom. Default 1. */
|
|
124
|
+
scale?: number | unknown[];
|
|
125
|
+
/** The pin under the pointer comes to the front (default true). */
|
|
126
|
+
hoverRaise?: boolean;
|
|
127
|
+
/** From this zoom on (default 13) the number is drawn into the pin, so an upper pin covers a lower one completely; false keeps it a separate layer. */
|
|
128
|
+
bakeZoom?: number | false;
|
|
129
|
+
/**
|
|
130
|
+
* Pins piled up under a click (default on): with `threshold` (4) or more within `radius` (12 px) the map zooms in by
|
|
131
|
+
* `zoomBy` (2) up to `maxZoom` (17); close up, or for pins at one spot, a chooser lists them (`label(properties)`).
|
|
132
|
+
* `false` turns it off.
|
|
133
|
+
*/
|
|
134
|
+
overlap?: false | { threshold?: number; radius?: number; zoomBy?: number; maxZoom?: number; label?: (properties: Record<string, unknown>, feature: GeoJSONFeature) => string };
|
|
135
|
+
/** Opacity of the pin, its number and its badge (default 1). */
|
|
136
|
+
opacity?: StyleValue<number>;
|
|
137
|
+
textMinzoom?: number;
|
|
138
|
+
/** Badges from this zoom on. */
|
|
139
|
+
badgeMinzoom?: number;
|
|
140
|
+
}
|
|
141
|
+
|
|
60
142
|
export interface PointOptions extends CommonLayerOptions {
|
|
143
|
+
/** Route-map pins instead of circles or an icon. */
|
|
144
|
+
marker?: MarkerOptions;
|
|
61
145
|
/** Groups nearby points into circles sized by their count; a click zooms in to split them. */
|
|
62
146
|
cluster?: boolean | { radius?: number; maxZoom?: number };
|
|
63
147
|
clusterColor?: string;
|
|
@@ -71,14 +155,23 @@ export interface PointOptions extends CommonLayerOptions {
|
|
|
71
155
|
iconAnchor?: string;
|
|
72
156
|
/** The property written under each point. */
|
|
73
157
|
label?: string;
|
|
158
|
+
/** Where the label sits: below the point (default) or 'right' of it. */
|
|
159
|
+
labelPosition?: 'below' | 'right';
|
|
74
160
|
}
|
|
75
161
|
|
|
76
162
|
export interface LineOptions extends CommonLayerOptions {
|
|
77
|
-
color
|
|
163
|
+
/** A colour, or one per feature (`{ property: 'color' }` or an expression): one layer for many routes. */
|
|
164
|
+
color?: StyleValue;
|
|
78
165
|
width?: number;
|
|
79
166
|
/** Dash and gap lengths in line widths, e.g. [2, 2]. */
|
|
80
167
|
dash?: number[];
|
|
81
168
|
opacity?: number;
|
|
169
|
+
/** A wider line under the line (true: white, 9 px). */
|
|
170
|
+
casing?: boolean | { color?: StyleValue; width?: number; opacity?: number };
|
|
171
|
+
/** A shadow line between the casing and the line (true: black, 7 px, opacity 0.3). */
|
|
172
|
+
shadow?: boolean | { color?: StyleValue; width?: number; opacity?: number };
|
|
173
|
+
/** Arrowheads along the line in its direction (true: every 80 px, 14 px, the line's colour, opacity 0.8). */
|
|
174
|
+
arrows?: boolean | { spacing?: number; size?: number; color?: StyleValue; opacity?: number };
|
|
82
175
|
}
|
|
83
176
|
|
|
84
177
|
export interface PolygonOptions extends CommonLayerOptions {
|
|
@@ -122,6 +215,10 @@ export interface MapOptions {
|
|
|
122
215
|
pitch?: number;
|
|
123
216
|
minZoom?: number;
|
|
124
217
|
maxZoom?: number;
|
|
218
|
+
/** Default popup options of every layer and of `openPopup`. */
|
|
219
|
+
popup?: PopupOptions;
|
|
220
|
+
/** Shown while a popup's content is a pending promise (HTML string or DOM node; default pulsing dots). */
|
|
221
|
+
popupLoading?: string | Node;
|
|
125
222
|
/** Every other option goes to the rendering engine. */
|
|
126
223
|
[engineOption: string]: unknown;
|
|
127
224
|
}
|
|
@@ -163,6 +260,12 @@ export declare class Map {
|
|
|
163
260
|
layers(): string[];
|
|
164
261
|
fitLayer(id: string, options?: FitOptions): this;
|
|
165
262
|
flyTo(options: FlyToOptions): this;
|
|
263
|
+
/** Opens the map's popup at a position, closing the one open before (one popup per map). */
|
|
264
|
+
openPopup(lngLat: LngLatLike, content: PopupContent | Promise<PopupContent>, options?: PopupOptions & { loading?: string | Node }): this;
|
|
265
|
+
/** Closes the map's popup, if one is open. */
|
|
266
|
+
closePopup(): this;
|
|
267
|
+
setAutoZoom(on: boolean): this;
|
|
268
|
+
autoZoom(): boolean;
|
|
166
269
|
on(type: string, ...args: any[]): this;
|
|
167
270
|
off(type: string, ...args: any[]): this;
|
|
168
271
|
once(type: string, ...args: any[]): any;
|
|
@@ -175,11 +278,17 @@ export declare const version: string;
|
|
|
175
278
|
export declare const styles: StyleFlavor[];
|
|
176
279
|
/** The bundled rendering engine, for anything the SDK does not wrap (loaded on the first call). */
|
|
177
280
|
export declare function getEngine(): any;
|
|
281
|
+
/**
|
|
282
|
+
* A popup function from a template: every `{name}` becomes the feature's property of that name, HTML-escaped (empty
|
|
283
|
+
* when missing). The template itself is trusted HTML. Compiled once; it runs only when a popup opens.
|
|
284
|
+
*/
|
|
285
|
+
export declare function popupTemplate(template: string): (properties: Record<string, unknown> | null | undefined, feature?: GeoJSONFeature) => string;
|
|
178
286
|
|
|
179
287
|
declare const sMap: {
|
|
180
288
|
Map: typeof Map;
|
|
181
289
|
version: string;
|
|
182
290
|
styles: StyleFlavor[];
|
|
183
291
|
getEngine: typeof getEngine;
|
|
292
|
+
popupTemplate: typeof popupTemplate;
|
|
184
293
|
};
|
|
185
294
|
export default sMap;
|