maplair 4.2.0 → 4.4.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/CHANGELOG.md +106 -8
- package/dist/esm/control/AttributionControl.js +10 -10
- package/dist/esm/control/AttributionControl.js.map +1 -1
- package/dist/esm/control/ButtonControl.js +0 -1
- package/dist/esm/control/ButtonControl.js.map +1 -1
- package/dist/esm/control/ContextMenu.js +1 -1
- package/dist/esm/control/ContextMenu.js.map +1 -1
- package/dist/esm/control/Control.js +16 -11
- package/dist/esm/control/Control.js.map +1 -1
- package/dist/esm/control/FullscreenControl.js +0 -1
- package/dist/esm/control/FullscreenControl.js.map +1 -1
- package/dist/esm/control/LayersControl.js +13 -9
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/RotateControl.js +0 -1
- package/dist/esm/control/RotateControl.js.map +1 -1
- package/dist/esm/control/ScaleControl.js +4 -5
- package/dist/esm/control/ScaleControl.js.map +1 -1
- package/dist/esm/control/SideBySideControl.js +3 -2
- package/dist/esm/control/SideBySideControl.js.map +1 -1
- package/dist/esm/control/ZoomControl.js +13 -13
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Events.js +4 -2
- package/dist/esm/core/Events.js.map +1 -1
- package/dist/esm/core/Util.js +16 -4
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.PointerEvents.js +55 -2
- package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
- package/dist/esm/dom/DomEvent.js +4 -7
- package/dist/esm/dom/DomEvent.js.map +1 -1
- package/dist/esm/dom/DomUtil.js +5 -5
- package/dist/esm/dom/DomUtil.js.map +1 -1
- package/dist/esm/dom/Draggable.js +4 -6
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/geo/LatLng.js +23 -34
- package/dist/esm/geo/LatLng.js.map +1 -1
- package/dist/esm/geo/LatLngBounds.js +6 -3
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geometry/Bounds.js +2 -2
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/Point.js +12 -17
- package/dist/esm/geometry/Point.js.map +1 -1
- package/dist/esm/geometry/Transformation.js +1 -7
- package/dist/esm/geometry/Transformation.js.map +1 -1
- package/dist/esm/layer/BlanketOverlay.js +1 -1
- package/dist/esm/layer/BlanketOverlay.js.map +1 -1
- package/dist/esm/layer/DivOverlay.js +23 -23
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/ImageOverlay.js +7 -4
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +11 -6
- package/dist/esm/layer/Layer.js.map +1 -1
- package/dist/esm/layer/Popup.js +30 -11
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/Tooltip.js +18 -35
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/VideoOverlay.js +2 -2
- package/dist/esm/layer/VideoOverlay.js.map +1 -1
- package/dist/esm/layer/marker/DivIcon.js +4 -8
- package/dist/esm/layer/marker/DivIcon.js.map +1 -1
- package/dist/esm/layer/marker/Icon.js +16 -15
- package/dist/esm/layer/marker/Icon.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js +6 -7
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +49 -48
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/marker/SvgIcon.js +1 -1
- package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
- package/dist/esm/layer/tile/GridLayer.js +18 -16
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +9 -9
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +44 -93
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +8 -7
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +9 -1
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.js +10 -5
- package/dist/esm/layer/vector/Path.js.map +1 -1
- package/dist/esm/layer/vector/Polygon.js +10 -11
- package/dist/esm/layer/vector/Polygon.js.map +1 -1
- package/dist/esm/layer/vector/Polyline.js +19 -26
- package/dist/esm/layer/vector/Polyline.js.map +1 -1
- package/dist/esm/layer/vector/Renderer.getRenderer.js +2 -1
- package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
- package/dist/esm/layer/vector/Renderer.js +16 -0
- package/dist/esm/layer/vector/Renderer.js.map +1 -1
- package/dist/esm/layer/vector/SVG.js +3 -3
- package/dist/esm/layer/vector/SVG.js.map +1 -1
- package/dist/esm/map/Map.Rotation.js +6 -9
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +104 -49
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/MapSync.js +1 -4
- package/dist/esm/map/MapSync.js.map +1 -1
- package/dist/esm/map/handler/BoxZoomHandler.js +2 -0
- package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DisplaceHandler.js +68 -30
- package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
- package/dist/esm/map/handler/KeyboardHandler.js +3 -5
- package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +3 -6
- package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +3 -6
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/TapDragZoomHandler.js +1 -4
- package/dist/esm/map/handler/TapDragZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/TapHoldHandler.js +8 -20
- package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
- package/dist/esm/package.js +1 -1
- package/dist/maplair-global-src.js +700 -687
- package/dist/maplair-global-src.js.map +1 -1
- package/dist/maplair-global.js +2 -2
- package/dist/maplair-global.js.map +1 -1
- package/dist/maplair-src.js +700 -687
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.css +1 -1
- package/dist/maplair.js +2 -2
- package/dist/maplair.js.map +1 -1
- package/i18n/en.json +1 -0
- package/package.json +2 -1
- package/src/control/AttributionControl.js +9 -9
- package/src/control/ButtonControl.js +0 -1
- package/src/control/ContextMenu.js +1 -1
- package/src/control/Control.js +13 -16
- package/src/control/FullscreenControl.js +0 -1
- package/src/control/LayersControl.js +14 -10
- package/src/control/RotateControl.js +0 -1
- package/src/control/ScaleControl.js +4 -5
- package/src/control/SideBySideControl.js +4 -2
- package/src/control/ZoomControl.js +10 -13
- package/src/core/Events.js +8 -2
- package/src/core/Util.js +16 -3
- package/src/dom/DomEvent.PointerEvents.js +47 -1
- package/src/dom/DomEvent.js +5 -17
- package/src/dom/DomUtil.js +5 -5
- package/src/dom/Draggable.js +5 -6
- package/src/geo/LatLng.js +22 -36
- package/src/geo/LatLngBounds.js +10 -4
- package/src/geometry/Bounds.js +3 -3
- package/src/geometry/Point.js +18 -26
- package/src/geometry/Transformation.js +1 -8
- package/src/layer/BlanketOverlay.js +1 -1
- package/src/layer/DivOverlay.js +28 -30
- package/src/layer/ImageOverlay.js +9 -7
- package/src/layer/Layer.js +18 -6
- package/src/layer/Popup.js +38 -17
- package/src/layer/Tooltip.js +17 -44
- package/src/layer/VideoOverlay.js +2 -2
- package/src/layer/marker/DivIcon.js +3 -6
- package/src/layer/marker/Icon.js +19 -18
- package/src/layer/marker/Marker.Drag.js +16 -18
- package/src/layer/marker/Marker.js +66 -59
- package/src/layer/marker/SvgIcon.js +1 -1
- package/src/layer/tile/GridLayer.js +21 -23
- package/src/layer/tile/TileLayer.js +17 -14
- package/src/layer/vector/Canvas.js +52 -148
- package/src/layer/vector/Circle.js +14 -9
- package/src/layer/vector/CircleMarker.js +11 -1
- package/src/layer/vector/Path.js +11 -5
- package/src/layer/vector/Polygon.js +11 -10
- package/src/layer/vector/Polyline.js +20 -21
- package/src/layer/vector/Renderer.getRenderer.js +2 -1
- package/src/layer/vector/Renderer.js +21 -3
- package/src/layer/vector/SVG.js +3 -3
- package/src/map/Map.Rotation.js +7 -6
- package/src/map/Map.js +135 -54
- package/src/map/MapSync.js +1 -1
- package/src/map/handler/BoxZoomHandler.js +2 -0
- package/src/map/handler/DisplaceHandler.js +53 -7
- package/src/map/handler/KeyboardHandler.js +5 -10
- package/src/map/handler/PinchZoomHandler.js +3 -3
- package/src/map/handler/ScrollWheelZoomHandler.js +3 -3
- package/src/map/handler/TapDragZoomHandler.js +1 -1
- package/src/map/handler/TapHoldHandler.js +13 -25
- package/src/maplair.css +38 -9
- package/dist/esm/dom/DomEvent.DoubleTap.js +0 -90
- package/dist/esm/dom/DomEvent.DoubleTap.js.map +0 -1
- package/src/dom/DomEvent.DoubleTap.js +0 -143
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,104 @@ Maplair Changelog
|
|
|
3
3
|
|
|
4
4
|
(all changes of Leaflet without author notice are by [@mourner](https://github.com/mourner))
|
|
5
5
|
|
|
6
|
+
## 4.4.0 (2026-11-09)
|
|
7
|
+
|
|
8
|
+
⚠️ Despite the minor version, this release contains breaking changes ported from Leaflet, see the refactorings below; e.g. canvas renderers no longer receive pointer events, `panBy()` is limited by `maxBounds`, and `Point` and `LatLng` throw on coordinates that are not numbers.
|
|
9
|
+
|
|
10
|
+
### Leaflet, since 4.3.0
|
|
11
|
+
|
|
12
|
+
Ported from Leaflet (changes without author notice are by [@mourner](https://github.com/mourner))
|
|
13
|
+
|
|
14
|
+
#### ❇️ New Features
|
|
15
|
+
|
|
16
|
+
* LayersControl: the option `title` for the toggle button and the label of the list in https://github.com/Leaflet/Leaflet/commit/77387ed1483b5628603b823acd89dc8ec3956403
|
|
17
|
+
* Popups and tooltips accept a `DocumentFragment` as content, which no longer disappears on reopen, by [@A350xt](https://github.com/A350xt) in https://github.com/Leaflet/Leaflet/pull/10540
|
|
18
|
+
* Control: `getEvents()` for map listeners added and removed with the control in https://github.com/Leaflet/Leaflet/commit/80618956304ce64674e585025d4f1143fd62f664
|
|
19
|
+
|
|
20
|
+
#### ✨ Refactorings (⚠️ Breaking Changes)
|
|
21
|
+
|
|
22
|
+
* The `<canvas>` element of a canvas renderer no longer receives pointer events, so DOM listeners added to it don't fire; listen on the layers or the map instead. The private `Canvas` methods `_onClick()`, `_onPointerMove()`, `_handlePointerOut()` and `_fireEvent()` are gone; the map calls `_layerAt()`, in https://github.com/Leaflet/Leaflet/pull/10523
|
|
23
|
+
* `panBy()` goes through `setView()`: it is limited by `maxBounds`, stops running animations and is applied after a running zoom animation; the pan animation itself is the private `_panBy()`, in https://github.com/Leaflet/Leaflet/pull/10549
|
|
24
|
+
* `Point` and `LatLng` convert numeric strings and throw on coordinates that are not numbers, e.g. `new LatLng(50, '')` or `new Point(5, 'auto')`, which became `0` or a string before; `validate()` matches the constructors, in https://github.com/Leaflet/Leaflet/pull/10550
|
|
25
|
+
* `DomEvent.on(el, 'dblclick', …)` no longer simulates double taps on iOS for elements outside a map, in https://github.com/Leaflet/Leaflet/pull/10524
|
|
26
|
+
* The Marker option `alt` defaults to `undefined`, which is the translation of `'Marker'`, in https://github.com/Leaflet/Leaflet/pull/10542
|
|
27
|
+
* Controls no longer refocus the map after a click, and the private `Control._refocusOnMap()` is gone, in https://github.com/Leaflet/Leaflet/commit/92e961262393a1acb697de148d43278a9e505a1b
|
|
28
|
+
|
|
29
|
+
#### ✨ Improvements
|
|
30
|
+
|
|
31
|
+
* Make the canvas renderer transparent to pointer events, so that SVG paths, markers, overlays and other canvas renderers below it get clicks and hovers, in https://github.com/Leaflet/Leaflet/pull/10523
|
|
32
|
+
* Stop throttling the hover events of canvas paths in https://github.com/Leaflet/Leaflet/commit/e9bdd59480901136caa1fde3fbbf6f8049eb47a0
|
|
33
|
+
* Draw the plus and minus signs of the zoom control in SVG, crisp and centered with any font, in https://github.com/Leaflet/Leaflet/commit/a203b006477cf9545aa723130a1e6a83f3a58f95
|
|
34
|
+
* Simplify the double tap simulation on iOS, which fires a single `dblclick` on a canvas renderer, in https://github.com/Leaflet/Leaflet/pull/10524
|
|
35
|
+
* Let Shift-drag pan the map when box zoom is disabled in https://github.com/Leaflet/Leaflet/commit/79c68c6429c232fe0a1b19a5061dec9d28b7ef57
|
|
36
|
+
* Use modern DOM APIs, small and mechanical code cleanups in https://github.com/Leaflet/Leaflet/commit/91633ca7a85ad7ab051d57cd8c3006c9a9295d68, https://github.com/Leaflet/Leaflet/commit/77e5f691e6746e7f11cbccadd223851254e4cd42, https://github.com/Leaflet/Leaflet/commit/99d8006ce0ae57ce5d2dfa9c009f23ceffa2e38a and https://github.com/Leaflet/Leaflet/commit/f1b911917ab0b23895883f22a62f7a0395451fe6
|
|
37
|
+
* Allow dragging the map during a zoom animation in https://github.com/Leaflet/Leaflet/commit/01eb901fd8c8b2c371ddb60e544f5cf11f5225e2
|
|
38
|
+
* Make view changes compose regardless of call order: `setView()` then `setZoom()`, repeated `zoomIn()` and `panTo()` then `panBy()` build on where an animation is heading, in https://github.com/Leaflet/Leaflet/pull/10549
|
|
39
|
+
|
|
40
|
+
#### ♿️ Accessibility
|
|
41
|
+
|
|
42
|
+
* Markers acting as buttons get `aria-expanded` and `aria-controls` for their popup, closing a popup returns the focus however it is closed, markers rise above others while focused, and increased contrast gets an opaque attribution and scale with underlined links, in https://github.com/Leaflet/Leaflet/pull/10536
|
|
43
|
+
* Improve the contrast of the attribution and the scale for WCAG AA in https://github.com/Leaflet/Leaflet/commit/17729390c752bf0d2bc960836653d4e937af9fcf
|
|
44
|
+
* Rise markers with `riseOnHover` on keyboard focus too in https://github.com/Leaflet/Leaflet/commit/2c28c1a22cf355e663738d8f08e03b2577f1fae4
|
|
45
|
+
* Open tooltips on keyboard focus only, not when the focus comes back to an element clicked with the mouse, in https://github.com/Leaflet/Leaflet/commit/f1fb25604d52afe5c2c433b11ae401fa27b9c140
|
|
46
|
+
* Set `aria-describedby` on a layer whenever its tooltip opens, however it was opened, in https://github.com/Leaflet/Leaflet/commit/dfab29d671bc2135cb3ac761e554d50856020fae
|
|
47
|
+
* Translate the default `alt` text of marker icons by [@nfreear](https://github.com/nfreear) in https://github.com/Leaflet/Leaflet/pull/10542
|
|
48
|
+
* Fix keyboard clicks on markers being ignored after a drag by [@Enfiladeguide](https://github.com/Enfiladeguide) in https://github.com/Leaflet/Leaflet/pull/10529
|
|
49
|
+
* Fix Escape being swallowed by the map after a popup was closed in https://github.com/Leaflet/Leaflet/commit/ee23ede2df59ac0d70007f4eea0e52d896ce817f
|
|
50
|
+
* Stop refocusing the map after clicks on controls in https://github.com/Leaflet/Leaflet/commit/92e961262393a1acb697de148d43278a9e505a1b
|
|
51
|
+
* Keep the focus on a marker clicked by a screen reader in https://github.com/Leaflet/Leaflet/commit/68c14509db2d12c2a2cec6df5705ae1ac6f7b464
|
|
52
|
+
|
|
53
|
+
#### 🐞 Bugfixes
|
|
54
|
+
|
|
55
|
+
* Fix paths jumping when they are changed or added during a zoom animation or pinch in https://github.com/Leaflet/Leaflet/commit/ff13df6ae03ff54126fa5126525d50d15c7ddf6f
|
|
56
|
+
* Fix view changes being lost during a zoom animation, they now apply once it ends (with [@yellowman](https://github.com/yellowman)) in https://github.com/Leaflet/Leaflet/commit/e61b254f4e6c29d8a185f3cdc6182887d8e37acc
|
|
57
|
+
* Fix `minNativeZoom` and `maxNativeZoom` with `detectRetina` and `zoomReverse` in https://github.com/Leaflet/Leaflet/commit/10388a5176ab998b2b22f8ddb3fd34b6715552c3
|
|
58
|
+
* Honor `coords.z` in TileLayer `getTileUrl()` (with [@yohanboniface](https://github.com/yohanboniface)) in https://github.com/Leaflet/Leaflet/commit/8f0fe7bfde0e9c6a948d2131e66619f5882c1111
|
|
59
|
+
* Fix `closestLayerPoint()` of polygons missing the segment closing the ring in https://github.com/Leaflet/Leaflet/commit/3c202e89f5cb74bd4e090b4a1a7c2cd97792c0fd
|
|
60
|
+
* Fix a repeated click on image, SVG and video overlays closing their popup instead of moving it in https://github.com/Leaflet/Leaflet/commit/1c7d70533414a4802455723fbe248b12000bd5cb
|
|
61
|
+
* Apply `zIndex` and `opacity` consistently on image, video and SVG overlays, also `zIndex: 0` and `opacity: 0`, by [@b84330808](https://github.com/b84330808) in https://github.com/Leaflet/Leaflet/pull/10533
|
|
62
|
+
* Reset the styles of the previous icon when a marker reuses its element by [@b84330808](https://github.com/b84330808) in https://github.com/Leaflet/Leaflet/pull/10538
|
|
63
|
+
* Fix `setContent('')` leaving the old content in a popup or tooltip by [@Don-Yin](https://github.com/Don-Yin) in https://github.com/Leaflet/Leaflet/pull/10532
|
|
64
|
+
* Fix markers losing their altitude after a drag in https://github.com/Leaflet/Leaflet/commit/310749e71daff3eec62774abe90839c81417719a
|
|
65
|
+
* Fix the autoPan of a dragged marker panning past `maxBounds` by [@A350xt](https://github.com/A350xt) in https://github.com/Leaflet/Leaflet/pull/10539
|
|
66
|
+
* Fix a click firing after a long-press `contextmenu` on iOS in https://github.com/Leaflet/Leaflet/commit/aff4916e019d03f3fa91a81e8da6b38d91f6c12b
|
|
67
|
+
* Fix the expanded list of the layers control hidden under other controls in https://github.com/Leaflet/Leaflet/commit/f4e449b61ba356ab83f712f167477daeec434c09
|
|
68
|
+
* Return the min zoom from `getBoundsZoom()` when the padding is larger than the map by [@jayhemnani9910](https://github.com/jayhemnani9910) in https://github.com/Leaflet/Leaflet/pull/10544
|
|
69
|
+
* Fix `overlaps()` for bounds with zero area by [@xunguangzlj-cloud](https://github.com/xunguangzlj-cloud) in https://github.com/Leaflet/Leaflet/pull/10547
|
|
70
|
+
* Ignore NaN when combining the zoom limits of the layers of a map by [@xunguangzlj-cloud](https://github.com/xunguangzlj-cloud) in https://github.com/Leaflet/Leaflet/pull/10548
|
|
71
|
+
* Don't call event listeners added during a fire of their event until the next fire, found with the specs of https://github.com/Leaflet/Leaflet/pull/10537
|
|
72
|
+
* Tooltip: replace the `center` direction class when the direction changes in https://github.com/Leaflet/Leaflet/commit/8ad17baed7639eea6b515b5f474d87d63325f48f
|
|
73
|
+
* Small fixes from the core `FullscreenControl` of Leaflet: the pseudo-fullscreen map ignores the margins of its container, `aria-keyshortcuts` is set as an attribute, in https://github.com/Leaflet/Leaflet/pull/10531
|
|
74
|
+
* Fix the position of tooltips in right-to-left containers in https://github.com/Leaflet/Leaflet/commit/a3f5687828c83a5fe9c446f8dfe827c725c0b34d
|
|
75
|
+
* Fix tiles flickering at fractional zoom past `maxZoom` (with [@sbquinlan](https://github.com/sbquinlan)) in https://github.com/Leaflet/Leaflet/commit/32d950de72dc508789509423d165e6eb0242e8dd
|
|
76
|
+
* Fix polygons disappearing with a string `weight` (with [@Falke-Design](https://github.com/Falke-Design)) in https://github.com/Leaflet/Leaflet/commit/08d2dd24157201b6706d9df40a0cc1e96c6cccf0
|
|
77
|
+
* Don't throw when toggling a popup or tooltip of a layer that isn't on the map by [@Enesuygurs](https://github.com/Enesuygurs) in https://github.com/Leaflet/Leaflet/pull/10551
|
|
78
|
+
* Validate `Point` and `LatLng` coordinates: numeric strings are converted, anything else that is not a number throws, in https://github.com/Leaflet/Leaflet/pull/10550
|
|
79
|
+
* Keep the exact center for `invalidateSize()` without a size change, handle a missing `weight` of polygons, in https://github.com/Leaflet/Leaflet/commit/f998a71de529184495bc42ff82767a2f6ce5b7dc
|
|
80
|
+
|
|
81
|
+
#### 📝 Docs
|
|
82
|
+
|
|
83
|
+
* Document the `animate` option of `setView()` and `invalidateSize()`, interactive targets, the renderers of custom panes, the `flyTo` and `pinch` flags of move and zoom events, and point from the base classes to the classes to use, in https://github.com/Leaflet/Leaflet/commit/ad3f0dd0cc0e4fcc77c713ba6b30c61f89438f50, https://github.com/Leaflet/Leaflet/commit/0b1c64a7395f105210e334d145ed51a9f78d9b9d, https://github.com/Leaflet/Leaflet/commit/cd0dbf0ded365094072bf6a55c9aac7de9f67ee7 and https://github.com/Leaflet/Leaflet/commit/b7f53cecf296338ee528ee0fc603ed65981dbc48
|
|
84
|
+
* Rewrite the plugin guide, with a section on a script build for the global `L`, in https://github.com/Leaflet/Leaflet/commit/c2ba3ff6fddb7b83e2e0333526cbe3df1624736d
|
|
85
|
+
* Fix a typo in the ImageOverlay spec by [@ninglinLiu](https://github.com/ninglinLiu) in https://github.com/Leaflet/Leaflet/pull/10543
|
|
86
|
+
|
|
87
|
+
## 4.3.0 (2026-11-02)
|
|
88
|
+
|
|
89
|
+
### Leaflet, since 4.2.0
|
|
90
|
+
|
|
91
|
+
Ported from Leaflet (changes without author notice are by [@mourner](https://github.com/mourner))
|
|
92
|
+
|
|
93
|
+
#### ❇️ New Features
|
|
94
|
+
|
|
95
|
+
* Aliases for an easier migration from Leaflet 1: propagated events carry the target as `layer` (the 1.x name of `propagatedFrom`), `new Circle(latlng, radius)` throws pointing to the `radius` option, `maplair/dist/maplair.css` is exported in https://github.com/Leaflet/Leaflet/commit/6c769f974dd9cbc2319763c87aa2293ec739454a
|
|
96
|
+
|
|
97
|
+
#### 📝 Docs
|
|
98
|
+
|
|
99
|
+
* Polish the tutorials: example frames filling the page width, a complete page and a bundler setup in the quick start, the class tutorial, outdated links and names, a hosted image in the overlays tutorial in https://github.com/Leaflet/Leaflet/commit/6d1f3f9b1f3c3d5586d737d3aaadea0c0ef95e5c, https://github.com/Leaflet/Leaflet/commit/44bc6cddf272aa7c29f5918c0fafdb2b8fe75a4e and https://github.com/Leaflet/Leaflet/commit/92e0bb50e4751536d2b6e022ff81a0976feecc9a
|
|
100
|
+
* Update the tile providers, tools and links in the FAQ in https://github.com/Leaflet/Leaflet/commit/a904a6d02f19d87aaea5a29288f83a65200291fd and https://github.com/Leaflet/Leaflet/commit/c7c073f62cbce65ec364557b44148accad1670f5
|
|
101
|
+
* Update the links and the publishing advice in the plugin guide in https://github.com/Leaflet/Leaflet/commit/381883ce944e6085caef5573954336ce9e3917b1
|
|
102
|
+
* Add location-picker to the plugins list by [@cyphercodes](https://github.com/cyphercodes) in https://github.com/Leaflet/Leaflet/pull/10514
|
|
103
|
+
|
|
6
104
|
## 4.2.0 (2026-10-31)
|
|
7
105
|
|
|
8
106
|
⚠️ Despite the minor version, this release contains breaking changes ported from Leaflet, see the refactorings below; e.g. the optional module `maplair/marker-rotation` is replaced by the Marker option `rotation`.
|
|
@@ -25,7 +123,7 @@ Ported from Leaflet (changes without author notice are by [@mourner](https://git
|
|
|
25
123
|
* Marker: the option `rotation` (in degrees, `null` for none) with `setRotation()` and `getRotation()` rotates the icon around its anchor, rotates the popup and tooltip anchors and hides the shadow; it replaces the optional module `maplair/marker-rotation` with `rotationAngle`, `rotationOrigin`, `setRotationAngle()` and `setRotationOrigin()`, `rotateWithView` is part of `maplair/map-rotation`, in https://github.com/Leaflet/Leaflet/pull/10489
|
|
26
124
|
* `latLngToLayerPoint()` and `latLngToContainerPoint()` keep subpixel precision instead of rounding, so polylines and polygons don't zigzag along whole pixels, in https://github.com/Leaflet/Leaflet/pull/10494
|
|
27
125
|
* Various small cleanups, e.g. KeyboardHandler reads `keyboardPanDelta` and `zoomDelta` on each key, Canvas draws ellipses with `ellipse()`, in https://github.com/Leaflet/Leaflet/pull/10490
|
|
28
|
-
* Only stop the propagation of clicks opening a popup in https://github.com/Leaflet/Leaflet/commit/
|
|
126
|
+
* Only stop the propagation of clicks opening a popup in https://github.com/Leaflet/Leaflet/commit/d10454a56bab4b6df1f8eba729c4d818a71c118f
|
|
29
127
|
|
|
30
128
|
#### 🐞 Bugfixes
|
|
31
129
|
|
|
@@ -36,11 +134,11 @@ Ported from Leaflet (changes without author notice are by [@mourner](https://git
|
|
|
36
134
|
* Fix Circle `getBounds()` throwing when not added to a map (with [@Schleuse](https://github.com/Schleuse)) in https://github.com/Leaflet/Leaflet/commit/4c7958990cfe586dfc05eede518694b81fe9f32c
|
|
37
135
|
* Fix FeatureGroup `getBounds()` throwing for layers without a position, include nested layer groups (with [@rafaelgallani](https://github.com/rafaelgallani)) in https://github.com/Leaflet/Leaflet/commit/ee37d374222822139af43580906a966186bccebf
|
|
38
136
|
* Fix an error when removing the map or a GridLayer on tile load (with [@pierreeurope](https://github.com/pierreeurope)) in https://github.com/Leaflet/Leaflet/commit/62c5f52791c5055ef4c94e508525b554ab158d15
|
|
39
|
-
* Fix an error with empty `subdomains` in https://github.com/Leaflet/Leaflet/commit/
|
|
137
|
+
* Fix an error with empty `subdomains` in https://github.com/Leaflet/Leaflet/commit/8861b5e4faac7243590017a7248f34f2c3d7762c
|
|
40
138
|
* Switch the tooltip handlers when rebinding a tooltip with different options, open it on focus after the layer is added again, don't fire `tileerror` for tiles pruned with `errorTileUrl` in https://github.com/Leaflet/Leaflet/pull/10490
|
|
41
|
-
* Fix the map drifting under the cursor on zoom in https://github.com/Leaflet/Leaflet/commit/
|
|
42
|
-
* Close popups on Escape more reliably, e.g. with the focus on a marker in https://github.com/Leaflet/Leaflet/commit/
|
|
43
|
-
* Isolate the stacking context of the map container in https://github.com/Leaflet/Leaflet/commit/
|
|
139
|
+
* Fix the map drifting under the cursor on zoom in https://github.com/Leaflet/Leaflet/commit/de0be695f714e3c0cef3097b27761a16283c3de7
|
|
140
|
+
* Close popups on Escape more reliably, e.g. with the focus on a marker in https://github.com/Leaflet/Leaflet/commit/aee4d5c907ae57ea83c3b2e9d6ed9f170c6fe174
|
|
141
|
+
* Isolate the stacking context of the map container in https://github.com/Leaflet/Leaflet/commit/611c300542de053bd9335204a4357677cbd76250
|
|
44
142
|
* Accept marker icons without `createShadow()` in https://github.com/Leaflet/Leaflet/pull/10489
|
|
45
143
|
* Make Draggable work outside a map in https://github.com/Leaflet/Leaflet/commit/2e770eb84bafca2368eef611922497cd0b3a81de
|
|
46
144
|
* LayersControl stops listening to map clicks when removed, TileLayer halves a `Point` tileSize with `detectRetina`, `isLoading()` returns a boolean in https://github.com/Leaflet/Leaflet/commit/1dc1b4ea0ffd779e15f8a5aeeb27dd15e597cd1f
|
|
@@ -52,16 +150,16 @@ Ported from Leaflet (changes without author notice are by [@mourner](https://git
|
|
|
52
150
|
|
|
53
151
|
* Fix doc typos and outdated links (with [@Kumar007-7](https://github.com/Kumar007-7)) in https://github.com/Leaflet/Leaflet/commit/ff2715f95cd8542eaf8706b9459620bedb3baec7
|
|
54
152
|
* Use viewport units in the mobile example by [@pierreeurope](https://github.com/pierreeurope) in https://github.com/Leaflet/Leaflet/pull/10120
|
|
55
|
-
* Fix a few stale things in the plugin guide in https://github.com/Leaflet/Leaflet/commit/
|
|
153
|
+
* Fix a few stale things in the plugin guide in https://github.com/Leaflet/Leaflet/commit/2869685c537efcaebad72723a907d7c01c226f56
|
|
56
154
|
|
|
57
155
|
#### 🔧 Workflow
|
|
58
156
|
|
|
59
157
|
* Minify `maplair.css` with lightningcss in https://github.com/Leaflet/Leaflet/pull/10493
|
|
60
|
-
* Reduce Dependabot noise with a better config in https://github.com/Leaflet/Leaflet/commit/
|
|
158
|
+
* Reduce Dependabot noise with a better config in https://github.com/Leaflet/Leaflet/commit/8dc45a82932d8c5682ee1a00a62ed54eb6533b50
|
|
61
159
|
|
|
62
160
|
#### 🧪 Tests
|
|
63
161
|
|
|
64
|
-
* Fix test flakiness on slow runners in https://github.com/Leaflet/Leaflet/commit/
|
|
162
|
+
* Fix test flakiness on slow runners in https://github.com/Leaflet/Leaflet/commit/d958d3ced7208e4e8bfa3ad80e2b7432317a0e84
|
|
65
163
|
|
|
66
164
|
## 4.1.0 (2026-10-28)
|
|
67
165
|
|
|
@@ -69,21 +69,22 @@ var AttributionControl = class AttributionControl extends Control {
|
|
|
69
69
|
disableClickPropagation(this._container);
|
|
70
70
|
if (map._loaded) map.eachLayer((layer) => this._addLayer({ layer }));
|
|
71
71
|
this._update();
|
|
72
|
-
map.on({
|
|
73
|
-
layeradd: this._addLayer,
|
|
74
|
-
layerremove: this._removeLayer
|
|
75
|
-
}, this);
|
|
76
72
|
return this._container;
|
|
77
73
|
}
|
|
78
74
|
/**
|
|
79
75
|
* @internal
|
|
80
|
-
* @
|
|
76
|
+
* @returns {Record<string, Function>}
|
|
81
77
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
getEvents() {
|
|
79
|
+
return {
|
|
84
80
|
layeradd: this._addLayer,
|
|
85
81
|
layerremove: this._removeLayer
|
|
86
|
-
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
onRemove() {
|
|
87
88
|
for (const layer of this._layerAttributions.keys()) this._removeLayer({ layer });
|
|
88
89
|
}
|
|
89
90
|
_addLayer({ layer }) {
|
|
@@ -117,8 +118,7 @@ var AttributionControl = class AttributionControl extends Control {
|
|
|
117
118
|
addAttribution(text, order = 0) {
|
|
118
119
|
if (!text) return this;
|
|
119
120
|
this._orders[text] = order;
|
|
120
|
-
|
|
121
|
-
this._attributions[text]++;
|
|
121
|
+
this._attributions[text] = (this._attributions[text] || 0) + 1;
|
|
122
122
|
this._update();
|
|
123
123
|
return this;
|
|
124
124
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttributionControl.js","names":["DomUtil.create"],"sources":["../../../src/control/AttributionControl.js"],"sourcesContent":["\nimport {Control} from './Control.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport {I18n} from '../core/I18n.js';\n/** @import {ControlOptions} from './Control.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n\nconst mapleLeaf = '<span aria-hidden=\"true\" class=\"maplair-attribution-leaf\">🍁</span>';\n\n/**\n * Options of `AttributionControl`.\n * @typedef {object} AttributionControlOptions\n * @property {string} [position='bottomright'] The position of the control (one of the\n * map corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or\n * `'bottomright'`.\n * @property {string|false|null} [prefix=null] The HTML text shown before the\n * attributions. Pass `false` to disable. By default (`null`), a link to Maplair.\n * @extends ControlOptions\n */\n\n/**\n * Map options of `AttributionControl`.\n * @typedef {object} AttributionControlMapOptions\n * @lends MaplairMapOptions\n * @property {boolean} [attributionControl=true] Whether a\n * [attribution control](#control-attribution) is added to the map by default.\n */\n\n/**\n * Properties of `MaplairMap` set by `AttributionControl`.\n * @typedef {object} AttributionControlMapProperties\n * @lends MaplairMap\n * @property {AttributionControl} attributionControl The attribution control of the map,\n * the default one (if the [`attributionControl` option](#map-attributioncontrol) was\n * `true` when creating the map) or the one added last.\n */\n\n/**\n * The attribution control allows you to display attribution data in a small text box\n * on a map. It is put on the map by default unless you set its\n * [`attributionControl` option](#map-attributioncontrol) to `false`, and it fetches\n * attribution texts from layers with the [`getAttribution` method](#layer-getattribution)\n * automatically.\n */\nexport class AttributionControl extends Control {\n\n\tstatic defaultOptions = {\n\t\tposition: 'bottomright',\n\t\tprefix: null\n\t};\n\n\t/**\n\t * Creates an attribution control.\n\t * @param {AttributionControlOptions} [options]\n\t */\n\tconstructor(options) {\n\t\tsuper(options);\n\t\tif (this.options.prefix === null) {\n\t\t\tconst title = I18n.translate('A JavaScript library for interactive maps');\n\t\t\tthis.options.prefix = `<a target=\"_blank\" href=\"https://maplair.org\" title=\"${title}\">${mapleLeaf}Maplair</a>`;\n\t\t}\n\n\t\tthis._attributions = {};\n\t\tthis._orders = {};\n\t\tthis._layerAttributions = new Map();\n\n\t\tthis.callInitHooks(AttributionControl);\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t * @returns {HTMLElement}\n\t */\n\tonAdd(map) {\n\t\tmap.attributionControl = this;\n\t\tthis._container = DomUtil.create('div', 'maplair-control-attribution');\n\t\tDomEvent.disableClickPropagation(this._container);\n\n\t\t// before the map is loaded, layers already added to it will still fire layeradd once it loads\n\t\tif (map._loaded) {\n\t\t\tmap.eachLayer(layer => this._addLayer({layer}));\n\t\t}\n\n\t\tthis._update();\n\n\t\
|
|
1
|
+
{"version":3,"file":"AttributionControl.js","names":["DomUtil.create"],"sources":["../../../src/control/AttributionControl.js"],"sourcesContent":["\nimport {Control} from './Control.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport {I18n} from '../core/I18n.js';\n/** @import {ControlOptions} from './Control.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n\nconst mapleLeaf = '<span aria-hidden=\"true\" class=\"maplair-attribution-leaf\">🍁</span>';\n\n/**\n * Options of `AttributionControl`.\n * @typedef {object} AttributionControlOptions\n * @property {string} [position='bottomright'] The position of the control (one of the\n * map corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or\n * `'bottomright'`.\n * @property {string|false|null} [prefix=null] The HTML text shown before the\n * attributions. Pass `false` to disable. By default (`null`), a link to Maplair.\n * @extends ControlOptions\n */\n\n/**\n * Map options of `AttributionControl`.\n * @typedef {object} AttributionControlMapOptions\n * @lends MaplairMapOptions\n * @property {boolean} [attributionControl=true] Whether a\n * [attribution control](#control-attribution) is added to the map by default.\n */\n\n/**\n * Properties of `MaplairMap` set by `AttributionControl`.\n * @typedef {object} AttributionControlMapProperties\n * @lends MaplairMap\n * @property {AttributionControl} attributionControl The attribution control of the map,\n * the default one (if the [`attributionControl` option](#map-attributioncontrol) was\n * `true` when creating the map) or the one added last.\n */\n\n/**\n * The attribution control allows you to display attribution data in a small text box\n * on a map. It is put on the map by default unless you set its\n * [`attributionControl` option](#map-attributioncontrol) to `false`, and it fetches\n * attribution texts from layers with the [`getAttribution` method](#layer-getattribution)\n * automatically.\n */\nexport class AttributionControl extends Control {\n\n\tstatic defaultOptions = {\n\t\tposition: 'bottomright',\n\t\tprefix: null\n\t};\n\n\t/**\n\t * Creates an attribution control.\n\t * @param {AttributionControlOptions} [options]\n\t */\n\tconstructor(options) {\n\t\tsuper(options);\n\t\tif (this.options.prefix === null) {\n\t\t\tconst title = I18n.translate('A JavaScript library for interactive maps');\n\t\t\tthis.options.prefix = `<a target=\"_blank\" href=\"https://maplair.org\" title=\"${title}\">${mapleLeaf}Maplair</a>`;\n\t\t}\n\n\t\tthis._attributions = {};\n\t\tthis._orders = {};\n\t\tthis._layerAttributions = new Map();\n\n\t\tthis.callInitHooks(AttributionControl);\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t * @returns {HTMLElement}\n\t */\n\tonAdd(map) {\n\t\tmap.attributionControl = this;\n\t\tthis._container = DomUtil.create('div', 'maplair-control-attribution');\n\t\tDomEvent.disableClickPropagation(this._container);\n\n\t\t// before the map is loaded, layers already added to it will still fire layeradd once it loads\n\t\tif (map._loaded) {\n\t\t\tmap.eachLayer(layer => this._addLayer({layer}));\n\t\t}\n\n\t\tthis._update();\n\n\t\treturn this._container;\n\t}\n\n\t/**\n\t * @internal\n\t * @returns {Record<string, Function>}\n\t */\n\tgetEvents() {\n\t\treturn {layeradd: this._addLayer, layerremove: this._removeLayer};\n\t}\n\n\t/**\n\t * @internal\n\t */\n\tonRemove() {\n\t\tfor (const layer of this._layerAttributions.keys()) {\n\t\t\tthis._removeLayer({layer});\n\t\t}\n\t}\n\n\t_addLayer({layer}) {\n\t\tconst text = layer.getAttribution?.();\n\t\tif (!text || this._layerAttributions.has(layer)) { return; }\n\n\t\tthis._layerAttributions.set(layer, text);\n\t\tthis.addAttribution(text, layer.options?.attributionOrder);\n\t}\n\n\t_removeLayer({layer}) {\n\t\tthis.removeAttribution(this._layerAttributions.get(layer));\n\t\tthis._layerAttributions.delete(layer);\n\t}\n\n\t/**\n\t * The HTML text shown before the attributions. Pass `false` to disable.\n\t * @param {string|false} prefix\n\t * @returns {this}\n\t */\n\tsetPrefix(prefix) {\n\t\tthis.options.prefix = prefix;\n\t\tthis._update();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds an attribution text (e.g. `'© OpenStreetMap contributors'`). Attributions\n\t * are sorted by `order` (see the layer option `attributionOrder`), then by the order\n\t * of adding.\n\t * @param {string} text\n\t * @param {number} [order=0]\n\t * @returns {this}\n\t */\n\taddAttribution(text, order = 0) {\n\t\tif (!text) { return this; }\n\n\t\tthis._orders[text] = order;\n\t\tthis._attributions[text] = (this._attributions[text] || 0) + 1;\n\n\t\tthis._update();\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes an attribution text.\n\t * @param {string} text\n\t * @returns {this}\n\t */\n\tremoveAttribution(text) {\n\t\tif (!text) { return this; }\n\n\t\tif (this._attributions[text]) {\n\t\t\tthis._attributions[text]--;\n\t\t\tthis._update();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t_update() {\n\t\tif (!this._map) { return; }\n\n\t\tconst attribs = Object.keys(this._attributions).filter(i => this._attributions[i])\n\t\t\t.sort((a, b) => this._orders[a] - this._orders[b]);\n\n\t\tconst prefixAndAttribs = [];\n\n\t\tif (this.options.prefix) {\n\t\t\tprefixAndAttribs.push(this.options.prefix);\n\t\t}\n\t\tif (attribs.length) {\n\t\t\tprefixAndAttribs.push(attribs.join(', '));\n\t\t}\n\n\t\tthis._container.innerHTML = prefixAndAttribs.join(' <span aria-hidden=\"true\">|</span> ');\n\t}\n\n\t/**\n\t * Registers this default feature on the map class, called by `MaplairMap` itself.\n\t * @internal\n\t * @param {typeof MaplairMap} MaplairMap\n\t */\n\tstatic register(MaplairMap) {\n\t\tMaplairMap.mergeOptions({\n\t\t\tattributionControl: true\n\t\t});\n\n\t\tMaplairMap.addInitHook(function () {\n\t\t\tif (this.options.attributionControl) {\n\t\t\t\tnew AttributionControl().addTo(this);\n\t\t\t}\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;AAQA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqClB,IAAa,qBAAb,MAAa,2BAA2B,QAAQ;CAE/C,OAAO,iBAAiB;EACvB,UAAU;EACV,QAAQ;CACT;;;;;CAMA,YAAY,SAAS;EACpB,MAAM,OAAO;EACb,IAAI,KAAK,QAAQ,WAAW,MAAM;GACjC,MAAM,QAAQ,KAAK,UAAU,2CAA2C;GACxE,KAAK,QAAQ,SAAS,wDAAwD,MAAM,IAAI,UAAU;EACnG;EAEA,KAAK,gBAAgB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;EACd;EAEA,OAAO;CACR;CAEA,UAAU;EACT,IAAI,CAAC,KAAK,MAAQ;EAElB,MAAM,UAAU,OAAO,KAAK,KAAK,aAAa,CAAC,CAAC,QAAO,MAAK,KAAK,cAAc,EAAE,CAAC,CAChF,MAAM,GAAG,MAAM,KAAK,QAAQ,KAAK,KAAK,QAAQ,EAAE;EAElD,MAAM,mBAAmB,CAAC;EAE1B,IAAI,KAAK,QAAQ,QAChB,iBAAiB,KAAK,KAAK,QAAQ,MAAM;EAE1C,IAAI,QAAQ,QACX,iBAAiB,KAAK,QAAQ,KAAK,IAAI,CAAC;EAGzC,KAAK,WAAW,YAAY,iBAAiB,KAAK,uCAAqC;CACxF;;;;;;CAOA,OAAO,SAAS,YAAY;EAC3B,WAAW,aAAa,EACvB,oBAAoB,KACrB,CAAC;EAED,WAAW,YAAY,WAAY;GAClC,IAAI,KAAK,QAAQ,oBAChB,IAAI,mBAAmB,CAAC,CAAC,MAAM,IAAI;EAErC,CAAC;CACF;AACD"}
|
|
@@ -99,7 +99,6 @@ var ButtonControl = class ButtonControl extends Control {
|
|
|
99
99
|
disableClickPropagation(button);
|
|
100
100
|
on(button, "click", stop);
|
|
101
101
|
on(button, "click", this._onClick, this);
|
|
102
|
-
on(button, "click", this._refocusOnMap, this);
|
|
103
102
|
this._update();
|
|
104
103
|
return button;
|
|
105
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonControl.js","names":["DomUtil.create","DomEvent.stop"],"sources":["../../../src/control/ButtonControl.js"],"sourcesContent":["import {Control} from './Control.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\n/** @import {ControlOptions} from './Control.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n\n/**\n * A state of a `ButtonControl`, see its `states` option.\n * @typedef {object} ButtonControlState\n * @property {string} name The name of the state, see `setState()`.\n * @property {string|HTMLElement} [content] The content of the button in this state.\n * @property {string} [title] The title of the button in this state.\n * @property {(this: ButtonControl, e: MouseEvent, button: ButtonControl, map: MaplairMap) => void} [onClick]\n * Called when clicking the button in this state.\n */\n\n/**\n * Options of `ButtonControl`.\n * @typedef {object} ButtonControlOptions\n * @property {string} [position='topleft'] The position of the control (one of the map\n * corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or\n * `'bottomright'`.\n * @property {string|HTMLElement} [content=''] The content of the button: HTML (e.g. an\n * icon or a character) or an element. String content is rendered as HTML; do not pass\n * untrusted input.\n * @property {string} [title=''] The title (tooltip) and accessible name of the button.\n * @property {(this: ButtonControl, e: MouseEvent, button: ButtonControl, map: MaplairMap) => void} [onClick]\n * Called with the click event, the `ButtonControl` and the map when clicking the button.\n * @property {ButtonControlState[]} [states] Alternative states of the button, each an\n * object with `name` and with `content`, `title` and `onClick` like the options. The\n * first state is the initial one, `setState()` switches them.\n * @property {string} [className=''] A custom CSS class name to assign to the button.\n * @property {string} [accessKey=''] A key to activate the button with the browser's\n * [access key](https://developer.mozilla.org/docs/Web/HTML/Reference/Global_attributes/accesskey)\n * modifiers (e.g. Alt+Shift+K), shown in the title.\n * @extends ControlOptions\n */\n\n/**\n * A control with a button, styled like the zoom control, calling a function when\n * clicked. It can have several states with their own content, title and function,\n * e.g. to toggle something. Several buttons can be grouped with `ButtonBarControl`.\n *\n * Inspired by the [Leaflet.EasyButton](https://github.com/CliffCloud/Leaflet.EasyButton) plugin.\n *\n * @example\n * ```js\n * new ButtonControl({\n * \tcontent: '⌂',\n * \ttitle: 'Home',\n * \tonClick: (e, button, map) => map.setView([47.27, 11.40], 13)\n * }).addTo(map);\n *\n * new ButtonControl({\n * \tstates: [{\n * \t\tname: 'show',\n * \t\tcontent: '👁',\n * \t\ttitle: 'Show the markers',\n * \t\tonClick(e, button, map) { markers.addTo(map); button.setState('hide'); }\n * \t}, {\n * \t\tname: 'hide',\n * \t\tcontent: '🙈',\n * \t\ttitle: 'Hide the markers',\n * \t\tonClick(e, button) { markers.remove(); button.setState('show'); }\n * \t}]\n * }).addTo(map);\n * ```\n */\nexport class ButtonControl extends Control {\n\n\tstatic defaultOptions = {\n\t\tposition: 'topleft',\n\t\tcontent: '',\n\t\ttitle: '',\n\t\tonClick: undefined,\n\t\tstates: undefined,\n\t\tclassName: '',\n\t\taccessKey: ''\n\t};\n\n\t/**\n\t * Creates a button control.\n\t * @param {...ButtonControlOptions} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis._state = this.options.states?.[0];\n\t\tthis.callInitHooks(ButtonControl);\n\t}\n\n\t/**\n\t * @internal\n\t * @returns {HTMLElement}\n\t */\n\tonAdd() {\n\t\tconst container = DomUtil.create('div', 'maplair-bar maplair-control-button');\n\t\tthis._createButton(container);\n\t\treturn container;\n\t}\n\n\t// Creates the button element in `container`, see `ButtonBarControl`\n\t_createButton(container) {\n\t\tconst button = this._button = DomUtil.create('button', `maplair-control-button-button ${this.options.className}`, container);\n\t\tbutton.type = 'button';\n\t\tbutton.accessKey = this.options.accessKey;\n\n\t\tDomEvent.disableClickPropagation(button);\n\t\tDomEvent.on(button, 'click', DomEvent.stop);\n\t\tDomEvent.on(button, 'click', this._onClick, this);\n\
|
|
1
|
+
{"version":3,"file":"ButtonControl.js","names":["DomUtil.create","DomEvent.stop"],"sources":["../../../src/control/ButtonControl.js"],"sourcesContent":["import {Control} from './Control.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\n/** @import {ControlOptions} from './Control.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n\n/**\n * A state of a `ButtonControl`, see its `states` option.\n * @typedef {object} ButtonControlState\n * @property {string} name The name of the state, see `setState()`.\n * @property {string|HTMLElement} [content] The content of the button in this state.\n * @property {string} [title] The title of the button in this state.\n * @property {(this: ButtonControl, e: MouseEvent, button: ButtonControl, map: MaplairMap) => void} [onClick]\n * Called when clicking the button in this state.\n */\n\n/**\n * Options of `ButtonControl`.\n * @typedef {object} ButtonControlOptions\n * @property {string} [position='topleft'] The position of the control (one of the map\n * corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or\n * `'bottomright'`.\n * @property {string|HTMLElement} [content=''] The content of the button: HTML (e.g. an\n * icon or a character) or an element. String content is rendered as HTML; do not pass\n * untrusted input.\n * @property {string} [title=''] The title (tooltip) and accessible name of the button.\n * @property {(this: ButtonControl, e: MouseEvent, button: ButtonControl, map: MaplairMap) => void} [onClick]\n * Called with the click event, the `ButtonControl` and the map when clicking the button.\n * @property {ButtonControlState[]} [states] Alternative states of the button, each an\n * object with `name` and with `content`, `title` and `onClick` like the options. The\n * first state is the initial one, `setState()` switches them.\n * @property {string} [className=''] A custom CSS class name to assign to the button.\n * @property {string} [accessKey=''] A key to activate the button with the browser's\n * [access key](https://developer.mozilla.org/docs/Web/HTML/Reference/Global_attributes/accesskey)\n * modifiers (e.g. Alt+Shift+K), shown in the title.\n * @extends ControlOptions\n */\n\n/**\n * A control with a button, styled like the zoom control, calling a function when\n * clicked. It can have several states with their own content, title and function,\n * e.g. to toggle something. Several buttons can be grouped with `ButtonBarControl`.\n *\n * Inspired by the [Leaflet.EasyButton](https://github.com/CliffCloud/Leaflet.EasyButton) plugin.\n *\n * @example\n * ```js\n * new ButtonControl({\n * \tcontent: '⌂',\n * \ttitle: 'Home',\n * \tonClick: (e, button, map) => map.setView([47.27, 11.40], 13)\n * }).addTo(map);\n *\n * new ButtonControl({\n * \tstates: [{\n * \t\tname: 'show',\n * \t\tcontent: '👁',\n * \t\ttitle: 'Show the markers',\n * \t\tonClick(e, button, map) { markers.addTo(map); button.setState('hide'); }\n * \t}, {\n * \t\tname: 'hide',\n * \t\tcontent: '🙈',\n * \t\ttitle: 'Hide the markers',\n * \t\tonClick(e, button) { markers.remove(); button.setState('show'); }\n * \t}]\n * }).addTo(map);\n * ```\n */\nexport class ButtonControl extends Control {\n\n\tstatic defaultOptions = {\n\t\tposition: 'topleft',\n\t\tcontent: '',\n\t\ttitle: '',\n\t\tonClick: undefined,\n\t\tstates: undefined,\n\t\tclassName: '',\n\t\taccessKey: ''\n\t};\n\n\t/**\n\t * Creates a button control.\n\t * @param {...ButtonControlOptions} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis._state = this.options.states?.[0];\n\t\tthis.callInitHooks(ButtonControl);\n\t}\n\n\t/**\n\t * @internal\n\t * @returns {HTMLElement}\n\t */\n\tonAdd() {\n\t\tconst container = DomUtil.create('div', 'maplair-bar maplair-control-button');\n\t\tthis._createButton(container);\n\t\treturn container;\n\t}\n\n\t// Creates the button element in `container`, see `ButtonBarControl`\n\t_createButton(container) {\n\t\tconst button = this._button = DomUtil.create('button', `maplair-control-button-button ${this.options.className}`, container);\n\t\tbutton.type = 'button';\n\t\tbutton.accessKey = this.options.accessKey;\n\n\t\tDomEvent.disableClickPropagation(button);\n\t\tDomEvent.on(button, 'click', DomEvent.stop);\n\t\tDomEvent.on(button, 'click', this._onClick, this);\n\n\t\tthis._update();\n\t\treturn button;\n\t}\n\n\t_onClick(e) {\n\t\tif (this._disabled) { return; }\n\t\t(this._state ?? this.options).onClick?.call(this, e, this, this._map);\n\t}\n\n\t_update() {\n\t\tif (!this._button) { return; }\n\t\tconst {content, title} = this._state ?? this.options,\n\t\tbutton = this._button;\n\n\t\tif (typeof content === 'string') {\n\t\t\tbutton.innerHTML = content;\n\t\t} else {\n\t\t\tbutton.replaceChildren(content);\n\t\t}\n\t\tconst key = button.accessKeyLabel || this.options.accessKey.toUpperCase();\n\t\tbutton.title = [title, key && `[${key}]`].filter(Boolean).join(' ');\n\t\tbutton.setAttribute('aria-label', title ?? '');\n\t\tif (this._state) {\n\t\t\tbutton.dataset.state = this._state.name;\n\t\t}\n\t\tbutton.classList.toggle('maplair-disabled', !!this._disabled);\n\t\tbutton.setAttribute('aria-disabled', !!this._disabled);\n\t}\n\n\t/**\n\t * Switches to the state with the given `name`, see the `states` option.\n\t * @param {string} name\n\t * @returns {this}\n\t */\n\tsetState(name) {\n\t\tconst state = this.options.states?.find(s => s.name === name);\n\t\tif (!state) {\n\t\t\tthrow new Error(`Unknown button state \"${name}\".`);\n\t\t}\n\t\tthis._state = state;\n\t\tthis._update();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the name of the current state, see the `states` option.\n\t * @returns {string|undefined}\n\t */\n\tgetState() {\n\t\treturn this._state?.name;\n\t}\n\n\t/**\n\t * Disables the button, so that clicking it does nothing.\n\t * @returns {this}\n\t */\n\tdisable() {\n\t\tthis._disabled = true;\n\t\tthis._update();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Enables the button again.\n\t * @returns {this}\n\t */\n\tenable() {\n\t\tthis._disabled = false;\n\t\tthis._update();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the button element.\n\t * @returns {HTMLElement}\n\t */\n\tgetButton() {\n\t\treturn this._button;\n\t}\n}\n\n/**\n * Groups several `ButtonControl`s in one bar, like the buttons of the zoom control.\n *\n * Inspired by the [Leaflet.EasyButton](https://github.com/CliffCloud/Leaflet.EasyButton) plugin.\n *\n * @example\n * ```js\n * new ButtonBarControl([\n * \tnew ButtonControl({content: 'A', title: 'First', onClick: () => {}}),\n * \tnew ButtonControl({content: 'B', title: 'Second', onClick: () => {}})\n * ]).addTo(map);\n * ```\n */\nexport class ButtonBarControl extends Control {\n\t/**\n\t * Creates a bar with the given buttons.\n\t * @param {ButtonControl[]} buttons\n\t * @param {ControlOptions} [options]\n\t */\n\tconstructor(buttons, options) {\n\t\tsuper(options);\n\t\tthis._buttons = buttons;\n\t\tthis.callInitHooks(ButtonBarControl);\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t * @returns {HTMLElement}\n\t */\n\tonAdd(map) {\n\t\tconst container = DomUtil.create('div', 'maplair-bar maplair-control-button-bar');\n\t\tfor (const button of this._buttons) {\n\t\t\tbutton._map = map;\n\t\t\tbutton._createButton(container);\n\t\t}\n\t\treturn container;\n\t}\n\n\t/** @internal */\n\tonRemove() {\n\t\tfor (const button of this._buttons) {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extMenu extends Class {
|
|
|
127
127
|
}
|
|
128
128
|
_createMenu(parent) {
|
|
129
129
|
const container = this._container ??= create("div", `maplair-contextmenu ${this.options.className}`);
|
|
130
|
-
if (container.parentNode !== parent) parent.
|
|
130
|
+
if (container.parentNode !== parent) parent.append(container);
|
|
131
131
|
container.popover = "auto";
|
|
132
132
|
container.setAttribute("role", "menu");
|
|
133
133
|
container.replaceChildren();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.js","names":["DomUtil.create","DomEvent.stop"],"sources":["../../../src/control/ContextMenu.js"],"sourcesContent":["import {Class} from '../core/Class.js';\nimport * as Util from '../core/Util.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport {Layer} from '../layer/Layer.js';\n/** @import {MaplairMap} from '../map/Map.js' */\n/** @import {LatLng} from '../geo/LatLng.js' */\n/** @import {Point} from '../geometry/Point.js' */\n\n/**\n * Options of `ContextMenu`.\n * @typedef {object} ContextMenuOptions\n * @property {string} [className=''] A custom CSS class name to assign to the menu.\n */\n\n/**\n * The argument of the `callback` of a `ContextMenu` item, with the location of the\n * `contextmenu` event.\n * @typedef {object} ContextMenuEvent\n * @property {LatLng} latlng The geographical point of the event.\n * @property {Point} containerPoint Pixel coordinates of the event relative to the map\n * container.\n * @property {Point} layerPoint Pixel coordinates of the event relative to the map layer.\n * @property {MouseEvent|PointerEvent} originalEvent The original DOM event.\n * @property {Layer} [relatedTarget] The layer, for menus of layers.\n */\n\n/**\n * An item of a `ContextMenu`.\n * @typedef {object} ContextMenuItem\n * @property {string} text The text of the item.\n * @property {(this: ContextMenu, event: ContextMenuEvent) => void} [callback] Called\n * when the item is chosen.\n * @property {boolean} [disabled] Whether the item is disabled.\n */\n\n/**\n * A menu opened with the `contextmenu` event (right click, or long tap on touch\n * screens) on the map or on a layer. Each item calls a function with the location\n * of the event. The menu is a [popover](https://developer.mozilla.org/docs/Web/API/Popover_API),\n * closed by clicking outside of it or pressing Escape, and can be used with the\n * keyboard (arrow keys, Enter).\n *\n * Inspired by the [Leaflet.contextmenu](https://github.com/aratcliffe/Leaflet.contextmenu) plugin.\n *\n * @example\n * ```js\n * new ContextMenu([\n * \t{text: 'Center the map here', callback: e => map.panTo(e.latlng)},\n * \t'-',\n * \t{text: 'Zoom in', callback: () => map.zoomIn()}\n * ]).addTo(map);\n *\n * new ContextMenu([\n * \t{text: 'Remove', callback: e => e.relatedTarget.remove()}\n * ]).addTo(marker);\n * ```\n */\nexport class ContextMenu extends Class {\n\n\tstatic defaultOptions = {\n\t\tclassName: ''\n\t};\n\n\t/**\n\t * Creates a context menu. Each item is an object with `text`, `callback` and the\n\t * optional `disabled`, or `'-'` for a separator. The `callback` gets an event with\n\t * `latlng`, `containerPoint`, `layerPoint`, `originalEvent` and `relatedTarget`\n\t * (the layer, for menus of layers).\n\t * @param {(ContextMenuItem|'-')[]} items\n\t * @param {ContextMenuOptions} [options]\n\t */\n\tconstructor(items, options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\t\tthis._items = items;\n\t\tthis.callInitHooks(ContextMenu);\n\t}\n\n\t/**\n\t * Opens the menu on `contextmenu` events of the map or the layer.\n\t * @param {MaplairMap|Layer} target\n\t * @returns {this}\n\t */\n\taddTo(target) {\n\t\tthis.remove();\n\t\tthis._target = target;\n\t\ttarget.on('contextmenu', this._open, this);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes the menu from its map or layer.\n\t * @returns {this}\n\t */\n\tremove() {\n\t\tthis.close();\n\t\tthis._target?.off('contextmenu', this._open, this);\n\t\tthis._target = null;\n\t\tthis._container?.remove();\n\t\tthis._container = null;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Closes the menu.\n\t * @returns {this}\n\t */\n\tclose() {\n\t\tif (this._container?.matches(':popover-open')) {\n\t\t\tthis._container.hidePopover();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns `true` if the menu is open.\n\t * @returns {boolean}\n\t */\n\tisOpen() {\n\t\treturn !!this._container?.matches(':popover-open');\n\t}\n\n\t_open(e) {\n\t\t// a menu of a layer replaces the one of the map\n\t\tDomEvent.stop(e);\n\t\tconst map = this._target instanceof Layer ? this._target._map : this._target;\n\t\tif (!map) { return; }\n\n\t\tthis._map = map;\n\t\tthis._event = {\n\t\t\tlatlng: e.latlng,\n\t\t\tcontainerPoint: e.containerPoint,\n\t\t\tlayerPoint: e.layerPoint,\n\t\t\toriginalEvent: e.originalEvent,\n\t\t\trelatedTarget: this._target instanceof Layer ? this._target : undefined\n\t\t};\n\n\t\tconst container = this._createMenu(map._container);\n\t\tif (!container.matches(':popover-open')) {\n\t\t\tcontainer.showPopover();\n\t\t}\n\t\tthis._position(e.originalEvent);\n\t\tcontainer.querySelector('button:not([disabled])')?.focus({preventScroll: true});\n\t\tmap.once('movestart', this.close, this);\n\t}\n\n\t_createMenu(parent) {\n\t\tconst container = this._container ??= DomUtil.create('div', `maplair-contextmenu ${this.options.className}`);\n\t\tif (container.parentNode !== parent) {\n\t\t\tparent.
|
|
1
|
+
{"version":3,"file":"ContextMenu.js","names":["DomUtil.create","DomEvent.stop"],"sources":["../../../src/control/ContextMenu.js"],"sourcesContent":["import {Class} from '../core/Class.js';\nimport * as Util from '../core/Util.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport {Layer} from '../layer/Layer.js';\n/** @import {MaplairMap} from '../map/Map.js' */\n/** @import {LatLng} from '../geo/LatLng.js' */\n/** @import {Point} from '../geometry/Point.js' */\n\n/**\n * Options of `ContextMenu`.\n * @typedef {object} ContextMenuOptions\n * @property {string} [className=''] A custom CSS class name to assign to the menu.\n */\n\n/**\n * The argument of the `callback` of a `ContextMenu` item, with the location of the\n * `contextmenu` event.\n * @typedef {object} ContextMenuEvent\n * @property {LatLng} latlng The geographical point of the event.\n * @property {Point} containerPoint Pixel coordinates of the event relative to the map\n * container.\n * @property {Point} layerPoint Pixel coordinates of the event relative to the map layer.\n * @property {MouseEvent|PointerEvent} originalEvent The original DOM event.\n * @property {Layer} [relatedTarget] The layer, for menus of layers.\n */\n\n/**\n * An item of a `ContextMenu`.\n * @typedef {object} ContextMenuItem\n * @property {string} text The text of the item.\n * @property {(this: ContextMenu, event: ContextMenuEvent) => void} [callback] Called\n * when the item is chosen.\n * @property {boolean} [disabled] Whether the item is disabled.\n */\n\n/**\n * A menu opened with the `contextmenu` event (right click, or long tap on touch\n * screens) on the map or on a layer. Each item calls a function with the location\n * of the event. The menu is a [popover](https://developer.mozilla.org/docs/Web/API/Popover_API),\n * closed by clicking outside of it or pressing Escape, and can be used with the\n * keyboard (arrow keys, Enter).\n *\n * Inspired by the [Leaflet.contextmenu](https://github.com/aratcliffe/Leaflet.contextmenu) plugin.\n *\n * @example\n * ```js\n * new ContextMenu([\n * \t{text: 'Center the map here', callback: e => map.panTo(e.latlng)},\n * \t'-',\n * \t{text: 'Zoom in', callback: () => map.zoomIn()}\n * ]).addTo(map);\n *\n * new ContextMenu([\n * \t{text: 'Remove', callback: e => e.relatedTarget.remove()}\n * ]).addTo(marker);\n * ```\n */\nexport class ContextMenu extends Class {\n\n\tstatic defaultOptions = {\n\t\tclassName: ''\n\t};\n\n\t/**\n\t * Creates a context menu. Each item is an object with `text`, `callback` and the\n\t * optional `disabled`, or `'-'` for a separator. The `callback` gets an event with\n\t * `latlng`, `containerPoint`, `layerPoint`, `originalEvent` and `relatedTarget`\n\t * (the layer, for menus of layers).\n\t * @param {(ContextMenuItem|'-')[]} items\n\t * @param {ContextMenuOptions} [options]\n\t */\n\tconstructor(items, options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\t\tthis._items = items;\n\t\tthis.callInitHooks(ContextMenu);\n\t}\n\n\t/**\n\t * Opens the menu on `contextmenu` events of the map or the layer.\n\t * @param {MaplairMap|Layer} target\n\t * @returns {this}\n\t */\n\taddTo(target) {\n\t\tthis.remove();\n\t\tthis._target = target;\n\t\ttarget.on('contextmenu', this._open, this);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes the menu from its map or layer.\n\t * @returns {this}\n\t */\n\tremove() {\n\t\tthis.close();\n\t\tthis._target?.off('contextmenu', this._open, this);\n\t\tthis._target = null;\n\t\tthis._container?.remove();\n\t\tthis._container = null;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Closes the menu.\n\t * @returns {this}\n\t */\n\tclose() {\n\t\tif (this._container?.matches(':popover-open')) {\n\t\t\tthis._container.hidePopover();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns `true` if the menu is open.\n\t * @returns {boolean}\n\t */\n\tisOpen() {\n\t\treturn !!this._container?.matches(':popover-open');\n\t}\n\n\t_open(e) {\n\t\t// a menu of a layer replaces the one of the map\n\t\tDomEvent.stop(e);\n\t\tconst map = this._target instanceof Layer ? this._target._map : this._target;\n\t\tif (!map) { return; }\n\n\t\tthis._map = map;\n\t\tthis._event = {\n\t\t\tlatlng: e.latlng,\n\t\t\tcontainerPoint: e.containerPoint,\n\t\t\tlayerPoint: e.layerPoint,\n\t\t\toriginalEvent: e.originalEvent,\n\t\t\trelatedTarget: this._target instanceof Layer ? this._target : undefined\n\t\t};\n\n\t\tconst container = this._createMenu(map._container);\n\t\tif (!container.matches(':popover-open')) {\n\t\t\tcontainer.showPopover();\n\t\t}\n\t\tthis._position(e.originalEvent);\n\t\tcontainer.querySelector('button:not([disabled])')?.focus({preventScroll: true});\n\t\tmap.once('movestart', this.close, this);\n\t}\n\n\t_createMenu(parent) {\n\t\tconst container = this._container ??= DomUtil.create('div', `maplair-contextmenu ${this.options.className}`);\n\t\tif (container.parentNode !== parent) {\n\t\t\tparent.append(container);\n\t\t}\n\t\tcontainer.popover = 'auto';\n\t\tcontainer.setAttribute('role', 'menu');\n\t\tcontainer.replaceChildren();\n\n\t\tfor (const item of this._items) {\n\t\t\tif (item === '-') {\n\t\t\t\tDomUtil.create('div', 'maplair-contextmenu-separator', container).setAttribute('role', 'separator');\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst button = DomUtil.create('button', 'maplair-contextmenu-item', container);\n\t\t\tbutton.type = 'button';\n\t\t\tbutton.setAttribute('role', 'menuitem');\n\t\t\tbutton.textContent = item.text;\n\t\t\tbutton.disabled = !!item.disabled;\n\t\t\tDomEvent.on(button, 'click', (ev) => {\n\t\t\t\tDomEvent.stop(ev);\n\t\t\t\tthis.close();\n\t\t\t\titem.callback?.call(this, this._event);\n\t\t\t});\n\t\t}\n\n\t\tDomEvent.on(container, 'keydown', this._onKeyDown, this);\n\t\tDomEvent.disableClickPropagation(container);\n\t\tDomEvent.disableScrollPropagation(container);\n\t\tDomEvent.on(container, 'contextmenu', DomEvent.stop);\n\t\treturn container;\n\t}\n\n\t// At the pointer, within the viewport\n\t_position(e) {\n\t\tconst container = this._container,\n\t\tviewport = document.documentElement,\n\t\tx = Math.min(e.clientX, viewport.clientWidth - container.offsetWidth),\n\t\ty = Math.min(e.clientY, viewport.clientHeight - container.offsetHeight);\n\t\tcontainer.style.left = `${Math.max(0, x)}px`;\n\t\tcontainer.style.top = `${Math.max(0, y)}px`;\n\t}\n\n\t_onKeyDown(e) {\n\t\tif (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') { return; }\n\t\tDomEvent.stop(e);\n\t\tconst buttons = [...this._container.querySelectorAll('button:not([disabled])')],\n\t\tindex = buttons.indexOf(document.activeElement),\n\t\tnext = e.key === 'ArrowDown' ? index + 1 : index - 1;\n\t\tbuttons.at(next % buttons.length)?.focus();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,IAAa,cAAb,MAAa,oBAAoB,MAAM;CAEtC,OAAO,iBAAiB,EACvB,WAAW,GACZ;;;;;;;;;CAUA,YAAY,OAAO,SAAS;EAC3B,MAAM;EACN,WAAgB,MAAM,OAAO;EAC7B,KAAK,SAAS;EACd,KAAK,cAAc,WAAW;CAC/B;;;;;;CAOA,MAAM,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,KAAK;IACjB,OAAe,OAAO,iCAAiC,SAAS,CAAC,CAAC,aAAa,QAAQ,WAAW;IAClG;GACD;GACA,MAAM,SAASA,OAAe,UAAU,4BAA4B,SAAS;GAC7E,OAAO,OAAO;GACd,OAAO,aAAa,QAAQ,UAAU;GACtC,OAAO,cAAc,KAAK;GAC1B,OAAO,WAAW,CAAC,CAAC,KAAK;GACzB,GAAY,QAAQ,UAAU,OAAO;IACpC,KAAc,EAAE;IAChB,KAAK,MAAM;IACX,KAAK,UAAU,KAAK,MAAM,KAAK,MAAM;GACtC,CAAC;EACF;EAEA,GAAY,WAAW,WAAW,KAAK,YAAY,IAAI;EACvD,wBAAiC,SAAS;EAC1C,yBAAkC,SAAS;EAC3C,GAAY,WAAW,eAAeC,IAAa;EACnD,OAAO;CACR;CAGA,UAAU,GAAG;EACZ,MAAM,YAAY,KAAK,YACvB,WAAW,SAAS,iBACpB,IAAI,KAAK,IAAI,EAAE,SAAS,SAAS,cAAc,UAAU,WAAW,GACpE,IAAI,KAAK,IAAI,EAAE,SAAS,SAAS,eAAe,UAAU,YAAY;EACtE,UAAU,MAAM,OAAO,GAAG,KAAK,IAAI,GAAG,CAAC,EAAE;EACzC,UAAU,MAAM,MAAM,GAAG,KAAK,IAAI,GAAG,CAAC,EAAE;CACzC;CAEA,WAAW,GAAG;EACb,IAAI,EAAE,QAAQ,eAAe,EAAE,QAAQ,WAAa;EACpD,KAAc,CAAC;EACf,MAAM,UAAU,CAAC,GAAG,KAAK,WAAW,iBAAiB,wBAAwB,CAAC,GAC9E,QAAQ,QAAQ,QAAQ,SAAS,aAAa,GAC9C,OAAO,EAAE,QAAQ,cAAc,QAAQ,IAAI,QAAQ;EACnD,QAAQ,GAAG,OAAO,QAAQ,MAAM,CAAC,EAAE,MAAM;CAC1C;AACD"}
|
|
@@ -58,12 +58,16 @@ const mapControlMethods = {
|
|
|
58
58
|
* @property {(map: MaplairMap) => void} [onRemove] Should contain all clean up code that
|
|
59
59
|
* removes the listeners previously added in `onAdd`. Called on
|
|
60
60
|
* [`control.remove()`](#control-remove).
|
|
61
|
+
* @property {() => Record<string, Function>} [getEvents] Should return an object like
|
|
62
|
+
* `{zoomend: this._update}` for [`on`](#evented-on). The event handlers in this object
|
|
63
|
+
* will be automatically added and removed from the map with your control.
|
|
61
64
|
* @lends Control
|
|
62
65
|
*/
|
|
63
66
|
const controlOrders = /* @__PURE__ */ new WeakMap();
|
|
64
67
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
68
|
+
* Base class for map controls such as `ZoomControl`, `AttributionControl`,
|
|
69
|
+
* `LayersControl` and `ScaleControl`, which handles positioning them. Extend it to
|
|
70
|
+
* create your own controls.
|
|
67
71
|
*
|
|
68
72
|
* Every control should extend from `Control` and (re-)implement the following methods:
|
|
69
73
|
*
|
|
@@ -73,6 +77,9 @@ const controlOrders = /* @__PURE__ */ new WeakMap();
|
|
|
73
77
|
* * `onRemove(map: MaplairMap)` (optional) should contain all clean up code that removes
|
|
74
78
|
* the listeners previously added in [`onAdd`](#control-onadd). Called on
|
|
75
79
|
* [`control.remove()`](#control-remove).
|
|
80
|
+
* * `getEvents(): Object` (optional) should return an object like
|
|
81
|
+
* `{zoomend: this._update}` for [`on`](#evented-on). The event handlers in this
|
|
82
|
+
* object will be automatically added and removed from the map with your control.
|
|
76
83
|
*/
|
|
77
84
|
var Control = class Control extends Class {
|
|
78
85
|
static defaultOptions = {
|
|
@@ -126,7 +133,11 @@ var Control = class Control extends Class {
|
|
|
126
133
|
const order = this.options.order ?? 0, bottom = pos.includes("bottom"), children = [...corner.children];
|
|
127
134
|
controlOrders.set(container, order);
|
|
128
135
|
corner.insertBefore(container, children.find((el) => bottom ? (controlOrders.get(el) ?? 0) <= order : (controlOrders.get(el) ?? 0) > order) ?? null);
|
|
129
|
-
this.
|
|
136
|
+
this._mapEvents = {
|
|
137
|
+
...this.getEvents?.(),
|
|
138
|
+
unload: this.remove
|
|
139
|
+
};
|
|
140
|
+
map.on(this._mapEvents, this);
|
|
130
141
|
return this;
|
|
131
142
|
}
|
|
132
143
|
/**
|
|
@@ -136,17 +147,11 @@ var Control = class Control extends Class {
|
|
|
136
147
|
remove() {
|
|
137
148
|
if (!this._map) return this;
|
|
138
149
|
this._container.remove();
|
|
139
|
-
|
|
140
|
-
this.
|
|
150
|
+
this._map.off(this._mapEvents, this);
|
|
151
|
+
this.onRemove?.(this._map);
|
|
141
152
|
this._map = null;
|
|
142
153
|
return this;
|
|
143
154
|
}
|
|
144
|
-
_refocusOnMap(e) {
|
|
145
|
-
if (this._map && e && !(e.screenX === 0 && e.screenY === 0)) this._map.getContainer().focus({
|
|
146
|
-
preventScroll: true,
|
|
147
|
-
focusVisible: false
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
155
|
/**
|
|
151
156
|
* Registers this default feature on the map class, called by `MaplairMap` itself.
|
|
152
157
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Control.js","names":["DomUtil.create"],"sources":["../../../src/control/Control.js"],"sourcesContent":["import {Class} from '../core/Class.js';\nimport * as Util from '../core/Util.js';\nimport * as DomUtil from '../dom/DomUtil.js';\n/** @import {MaplairMap} from '../map/Map.js' */\n\n/**\n * Options of `Control`, inherited by all controls.\n * @typedef {object} ControlOptions\n * @property {string} [position='topright'] The position of the control (one of the map\n * corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or\n * `'bottomright'`.\n * @property {number} [order=0] The position of the control within its corner: controls\n * with a lower order are closer to the corner of the map, those with the same order in\n * the order of adding.\n */\n\n/**\n * Methods of `MaplairMap` for controls.\n * @lends MaplairMap.prototype\n */\nconst mapControlMethods = {\n\t/**\n\t * Adds the given control to the map.\n\t * @group Methods for layers and controls\n\t * @param {Control} control\n\t * @returns {this}\n\t */\n\taddControl(control) {\n\t\tcontrol.addTo(this);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Removes the given control from the map.\n\t * @group Methods for layers and controls\n\t * @param {Control} control\n\t * @returns {this}\n\t */\n\tremoveControl(control) {\n\t\tcontrol.remove();\n\t\treturn this;\n\t},\n\n\t_initControlPos() {\n\t\tconst corners = this._controlCorners = {},\n\t\tl = 'maplair-',\n\t\tcontainer = this._controlContainer = DomUtil.create('div', `${l}control-container`, this._container);\n\n\t\tfor (const v of ['top', 'bottom']) {\n\t\t\tfor (const h of ['left', 'right']) {\n\t\t\t\tcorners[v + h] = DomUtil.create('div', `${l + v} ${l}${h}`, container);\n\t\t\t}\n\t\t}\n\t},\n\n\t_clearControlPos() {\n\t\tthis._controlContainer.remove();\n\t\tdelete this._controlCorners;\n\t\tdelete this._controlContainer;\n\t}\n};\n/** @typedef {typeof mapControlMethods} MapControlMethods */\n\n/**\n * The methods which controls implement, see `Control`.\n * @typedef {object} ControlExtensionMethods\n * @property {(map: MaplairMap) => HTMLElement} [onAdd] Should return the container DOM\n * element for the control and add listeners on relevant map events. Called on\n * [`control.addTo(map)`](#control-addto).\n * @property {(map: MaplairMap) => void} [onRemove] Should contain all clean up code that\n * removes the listeners previously added in `onAdd`. Called on\n * [`control.remove()`](#control-remove).\n * @lends Control\n */\n\n// The `order` option of the containers of added controls\nconst controlOrders = new WeakMap();\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"Control.js","names":["DomUtil.create"],"sources":["../../../src/control/Control.js"],"sourcesContent":["import {Class} from '../core/Class.js';\nimport * as Util from '../core/Util.js';\nimport * as DomUtil from '../dom/DomUtil.js';\n/** @import {MaplairMap} from '../map/Map.js' */\n\n/**\n * Options of `Control`, inherited by all controls.\n * @typedef {object} ControlOptions\n * @property {string} [position='topright'] The position of the control (one of the map\n * corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or\n * `'bottomright'`.\n * @property {number} [order=0] The position of the control within its corner: controls\n * with a lower order are closer to the corner of the map, those with the same order in\n * the order of adding.\n */\n\n/**\n * Methods of `MaplairMap` for controls.\n * @lends MaplairMap.prototype\n */\nconst mapControlMethods = {\n\t/**\n\t * Adds the given control to the map.\n\t * @group Methods for layers and controls\n\t * @param {Control} control\n\t * @returns {this}\n\t */\n\taddControl(control) {\n\t\tcontrol.addTo(this);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Removes the given control from the map.\n\t * @group Methods for layers and controls\n\t * @param {Control} control\n\t * @returns {this}\n\t */\n\tremoveControl(control) {\n\t\tcontrol.remove();\n\t\treturn this;\n\t},\n\n\t_initControlPos() {\n\t\tconst corners = this._controlCorners = {},\n\t\tl = 'maplair-',\n\t\tcontainer = this._controlContainer = DomUtil.create('div', `${l}control-container`, this._container);\n\n\t\tfor (const v of ['top', 'bottom']) {\n\t\t\tfor (const h of ['left', 'right']) {\n\t\t\t\tcorners[v + h] = DomUtil.create('div', `${l + v} ${l}${h}`, container);\n\t\t\t}\n\t\t}\n\t},\n\n\t_clearControlPos() {\n\t\tthis._controlContainer.remove();\n\t\tdelete this._controlCorners;\n\t\tdelete this._controlContainer;\n\t}\n};\n/** @typedef {typeof mapControlMethods} MapControlMethods */\n\n/**\n * The methods which controls implement, see `Control`.\n * @typedef {object} ControlExtensionMethods\n * @property {(map: MaplairMap) => HTMLElement} [onAdd] Should return the container DOM\n * element for the control and add listeners on relevant map events. Called on\n * [`control.addTo(map)`](#control-addto).\n * @property {(map: MaplairMap) => void} [onRemove] Should contain all clean up code that\n * removes the listeners previously added in `onAdd`. Called on\n * [`control.remove()`](#control-remove).\n * @property {() => Record<string, Function>} [getEvents] Should return an object like\n * `{zoomend: this._update}` for [`on`](#evented-on). The event handlers in this object\n * will be automatically added and removed from the map with your control.\n * @lends Control\n */\n\n// The `order` option of the containers of added controls\nconst controlOrders = new WeakMap();\n\n/**\n * Base class for map controls such as `ZoomControl`, `AttributionControl`,\n * `LayersControl` and `ScaleControl`, which handles positioning them. Extend it to\n * create your own controls.\n *\n * Every control should extend from `Control` and (re-)implement the following methods:\n *\n * * `onAdd(map: MaplairMap): HTMLElement` should return the container DOM element for\n * the control and add listeners on relevant map events. Called on\n * [`control.addTo(map)`](#control-addTo).\n * * `onRemove(map: MaplairMap)` (optional) should contain all clean up code that removes\n * the listeners previously added in [`onAdd`](#control-onadd). Called on\n * [`control.remove()`](#control-remove).\n * * `getEvents(): Object` (optional) should return an object like\n * `{zoomend: this._update}` for [`on`](#evented-on). The event handlers in this\n * object will be automatically added and removed from the map with your control.\n */\nexport class Control extends Class {\n\n\tstatic defaultOptions = {\n\t\tposition: 'topright',\n\t\torder: 0\n\t};\n\n\t/**\n\t * @param {ControlOptions} [options]\n\t */\n\tconstructor(options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\n\t\tthis.callInitHooks(Control);\n\t}\n\n\t/**\n\t * Returns the position of the control.\n\t * @returns {string}\n\t */\n\tgetPosition() {\n\t\treturn this.options.position;\n\t}\n\n\t/**\n\t * Sets the position of the control.\n\t * @param {string} position\n\t * @returns {this}\n\t */\n\tsetPosition(position) {\n\t\tconst map = this._map;\n\n\t\tmap?.removeControl(this);\n\n\t\tthis.options.position = position;\n\n\t\tmap?.addControl(this);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the HTMLElement that contains the control.\n\t * @returns {HTMLElement}\n\t */\n\tgetContainer() {\n\t\treturn this._container;\n\t}\n\n\t/**\n\t * Adds the control to the given map.\n\t * @param {MaplairMap} map\n\t * @returns {this}\n\t */\n\taddTo(map) {\n\t\tthis.remove();\n\t\tthis._map = map;\n\n\t\tconst container = this._container = this.onAdd(map),\n\t\tpos = this.getPosition(),\n\t\tcorner = map._controlCorners[pos];\n\n\t\tcontainer.classList.add('maplair-control');\n\n\t\t// sorted by order from the corner of the map (bottom corners are filled upwards),\n\t\t// farther than the controls with the same order\n\t\tconst order = this.options.order ?? 0,\n\t\tbottom = pos.includes('bottom'),\n\t\tchildren = [...corner.children];\n\t\tcontrolOrders.set(container, order);\n\t\tcorner.insertBefore(container, children.find(el => bottom ?\n\t\t\t(controlOrders.get(el) ?? 0) <= order :\n\t\t\t(controlOrders.get(el) ?? 0) > order) ?? null);\n\n\t\tthis._mapEvents = {...this.getEvents?.(), unload: this.remove};\n\t\tmap.on(this._mapEvents, this);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes the control from the map it is currently active on.\n\t * @returns {this}\n\t */\n\tremove() {\n\t\tif (!this._map) {\n\t\t\treturn this;\n\t\t}\n\n\t\tthis._container.remove();\n\t\tthis._map.off(this._mapEvents, this);\n\t\tthis.onRemove?.(this._map);\n\n\t\tthis._map = null;\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Registers this default feature on the map class, called by `MaplairMap` itself.\n\t * @internal\n\t * @param {typeof MaplairMap} MaplairMap\n\t */\n\tstatic register(MaplairMap) {\n\t\tMaplairMap.include(mapControlMethods);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoBA,MAAM,oBAAoB;;;;;;;CAOzB,WAAW,SAAS;EACnB,QAAQ,MAAM,IAAI;EAClB,OAAO;CACR;;;;;;;CAQA,cAAc,SAAS;EACtB,QAAQ,OAAO;EACf,OAAO;CACR;CAEA,kBAAkB;EACjB,MAAM,UAAU,KAAK,kBAAkB,CAAC,GACxC,IAAI,YACJ,YAAY,KAAK,oBAAoBA,OAAe,OAAO,GAAG,EAAE,oBAAoB,KAAK,UAAU;EAEnG,KAAK,MAAM,KAAK,CAAC,OAAO,QAAQ,GAC/B,KAAK,MAAM,KAAK,CAAC,QAAQ,OAAO,GAC/B,QAAQ,IAAI,KAAKA,OAAe,OAAO,GAAG,IAAI,EAAE,GAAG,IAAI,KAAK,SAAS;CAGxE;CAEA,mBAAmB;EAClB,KAAK,kBAAkB,OAAO;EAC9B,OAAO,KAAK;EACZ,OAAO,KAAK;CACb;AACD;;;;;;;;;;;;;;;;AAmBA,MAAM,gCAAgB,IAAI,QAAQ;;;;;;;;;;;;;;;;;;AAmBlC,IAAa,UAAb,MAAa,gBAAgB,MAAM;CAElC,OAAO,iBAAiB;EACvB,UAAU;EACV,OAAO;CACR;;;;CAKA,YAAY,SAAS;EACpB,MAAM;EACN,WAAgB,MAAM,OAAO;EAE7B,KAAK,cAAc,OAAO;CAC3B;;;;;CAMA,cAAc;EACb,OAAO,KAAK,QAAQ;CACrB;;;;;;CAOA,YAAY,UAAU;EACrB,MAAM,MAAM,KAAK;EAEjB,KAAK,cAAc,IAAI;EAEvB,KAAK,QAAQ,WAAW;EAExB,KAAK,WAAW,IAAI;EAEpB,OAAO;CACR;;;;;CAMA,eAAe;EACd,OAAO,KAAK;CACb;;;;;;CAOA,MAAM,KAAK;EACV,KAAK,OAAO;EACZ,KAAK,OAAO;EAEZ,MAAM,YAAY,KAAK,aAAa,KAAK,MAAM,GAAG,GAClD,MAAM,KAAK,YAAY,GACvB,SAAS,IAAI,gBAAgB;EAE7B,UAAU,UAAU,IAAI,iBAAiB;EAIzC,MAAM,QAAQ,KAAK,QAAQ,SAAS,GACpC,SAAS,IAAI,SAAS,QAAQ,GAC9B,WAAW,CAAC,GAAG,OAAO,QAAQ;EAC9B,cAAc,IAAI,WAAW,KAAK;EAClC,OAAO,aAAa,WAAW,SAAS,MAAK,OAAM,UACjD,cAAc,IAAI,EAAE,KAAK,MAAM,SAC/B,cAAc,IAAI,EAAE,KAAK,KAAK,KAAK,KAAK,IAAI;EAE9C,KAAK,aAAa;GAAC,GAAG,KAAK,YAAY;GAAG,QAAQ,KAAK;EAAM;EAC7D,IAAI,GAAG,KAAK,YAAY,IAAI;EAE5B,OAAO;CACR;;;;;CAMA,SAAS;EACR,IAAI,CAAC,KAAK,MACT,OAAO;EAGR,KAAK,WAAW,OAAO;EACvB,KAAK,KAAK,IAAI,KAAK,YAAY,IAAI;EACnC,KAAK,WAAW,KAAK,IAAI;EAEzB,KAAK,OAAO;EAEZ,OAAO;CACR;;;;;;CAOA,OAAO,SAAS,YAAY;EAC3B,WAAW,QAAQ,iBAAiB;CACrC;AACD"}
|
|
@@ -131,7 +131,6 @@ var FullscreenControl = class FullscreenControl extends Control {
|
|
|
131
131
|
disableClickPropagation(button);
|
|
132
132
|
on(button, "click", stop);
|
|
133
133
|
on(button, "click", this._toggleFullscreen, this);
|
|
134
|
-
on(button, "click", this._refocusOnMap, this);
|
|
135
134
|
this._update();
|
|
136
135
|
map.on("fullscreenchange", this._update, this);
|
|
137
136
|
return container;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FullscreenControl.js","names":["DomUtil.create","DomEvent.stop"],"sources":["../../../src/control/FullscreenControl.js"],"sourcesContent":["import {Control} from './Control.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport {I18n} from '../core/I18n.js';\n/** @import {ControlOptions} from './Control.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n/** @import {MaplairEvent} from '../core/Events.js' */\n\nconst enterIcon = '<svg aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\"><path d=\"M2 2h5v2H4v3H2zm7 0h5v5h-2V4H9zM2 9h2v3h3v2H2zm10 0h2v5H9v-2h3z\"/></svg>';\nconst exitIcon = '<svg aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\"><path d=\"M5 2h2v5H2V5h3zm4 0h2v3h3v2H9zM2 9h5v5H5v-3H2zm7 0h5v2h-3v3H9z\"/></svg>';\n\n/**\n * Options of `FullscreenControl`.\n * @typedef {object} FullscreenControlOptions\n * @property {string} [position='topleft'] The position of the control (one of the map\n * corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or\n * `'bottomright'`.\n * @property {string} [enterText] The HTML content of the button while the map is not in\n * fullscreen, by default an expand icon.\n * @property {string} [exitText] The HTML content of the button while the map is in\n * fullscreen, by default a collapse icon.\n * @extends ControlOptions\n */\n\n/**\n * Map options of `FullscreenControl`.\n * @typedef {object} FullscreenControlMapOptions\n * @lends MaplairMapOptions\n * @property {boolean} [fullscreenControl=false] Whether a\n * [fullscreen control](#fullscreencontrol) is added to the map by default.\n */\n\n/**\n * Properties of `MaplairMap` set by `FullscreenControl`.\n * @typedef {object} FullscreenControlMapProperties\n * @lends MaplairMap\n * @property {FullscreenControl} fullscreenControl The default fullscreen control (only\n * available if the [`fullscreenControl` option](#map-fullscreencontrol) was `true` when\n * creating the map).\n */\n\n/**\n * Methods of `MaplairMap` for the fullscreen view.\n * @lends MaplairMap.prototype\n * @fires MaplairMap#enterfullscreen {MaplairEvent} Fired when the map enters fullscreen.\n * @fires MaplairMap#exitfullscreen {MaplairEvent} Fired when the map exits fullscreen.\n * @fires MaplairMap#fullscreenchange {MaplairEvent} Fired when the map enters or exits\n * fullscreen.\n */\nconst mapFullscreenMethods = {\n\t/**\n\t * Enters or exits the fullscreen view of the map, see `FullscreenControl`.\n\t * Browsers allow entering fullscreen only in response to a user interaction,\n\t * e.g. a click.\n\t * @group Methods for modifying map state\n\t * @returns {this}\n\t */\n\ttoggleFullscreen() {\n\t\tconst container = this._container;\n\n\t\tif (this._fullscreen === 'pseudo') {\n\t\t\tthis._setFullscreen(false);\n\t\t} else if (this._fullscreen) {\n\t\t\tdocument.exitFullscreen();\n\t\t} else if (document.fullscreenEnabled && container.requestFullscreen) {\n\t\t\tDomEvent.on(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t\tcontainer.requestFullscreen().catch(() => {\n\t\t\t\tDomEvent.off(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t\t\tthis._setFullscreen('pseudo');\n\t\t\t});\n\t\t} else {\n\t\t\tthis._setFullscreen('pseudo');\n\t\t}\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` if the map is viewed in fullscreen.\n\t * @group Other methods\n\t * @returns {boolean}\n\t */\n\tisFullscreen() {\n\t\treturn !!this._fullscreen;\n\t},\n\n\t_onFullscreenChange() {\n\t\tconst fullscreen = document.fullscreenElement === this._container;\n\t\tif (!fullscreen) {\n\t\t\tDomEvent.off(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t}\n\t\tif (fullscreen !== this.isFullscreen()) {\n\t\t\tthis._setFullscreen(fullscreen && 'native');\n\t\t}\n\t},\n\n\t_onFullscreenKeyDown(e) {\n\t\tif (e.key === 'Escape') {\n\t\t\tthis._setFullscreen(false);\n\t\t}\n\t},\n\n\t// `mode` is `'native'` (Fullscreen API), `'pseudo'` (CSS) or `false`\n\t_setFullscreen(mode) {\n\t\tconst container = this._container;\n\t\tthis._fullscreen = mode;\n\n\t\tcontainer.classList.toggle('maplair-fullscreen', !!mode);\n\t\tcontainer.classList.toggle('maplair-pseudo-fullscreen', mode === 'pseudo');\n\t\tif (mode === 'pseudo') {\n\t\t\tDomEvent.on(document, 'keydown', this._onFullscreenKeyDown, this);\n\t\t} else {\n\t\t\tDomEvent.off(document, 'keydown', this._onFullscreenKeyDown, this);\n\t\t}\n\n\t\tthis.invalidateSize();\n\n\t\tthis.fire(mode ? 'enterfullscreen' : 'exitfullscreen');\n\t\tthis.fire('fullscreenchange');\n\t}\n};\n/** @typedef {typeof mapFullscreenMethods} MapFullscreenMethods */\n\n/**\n * A control with a button to view the map in fullscreen and to exit it again. It is\n * put on the map if you set its [`fullscreenControl` option](#map-fullscreencontrol)\n * to `true`. Where the browser does not support the\n * [Fullscreen API](https://developer.mozilla.org/docs/Web/API/Fullscreen_API)\n * (e.g. Safari on iPhone) or refuses fullscreen (e.g. in an iframe without\n * `allow=\"fullscreen\"`), the map is enlarged to the size of the window instead.\n *\n * @example\n * ```js\n * new FullscreenControl({position: 'topright'}).addTo(map);\n * ```\n */\nexport class FullscreenControl extends Control {\n\n\tstatic defaultOptions = {\n\t\tposition: 'topleft',\n\t\tenterText: enterIcon,\n\t\texitText: exitIcon\n\t};\n\n\t/**\n\t * Creates a fullscreen control.\n\t * @param {...FullscreenControlOptions} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(FullscreenControl);\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t * @returns {HTMLElement}\n\t */\n\tonAdd(map) {\n\t\tconst container = DomUtil.create('div', 'maplair-control-fullscreen maplair-bar'),\n\t\tbutton = this._button = DomUtil.create('button', 'maplair-control-fullscreen-button', container);\n\t\tbutton.type = 'button';\n\n\t\tDomEvent.disableClickPropagation(button);\n\t\tDomEvent.on(button, 'click', DomEvent.stop);\n\t\tDomEvent.on(button, 'click', this._toggleFullscreen, this);\n\t\tDomEvent.on(button, 'click', this._refocusOnMap, this);\n\n\t\tthis._update();\n\t\tmap.on('fullscreenchange', this._update, this);\n\n\t\treturn container;\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tmap.off('fullscreenchange', this._update, this);\n\t}\n\n\t_toggleFullscreen() {\n\t\tthis._map.toggleFullscreen();\n\t}\n\n\t_update() {\n\t\tconst fullscreen = this._map.isFullscreen(),\n\t\ttitle = fullscreen ? I18n.translate('Exit fullscreen') : I18n.translate('View fullscreen');\n\n\t\tthis._button.innerHTML = fullscreen ? this.options.exitText : this.options.enterText;\n\t\tthis._button.title = title;\n\t\tthis._button.setAttribute('aria-label', title);\n\t\tthis._button.setAttribute('aria-pressed', fullscreen);\n\t}\n\n\t/**\n\t * Registers this default feature on the map class, called by `MaplairMap` itself.\n\t * @internal\n\t * @param {typeof MaplairMap} MaplairMap\n\t */\n\tstatic register(MaplairMap) {\n\t\tMaplairMap.mergeOptions({\n\t\t\tfullscreenControl: false\n\t\t});\n\n\t\tMaplairMap.include(mapFullscreenMethods);\n\n\t\tMaplairMap.addInitHook(function () {\n\t\t\tthis.on('unload', function () {\n\t\t\t\tif (this._fullscreen === 'native') {\n\t\t\t\t\tDomEvent.off(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t\t\t\tdocument.exitFullscreen();\n\t\t\t\t}\n\t\t\t\tthis._container.classList.remove('maplair-fullscreen', 'maplair-pseudo-fullscreen');\n\t\t\t\tDomEvent.off(document, 'keydown', this._onFullscreenKeyDown, this);\n\t\t\t\tthis._fullscreen = false;\n\t\t\t});\n\n\t\t\tif (this.options.fullscreenControl) {\n\t\t\t\tthis.fullscre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KAAK,qBAAqB,IAAI;KACzE,SAAS,eAAe;IACzB;IACA,KAAK,WAAW,UAAU,OAAO,sBAAsB,2BAA2B;IAClF,IAAa,UAAU,WAAW,KAAK,sBAAsB,IAAI;IACjE,KAAK,cAAc;GACpB,CAAC;GAED,IAAI,KAAK,QAAQ,mBAAmB;IACnC,KAAK,oBAAoB,IAAI,kBAAkB;IAC/C,KAAK,WAAW,KAAK,iBAAiB;GACvC;EACD,CAAC;CACF;AACD"}
|
|
1
|
+
{"version":3,"file":"FullscreenControl.js","names":["DomUtil.create","DomEvent.stop"],"sources":["../../../src/control/FullscreenControl.js"],"sourcesContent":["import {Control} from './Control.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport {I18n} from '../core/I18n.js';\n/** @import {ControlOptions} from './Control.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n/** @import {MaplairEvent} from '../core/Events.js' */\n\nconst enterIcon = '<svg aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\"><path d=\"M2 2h5v2H4v3H2zm7 0h5v5h-2V4H9zM2 9h2v3h3v2H2zm10 0h2v5H9v-2h3z\"/></svg>';\nconst exitIcon = '<svg aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\"><path d=\"M5 2h2v5H2V5h3zm4 0h2v3h3v2H9zM2 9h5v5H5v-3H2zm7 0h5v2h-3v3H9z\"/></svg>';\n\n/**\n * Options of `FullscreenControl`.\n * @typedef {object} FullscreenControlOptions\n * @property {string} [position='topleft'] The position of the control (one of the map\n * corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or\n * `'bottomright'`.\n * @property {string} [enterText] The HTML content of the button while the map is not in\n * fullscreen, by default an expand icon.\n * @property {string} [exitText] The HTML content of the button while the map is in\n * fullscreen, by default a collapse icon.\n * @extends ControlOptions\n */\n\n/**\n * Map options of `FullscreenControl`.\n * @typedef {object} FullscreenControlMapOptions\n * @lends MaplairMapOptions\n * @property {boolean} [fullscreenControl=false] Whether a\n * [fullscreen control](#fullscreencontrol) is added to the map by default.\n */\n\n/**\n * Properties of `MaplairMap` set by `FullscreenControl`.\n * @typedef {object} FullscreenControlMapProperties\n * @lends MaplairMap\n * @property {FullscreenControl} fullscreenControl The default fullscreen control (only\n * available if the [`fullscreenControl` option](#map-fullscreencontrol) was `true` when\n * creating the map).\n */\n\n/**\n * Methods of `MaplairMap` for the fullscreen view.\n * @lends MaplairMap.prototype\n * @fires MaplairMap#enterfullscreen {MaplairEvent} Fired when the map enters fullscreen.\n * @fires MaplairMap#exitfullscreen {MaplairEvent} Fired when the map exits fullscreen.\n * @fires MaplairMap#fullscreenchange {MaplairEvent} Fired when the map enters or exits\n * fullscreen.\n */\nconst mapFullscreenMethods = {\n\t/**\n\t * Enters or exits the fullscreen view of the map, see `FullscreenControl`.\n\t * Browsers allow entering fullscreen only in response to a user interaction,\n\t * e.g. a click.\n\t * @group Methods for modifying map state\n\t * @returns {this}\n\t */\n\ttoggleFullscreen() {\n\t\tconst container = this._container;\n\n\t\tif (this._fullscreen === 'pseudo') {\n\t\t\tthis._setFullscreen(false);\n\t\t} else if (this._fullscreen) {\n\t\t\tdocument.exitFullscreen();\n\t\t} else if (document.fullscreenEnabled && container.requestFullscreen) {\n\t\t\tDomEvent.on(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t\tcontainer.requestFullscreen().catch(() => {\n\t\t\t\tDomEvent.off(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t\t\tthis._setFullscreen('pseudo');\n\t\t\t});\n\t\t} else {\n\t\t\tthis._setFullscreen('pseudo');\n\t\t}\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` if the map is viewed in fullscreen.\n\t * @group Other methods\n\t * @returns {boolean}\n\t */\n\tisFullscreen() {\n\t\treturn !!this._fullscreen;\n\t},\n\n\t_onFullscreenChange() {\n\t\tconst fullscreen = document.fullscreenElement === this._container;\n\t\tif (!fullscreen) {\n\t\t\tDomEvent.off(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t}\n\t\tif (fullscreen !== this.isFullscreen()) {\n\t\t\tthis._setFullscreen(fullscreen && 'native');\n\t\t}\n\t},\n\n\t_onFullscreenKeyDown(e) {\n\t\tif (e.key === 'Escape') {\n\t\t\tthis._setFullscreen(false);\n\t\t}\n\t},\n\n\t// `mode` is `'native'` (Fullscreen API), `'pseudo'` (CSS) or `false`\n\t_setFullscreen(mode) {\n\t\tconst container = this._container;\n\t\tthis._fullscreen = mode;\n\n\t\tcontainer.classList.toggle('maplair-fullscreen', !!mode);\n\t\tcontainer.classList.toggle('maplair-pseudo-fullscreen', mode === 'pseudo');\n\t\tif (mode === 'pseudo') {\n\t\t\tDomEvent.on(document, 'keydown', this._onFullscreenKeyDown, this);\n\t\t} else {\n\t\t\tDomEvent.off(document, 'keydown', this._onFullscreenKeyDown, this);\n\t\t}\n\n\t\tthis.invalidateSize();\n\n\t\tthis.fire(mode ? 'enterfullscreen' : 'exitfullscreen');\n\t\tthis.fire('fullscreenchange');\n\t}\n};\n/** @typedef {typeof mapFullscreenMethods} MapFullscreenMethods */\n\n/**\n * A control with a button to view the map in fullscreen and to exit it again. It is\n * put on the map if you set its [`fullscreenControl` option](#map-fullscreencontrol)\n * to `true`. Where the browser does not support the\n * [Fullscreen API](https://developer.mozilla.org/docs/Web/API/Fullscreen_API)\n * (e.g. Safari on iPhone) or refuses fullscreen (e.g. in an iframe without\n * `allow=\"fullscreen\"`), the map is enlarged to the size of the window instead.\n *\n * @example\n * ```js\n * new FullscreenControl({position: 'topright'}).addTo(map);\n * ```\n */\nexport class FullscreenControl extends Control {\n\n\tstatic defaultOptions = {\n\t\tposition: 'topleft',\n\t\tenterText: enterIcon,\n\t\texitText: exitIcon\n\t};\n\n\t/**\n\t * Creates a fullscreen control.\n\t * @param {...FullscreenControlOptions} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(FullscreenControl);\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t * @returns {HTMLElement}\n\t */\n\tonAdd(map) {\n\t\tconst container = DomUtil.create('div', 'maplair-control-fullscreen maplair-bar'),\n\t\tbutton = this._button = DomUtil.create('button', 'maplair-control-fullscreen-button', container);\n\t\tbutton.type = 'button';\n\n\t\tDomEvent.disableClickPropagation(button);\n\t\tDomEvent.on(button, 'click', DomEvent.stop);\n\t\tDomEvent.on(button, 'click', this._toggleFullscreen, this);\n\n\t\tthis._update();\n\t\tmap.on('fullscreenchange', this._update, this);\n\n\t\treturn container;\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tmap.off('fullscreenchange', this._update, this);\n\t}\n\n\t_toggleFullscreen() {\n\t\tthis._map.toggleFullscreen();\n\t}\n\n\t_update() {\n\t\tconst fullscreen = this._map.isFullscreen(),\n\t\ttitle = fullscreen ? I18n.translate('Exit fullscreen') : I18n.translate('View fullscreen');\n\n\t\tthis._button.innerHTML = fullscreen ? this.options.exitText : this.options.enterText;\n\t\tthis._button.title = title;\n\t\tthis._button.setAttribute('aria-label', title);\n\t\tthis._button.setAttribute('aria-pressed', fullscreen);\n\t}\n\n\t/**\n\t * Registers this default feature on the map class, called by `MaplairMap` itself.\n\t * @internal\n\t * @param {typeof MaplairMap} MaplairMap\n\t */\n\tstatic register(MaplairMap) {\n\t\tMaplairMap.mergeOptions({\n\t\t\tfullscreenControl: false\n\t\t});\n\n\t\tMaplairMap.include(mapFullscreenMethods);\n\n\t\tMaplairMap.addInitHook(function () {\n\t\t\tthis.on('unload', function () {\n\t\t\t\tif (this._fullscreen === 'native') {\n\t\t\t\t\tDomEvent.off(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t\t\t\tdocument.exitFullscreen();\n\t\t\t\t}\n\t\t\t\tthis._container.classList.remove('maplair-fullscreen', 'maplair-pseudo-fullscreen');\n\t\t\t\tDomEvent.off(document, 'keydown', this._onFullscreenKeyDown, this);\n\t\t\t\tthis._fullscreen = false;\n\t\t\t});\n\n\t\t\tif (this.options.fullscreenControl) {\n\t\t\t\tthis.fullscreenControl = new FullscreenControl();\n\t\t\t\tthis.addControl(this.fullscreenControl);\n\t\t\t}\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,YAAY;AAClB,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCjB,MAAM,uBAAuB;;;;;;;;CAQ5B,mBAAmB;EAClB,MAAM,YAAY,KAAK;EAEvB,IAAI,KAAK,gBAAgB,UACxB,KAAK,eAAe,KAAK;OACnB,IAAI,KAAK,aACf,SAAS,eAAe;OAClB,IAAI,SAAS,qBAAqB,UAAU,mBAAmB;GACrE,GAAY,UAAU,oBAAoB,KAAK,qBAAqB,IAAI;GACxE,UAAU,kBAAkB,CAAC,CAAC,YAAY;IACzC,IAAa,UAAU,oBAAoB,KAAK,qBAAqB,IAAI;IACzE,KAAK,eAAe,QAAQ;GAC7B,CAAC;EACF,OACC,KAAK,eAAe,QAAQ;EAE7B,OAAO;CACR;;;;;;CAOA,eAAe;EACd,OAAO,CAAC,CAAC,KAAK;CACf;CAEA,sBAAsB;EACrB,MAAM,aAAa,SAAS,sBAAsB,KAAK;EACvD,IAAI,CAAC,YACJ,IAAa,UAAU,oBAAoB,KAAK,qBAAqB,IAAI;EAE1E,IAAI,eAAe,KAAK,aAAa,GACpC,KAAK,eAAe,cAAc,QAAQ;CAE5C;CAEA,qBAAqB,GAAG;EACvB,IAAI,EAAE,QAAQ,UACb,KAAK,eAAe,KAAK;CAE3B;CAGA,eAAe,MAAM;EACpB,MAAM,YAAY,KAAK;EACvB,KAAK,cAAc;EAEnB,UAAU,UAAU,OAAO,sBAAsB,CAAC,CAAC,IAAI;EACvD,UAAU,UAAU,OAAO,6BAA6B,SAAS,QAAQ;EACzE,IAAI,SAAS,UACZ,GAAY,UAAU,WAAW,KAAK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AAG,UAAU,WAAY;IAC7B,IAAI,KAAK,gBAAgB,UAAU;KAClC,IAAa,UAAU,oBAAoB,KAAK,qBAAqB,IAAI;KACzE,SAAS,eAAe;IACzB;IACA,KAAK,WAAW,UAAU,OAAO,sBAAsB,2BAA2B;IAClF,IAAa,UAAU,WAAW,KAAK,sBAAsB,IAAI;IACjE,KAAK,cAAc;GACpB,CAAC;GAED,IAAI,KAAK,QAAQ,mBAAmB;IACnC,KAAK,oBAAoB,IAAI,kBAAkB;IAC/C,KAAK,WAAW,KAAK,iBAAiB;GACvC;EACD,CAAC;CACF;AACD"}
|
|
@@ -40,6 +40,8 @@ import { I18n } from "../core/I18n.js";
|
|
|
40
40
|
* `maplair-control-layers-group-name` element, and each entry shows only its label.
|
|
41
41
|
* Events like `baselayerchange` still carry the full `name`. When combined with
|
|
42
42
|
* `sortLayers`, the entries are sorted first and grouped afterwards.
|
|
43
|
+
* @property {string} [title] The title of the toggle button and the accessible label
|
|
44
|
+
* of the layers list, the translation of `'Layers'` by default.
|
|
43
45
|
* @property {string|HTMLElement} [toggleContent] The content of the toggle button of a
|
|
44
46
|
* collapsed control instead of the layers icon: HTML (e.g. an icon or a character) or an
|
|
45
47
|
* element. String content is rendered as HTML; do not pass untrusted input.
|
|
@@ -124,6 +126,7 @@ var LayersControl = class LayersControl extends Control {
|
|
|
124
126
|
collapsed: true,
|
|
125
127
|
inline: false,
|
|
126
128
|
groupBy: void 0,
|
|
129
|
+
title: void 0,
|
|
127
130
|
toggleContent: void 0,
|
|
128
131
|
collapseDelay: 0,
|
|
129
132
|
position: "topright",
|
|
@@ -270,13 +273,16 @@ var LayersControl = class LayersControl extends Control {
|
|
|
270
273
|
else this._container.classList.remove("maplair-control-layers-expanded");
|
|
271
274
|
return this;
|
|
272
275
|
}
|
|
276
|
+
_getTitle() {
|
|
277
|
+
return this.options.title ?? I18n.translate("Layers");
|
|
278
|
+
}
|
|
273
279
|
_initLayout() {
|
|
274
280
|
const className = "maplair-control-layers", container = this._container = create("div", className), collapsed = this._isCollapsible();
|
|
275
281
|
if (this.options.inline) container.classList.add(`${className}-inline`);
|
|
276
282
|
disableClickPropagation(container);
|
|
277
283
|
disableScrollPropagation(container);
|
|
278
284
|
const section = this._section = create("fieldset", `${className}-list`);
|
|
279
|
-
section.setAttribute("aria-label",
|
|
285
|
+
section.setAttribute("aria-label", this._getTitle());
|
|
280
286
|
if (collapsed) {
|
|
281
287
|
this._map.on("click", this.collapse, this);
|
|
282
288
|
on(container, {
|
|
@@ -289,8 +295,8 @@ var LayersControl = class LayersControl extends Control {
|
|
|
289
295
|
if (!this.options.inline) {
|
|
290
296
|
const link = this._layersLink = create("button", `${className}-toggle`, container);
|
|
291
297
|
link.type = "button";
|
|
292
|
-
link.title =
|
|
293
|
-
link.setAttribute("aria-label",
|
|
298
|
+
link.title = this._getTitle();
|
|
299
|
+
link.setAttribute("aria-label", link.title);
|
|
294
300
|
const { toggleContent } = this.options;
|
|
295
301
|
if (typeof toggleContent === "string") link.innerHTML = toggleContent;
|
|
296
302
|
else if (toggleContent) link.replaceChildren(toggleContent);
|
|
@@ -308,7 +314,7 @@ var LayersControl = class LayersControl extends Control {
|
|
|
308
314
|
this._baseLayersList = create("div", `${className}-base`, section);
|
|
309
315
|
this._separator = create("div", `${className}-separator`, section);
|
|
310
316
|
this._overlaysList = create("div", `${className}-overlays`, section);
|
|
311
|
-
container.
|
|
317
|
+
container.append(section);
|
|
312
318
|
}
|
|
313
319
|
_addLayer(layer, name, overlay) {
|
|
314
320
|
if (this._map) layer.on("add remove", this._onLayerChange, this);
|
|
@@ -367,11 +373,10 @@ var LayersControl = class LayersControl extends Control {
|
|
|
367
373
|
const name = document.createElement("span");
|
|
368
374
|
name.innerHTML = ` ${group ? group.label : obj.name}`;
|
|
369
375
|
const holder = document.createElement("span");
|
|
370
|
-
label.
|
|
371
|
-
holder.
|
|
372
|
-
holder.appendChild(name);
|
|
376
|
+
label.append(holder);
|
|
377
|
+
holder.append(input, name);
|
|
373
378
|
const list = obj.overlay ? this._overlaysList : this._baseLayersList;
|
|
374
|
-
(group ? this._getGroupContainer(list, group.group) : list).
|
|
379
|
+
(group ? this._getGroupContainer(list, group.group) : list).append(label);
|
|
375
380
|
this._checkDisabledLayers();
|
|
376
381
|
return label;
|
|
377
382
|
}
|
|
@@ -412,7 +417,6 @@ var LayersControl = class LayersControl extends Control {
|
|
|
412
417
|
this._update();
|
|
413
418
|
break;
|
|
414
419
|
}
|
|
415
|
-
this._refocusOnMap(e);
|
|
416
420
|
}
|
|
417
421
|
_checkDisabledLayers() {
|
|
418
422
|
const inputs = this._layerControlInputs, zoom = this._map.getZoom();
|