@acalcutt/maplibre-gl-native-test 5.0.20 → 5.2.1-pre.10
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
package/LICENSE.mbgl-core.md
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
### [
|
|
1
|
+
### [Maplibre Native](https://github.com/maplibre/maplibre-native/)
|
|
2
2
|
|
|
3
3
|
```
|
|
4
|
-
|
|
4
|
+
BSD 2-Clause License
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2021 MapLibre contributors
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2018-2021 MapTiler.com
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2014-2020 Mapbox
|
|
5
11
|
|
|
6
12
|
Redistribution and use in source and binary forms, with or without
|
|
7
13
|
modification, are permitted provided that the following conditions are
|
package/README.md
CHANGED
|
@@ -1,152 +1,87 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://maplibre.org/)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# MapLibre Native
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://codecov.io/github/maplibre/maplibre-native) [](https://slack.openstreetmap.us/)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
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.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
* CI/CD was migrated from CircleCI to GitHub Actions.
|
|
11
|
-
* Along with GitHub releases, binaries are distributed as follows:
|
|
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
|
+
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).
|
|
14
10
|
|
|
15
|
-
>
|
|
16
|
-
|
|
11
|
+
<p align="center">
|
|
12
|
+
<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%">
|
|
13
|
+
</p>
|
|
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
|
+
## Getting Started
|
|
24
16
|
|
|
17
|
+
To get started with MapLibre Native, go to your platform below.
|
|
25
18
|
|
|
26
|
-
##
|
|
19
|
+
## Documentation
|
|
27
20
|
|
|
28
|
-
|
|
21
|
+
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.
|
|
29
22
|
|
|
30
|
-
|
|
23
|
+
## Platforms
|
|
31
24
|
|
|
32
|
-
|
|
25
|
+
- [⭐️ Android](platform/android/README.md)
|
|
26
|
+
- [⭐️ iOS](platform/ios/README.md)
|
|
27
|
+
- [GLFW](platform/glfw)
|
|
28
|
+
- [Linux](platform/linux/README.md)
|
|
29
|
+
- [Node.js](platform/node/README.md)
|
|
30
|
+
- [Qt](platform/qt/README.md)
|
|
31
|
+
- [Windows](platform/windows/README.md)
|
|
32
|
+
- [macOS](platform/macos/README.md)
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
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).
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
## Renderer Modularization & Metal
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
allprojects {
|
|
40
|
-
repositories {
|
|
41
|
-
...
|
|
42
|
-
mavenCentral()
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
```
|
|
38
|
+

|
|
46
39
|
|
|
47
|
-
|
|
40
|
+
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.
|
|
48
41
|
|
|
49
|
-
|
|
42
|
+
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!
|
|
50
43
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
...
|
|
54
|
-
implementation 'org.maplibre.gl:android-sdk:9.4.0'
|
|
55
|
-
...
|
|
56
|
-
}
|
|
57
|
-
```
|
|
44
|
+
- Check out the [news](https://maplibre.org/news/) on MapLibre's website.
|
|
45
|
+
- 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).
|
|
58
46
|
|
|
59
|
-
|
|
47
|
+
## Contributing
|
|
60
48
|
|
|
61
|
-
|
|
49
|
+
To contribute to MapLibre Native, see [`CONTRIBUTING.md`](CONTRIBUTING.md) and (if applicable) the specific instructions for the platform you want to contribute to.
|
|
62
50
|
|
|
63
|
-
|
|
51
|
+
### Getting Involved
|
|
64
52
|
|
|
65
|
-
|
|
53
|
+
Join the `#maplibre-native` Slack channel at OSMUS. Get an invite at https://slack.openstreetmap.us/
|
|
66
54
|
|
|
67
|
-
|
|
55
|
+
### Bounties 💰
|
|
68
56
|
|
|
69
|
-
|
|
57
|
+
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/).
|
|
70
58
|
|
|
71
|
-
|
|
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!
|
|
72
60
|
|
|
73
|
-
|
|
61
|
+
Read more about the MapLibre Sponsorship Program at [https://maplibre.org/sponsors/](https://maplibre.org/sponsors/).
|
|
74
62
|
|
|
75
|
-
|
|
63
|
+
Platinum:
|
|
76
64
|
|
|
77
|
-
|
|
78
|
-
git clone --recurse-submodules https://github.com/maplibre/maplibre-gl-native.git
|
|
79
|
-
```
|
|
65
|
+
<a href="https://aws.com"><img src="https://maplibre.org/img/aws-logo.svg" alt="Logo AWS" width="25%"/></a>
|
|
80
66
|
|
|
81
|
-
|
|
67
|
+
Gold:
|
|
82
68
|
|
|
83
|
-
|
|
69
|
+
<a href="https://meta.com"><img src="https://maplibre.org/img/meta-logo.svg" alt="Logo Meta" width="25%"/></a>
|
|
84
70
|
|
|
85
|
-
|
|
71
|
+
Silver:
|
|
86
72
|
|
|
87
|
-
|
|
88
|
-
# 1. Obtain a list of tags, which matches to release versions
|
|
89
|
-
git tag
|
|
73
|
+
<a href="https://www.mierune.co.jp/?lang=en"><img src="https://maplibre.org/img/mierune-logo.svg" alt="Logo MIERUNE" width="25%"/></a>
|
|
90
74
|
|
|
91
|
-
|
|
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
|
|
75
|
+
<a href="https://komoot.com/"><img src="https://maplibre.org/img/komoot-logo.svg" alt="Logo komoot" width="25%"/></a>
|
|
96
76
|
|
|
97
|
-
|
|
98
|
-
git checkout tags/$TAG -b $TAG
|
|
77
|
+
<a href="https://www.jawg.io/"><img src="https://maplibre.org/img/jawgmaps-logo.svg" alt="Logo JawgMaps" width="25%"/></a>
|
|
99
78
|
|
|
100
|
-
|
|
101
|
-
# clean, if you need to troubleshoot build dependencies by using `make clean`
|
|
102
|
-
```
|
|
79
|
+
<a href="https://www.radar.com/"><img src="https://maplibre.org/img/radar-logo.svg" alt="Logo Radar" width="25%"/></a>
|
|
103
80
|
|
|
104
|
-
|
|
81
|
+
Backers and Supporters:
|
|
105
82
|
|
|
106
|
-
|
|
83
|
+
[](https://opencollective.com/maplibre)
|
|
107
84
|
|
|
108
|
-
|
|
109
|
-
cd platform/android
|
|
110
|
-
BUILDTYPE=Release make apackage
|
|
111
|
-
```
|
|
85
|
+
## License
|
|
112
86
|
|
|
113
|
-
|
|
114
|
-
Please refer to [Mapbox Maps SDK for Android](platform/android/) for detailed instructions.
|
|
115
|
-
|
|
116
|
-
#### iOS
|
|
117
|
-
|
|
118
|
-
You can run automated test on a Simulator or Device by changing to the Scheme `iosapp` and choosing `Product` > `Test` (or use `⌘-U`). Use `⌘-9` to navigate to `Reports` to see results and browse through screenshots. This method of testing should work well with CI tools such as GitHub Actions, Xcode Server Bots, & AWS Device Farm.
|
|
119
|
-
|
|
120
|
-
```bash
|
|
121
|
-
cd platform/ios
|
|
122
|
-
|
|
123
|
-
# make and open the Xcode workspace
|
|
124
|
-
make iproj
|
|
125
|
-
|
|
126
|
-
# make Xcode workspace, but run in headless mode
|
|
127
|
-
make iproj CI=1
|
|
128
|
-
|
|
129
|
-
# Make Frameworks
|
|
130
|
-
make xcframework BUILDTYPE=Release
|
|
131
|
-
|
|
132
|
-
# test
|
|
133
|
-
make ios-test
|
|
134
|
-
|
|
135
|
-
# UITests
|
|
136
|
-
# You can review uitest results: $(IOS_OUTPUT_PATH)/Logs/Test
|
|
137
|
-
make ios-uitest
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
The packaging script will produce a `Mapbox.xcframework` in the `platform/ios/build/ios/pkg/dynamic` folder.
|
|
141
|
-
Please refer to [Mapbox Maps SDK for iOS](platform/ios/platform/ios/) for detailed instructions.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
#### MacOS
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
cd platform/ios
|
|
148
|
-
make xpackage
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
This produces a `Mapbox.framework` in the `platform/ios/build/macos/pkg/` folder.
|
|
152
|
-
Please refer to [Mapbox Maps SDK for macos](platform/ios/platform/macos/) for detailed instructions.
|
|
87
|
+
**MapLibre Native** is licensed under the [BSD 2-Clause License](./LICENSE.md).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acalcutt/maplibre-gl-native-test",
|
|
3
|
-
"version": "5.
|
|
4
|
-
"description": "Renders map tiles with
|
|
3
|
+
"version": "5.2.1-pre.10",
|
|
4
|
+
"description": "Renders map tiles with MapLibre Native",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"maplibre",
|
|
7
7
|
"gl"
|
|
@@ -10,67 +10,67 @@
|
|
|
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.5.2",
|
|
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"
|
|
57
59
|
},
|
|
58
60
|
"scripts": {
|
|
59
|
-
"install": "node-pre-gyp install --fallback-to-build=
|
|
61
|
+
"install": "node-pre-gyp install --fallback-to-build=false",
|
|
60
62
|
"test": "tape platform/node/test/js/**/*.test.js",
|
|
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
70
|
"module_name": "mbgl",
|
|
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 22.04 (amd64/arm64)
|
|
12
|
+
- macOS 12 (amd64/arm64)
|
|
13
|
+
- Windows (amd64)
|
|
14
|
+
- Node.js 16, 18, 20
|
|
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');
|