@acalcutt/maplibre-gl-native-test 5.0.20 → 5.2.1-pre.7
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 +46 -117
- package/package.json +30 -30
- 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
package/README.md
CHANGED
|
@@ -1,152 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://maplibre.org/)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# MapLibre Native
|
|
4
4
|
|
|
5
|
-
MapLibre
|
|
5
|
+
MapLibre Native is a free and open-source library for publishing maps in your apps and desktop applications on various platforms. Fast displaying of maps is possible thanks to GPU-accelerated vector tile rendering.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
This project originated as a fork of Mapbox GL Native, before their switch to a non-OSS license in December 2020. For more information, see: [`FORK.md`](./FORK.md).
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* The iOS binaries distribution was upgraded from fat packages to Swift package containing XCFramework.
|
|
13
|
-
* The Android binaries are distributed to GitHub maven package repository.
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img src="https://user-images.githubusercontent.com/649392/211550776-8779041a-7c12-4bed-a7bd-c2ec80af2b29.png" alt="Android device with MapLibre" width="24%"> <img src="https://user-images.githubusercontent.com/649392/211550762-0f42ebc9-05ab-4d89-bd59-c306453ea9af.png" alt="iOS device with MapLibre" width="25%">
|
|
11
|
+
</p>
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
## Build Status
|
|
13
|
+
## Getting Started
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|---------------------------------------------------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
20
|
-
| [Maps SDK for iOS](platform/ios/) | CI | [](https://github.com/maplibre/maplibre-gl-native/workflows/ios-ci) |
|
|
21
|
-
| [Maps SDK for iOS](platform/ios/) | Release | [](https://github.com/maplibre/maplibre-gl-native/workflows/ios-release) |
|
|
22
|
-
| [Maps SDK for Android](platform/android/) | CI | [](https://github.com/maplibre/maplibre-gl-native/workflows/android-ci) |
|
|
23
|
-
| [Maps SDK for Android](platform/android/) | Release | [](https://github.com/maplibre/maplibre-gl-native/workflows/android-release) |
|
|
15
|
+
To get started with MapLibre Native, go to your platform below.
|
|
24
16
|
|
|
17
|
+
## Documentation
|
|
25
18
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
We thank everyone who supported us financially in the past and special thanks to the people and organizations who support us with recurring dontations:
|
|
29
|
-
|
|
30
|
-
[MIERUNE Inc.](https://www.mierune.co.jp/?lang=en) [@MIERUNE](https://github.com/MIERUNE), [@jawg](https://github.com/jawg), [@nekoyasan](https://github.com/nekoyasan), [@atierian](https://github.com/atierian), [@photoprism](https://github.com/photoprism), [@kaplanlior](https://github.com/kaplanlior), [@francois2metz](https://github.com/francois2metz), [@Schneider-Geo](https://github.com/Schneider-Geo), [@serghov](https://github.com/serghov), [@ambientlight](https://github.com/ambientlight), [@joschi77](https://github.com/joschi77), [@geoffhill](https://github.com/geoffhill), [@jasongode](https://github.com/jasongode)
|
|
31
|
-
|
|
32
|
-
## Installation
|
|
33
|
-
|
|
34
|
-
### Android
|
|
35
|
-
|
|
36
|
-
1. Add bintray maven repositories to your build.gradle at project level so that you can access MapLibre packages for Android:
|
|
37
|
-
|
|
38
|
-
```gradle
|
|
39
|
-
allprojects {
|
|
40
|
-
repositories {
|
|
41
|
-
...
|
|
42
|
-
mavenCentral()
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
> Note: [Bintray was turn off May 1st, 2021](https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/) so we migrated all packages to maven central.
|
|
48
|
-
|
|
49
|
-
2. Add the library as a dependency into your module build.gradle
|
|
19
|
+
The documentation of MapLibre Native is a work in progress. To get an architectural overview and to learn about the current state of the project and its path forward read the [MapLibre Native Markdown Book](https://maplibre.org/maplibre-native/docs/book/). See below for platform-specific documentation.
|
|
50
20
|
|
|
51
|
-
|
|
52
|
-
dependencies {
|
|
53
|
-
...
|
|
54
|
-
implementation 'org.maplibre.gl:android-sdk:9.4.0'
|
|
55
|
-
...
|
|
56
|
-
}
|
|
57
|
-
```
|
|
21
|
+
## Platforms
|
|
58
22
|
|
|
59
|
-
|
|
23
|
+
- [⭐️ Android](platform/android/README.md)
|
|
24
|
+
- [⭐️ iOS](platform/ios/README.md)
|
|
25
|
+
- [GLFW](platform/glfw)
|
|
26
|
+
- [Linux](platform/linux/README.md)
|
|
27
|
+
- [Node.js](platform/node/README.md)
|
|
28
|
+
- [Qt](platform/qt/README.md)
|
|
29
|
+
- [Windows](platform/windows/README.md)
|
|
30
|
+
- [macOS](platform/macos/README.md)
|
|
60
31
|
|
|
61
|
-
|
|
32
|
+
Platforms with a ⭐️ are **MapLibre Core Projects** and have a substantial amount of financial resources allocated to them. Learn about the different [project tiers](https://github.com/maplibre/maplibre/blob/main/PROJECT_TIERS.md#project-tiers).
|
|
62
33
|
|
|
63
|
-
|
|
34
|
+
## Renderer Modularization & Metal
|
|
64
35
|
|
|
65
|
-
|
|
36
|
+

|
|
66
37
|
|
|
67
|
-
|
|
38
|
+
MapLibre Native is being actively developed. Our big goal for 2023 is to modularize the OpenGL renderer and implement a Metal graphics backend (https://developer.apple.com/metal/). This will improve the performance and yield lower power consumption on iOS devices. At the same time, the Metal preparations will help us in the implementation of a Vulkan graphics backend.
|
|
68
39
|
|
|
69
|
-
|
|
40
|
+
Your help in preparing the codebase for the latest graphics backends is more than welcome. Feel free to reach out if you are interested in joining the effort!
|
|
70
41
|
|
|
71
|
-
|
|
42
|
+
- Check out the [news](https://maplibre.org/news/) on MapLibre's website.
|
|
43
|
+
- See the [Design Proposals](https://github.com/maplibre/maplibre-native/tree/main/design-proposals) that have been accepted and are being worked on, the most recent ones being the [Rendering Modularization Design Proposal](design-proposals/2022-10-27-rendering-modularization.md) and the [Metal Port Design Proposal](design-proposals/2022-11-29-metal-port.md).
|
|
72
44
|
|
|
73
|
-
##
|
|
45
|
+
## Contributing
|
|
74
46
|
|
|
75
|
-
|
|
47
|
+
To contribute to MapLibre Native, see [`CONTRIBUTING.md`](CONTRIBUTING.md) and (if applicable) the specific instructions for the platform you want to contribute to.
|
|
76
48
|
|
|
77
|
-
|
|
78
|
-
git clone --recurse-submodules https://github.com/maplibre/maplibre-gl-native.git
|
|
79
|
-
```
|
|
49
|
+
### Getting Involved
|
|
80
50
|
|
|
81
|
-
|
|
51
|
+
Join the `#maplibre-native` Slack channel at OSMUS. Get an invite at https://slack.openstreetmap.us/
|
|
82
52
|
|
|
83
|
-
|
|
53
|
+
### Bounties 💰
|
|
84
54
|
|
|
85
|
-
|
|
55
|
+
Thanks to our sponsors, we are able to award bounties to developers making contributions toward certain [bounty directions](https://github.com/maplibre/maplibre/issues?q=is%3Aissue+is%3Aopen+label%3A%22bounty+direction%22). To get started doing bounties, refer to the [step-by-step bounties guide](https://maplibre.org/roadmap/step-by-step-bounties-guide/).
|
|
86
56
|
|
|
87
|
-
|
|
88
|
-
# 1. Obtain a list of tags, which matches to release versions
|
|
89
|
-
git tag
|
|
90
|
-
|
|
91
|
-
# 2. Set a convenience variable with the desired TAG
|
|
92
|
-
# TAG=android-v9.2.1
|
|
93
|
-
# TAG=android-v9.4.2
|
|
94
|
-
TAG=ios-v5.11.0
|
|
95
|
-
# TAG=ios-v5.12.0-pre.1
|
|
96
|
-
|
|
97
|
-
# 3. Check out a particular TAG
|
|
98
|
-
git checkout tags/$TAG -b $TAG
|
|
99
|
-
|
|
100
|
-
# 4. build, debug or enhance features based on the tag
|
|
101
|
-
# clean, if you need to troubleshoot build dependencies by using `make clean`
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
#### Android
|
|
105
|
-
|
|
106
|
-
> Make sure you have set Android SDK path in platform/android/local.properties, variable sdk.dir
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
cd platform/android
|
|
110
|
-
BUILDTYPE=Release make apackage
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
Binaries are produced in `platform/android/MapboxGLAndroidSDK/build/outputs/aar/MapboxGLAndroidSDK-release.aar`
|
|
114
|
-
Please refer to [Mapbox Maps SDK for Android](platform/android/) for detailed instructions.
|
|
115
|
-
|
|
116
|
-
#### iOS
|
|
57
|
+
## Sponsors
|
|
117
58
|
|
|
118
|
-
|
|
59
|
+
We thank everyone who supported us financially in the past and special thanks to the people and organizations who support us with recurring donations!
|
|
119
60
|
|
|
120
|
-
|
|
121
|
-
cd platform/ios
|
|
61
|
+
Read more about the MapLibre Sponsorship Program at [https://maplibre.org/sponsors/](https://maplibre.org/sponsors/).
|
|
122
62
|
|
|
123
|
-
|
|
124
|
-
make iproj
|
|
63
|
+
Platinum:
|
|
125
64
|
|
|
126
|
-
|
|
127
|
-
make iproj CI=1
|
|
65
|
+
<a href="https://aws.com"><img src="https://maplibre.org/img/aws-logo.svg" alt="Logo AWS" width="25%"/></a>
|
|
128
66
|
|
|
129
|
-
|
|
130
|
-
make xcframework BUILDTYPE=Release
|
|
67
|
+
Silver:
|
|
131
68
|
|
|
132
|
-
|
|
133
|
-
make ios-test
|
|
69
|
+
<a href="https://meta.com"><img src="https://maplibre.org/img/meta-logo.svg" alt="Logo Meta" width="25%"/></a>
|
|
134
70
|
|
|
135
|
-
|
|
136
|
-
# You can review uitest results: $(IOS_OUTPUT_PATH)/Logs/Test
|
|
137
|
-
make ios-uitest
|
|
138
|
-
```
|
|
71
|
+
<a href="https://www.mierune.co.jp/?lang=en"><img src="https://maplibre.org/img/mierune-logo.svg" alt="Logo MIERUNE" width="25%"/></a>
|
|
139
72
|
|
|
140
|
-
|
|
141
|
-
Please refer to [Mapbox Maps SDK for iOS](platform/ios/platform/ios/) for detailed instructions.
|
|
73
|
+
<a href="https://komoot.com/"><img src="https://maplibre.org/img/komoot-logo.svg" alt="Logo komoot" width="25%"/></a>
|
|
142
74
|
|
|
75
|
+
Backers and Supporters:
|
|
143
76
|
|
|
144
|
-
|
|
77
|
+
[](https://opencollective.com/maplibre)
|
|
145
78
|
|
|
146
|
-
|
|
147
|
-
cd platform/ios
|
|
148
|
-
make xpackage
|
|
149
|
-
```
|
|
79
|
+
## License
|
|
150
80
|
|
|
151
|
-
|
|
152
|
-
Please refer to [Mapbox Maps SDK for macos](platform/ios/platform/macos/) for detailed instructions.
|
|
81
|
+
**MapLibre Native** is licensed under the [BSD 2-Clause License](./LICENSE.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acalcutt/maplibre-gl-native-test",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.1-pre.7",
|
|
4
4
|
"description": "Renders map tiles with Maplibre GL",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"maplibre",
|
|
@@ -10,47 +10,49 @@
|
|
|
10
10
|
"lib": "lib"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
|
-
"lib"
|
|
13
|
+
"lib",
|
|
14
|
+
"platform/node/index.d.ts"
|
|
14
15
|
],
|
|
15
16
|
"main": "platform/node/index.js",
|
|
17
|
+
"types": "platform/node/index.d.ts",
|
|
16
18
|
"repository": {
|
|
17
19
|
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/
|
|
20
|
+
"url": "git+https://github.com/wifidb/maplibre-native.git"
|
|
19
21
|
},
|
|
20
22
|
"license": "BSD-2-Clause",
|
|
21
23
|
"dependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"
|
|
25
|
-
"minimatch": "^3.0.4",
|
|
24
|
+
"@acalcutt/node-pre-gyp": "^1.0.14",
|
|
25
|
+
"@acalcutt/node-pre-gyp-github": "1.4.8",
|
|
26
|
+
"minimatch": "^7.2.0",
|
|
26
27
|
"npm-run-all": "^4.0.2"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"@mapbox/flow-remove-types": "^
|
|
30
|
-
"@mapbox/mvt-fixtures": "3.
|
|
31
|
-
"@octokit/plugin-retry": "^
|
|
32
|
-
"@octokit/rest": "^
|
|
33
|
-
"
|
|
30
|
+
"@mapbox/flow-remove-types": "^2.0.0",
|
|
31
|
+
"@mapbox/mvt-fixtures": "3.10.0",
|
|
32
|
+
"@octokit/plugin-retry": "^4.1.2",
|
|
33
|
+
"@octokit/rest": "^19.0.7",
|
|
34
|
+
"argparse": "^2.0.1",
|
|
35
|
+
"aws-sdk": "^2.1318.0",
|
|
34
36
|
"csscolorparser": "~1.0.2",
|
|
35
37
|
"d3-queue": "3.0.7",
|
|
36
|
-
"diff": "
|
|
37
|
-
"ejs": "^
|
|
38
|
+
"diff": "5.1.0",
|
|
39
|
+
"ejs": "^3.1.8",
|
|
38
40
|
"esm": "~3.2.25",
|
|
39
|
-
"express": "^4.
|
|
40
|
-
"json-stringify-pretty-compact": "^
|
|
41
|
-
"jsonwebtoken": "^
|
|
41
|
+
"express": "^4.18.2",
|
|
42
|
+
"json-stringify-pretty-compact": "^4.0.0",
|
|
43
|
+
"jsonwebtoken": "^9.0.0",
|
|
42
44
|
"lodash": "^4.16.4",
|
|
43
45
|
"lodash.template": "4.5.0",
|
|
44
46
|
"mapbox-gl-styles": "2.0.2",
|
|
45
|
-
"pixelmatch": "^
|
|
46
|
-
"pngjs": "^
|
|
47
|
-
"pretty-bytes": "^
|
|
47
|
+
"pixelmatch": "^5.3.0",
|
|
48
|
+
"pngjs": "^6.0.0",
|
|
49
|
+
"pretty-bytes": "^6.1.0",
|
|
48
50
|
"request": "^2.88.0",
|
|
49
|
-
"semver": "^
|
|
51
|
+
"semver": "^7.3.8",
|
|
50
52
|
"shuffle-seed": "1.1.6",
|
|
51
|
-
"st": "
|
|
52
|
-
"tape": "^
|
|
53
|
-
"xcode": "^
|
|
53
|
+
"st": "3.0.0",
|
|
54
|
+
"tape": "^5.6.3",
|
|
55
|
+
"xcode": "^3.0.1"
|
|
54
56
|
},
|
|
55
57
|
"engines": {
|
|
56
58
|
"node": ">=6"
|
|
@@ -61,16 +63,14 @@
|
|
|
61
63
|
"test-memory": "node --expose-gc platform/node/test/memory.test.js",
|
|
62
64
|
"test-expressions": "node -r esm platform/node/test/expression.test.js",
|
|
63
65
|
"test-render": "node -r esm platform/node/test/render.test.js",
|
|
64
|
-
"test-query": "node -r esm platform/node/test/query.test.js"
|
|
65
|
-
"package": "node-pre-gyp package",
|
|
66
|
-
"release": "node-pre-gyp-github publish --release"
|
|
66
|
+
"test-query": "node -r esm platform/node/test/query.test.js"
|
|
67
67
|
},
|
|
68
68
|
"gypfile": true,
|
|
69
69
|
"binary": {
|
|
70
|
-
"module_name": "
|
|
70
|
+
"module_name": "mln",
|
|
71
71
|
"module_path": "./lib/{node_abi}",
|
|
72
|
-
"host": "https://github.com/
|
|
73
|
-
"remote_path": "node-
|
|
72
|
+
"host": "https://github.com/wifidb/maplibre-native/releases/download/",
|
|
73
|
+
"remote_path": "node-v{version}",
|
|
74
74
|
"package_name": "{node_abi}-{platform}-{arch}-{configuration}.tar.gz"
|
|
75
75
|
}
|
|
76
76
|
}
|
package/platform/node/README.md
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
# @maplibre/maplibre-gl-native
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@maplibre/maplibre-gl-native)
|
|
4
|
+
[](https://github.com/maplibre/maplibre-native/actions/workflows/node-ci.yml)
|
|
5
5
|
|
|
6
6
|
## Installing
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Binaries are available and downloaded during install for the following platforms:
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
- Node.js v10.x
|
|
10
|
+
- Operating systems:
|
|
11
|
+
- Ubuntu 20.04 (amd64/arm64)
|
|
12
|
+
- macOS 12 (amd64/arm64)
|
|
13
|
+
- Windows (amd64)
|
|
14
|
+
- Node.js 14, 16, 18
|
|
16
15
|
|
|
17
16
|
Run:
|
|
18
17
|
|
|
@@ -20,18 +19,48 @@ Run:
|
|
|
20
19
|
npm install @maplibre/maplibre-gl-native
|
|
21
20
|
```
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
building from source.
|
|
22
|
+
Further platforms might work [with additional libraries installed](https://github.com/maplibre/maplibre-native/tree/main/platform/linux#prerequisites).
|
|
25
23
|
|
|
26
24
|
## Testing
|
|
27
25
|
|
|
28
26
|
```
|
|
29
27
|
npm test
|
|
30
|
-
npm run test-suite
|
|
31
28
|
```
|
|
32
29
|
|
|
33
30
|
## Rendering a map tile
|
|
34
31
|
|
|
32
|
+
The minimal example requires only the instantiation of the `mbgl.Map` object, loading a style and calling the `map.render` method:
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
var mbgl = require('@maplibre/maplibre-gl-native');
|
|
36
|
+
var sharp = require('sharp');
|
|
37
|
+
|
|
38
|
+
var map = new mbgl.Map();
|
|
39
|
+
|
|
40
|
+
map.load(require('./test/fixtures/style.json'));
|
|
41
|
+
|
|
42
|
+
map.render(function(err, buffer) {
|
|
43
|
+
if (err) throw err;
|
|
44
|
+
|
|
45
|
+
map.release();
|
|
46
|
+
|
|
47
|
+
var image = sharp(buffer, {
|
|
48
|
+
raw: {
|
|
49
|
+
width: 512,
|
|
50
|
+
height: 512,
|
|
51
|
+
channels: 4
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Convert raw image buffer to PNG
|
|
56
|
+
image.toFile('image.png', function(err) {
|
|
57
|
+
if (err) throw err;
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
But you can customize the map providing an options object to `mbgl.Map` constructor and to `map.render` method:
|
|
63
|
+
|
|
35
64
|
```js
|
|
36
65
|
var fs = require('fs');
|
|
37
66
|
var path = require('path');
|
|
@@ -89,7 +118,7 @@ When you are finished using a map object, you can call `map.release()` to perman
|
|
|
89
118
|
|
|
90
119
|
## Implementing a file source
|
|
91
120
|
|
|
92
|
-
When creating a `Map`, you
|
|
121
|
+
When creating a `Map`, you can optionally pass an options object (with an optional `request` method and optional `ratio` number) as the first parameter. The `request()` method handles a request for a resource. The `ratio` sets the scale at which the map will render tiles, such as `2.0` for rendering images for high pixel density displays:
|
|
93
122
|
|
|
94
123
|
```js
|
|
95
124
|
var map = new mbgl.Map({
|
|
@@ -100,7 +129,7 @@ var map = new mbgl.Map({
|
|
|
100
129
|
});
|
|
101
130
|
```
|
|
102
131
|
|
|
103
|
-
|
|
132
|
+
If you omit the `request` method, the `map` object will use the default internal request handlers, which is ok for most cases. However, if you have specific needs, you can implement your own `request` handler. When a `request` method is provided, all `map` resources will be requested by calling the `request` method with two parameters, called `req` and `callback` respectively in this example. The `req` parameter has two properties:
|
|
104
133
|
|
|
105
134
|
```json
|
|
106
135
|
{
|
|
@@ -109,7 +138,7 @@ The `request()` method handles a request for a resource. The `ratio` sets the sc
|
|
|
109
138
|
}
|
|
110
139
|
```
|
|
111
140
|
|
|
112
|
-
The `kind` is an enum and defined in [`mbgl.Resource`](https://github.com/maplibre/maplibre-
|
|
141
|
+
The `kind` is an enum and defined in [`mbgl.Resource`](https://github.com/maplibre/maplibre-native/blob/main/include/mbgl/storage/resource.hpp):
|
|
113
142
|
|
|
114
143
|
```json
|
|
115
144
|
{
|
|
@@ -125,7 +154,18 @@ The `kind` is an enum and defined in [`mbgl.Resource`](https://github.com/maplib
|
|
|
125
154
|
|
|
126
155
|
The `kind` enum has no significance for anything but serves as a hint to your implemention as to what sort of resource to expect. E.g., your implementation could choose caching strategies based on the expected file type.
|
|
127
156
|
|
|
128
|
-
The `
|
|
157
|
+
The `callback` parameter is a function that must be called with two parameters: an error message (if there are no errors, then you must pass `null`), and a response object:
|
|
158
|
+
|
|
159
|
+
```js
|
|
160
|
+
{
|
|
161
|
+
data: {data}, // required, must be a byte array, usually a Buffer object
|
|
162
|
+
modified: {modified}, // Date, optional
|
|
163
|
+
expires: {expires}, // Date, optional
|
|
164
|
+
etag: {etag} // string, optional
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
If there is no data to be sent to the `callback` (empty data, or `no-content` respose), then it must be called without parameters. The `request` implementation should pass uncompressed data to `callback`. If you are downloading assets from a source that applies gzip transport encoding, the implementation must decompress the results before passing them on.
|
|
129
169
|
|
|
130
170
|
A sample implementation that reads files from disk would look like the following:
|
|
131
171
|
|
|
@@ -175,6 +215,8 @@ var map = new mbgl.Map({
|
|
|
175
215
|
response.data = body;
|
|
176
216
|
|
|
177
217
|
callback(null, response);
|
|
218
|
+
} else if (res.statusCode == 204) {
|
|
219
|
+
callback();
|
|
178
220
|
} else {
|
|
179
221
|
callback(new Error(JSON.parse(body).message));
|
|
180
222
|
}
|
|
@@ -187,7 +229,7 @@ Stylesheets are free to use any protocols, but your implementation of `request`
|
|
|
187
229
|
|
|
188
230
|
## Listening for log events
|
|
189
231
|
|
|
190
|
-
The module imported with `require('maplibre-gl-native')` inherits from [`EventEmitter`](https://nodejs.org/api/events.html), and the `NodeLogObserver` will push log events to this. Log messages can have [`class`](https://github.com/maplibre/maplibre-
|
|
232
|
+
The module imported with `require('maplibre-gl-native')` inherits from [`EventEmitter`](https://nodejs.org/api/events.html), and the `NodeLogObserver` will push log events to this. Log messages can have [`class`](https://github.com/maplibre/maplibre-native/blob/node-v2.1.0/include/mbgl/platform/event.hpp#L43-L60), [`severity`](https://github.com/maplibre/maplibre-native/blob/node-v2.1.0/include/mbgl/platform/event.hpp#L17-L23), `code` ([HTTP status codes](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)), and `text` parameters.
|
|
191
233
|
|
|
192
234
|
```js
|
|
193
235
|
var mbgl = require('@maplibre/maplibre-gl-native');
|