maplibre-gl-leaflet-with-canvas-dash-offset 0.1.4
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/.github/FUNDING.yml +2 -0
- package/.github/workflows/publish.yml +27 -0
- package/.github/workflows/test.yml +27 -0
- package/.travis.yml +6 -0
- package/API.md +43 -0
- package/CHANGELOG.md +145 -0
- package/CONTRIBUTING.md +8 -0
- package/LICENSE +15 -0
- package/README.md +99 -0
- package/debug/README.md +5 -0
- package/debug/maps-concurrent-resizing.html +362 -0
- package/debug/max-latitude-bug-reproduction.html +49 -0
- package/examples/basic.html +52 -0
- package/examples/cluster.html +52 -0
- package/examples/events.html +86 -0
- package/examples/overlay.html +47 -0
- package/leaflet-maplibre-gl.d.ts +20 -0
- package/leaflet-maplibre-gl.js +346 -0
- package/package.json +37 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
push:
|
|
6
|
+
tags:
|
|
7
|
+
- v*
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
publish:
|
|
11
|
+
name: Publish
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v2
|
|
15
|
+
|
|
16
|
+
- name: Use Node.js 18 x64
|
|
17
|
+
uses: actions/setup-node@v2
|
|
18
|
+
with:
|
|
19
|
+
node-version: 18
|
|
20
|
+
architecture: x64
|
|
21
|
+
registry-url: 'https://registry.npmjs.org'
|
|
22
|
+
|
|
23
|
+
- name: Publish
|
|
24
|
+
run: |
|
|
25
|
+
npm publish --access=public --non-interactive
|
|
26
|
+
env:
|
|
27
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_ORG_TOKEN }}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
push:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
name: Test
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v2
|
|
13
|
+
|
|
14
|
+
- name: Use Node.js 18 x64
|
|
15
|
+
uses: actions/setup-node@v2
|
|
16
|
+
with:
|
|
17
|
+
node-version: 18
|
|
18
|
+
architecture: x64
|
|
19
|
+
registry-url: 'https://registry.npmjs.org'
|
|
20
|
+
|
|
21
|
+
- name: Install
|
|
22
|
+
run: |
|
|
23
|
+
npm ci
|
|
24
|
+
|
|
25
|
+
- name: Test
|
|
26
|
+
run: |
|
|
27
|
+
npm run test
|
package/.travis.yml
ADDED
package/API.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
## `L.maplibreGL(options)`
|
|
2
|
+
|
|
3
|
+
Create a new MapLibre GL layer in a Leaflet-compatible wrapper.
|
|
4
|
+
|
|
5
|
+
<span class='leaflet icon'>_Extends_: `L.Class`</span>
|
|
6
|
+
|
|
7
|
+
`options` is an object of options. All options given are passed to a MapLibre GL `Map` object,
|
|
8
|
+
so consult [the MapLibre GL .Map documentation](https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/)
|
|
9
|
+
for the full range.
|
|
10
|
+
|
|
11
|
+
| Option | Value | Description |
|
|
12
|
+
| ---- | ---- | ---- |
|
|
13
|
+
| padding | number | [0.15] | Relative padding of the maplibre-gl layer to avoid the background flickering around the edges of the map |
|
|
14
|
+
| interactive | boolean | [false] | Wheter or not to register the mouse and keyboard events on the maplibre-gl layer. Turn this on if you intend to use the maplibre-gl layer events. |
|
|
15
|
+
|
|
16
|
+
### `layer.addTo(map)`
|
|
17
|
+
|
|
18
|
+
Same behavior as `.addTo` on any Leaflet layer: this adds the layer to a given
|
|
19
|
+
map or group.
|
|
20
|
+
|
|
21
|
+
### `layer.getMaplibreMap(): maplibre.Map`
|
|
22
|
+
|
|
23
|
+
Returns `maplibre-gl.Map` object.
|
|
24
|
+
|
|
25
|
+
### `layer.getContainer(): HTMLDivElement`
|
|
26
|
+
|
|
27
|
+
Returns layer's DOM container `div`.
|
|
28
|
+
|
|
29
|
+
### `layer.getCanvas(): HTMLCanvasElement`
|
|
30
|
+
|
|
31
|
+
Returns `maplibre-gl.Map` canvas.
|
|
32
|
+
|
|
33
|
+
### `layer.getSize(): L.Point`
|
|
34
|
+
|
|
35
|
+
Returns layer size in pixels including padding.
|
|
36
|
+
|
|
37
|
+
### `layer.getBounds(): L.LatLngBounds`
|
|
38
|
+
|
|
39
|
+
Returns layer bounds including padding.
|
|
40
|
+
|
|
41
|
+
### `layer.getPaneName(): string`
|
|
42
|
+
|
|
43
|
+
Returns the pane name set in options if it is a valid pane, defaults to tilePane.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
|
+
|
|
7
|
+
## Unreleased
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Add attribution handling to the Leaflet layer based on the `attributionControl` option and the source's `attribution` property
|
|
12
|
+
|
|
13
|
+
## 0.1.0
|
|
14
|
+
|
|
15
|
+
### Fixed - 2025-03-24
|
|
16
|
+
|
|
17
|
+
- Fix [#64](https://github.com/maplibre/maplibre-gl-leaflet/issues/64) to allow this library to work with MapLibre GL JS v5.0.0. ([#66](https://github.com/maplibre/maplibre-gl-leaflet/pull/66))
|
|
18
|
+
|
|
19
|
+
## 0.0.22 - 2024-07-08
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- Fix [#29](https://github.com/maplibre/maplibre-gl-leaflet/issues/58) - added missing guard for empty object
|
|
24
|
+
|
|
25
|
+
## 0.0.20 - 2023-09-19
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- Add `mapbox-gl-js v3.x.x` to allowed versions in peerDependencies.
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- Fix [#29](https://github.com/maplibre/maplibre-gl-leaflet/issues/29) - layer is mis-aligned with map when panning the map off screen ([#31](https://github.com/maplibre/maplibre-gl-leaflet/pulls/31))
|
|
34
|
+
|
|
35
|
+
## 0.0.19 - 2022-11-30
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- round CSS translate values to avoid blurry tiles ([#41](https://github.com/maplibre/maplibre-gl-leaflet/issues/41)).
|
|
40
|
+
|
|
41
|
+
## 0.0.18 - 2022-11-11
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
|
|
45
|
+
- import MapOptions instead of obsolete MapboxOptions for compatibility with neuer maplibre-gl versions ([#25](https://github.com/maplibre/maplibre-gl-leaflet/issues/25)).
|
|
46
|
+
|
|
47
|
+
## 0.0.15 - 2021-07-08
|
|
48
|
+
|
|
49
|
+
### Added
|
|
50
|
+
- types definition
|
|
51
|
+
|
|
52
|
+
## 0.0.14 - 2020-11-24
|
|
53
|
+
|
|
54
|
+
### Fixed
|
|
55
|
+
|
|
56
|
+
- fix gl offset issue in low zoom level
|
|
57
|
+
|
|
58
|
+
## 0.0.13 - 2020-08-31
|
|
59
|
+
|
|
60
|
+
### Added
|
|
61
|
+
- `.getPaneName()` method
|
|
62
|
+
|
|
63
|
+
### Fixed
|
|
64
|
+
- Allow gl tiles to be added to a custom pane defined in options
|
|
65
|
+
|
|
66
|
+
## 0.0.12 - 2020-03-27
|
|
67
|
+
|
|
68
|
+
### Fixed
|
|
69
|
+
|
|
70
|
+
- `accessToken` is now optional
|
|
71
|
+
|
|
72
|
+
## 0.0.11 - 2019-11-04
|
|
73
|
+
|
|
74
|
+
### Fixed
|
|
75
|
+
|
|
76
|
+
- ensure gl map is added to leaflet TilePane
|
|
77
|
+
|
|
78
|
+
## 0.0.10 - 2019-09-16
|
|
79
|
+
|
|
80
|
+
## Added
|
|
81
|
+
|
|
82
|
+
- `.getContainer()`, `.getSize()`, `getBounds()` and `getCanvas()` methods.
|
|
83
|
+
|
|
84
|
+
## Fixed
|
|
85
|
+
|
|
86
|
+
- internal code changes to bring it closer to other overlay layers.
|
|
87
|
+
|
|
88
|
+
## 0.0.9 - 2019-09-02
|
|
89
|
+
|
|
90
|
+
## Added
|
|
91
|
+
|
|
92
|
+
- Added `interactive` option to make `mapbox-gl` map events handling possible.
|
|
93
|
+
- added public accessor to `mapbox-gl` map object
|
|
94
|
+
|
|
95
|
+
## 0.0.8 - 2019-08-07
|
|
96
|
+
|
|
97
|
+
## Added
|
|
98
|
+
|
|
99
|
+
- Added a `padding` option to fix the grey backgrougd flickering around the edges of the map while panning/zooming
|
|
100
|
+
- bumped the libraries in examples
|
|
101
|
+
|
|
102
|
+
## 0.0.7 - 2019-07-01
|
|
103
|
+
|
|
104
|
+
### Fixed
|
|
105
|
+
|
|
106
|
+
- Ensure no blank/gray area is displayed when zooming out.
|
|
107
|
+
|
|
108
|
+
## 0.0.6 - 2019-05-07
|
|
109
|
+
|
|
110
|
+
### Fixed
|
|
111
|
+
|
|
112
|
+
- `.git` directory removed from npm tarball.
|
|
113
|
+
|
|
114
|
+
## 0.0.5 - 2019-05-01
|
|
115
|
+
|
|
116
|
+
### Added
|
|
117
|
+
|
|
118
|
+
- `leaflet` and `mapbox-gl-js` are now declared as peerDependencies.
|
|
119
|
+
|
|
120
|
+
## 0.0.4 - 2019-02-27
|
|
121
|
+
|
|
122
|
+
### Added
|
|
123
|
+
|
|
124
|
+
- UMD wrapper
|
|
125
|
+
- support for `pane` in constructor
|
|
126
|
+
|
|
127
|
+
### Fixed
|
|
128
|
+
|
|
129
|
+
- webkitTransitionEnd event crash
|
|
130
|
+
|
|
131
|
+
## 0.0.3 - 2017-04-18
|
|
132
|
+
|
|
133
|
+
### Added
|
|
134
|
+
|
|
135
|
+
- Improved support for older versions of `mapbox-gl-js`
|
|
136
|
+
|
|
137
|
+
## 0.0.2 - 2017-03-08
|
|
138
|
+
|
|
139
|
+
### Added
|
|
140
|
+
|
|
141
|
+
- Introduced support for Leaflet `v1.0.x`
|
|
142
|
+
|
|
143
|
+
## 0.7. - 2016-10-09
|
|
144
|
+
|
|
145
|
+
- Compatibility release for Leaflet `v0.7.x`
|
package/CONTRIBUTING.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Copyright (c) 2021 MapLibre contributors
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014, Mapbox
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
## MapLibre GL Leaflet
|
|
2
|
+
|
|
3
|
+
This is a binding from [MapLibre GL JS](https://maplibre.org) to the familiar
|
|
4
|
+
[Leaflet](http://leafletjs.com/) API. It was originally developed for Mapbox (<https://github.com/mapbox/mapbox-gl-leaflet>) and was migrated to MapLibre after Mapbox changed its license.
|
|
5
|
+
|
|
6
|
+
## Code example
|
|
7
|
+
|
|
8
|
+
```javascript
|
|
9
|
+
var map = L.map("map", {
|
|
10
|
+
maxBounds: [[180, -Infinity], [-180, Infinity]], // restrict bounds to avoid max latitude issues with MapLibre GL
|
|
11
|
+
maxBoundsViscosity: 1, // make the max bounds "solid" so users cannot pan past them
|
|
12
|
+
minZoom: 1 // prevent sync issues at zoom 0
|
|
13
|
+
}).setView([38.912753, -77.032194], 15);
|
|
14
|
+
|
|
15
|
+
L.marker([38.912753, -77.032194])
|
|
16
|
+
.bindPopup("Hello <b>Leaflet GL</b>!<br>Whoa, it works!")
|
|
17
|
+
.addTo(map)
|
|
18
|
+
.openPopup();
|
|
19
|
+
|
|
20
|
+
var gl = L.maplibreGL({
|
|
21
|
+
style: "mapbox://styles/mapbox/bright-v8",
|
|
22
|
+
}).addTo(map);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Note that you can use any vector tile source useable by maplibre-gl. For instance, you can use [OSM2VectorTiles](http://osm2vectortiles.org/) with:
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
var gl = L.maplibreGL({
|
|
29
|
+
style:
|
|
30
|
+
"https://api.maptiler.com/maps/topo/style.json?key=<YOUR_MAPTILER_API_KEY>",
|
|
31
|
+
}).addTo(map);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Once you have created the leaflet layer, the maplibre-gl map object can be accessed using
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
gl.getMaplibreMap()....
|
|
38
|
+
// add a source to the maplibre-gl layer
|
|
39
|
+
gl.getMaplibreMap().addSource({...})
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Live examples
|
|
43
|
+
|
|
44
|
+
[Basic example](https://raw.githack.com/maplibre/maplibre-gl-leaflet/main/examples/basic.html)
|
|
45
|
+
|
|
46
|
+
[Cluster example](https://raw.githack.com/maplibre/maplibre-gl-leaflet/main/examples/cluster.html)
|
|
47
|
+
|
|
48
|
+
[Map events example](https://raw.githack.com/maplibre/maplibre-gl-leaflet/main/examples/events.html)
|
|
49
|
+
|
|
50
|
+
Code for these examples is hosted in the [examples folder](https://github.com/maplibre/maplibre-gl-leaflet/tree/main/examples)
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
Add a script tag referencing maplibre-gl-leaflet after adding leaflet and maplibre-gl-js in your website:
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<!-- Leaflet -->
|
|
58
|
+
<link
|
|
59
|
+
rel="stylesheet"
|
|
60
|
+
href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css"
|
|
61
|
+
/>
|
|
62
|
+
<script src="https://unpkg.com/leaflet@1.8.0/dist/leaflet.js"></script>
|
|
63
|
+
|
|
64
|
+
<!-- Maplibre GL -->
|
|
65
|
+
<link
|
|
66
|
+
href="https://unpkg.com/maplibre-gl@2.2.1/dist/maplibre-gl.css"
|
|
67
|
+
rel="stylesheet"
|
|
68
|
+
/>
|
|
69
|
+
<script src="https://unpkg.com/maplibre-gl@2.2.1/dist/maplibre-gl.js"></script>
|
|
70
|
+
|
|
71
|
+
<script src="https://unpkg.com/@maplibre/maplibre-gl-leaflet@0.0.20/leaflet-maplibre-gl.js"></script>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Motivation
|
|
75
|
+
|
|
76
|
+
This project makes it possible to easily add a maplibre-gl-js layer in your Leaflet map. When using maplibre-gl-leaflet, you won't be able to use some of the maplibre-gl-js features.
|
|
77
|
+
Here are the main differences between a "pure" maplibre-gl-js map and a Leaflet map using maplibre-gl-leaflet:
|
|
78
|
+
|
|
79
|
+
- No rotation / bearing / pitch support
|
|
80
|
+
- Slower performances: When using maplibre-gl-leaflet, maplibre-gl-js is set as not interactive. Leaflet receives the touch/mouse events and updates the maplibre-gl-js map behind the scenes. Because maplibre-gl-js doesn't redraw as fast as Leaflet, the map can seem slower.
|
|
81
|
+
- MapLibre restricts the maximum latitude of the map in a stricter way then Leaflet. In order to maximize compatibility it it is recommended to set a `maxBounds: [[180, -Infinity], [-180, Infinity]]` and `maxBoundsViscosity: 1` on your Leaflet `Map` to prevent users from panning past the minimum and maximum latitude supported by MapLibre.
|
|
82
|
+
- Setting `minZoom: 1` is also recommended to reduce some issues with the map syncing at zoom level 0.
|
|
83
|
+
|
|
84
|
+
On the bright side, the maplibre-gl-leaflet binding will allow you to use all the leaflet features and plugins.
|
|
85
|
+
|
|
86
|
+
If you only need the maplibre-gl-js features ([adding a map with a mapbox-style, adding a GeoJSON, etc.](https://maplibre.org/maplibre-gl-js/docs/examples/)), you are probably better off using it directly.
|
|
87
|
+
|
|
88
|
+
## API Reference
|
|
89
|
+
|
|
90
|
+
[API Reference](API.md)
|
|
91
|
+
|
|
92
|
+
## Bug Reports & Feature Requests
|
|
93
|
+
|
|
94
|
+
Please use the [issue tracker](https://github.com/maplibre/maplibre-gl-leaflet/issues) to report any bugs or file feature requests.
|
|
95
|
+
You can fork this [jsfiddle template](https://jsfiddle.net/fnicollet/9w9er53v/) to reproduce a bug, then share the URL of your fork in the GitHub issue.
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
ISC © [MapLibre](https://github.com/maplibre) © [Mapbox](https://github.com/mapbox)
|
package/debug/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Debugging Examples
|
|
2
|
+
|
|
3
|
+
These files reproduce difficult to test issues and are used for debugging specific issues.
|
|
4
|
+
|
|
5
|
+
* [`max-latitude-bug-reproduction.html`](./max-latitude-bug-reproduction.html) reproduces [#29](https://github.com/maplibre/maplibre-gl-leaflet/issues/29);
|