@acalcutt/maplibre-gl-native-test 5.0.20 → 5.2.1-pre.2
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 -116
- package/package.json +28 -29
- package/platform/node/README.md +10 -10
- 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,82 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://maplibre.org/)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# MapLibre GL Native
|
|
4
4
|
|
|
5
|
-
MapLibre GL Native is a
|
|
5
|
+
MapLibre GL 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 GL 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 GL 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 GL Native Markdown Book](https://maplibre.org/maplibre-gl-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/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/ios/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 GL 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/louwers/maplibre-gl-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 GL 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.
|
|
57
|
+
## Sponsors
|
|
115
58
|
|
|
116
|
-
|
|
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!
|
|
117
60
|
|
|
118
|
-
|
|
61
|
+
Read more about the MapLibre Sponsorship Program at [https://maplibre.org/sponsors/](https://maplibre.org/sponsors/).
|
|
119
62
|
|
|
120
|
-
|
|
121
|
-
cd platform/ios
|
|
63
|
+
Platinum:
|
|
122
64
|
|
|
123
|
-
|
|
124
|
-
make iproj
|
|
65
|
+
<img src="https://maplibre.org/img/aws-logo.svg" alt="Logo AWS" width="25%"/>
|
|
125
66
|
|
|
126
|
-
# make Xcode workspace, but run in headless mode
|
|
127
|
-
make iproj CI=1
|
|
128
67
|
|
|
129
|
-
|
|
130
|
-
make xcframework BUILDTYPE=Release
|
|
68
|
+
Silver:
|
|
131
69
|
|
|
132
|
-
|
|
133
|
-
make ios-test
|
|
70
|
+
<img src="https://maplibre.org/img/meta-logo.svg" alt="Logo Meta" width="50%"/>
|
|
134
71
|
|
|
135
|
-
|
|
136
|
-
# You can review uitest results: $(IOS_OUTPUT_PATH)/Logs/Test
|
|
137
|
-
make ios-uitest
|
|
138
|
-
```
|
|
72
|
+
Stone:
|
|
139
73
|
|
|
140
|
-
|
|
141
|
-
Please refer to [Mapbox Maps SDK for iOS](platform/ios/platform/ios/) for detailed instructions.
|
|
74
|
+
[MIERUNE Inc.](https://www.mierune.co.jp/?lang=en)
|
|
142
75
|
|
|
76
|
+
Backers and Supporters:
|
|
143
77
|
|
|
144
|
-
|
|
78
|
+
[](https://opencollective.com/maplibre)
|
|
145
79
|
|
|
146
|
-
|
|
147
|
-
cd platform/ios
|
|
148
|
-
make xpackage
|
|
149
|
-
```
|
|
80
|
+
## License
|
|
150
81
|
|
|
151
|
-
|
|
152
|
-
Please refer to [Mapbox Maps SDK for macos](platform/ios/platform/macos/) for detailed instructions.
|
|
82
|
+
**MapLibre GL 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.2",
|
|
4
4
|
"description": "Renders map tiles with Maplibre GL",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"maplibre",
|
|
@@ -10,47 +10,48 @@
|
|
|
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-gl-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.11",
|
|
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
|
-
"aws-sdk": "^2.
|
|
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
|
+
"aws-sdk": "^2.1318.0",
|
|
34
35
|
"csscolorparser": "~1.0.2",
|
|
35
36
|
"d3-queue": "3.0.7",
|
|
36
|
-
"diff": "
|
|
37
|
-
"ejs": "^
|
|
37
|
+
"diff": "5.1.0",
|
|
38
|
+
"ejs": "^3.1.8",
|
|
38
39
|
"esm": "~3.2.25",
|
|
39
|
-
"express": "^4.
|
|
40
|
-
"json-stringify-pretty-compact": "^
|
|
41
|
-
"jsonwebtoken": "^
|
|
40
|
+
"express": "^4.18.2",
|
|
41
|
+
"json-stringify-pretty-compact": "^4.0.0",
|
|
42
|
+
"jsonwebtoken": "^9.0.0",
|
|
42
43
|
"lodash": "^4.16.4",
|
|
43
44
|
"lodash.template": "4.5.0",
|
|
44
45
|
"mapbox-gl-styles": "2.0.2",
|
|
45
|
-
"pixelmatch": "^
|
|
46
|
-
"pngjs": "^
|
|
47
|
-
"pretty-bytes": "^
|
|
46
|
+
"pixelmatch": "^5.3.0",
|
|
47
|
+
"pngjs": "^6.0.0",
|
|
48
|
+
"pretty-bytes": "^6.1.0",
|
|
48
49
|
"request": "^2.88.0",
|
|
49
|
-
"semver": "^
|
|
50
|
+
"semver": "^7.3.8",
|
|
50
51
|
"shuffle-seed": "1.1.6",
|
|
51
|
-
"st": "
|
|
52
|
-
"tape": "^
|
|
53
|
-
"xcode": "^
|
|
52
|
+
"st": "3.0.0",
|
|
53
|
+
"tape": "^5.6.3",
|
|
54
|
+
"xcode": "^3.0.1"
|
|
54
55
|
},
|
|
55
56
|
"engines": {
|
|
56
57
|
"node": ">=6"
|
|
@@ -61,16 +62,14 @@
|
|
|
61
62
|
"test-memory": "node --expose-gc platform/node/test/memory.test.js",
|
|
62
63
|
"test-expressions": "node -r esm platform/node/test/expression.test.js",
|
|
63
64
|
"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"
|
|
65
|
+
"test-query": "node -r esm platform/node/test/query.test.js"
|
|
67
66
|
},
|
|
68
67
|
"gypfile": true,
|
|
69
68
|
"binary": {
|
|
70
69
|
"module_name": "mbgl",
|
|
71
70
|
"module_path": "./lib/{node_abi}",
|
|
72
|
-
"host": "https://github.com/
|
|
73
|
-
"remote_path": "node-
|
|
71
|
+
"host": "https://github.com/wifidb/maplibre-gl-native/releases/download/",
|
|
72
|
+
"remote_path": "node-v{version}",
|
|
74
73
|
"package_name": "{node_abi}-{platform}-{arch}-{configuration}.tar.gz"
|
|
75
74
|
}
|
|
76
75
|
}
|
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
4
|
[](https://github.com/maplibre/maplibre-gl-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,8 +19,7 @@ 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-gl-native/tree/main/platform/linux#prerequisites).
|
|
25
23
|
|
|
26
24
|
## Testing
|
|
27
25
|
|
|
@@ -175,6 +173,8 @@ var map = new mbgl.Map({
|
|
|
175
173
|
response.data = body;
|
|
176
174
|
|
|
177
175
|
callback(null, response);
|
|
176
|
+
} else if (res.statusCode == 204) {
|
|
177
|
+
callback();
|
|
178
178
|
} else {
|
|
179
179
|
callback(new Error(JSON.parse(body).message));
|
|
180
180
|
}
|
|
@@ -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;
|