maplibre-gl 3.0.0 → 3.1.0
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 +9 -7
- package/build/generate-shaders.ts +39 -6
- package/build/readme.md +0 -5
- package/dist/maplibre-gl-csp-worker.js +1 -1
- package/dist/maplibre-gl-csp-worker.js.map +1 -1
- package/dist/maplibre-gl-csp.js +1 -1
- package/dist/maplibre-gl-csp.js.map +1 -1
- package/dist/maplibre-gl-dev.js +176 -127
- package/dist/maplibre-gl-dev.js.map +1 -1
- package/dist/maplibre-gl.d.ts +48 -42
- package/dist/maplibre-gl.js +4 -4
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +34 -33
- package/src/geo/lng_lat.ts +2 -2
- package/src/gl/context.ts +27 -9
- package/src/gl/types.ts +14 -14
- package/src/gl/value.ts +11 -3
- package/src/gl/vertex_buffer.ts +2 -2
- package/src/gl/webgl2.ts +12 -0
- package/src/index.ts +0 -17
- package/src/render/draw_heatmap.ts +1 -0
- package/src/render/painter.ts +1 -1
- package/src/render/program.ts +3 -2
- package/src/render/texture.ts +4 -4
- package/src/render/uniform_binding.ts +1 -1
- package/src/shaders/README.md +4 -4
- package/src/shaders/_prelude.fragment.glsl +2 -0
- package/src/shaders/_prelude.fragment.glsl.g.ts +1 -1
- package/src/shaders/_prelude.vertex.glsl +3 -3
- package/src/shaders/background.fragment.glsl +2 -2
- package/src/shaders/background.vertex.glsl +1 -1
- package/src/shaders/background_pattern.fragment.glsl +6 -6
- package/src/shaders/background_pattern.vertex.glsl +3 -4
- package/src/shaders/circle.fragment.glsl +5 -9
- package/src/shaders/circle.vertex.glsl +3 -3
- package/src/shaders/clipping_mask.fragment.glsl +1 -1
- package/src/shaders/clipping_mask.vertex.glsl +1 -1
- package/src/shaders/collision_box.fragment.glsl +5 -6
- package/src/shaders/collision_box.vertex.glsl +7 -7
- package/src/shaders/collision_circle.fragment.glsl +5 -5
- package/src/shaders/collision_circle.vertex.glsl +7 -7
- package/src/shaders/debug.fragment.glsl +3 -3
- package/src/shaders/debug.vertex.glsl +2 -2
- package/src/shaders/fill.fragment.glsl +2 -2
- package/src/shaders/fill.vertex.glsl +1 -1
- package/src/shaders/fill_extrusion.fragment.glsl +3 -3
- package/src/shaders/fill_extrusion.vertex.glsl +4 -4
- package/src/shaders/fill_extrusion_pattern.fragment.glsl +9 -7
- package/src/shaders/fill_extrusion_pattern.vertex.glsl +6 -6
- package/src/shaders/fill_outline.fragment.glsl +3 -3
- package/src/shaders/fill_outline.vertex.glsl +2 -2
- package/src/shaders/fill_outline_pattern.fragment.glsl +7 -7
- package/src/shaders/fill_outline_pattern.vertex.glsl +4 -4
- package/src/shaders/fill_pattern.fragment.glsl +6 -6
- package/src/shaders/fill_pattern.vertex.glsl +3 -3
- package/src/shaders/heatmap.fragment.glsl +3 -3
- package/src/shaders/heatmap.vertex.glsl +4 -4
- package/src/shaders/heatmap_texture.fragment.glsl +6 -5
- package/src/shaders/heatmap_texture.vertex.glsl +2 -2
- package/src/shaders/hillshade.fragment.glsl +4 -4
- package/src/shaders/hillshade.vertex.glsl +3 -3
- package/src/shaders/hillshade_prepare.fragment.glsl +6 -4
- package/src/shaders/hillshade_prepare.vertex.glsl +3 -3
- package/src/shaders/line.fragment.glsl +5 -5
- package/src/shaders/line.vertex.glsl +6 -6
- package/src/shaders/line_gradient.fragment.glsl +7 -7
- package/src/shaders/line_gradient.vertex.glsl +8 -8
- package/src/shaders/line_pattern.fragment.glsl +8 -8
- package/src/shaders/line_pattern.vertex.glsl +7 -7
- package/src/shaders/line_sdf.fragment.glsl +9 -9
- package/src/shaders/line_sdf.vertex.glsl +7 -7
- package/src/shaders/raster.fragment.glsl +7 -6
- package/src/shaders/raster.vertex.glsl +4 -4
- package/src/shaders/symbol_icon.fragment.glsl +4 -4
- package/src/shaders/symbol_icon.vertex.glsl +7 -7
- package/src/shaders/symbol_sdf.fragment.glsl +5 -5
- package/src/shaders/symbol_sdf.vertex.glsl +7 -7
- package/src/shaders/symbol_text_and_icon.fragment.glsl +7 -7
- package/src/shaders/symbol_text_and_icon.vertex.glsl +6 -6
- package/src/shaders/terrain.fragment.glsl +2 -2
- package/src/shaders/terrain.vertex.glsl +3 -3
- package/src/shaders/terrain_coords.fragment.glsl +3 -3
- package/src/shaders/terrain_depth.fragment.glsl +2 -2
- package/src/source/raster_dem_tile_source.ts +4 -3
- package/src/source/source_cache.ts +8 -3
- package/src/source/vector_tile_source.test.ts +11 -11
- package/src/source/vector_tile_worker_source.ts +1 -1
- package/src/style/style_layer/custom_style_layer.ts +7 -7
- package/src/ui/control/attribution_control.ts +1 -1
- package/src/ui/control/fullscreen_control.ts +1 -1
- package/src/ui/control/geolocate_control.ts +6 -6
- package/src/ui/control/navigation_control.ts +4 -4
- package/src/ui/control/scale_control.ts +1 -1
- package/src/ui/control/terrain_control.ts +4 -5
- package/src/ui/events.ts +2 -0
- package/src/ui/map.test.ts +11 -0
- package/src/ui/map.ts +19 -12
- package/src/ui/marker.ts +2 -2
- package/src/ui/popup.ts +2 -2
- package/src/util/browser.ts +2 -2
- package/src/util/config.ts +2 -0
- package/src/util/request_manager.ts +1 -1
- package/src/util/test/mock_webgl.ts +4 -1
- package/src/util/webp_supported.ts +3 -3
package/README.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
# MapLibre GL JS
|
|
4
4
|
|
|
5
|
+
[](LICENSE.txt) [](https://www.npmjs.com/package/maplibre-gl) [](https://github.com/maplibre/maplibre-gl-js/actions/workflows/ci.yml) [](https://opensource.org/licenses/BSD-3-Clause) [](https://codecov.io/gh/maplibre/maplibre-gl-js)
|
|
6
|
+
|
|
5
7
|
**[MapLibre GL JS](https://maplibre.org/maplibre-gl-js-docs/api/)** is an open-source library for publishing maps on your websites or webview based apps. Fast displaying of maps is possible thanks to GPU-accelerated vector tile rendering.
|
|
6
8
|
|
|
7
9
|
It originated as an open-source fork of [mapbox-gl-js](https://github.com/mapbox/mapbox-gl-js), before their switch to a non-OSS license in December 2020. The library's initial versions (1.x) were intended to be a drop-in replacement for the Mapbox’s OSS version (1.x) with additional functionality, but have evolved a lot since then.
|
|
8
10
|
|
|
9
|
-
[](LICENSE.txt)[](https://www.npmjs.com/package/maplibre-gl)[](https://github.com/maplibre/maplibre-gl-js/actions/workflows/ci.yml)[](https://opensource.org/licenses/BSD-3-Clause)
|
|
10
|
-
|
|
11
11
|
## Getting Started
|
|
12
12
|
|
|
13
13
|
Include the JavaScript and CSS files in the `<head>` of your HTML file.
|
|
@@ -64,11 +64,11 @@ The overall migration happens by uninstalling `mapbox-gl` and installing `maplib
|
|
|
64
64
|
|
|
65
65
|
#### Compatibility branch
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
MapLibre GL JS v1 is completely backward compatible with Mapbox GL JS v1. This compatibility branch (named 1.x) is tagged v1 on npm, and its current version is 1.15.3.
|
|
68
68
|
|
|
69
69
|
#### CDN Links
|
|
70
70
|
|
|
71
|
-
> MapLibre GL JS is distributed via [unpkg.com](https://unpkg.com). For more information, please see [MapLibre GL is on unpkg.com](./documents_and_diagrams/README-unpkg.md#maplibre-gl-on-unpkgcom).
|
|
71
|
+
> MapLibre GL JS is distributed via [unpkg.com](https://unpkg.com). For more information, please see [MapLibre GL JS is on unpkg.com](./documents_and_diagrams/README-unpkg.md#maplibre-gl-on-unpkgcom).
|
|
72
72
|
|
|
73
73
|
```diff
|
|
74
74
|
- <script src="https://api.mapbox.com/mapbox-gl-js/v#.#.#/mapbox-gl.js"></script>
|
|
@@ -105,10 +105,10 @@ You can find the official status of the backing community and steering committee
|
|
|
105
105
|
|
|
106
106
|
### Avoid Fragmentation
|
|
107
107
|
|
|
108
|
-
If you depend on a free software alternative to `mapbox-gl-js`, please consider joining our effort! Anyone with a stake in a healthy community-led fork is welcome to help us figure out our next steps. We welcome contributors and leaders! MapLibre GL already represents the combined efforts of a few early fork efforts, and we all benefit from "one project" rather than "our way". If you know of other forks, please reach out to them and direct them here.
|
|
108
|
+
If you depend on a free software alternative to `mapbox-gl-js`, please consider joining our effort! Anyone with a stake in a healthy community-led fork is welcome to help us figure out our next steps. We welcome contributors and leaders! MapLibre GL JS already represents the combined efforts of a few early fork efforts, and we all benefit from "one project" rather than "our way". If you know of other forks, please reach out to them and direct them here.
|
|
109
109
|
|
|
110
110
|
|
|
111
|
-
> **MapLibre GL** is developed following [Semantic Versioning (2.0.0)](https://semver.org/spec/v2.0.0.html).
|
|
111
|
+
> **MapLibre GL JS** is developed following [Semantic Versioning (2.0.0)](https://semver.org/spec/v2.0.0.html).
|
|
112
112
|
|
|
113
113
|
### Bounties
|
|
114
114
|
|
|
@@ -138,6 +138,8 @@ Silver:
|
|
|
138
138
|
|
|
139
139
|
<a href="https://komoot.com/"><img src="https://maplibre.org/img/komoot-logo.svg" alt="Logo komoot" width="25%"/></a>
|
|
140
140
|
|
|
141
|
+
<a href="https://www.jawg.io/"><img src="https://maplibre.org/img/jawgmaps-logo.svg" alt="Logo JawgMaps" width="25%"/></a>
|
|
142
|
+
|
|
141
143
|
|
|
142
144
|
Backers and Supporters:
|
|
143
145
|
|
|
@@ -185,4 +187,4 @@ Please keep in mind: Unauthorized backports are the biggest threat to the MapLib
|
|
|
185
187
|
|
|
186
188
|
## License
|
|
187
189
|
|
|
188
|
-
**MapLibre GL** is licensed under the [3-Clause BSD license](./LICENSE.txt).
|
|
190
|
+
**MapLibre GL JS** is licensed under the [3-Clause BSD license](./LICENSE.txt).
|
|
@@ -12,18 +12,51 @@ console.log('Generating shaders');
|
|
|
12
12
|
* It will also create a simple package.json file to allow importing this package in webpack
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
for (const file of
|
|
15
|
+
const vertex = globSync('./src/shaders/*.vertex.glsl');
|
|
16
|
+
for (const file of vertex) {
|
|
17
17
|
const code = fs.readFileSync(file, 'utf8');
|
|
18
|
-
const content = glslToTs(code);
|
|
18
|
+
const content = glslToTs(code, 'vertex');
|
|
19
19
|
const fileName = path.join('.', 'src', 'shaders', `${file.split(path.sep).splice(-1)}.g.ts`);
|
|
20
20
|
fs.writeFileSync(fileName, content);
|
|
21
21
|
}
|
|
22
|
-
console.log(`Finished converting ${files.length} glsl files`);
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
console.log(`Finished converting ${vertex.length} vertex shaders`);
|
|
24
|
+
|
|
25
|
+
const fragment = globSync('./src/shaders/*.fragment.glsl');
|
|
26
|
+
for (const file of fragment) {
|
|
27
|
+
const code = fs.readFileSync(file, 'utf8');
|
|
28
|
+
const content = glslToTs(code, 'fragment');
|
|
29
|
+
const fileName = path.join('.', 'src', 'shaders', `${file.split(path.sep).splice(-1)}.g.ts`);
|
|
30
|
+
fs.writeFileSync(fileName, content);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
console.log(`Finished converting ${fragment.length} fragment shaders`);
|
|
34
|
+
|
|
35
|
+
function glslToTs(code: string, type: 'fragment'|'vertex'): string {
|
|
36
|
+
code = code
|
|
37
|
+
.trim(); // strip whitespace at the start/end
|
|
38
|
+
|
|
39
|
+
// WebGL1 Compat -- Start
|
|
40
|
+
|
|
41
|
+
if (type === 'fragment') {
|
|
42
|
+
code = code
|
|
43
|
+
.replace(/\bin\s/g, 'varying ') // For fragment shaders, replace "in " with "varying "
|
|
44
|
+
.replace('out highp vec4 fragColor;', '');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (type === 'vertex') {
|
|
48
|
+
code = code
|
|
49
|
+
.replace(/\bin\s/g, 'attribute ') // For vertex shaders, replace "in " with "attribute "
|
|
50
|
+
.replace(/\bout\s/g, 'varying '); // For vertex shaders, replace "out " with "varying "
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
code = code
|
|
54
|
+
.replace(/fragColor/g, 'gl_FragColor')
|
|
55
|
+
.replace(/texture\(/g, 'texture2D(');
|
|
56
|
+
|
|
57
|
+
// WebGL1 Compat -- End
|
|
58
|
+
|
|
25
59
|
code = code
|
|
26
|
-
.trim() // strip whitespace at the start/end
|
|
27
60
|
.replace(/\s*\/\/[^\n]*\n/g, '\n') // strip double-slash comments
|
|
28
61
|
.replace(/\n+/g, '\n') // collapse multi line breaks
|
|
29
62
|
.replace(/\n\s+/g, '\n') // strip indentation
|
package/build/readme.md
CHANGED
|
@@ -29,9 +29,6 @@ Rollup is generating 3 files throughout the process of bundling:
|
|
|
29
29
|
|
|
30
30
|
These 3 files are then referenced and used by the `bundle_prelude.js` file. It allows loading the web wroker code automatically in web workers without any extra effort from someone who would like to use the library, i.e. it simply works.
|
|
31
31
|
|
|
32
|
-
### check-bundle-size.js
|
|
33
|
-
This file is used by CI to make sure the bundle size is kept constant
|
|
34
|
-
|
|
35
32
|
<hr>
|
|
36
33
|
|
|
37
34
|
### `npm run codegen`
|
|
@@ -43,8 +40,6 @@ Generates `data/array_types.ts`, which consists of:
|
|
|
43
40
|
- Specific named `StructArray` subclasses, when type-specific struct accessors are needed (e.g., `CollisionBoxArray`)
|
|
44
41
|
#### generate-style-code.ts
|
|
45
42
|
Generates the various `style/style_layer/[layer type]_style_layer_properties.ts` code files based on the content of `v8.json`. These files provide the type signatures for the paint and layout properties for each type of style layer.
|
|
46
|
-
#### generate-style-spec.ts
|
|
47
|
-
Generates `style-spec/types.ts` based on the content of `v8.json`. This provides the type signatures for a style specification (sources, layers, etc.).
|
|
48
43
|
<hr>
|
|
49
44
|
|
|
50
45
|
### Generate Release Nodes
|