@acalcutt/maplibre-gl-native-test 5.0.20 → 5.2.1-pre.11
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/LICENSE.mbgl-core.md +8 -2
- package/README.md +49 -114
- package/package.json +31 -31
- package/platform/node/README.md +59 -17
- package/platform/node/index.d.ts +226 -0
- package/platform/node/index.js +36 -30
- package/CHANGELOG.md +0 -517
- package/lib/node-v102/mbgl.node +0 -0
- package/lib/node-v108/mbgl.node +0 -0
- package/lib/node-v57/mbgl.node +0 -0
- package/lib/node-v59/mbgl.node +0 -0
- package/lib/node-v64/mbgl.node +0 -0
- package/lib/node-v67/mbgl.node +0 -0
- package/lib/node-v72/mbgl.node +0 -0
- package/lib/node-v79/mbgl.node +0 -0
- package/lib/node-v83/mbgl.node +0 -0
- package/lib/node-v88/mbgl.node +0 -0
- package/lib/node-v93/mbgl.node +0 -0
- package/platform/node/CHANGELOG.md +0 -284
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
declare module '@maplibre/maplibre-gl-native' {
|
|
2
|
+
const enum ResourceKind {
|
|
3
|
+
Unknown = 0,
|
|
4
|
+
Style = 1,
|
|
5
|
+
Source = 2,
|
|
6
|
+
Tile = 3,
|
|
7
|
+
Glyphs = 4,
|
|
8
|
+
SpriteImage = 5,
|
|
9
|
+
SpriteJSON = 6,
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Response expected by a request call during render
|
|
14
|
+
*/
|
|
15
|
+
type RequestResponse = {
|
|
16
|
+
data: Uint8Array;
|
|
17
|
+
modified?: Date;
|
|
18
|
+
expires?: Date;
|
|
19
|
+
etag?: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const enum MapMode {
|
|
23
|
+
/**
|
|
24
|
+
* Render all tiles in map view
|
|
25
|
+
*/
|
|
26
|
+
Static = 'static',
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Render and request only a single tile
|
|
30
|
+
*/
|
|
31
|
+
Tile = 'tile',
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type MapOptions = {
|
|
35
|
+
/**
|
|
36
|
+
* Will be used during a `Map.render` call to request all necessary map resources (tiles, fonts...)
|
|
37
|
+
*/
|
|
38
|
+
request?: (
|
|
39
|
+
request: { url: string; kind: ResourceKind },
|
|
40
|
+
callback: (error?: Error, response?: RequestResponse) => void,
|
|
41
|
+
) => void;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Pixel ratio at which to render images
|
|
45
|
+
*
|
|
46
|
+
* @default 1
|
|
47
|
+
*/
|
|
48
|
+
ratio?: number;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Mode in which map view will be rendered
|
|
52
|
+
*
|
|
53
|
+
* @default MapMode.Static
|
|
54
|
+
*/
|
|
55
|
+
mode?: MapMode;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Defines the map view to render and the resulting image
|
|
60
|
+
*/
|
|
61
|
+
type RenderOptions = {
|
|
62
|
+
/**
|
|
63
|
+
* Zoom level
|
|
64
|
+
*
|
|
65
|
+
* @default 0
|
|
66
|
+
*/
|
|
67
|
+
zoom?: number;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Width of image in pixel
|
|
71
|
+
*
|
|
72
|
+
* @default 512
|
|
73
|
+
*/
|
|
74
|
+
width?: number;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Height of image in pixel
|
|
78
|
+
*
|
|
79
|
+
* @default 512
|
|
80
|
+
*/
|
|
81
|
+
height?: number;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Coordinates [longitude, latitude]
|
|
85
|
+
*
|
|
86
|
+
* @default [0, 0]
|
|
87
|
+
*/
|
|
88
|
+
center?: [number, number];
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Bearing of map view in degrees, counter-clockwise from north
|
|
92
|
+
*
|
|
93
|
+
* @default 0
|
|
94
|
+
*/
|
|
95
|
+
bearing?: number;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Pitch of map view in degrees, arcing towards the horizon
|
|
99
|
+
*
|
|
100
|
+
* @default 0
|
|
101
|
+
*/
|
|
102
|
+
pitch?: number;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @default []
|
|
106
|
+
*/
|
|
107
|
+
classes?: string[];
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* A `Map` instance is used to render images from map views
|
|
112
|
+
*/
|
|
113
|
+
class Map {
|
|
114
|
+
constructor(mapOptions?: MapOptions);
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Load a style into a map
|
|
118
|
+
*/
|
|
119
|
+
load: (style: any) => void;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Render a specific map view to an image with previously loaded map styles with render options.
|
|
123
|
+
*/
|
|
124
|
+
render(renderOptions: RenderOptions, callback: (...args: [error: Error, buffer: undefined] | [error: undefined, buffer: Uint8Array]) => void): void;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Render a specific map view to an image with previously loaded map styles without render options.
|
|
128
|
+
*/
|
|
129
|
+
render(callback: (...args: [error: Error, buffer: undefined] | [error: undefined, buffer: Uint8Array]) => void): void;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Call to permanently dispose the internal map resources, instance can't be used for further render calls
|
|
133
|
+
*/
|
|
134
|
+
release: () => void;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Add source to map's style
|
|
138
|
+
*/
|
|
139
|
+
addSource: (sourceId: string, source: object) => void;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Remove source from map's style
|
|
143
|
+
*/
|
|
144
|
+
removeSource: (sourceId: string) => void;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Add layer to map's style
|
|
148
|
+
*/
|
|
149
|
+
addLayer: (layer: object, beforeId?: string) => void;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Remove layer from map's style
|
|
153
|
+
*/
|
|
154
|
+
removeLayer: (layerId: string) => void;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Add image to map's style
|
|
158
|
+
*/
|
|
159
|
+
addImage: (imageId: string, image: any) => void;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Remove image from map's style
|
|
163
|
+
*/
|
|
164
|
+
removeImage: (imageId: string) => void;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Set the extent of the zoom for a specified layer
|
|
168
|
+
*/
|
|
169
|
+
setLayerZoomRange: (layerId: string, minZoom: number, maxZoom: number) => void;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Set the value for a layer's property
|
|
173
|
+
*/
|
|
174
|
+
setLayoutProperty: (layerId: string, name: string, value: string) => void;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Set filter for specified style layer
|
|
178
|
+
*/
|
|
179
|
+
setFilter: (layerId: string, filter: [] | null | undefined) => void;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Set size of the tile
|
|
183
|
+
*/
|
|
184
|
+
setSize: (size: [number, number]) => void;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Set the center of the map
|
|
188
|
+
*/
|
|
189
|
+
setCenter: (center: [number, number]) => void;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Set zoom of the map
|
|
193
|
+
*/
|
|
194
|
+
setZoom: (zoom: number) => void;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Set bearing (rotation) of map
|
|
198
|
+
*/
|
|
199
|
+
setBearing: (bearing: number) => void;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Set pitch (tilt angle) of map
|
|
203
|
+
*/
|
|
204
|
+
setPitch: (pitch: number) => void;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Set light value of map
|
|
208
|
+
*/
|
|
209
|
+
setLight: (light: any) => void;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Set axonometric view of map
|
|
213
|
+
*/
|
|
214
|
+
setAxonometric: (state: boolean) => void;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Set X skew of map
|
|
218
|
+
*/
|
|
219
|
+
setXSkew: (x: number) => void;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Set Y skew of map
|
|
223
|
+
*/
|
|
224
|
+
setYSkew: (y: number) => void;
|
|
225
|
+
}
|
|
226
|
+
}
|
package/platform/node/index.js
CHANGED
|
@@ -6,43 +6,49 @@ var mbgl = require('../../lib/node-v' + process.versions.modules + '/mbgl');
|
|
|
6
6
|
var constructor = mbgl.Map.prototype.constructor;
|
|
7
7
|
|
|
8
8
|
var Map = function(options) {
|
|
9
|
-
if (!(options instanceof Object)) {
|
|
9
|
+
if (options && !(options instanceof Object)) {
|
|
10
10
|
throw TypeError("Requires an options object as first argument");
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
if (
|
|
14
|
-
throw TypeError("Options object must
|
|
13
|
+
if (options && options.hasOwnProperty('request') && !(options.request instanceof Function)) {
|
|
14
|
+
throw TypeError("Options object 'request' property must be a function");
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
responded
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
if (options && options.request) {
|
|
18
|
+
var request = options.request;
|
|
19
|
+
|
|
20
|
+
return new constructor(Object.assign(options, {
|
|
21
|
+
request: function(req) {
|
|
22
|
+
// Protect against `request` implementations that call the callback synchronously,
|
|
23
|
+
// call it multiple times, or throw exceptions.
|
|
24
|
+
// http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony
|
|
25
|
+
|
|
26
|
+
var responded = false;
|
|
27
|
+
var callback = function() {
|
|
28
|
+
var args = arguments;
|
|
29
|
+
if (!responded) {
|
|
30
|
+
responded = true;
|
|
31
|
+
process.nextTick(function() {
|
|
32
|
+
req.respond.apply(req, args);
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
console.warn('request function responded multiple times; it should call the callback only once');
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
request(req, callback);
|
|
41
|
+
} catch (e) {
|
|
42
|
+
console.warn('request function threw an exception; it should call the callback with an error instead');
|
|
43
|
+
callback(e);
|
|
35
44
|
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
request(req, callback);
|
|
40
|
-
} catch (e) {
|
|
41
|
-
console.warn('request function threw an exception; it should call the callback with an error instead');
|
|
42
|
-
callback(e);
|
|
43
45
|
}
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
+
}));
|
|
47
|
+
} else if (options) {
|
|
48
|
+
return new constructor(options);
|
|
49
|
+
} else {
|
|
50
|
+
return new constructor();
|
|
51
|
+
}
|
|
46
52
|
};
|
|
47
53
|
|
|
48
54
|
Map.prototype = mbgl.Map.prototype;
|