maplair 4.0.0-alpha.1 → 4.0.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 +47 -3
- package/LICENSE +1 -1
- package/README.md +10 -7
- package/dist/esm/Maplair.js +52 -33
- package/dist/esm/Maplair.js.map +1 -1
- package/dist/esm/control/AttributionControl.js +76 -4
- package/dist/esm/control/AttributionControl.js.map +1 -1
- package/dist/esm/control/ButtonControl.js +221 -0
- package/dist/esm/control/ButtonControl.js.map +1 -0
- package/dist/esm/control/ContextMenu.js +173 -0
- package/dist/esm/control/ContextMenu.js.map +1 -0
- package/dist/esm/control/Control.js +118 -30
- package/dist/esm/control/Control.js.map +1 -1
- package/dist/esm/control/FullscreenControl.js +186 -0
- package/dist/esm/control/FullscreenControl.js.map +1 -0
- package/dist/esm/control/LayersControl.js +122 -3
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/LegendControl.js +230 -0
- package/dist/esm/control/LegendControl.js.map +1 -0
- package/dist/esm/control/MiniMapControl.js +182 -0
- package/dist/esm/control/MiniMapControl.js.map +1 -0
- package/dist/esm/control/RotateControl.js +104 -0
- package/dist/esm/control/RotateControl.js.map +1 -0
- package/dist/esm/control/ScaleControl.js +40 -0
- package/dist/esm/control/ScaleControl.js.map +1 -1
- package/dist/esm/control/SearchControl.js +442 -0
- package/dist/esm/control/SearchControl.js.map +1 -0
- package/dist/esm/control/SideBySideControl.js +208 -0
- package/dist/esm/control/SideBySideControl.js.map +1 -0
- package/dist/esm/control/TextControl.js +83 -0
- package/dist/esm/control/TextControl.js.map +1 -0
- package/dist/esm/control/ZoomControl.js +68 -5
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Browser.js +71 -2
- package/dist/esm/core/Browser.js.map +1 -1
- package/dist/esm/core/Class.js +193 -0
- package/dist/esm/core/Class.js.map +1 -1
- package/dist/esm/core/Events.js +231 -0
- package/dist/esm/core/Events.js.map +1 -1
- package/dist/esm/core/Handler.js +34 -0
- package/dist/esm/core/Handler.js.map +1 -1
- package/dist/esm/core/I18n.js +38 -0
- package/dist/esm/core/I18n.js.map +1 -1
- package/dist/esm/core/Util.js +62 -0
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.DoubleTap.js +14 -0
- package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -1
- package/dist/esm/dom/DomEvent.PointerEvents.js +25 -1
- package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
- package/dist/esm/dom/DomEvent.js +95 -0
- package/dist/esm/dom/DomEvent.js.map +1 -1
- package/dist/esm/dom/DomUtil.js +94 -0
- package/dist/esm/dom/DomUtil.js.map +1 -1
- package/dist/esm/dom/Draggable.js +55 -1
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/dom/PosAnimation.js +48 -0
- package/dist/esm/dom/PosAnimation.js.map +1 -1
- package/dist/esm/geo/LatLng.js +154 -3
- package/dist/esm/geo/LatLng.js.map +1 -1
- package/dist/esm/geo/LatLngBounds.js +148 -7
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geo/crs/CRS.js +102 -1
- package/dist/esm/geo/crs/CRS.js.map +1 -1
- package/dist/esm/geo/crs/EPSG3395.js +8 -1
- package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
- package/dist/esm/geo/crs/EPSG3857.js +14 -1
- package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
- package/dist/esm/geo/crs/EPSG4326.js +15 -1
- package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
- package/dist/esm/geo/crs/EarthCRS.js +24 -0
- package/dist/esm/geo/crs/EarthCRS.js.map +1 -1
- package/dist/esm/geo/crs/SimpleCRS.js +28 -1
- package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
- package/dist/esm/geo/projection/Projection.LonLat.js +10 -2
- package/dist/esm/geo/projection/Projection.LonLat.js.map +1 -1
- package/dist/esm/geo/projection/Projection.Mercator.js +7 -2
- package/dist/esm/geo/projection/Projection.Mercator.js.map +1 -1
- package/dist/esm/geo/projection/Projection.SphericalMercator.js +9 -2
- package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +1 -1
- package/dist/esm/geo/projection/index.js +1 -1
- package/dist/esm/geo/projection/index.js.map +1 -1
- package/dist/esm/geometry/Bounds.js +125 -7
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/LineUtil.js +55 -0
- package/dist/esm/geometry/LineUtil.js.map +1 -1
- package/dist/esm/geometry/Point.js +144 -5
- package/dist/esm/geometry/Point.js.map +1 -1
- package/dist/esm/geometry/PolyUtil.js +27 -1
- package/dist/esm/geometry/PolyUtil.js.map +1 -1
- package/dist/esm/geometry/Transformation.js +35 -0
- package/dist/esm/geometry/Transformation.js.map +1 -1
- package/dist/esm/layer/BlanketOverlay.js +54 -1
- package/dist/esm/layer/BlanketOverlay.js.map +1 -1
- package/dist/esm/layer/Classification.js +273 -0
- package/dist/esm/layer/Classification.js.map +1 -0
- package/dist/esm/layer/DivOverlay.js +219 -24
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/FeatureGroup.js +71 -0
- package/dist/esm/layer/FeatureGroup.js.map +1 -1
- package/dist/esm/layer/GeoJSON.Load.js +61 -0
- package/dist/esm/layer/GeoJSON.Load.js.map +1 -0
- package/dist/esm/layer/GeoJSON.js +219 -8
- package/dist/esm/layer/GeoJSON.js.map +1 -1
- package/dist/esm/layer/HeatLayer.js +198 -0
- package/dist/esm/layer/HeatLayer.js.map +1 -0
- package/dist/esm/layer/ImageOverlay.js +126 -1
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +273 -63
- package/dist/esm/layer/Layer.js.map +1 -1
- package/dist/esm/layer/LayerGroup.js +77 -0
- package/dist/esm/layer/LayerGroup.js.map +1 -1
- package/dist/esm/layer/Popup.js +333 -90
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/SVGOverlay.js +33 -0
- package/dist/esm/layer/SVGOverlay.js.map +1 -1
- package/dist/esm/layer/Tooltip.js +405 -149
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/VideoOverlay.js +49 -0
- package/dist/esm/layer/VideoOverlay.js.map +1 -1
- package/dist/esm/layer/marker/DefaultIcon.js +33 -0
- package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
- package/dist/esm/layer/marker/DivIcon.js +45 -1
- package/dist/esm/layer/marker/DivIcon.js.map +1 -1
- package/dist/esm/layer/marker/Icon.js +73 -2
- package/dist/esm/layer/marker/Icon.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js +29 -1
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Move.js +107 -0
- package/dist/esm/layer/marker/Marker.Move.js.map +1 -0
- package/dist/esm/layer/marker/Marker.Rotation.js +70 -0
- package/dist/esm/layer/marker/Marker.Rotation.js.map +1 -0
- package/dist/esm/layer/marker/Marker.js +157 -3
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/marker/SvgIcon.js +116 -0
- package/dist/esm/layer/marker/SvgIcon.js.map +1 -0
- package/dist/esm/layer/tile/GridLayer.js +254 -5
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +190 -8
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/tile/WMSTileLayer.js +114 -6
- package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +58 -0
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +30 -0
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +54 -1
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.DashAnimation.js +78 -0
- package/dist/esm/layer/vector/Path.DashAnimation.js.map +1 -0
- package/dist/esm/layer/vector/Path.ZoomStyles.js +77 -0
- package/dist/esm/layer/vector/Path.ZoomStyles.js.map +1 -0
- package/dist/esm/layer/vector/Path.js +74 -0
- package/dist/esm/layer/vector/Path.js.map +1 -1
- package/dist/esm/layer/vector/Polygon.js +67 -0
- package/dist/esm/layer/vector/Polygon.js.map +1 -1
- package/dist/esm/layer/vector/Polyline.Decorations.js +244 -0
- package/dist/esm/layer/vector/Polyline.Decorations.js.map +1 -0
- package/dist/esm/layer/vector/Polyline.js +91 -2
- package/dist/esm/layer/vector/Polyline.js.map +1 -1
- package/dist/esm/layer/vector/Rectangle.js +28 -0
- package/dist/esm/layer/vector/Rectangle.js.map +1 -1
- package/dist/esm/layer/vector/Renderer.getRenderer.js +52 -20
- package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
- package/dist/esm/layer/vector/Renderer.js +36 -0
- package/dist/esm/layer/vector/Renderer.js.map +1 -1
- package/dist/esm/layer/vector/SVG.js +49 -0
- package/dist/esm/layer/vector/SVG.js.map +1 -1
- package/dist/esm/map/Hash.js +237 -0
- package/dist/esm/map/Hash.js.map +1 -0
- package/dist/esm/map/Map.Rotation.js +500 -0
- package/dist/esm/map/Map.Rotation.js.map +1 -0
- package/dist/esm/map/Map.js +817 -33
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/MapSync.js +168 -0
- package/dist/esm/map/MapSync.js.map +1 -0
- package/dist/esm/map/handler/BoxZoomHandler.js +50 -1
- package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DisplaceHandler.js +349 -0
- package/dist/esm/map/handler/DisplaceHandler.js.map +1 -0
- package/dist/esm/map/handler/DoubleClickZoomHandler.js +44 -0
- package/dist/esm/map/handler/DoubleClickZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DragHandler.js +67 -5
- package/dist/esm/map/handler/DragHandler.js.map +1 -1
- package/dist/esm/map/handler/KeyboardHandler.js +92 -5
- package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +39 -0
- package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +161 -0
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/TapDragZoomHandler.js +150 -0
- package/dist/esm/map/handler/TapDragZoomHandler.js.map +1 -0
- package/dist/esm/map/handler/TapHoldHandler.js +35 -0
- package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
- package/dist/esm/package.js +1 -1
- package/dist/maplair-global-src.js +15438 -4749
- package/dist/maplair-global-src.js.map +1 -1
- package/dist/maplair-global.js +3 -3
- package/dist/maplair-global.js.map +1 -1
- package/dist/maplair-src.js +15421 -4750
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.css +629 -146
- package/dist/maplair.js +3 -3
- package/dist/maplair.js.map +1 -1
- package/i18n/cs.json +21 -1
- package/i18n/de.json +21 -1
- package/i18n/en.json +21 -1
- package/i18n/es.json +21 -1
- package/i18n/fr.json +21 -1
- package/i18n/hu.json +21 -1
- package/i18n/it.json +21 -1
- package/i18n/rm.json +21 -1
- package/i18n/sk.json +21 -1
- package/i18n/sl.json +21 -1
- package/package.json +84 -34
- package/src/Maplair.all.js +10 -0
- package/src/Maplair.js +4 -0
- package/src/control/AttributionControl.js +78 -31
- package/src/control/ButtonControl.js +248 -0
- package/src/control/ContextMenu.js +201 -0
- package/src/control/Control.js +132 -87
- package/src/control/FullscreenControl.js +227 -0
- package/src/control/LayersControl.js +92 -56
- package/src/control/LegendControl.js +273 -0
- package/src/control/MiniMapControl.js +198 -0
- package/src/control/RotateControl.js +122 -0
- package/src/control/ScaleControl.js +34 -25
- package/src/control/SearchControl.js +530 -0
- package/src/control/SideBySideControl.js +236 -0
- package/src/control/TextControl.js +91 -0
- package/src/control/ZoomControl.js +63 -35
- package/src/control/index.js +8 -0
- package/src/core/Browser.js +71 -36
- package/src/core/Class.js +193 -18
- package/src/core/Events.js +227 -35
- package/src/core/Handler.js +34 -24
- package/src/core/I18n.js +26 -19
- package/src/core/Util.js +63 -34
- package/src/dom/DomEvent.DoubleTap.js +15 -0
- package/src/dom/DomEvent.PointerEvents.js +30 -15
- package/src/dom/DomEvent.js +98 -62
- package/src/dom/DomUtil.js +102 -52
- package/src/dom/Draggable.js +49 -29
- package/src/dom/PosAnimation.js +27 -22
- package/src/geo/LatLng.js +150 -54
- package/src/geo/LatLngBounds.js +129 -69
- package/src/geo/crs/CRS.js +95 -56
- package/src/geo/crs/EPSG3395.js +5 -5
- package/src/geo/crs/EPSG3857.js +9 -6
- package/src/geo/crs/EPSG4326.js +11 -9
- package/src/geo/crs/EarthCRS.js +19 -9
- package/src/geo/crs/SimpleCRS.js +22 -5
- package/src/geo/projection/Projection.LonLat.js +7 -11
- package/src/geo/projection/Projection.Mercator.js +8 -8
- package/src/geo/projection/Projection.SphericalMercator.js +8 -9
- package/src/geo/projection/index.js +17 -15
- package/src/geometry/Bounds.js +108 -63
- package/src/geometry/LineUtil.js +56 -27
- package/src/geometry/Point.js +128 -69
- package/src/geometry/PolyUtil.js +22 -10
- package/src/geometry/Transformation.js +23 -18
- package/src/layer/BlanketOverlay.js +50 -51
- package/src/layer/Classification.js +302 -0
- package/src/layer/DivOverlay.js +247 -92
- package/src/layer/FeatureGroup.js +62 -26
- package/src/layer/GeoJSON.Load.js +109 -0
- package/src/layer/GeoJSON.js +220 -124
- package/src/layer/HeatLayer.js +231 -0
- package/src/layer/ImageOverlay.js +122 -62
- package/src/layer/Layer.js +311 -192
- package/src/layer/LayerGroup.js +66 -35
- package/src/layer/Popup.js +343 -270
- package/src/layer/SVGOverlay.js +22 -15
- package/src/layer/Tooltip.js +453 -298
- package/src/layer/VideoOverlay.js +41 -37
- package/src/layer/index.js +2 -0
- package/src/layer/marker/DefaultIcon.js +27 -11
- package/src/layer/marker/DivIcon.js +36 -20
- package/src/layer/marker/Icon.js +56 -61
- package/src/layer/marker/Marker.Drag.js +26 -29
- package/src/layer/marker/Marker.Move.js +153 -0
- package/src/layer/marker/Marker.Rotation.js +103 -0
- package/src/layer/marker/Marker.js +153 -94
- package/src/layer/marker/SvgIcon.js +122 -0
- package/src/layer/marker/index.js +1 -0
- package/src/layer/tile/GridLayer.js +224 -112
- package/src/layer/tile/TileLayer.js +204 -80
- package/src/layer/tile/WMSTileLayer.js +118 -44
- package/src/layer/vector/Canvas.js +44 -12
- package/src/layer/vector/Circle.js +24 -22
- package/src/layer/vector/CircleMarker.js +53 -22
- package/src/layer/vector/Path.DashAnimation.js +108 -0
- package/src/layer/vector/Path.ZoomStyles.js +103 -0
- package/src/layer/vector/Path.js +73 -57
- package/src/layer/vector/Polygon.js +32 -12
- package/src/layer/vector/Polyline.Decorations.js +299 -0
- package/src/layer/vector/Polyline.js +60 -37
- package/src/layer/vector/Rectangle.js +14 -14
- package/src/layer/vector/Renderer.getRenderer.js +65 -43
- package/src/layer/vector/Renderer.js +24 -9
- package/src/layer/vector/SVG.js +29 -19
- package/src/map/Hash.js +255 -0
- package/src/map/Map.Rotation.js +927 -0
- package/src/map/Map.js +866 -421
- package/src/map/MapSync.js +225 -0
- package/src/map/handler/BoxZoomHandler.js +50 -12
- package/src/map/handler/DisplaceHandler.js +416 -0
- package/src/map/handler/DoubleClickZoomHandler.js +43 -22
- package/src/map/handler/DragHandler.js +65 -40
- package/src/map/handler/KeyboardHandler.js +96 -18
- package/src/map/handler/PinchZoomHandler.js +39 -18
- package/src/map/handler/ScrollWheelZoomHandler.js +204 -21
- package/src/map/handler/TapDragZoomHandler.js +209 -0
- package/src/map/handler/TapHoldHandler.js +36 -17
- package/src/map/index.js +4 -0
- package/src/maplair.css +629 -146
package/CHANGELOG.md
CHANGED
|
@@ -3,11 +3,11 @@ Maplair Changelog
|
|
|
3
3
|
|
|
4
4
|
(all changes of Leaflet without author notice are by [@mourner](https://github.com/mourner))
|
|
5
5
|
|
|
6
|
-
## 4.0.0
|
|
6
|
+
## 4.0.0 (2026-10-19) 🍁 Maplair, a fork of Leaflet
|
|
7
7
|
|
|
8
|
-
The first
|
|
8
|
+
The first release of Maplair, a fork of Leaflet. It contains all changes since Leaflet 1.9.4: those of Leaflet 2.0.0-alpha and 2.0.0-alpha.1 (see below), the unreleased changes of Leaflet until the fork, and Maplair's own changes.
|
|
9
9
|
|
|
10
|
-
For an overview and a migration guide from Leaflet 1.9.4, see the blog post: https://maplair.org/2026/10/
|
|
10
|
+
For an overview and a migration guide from Leaflet 1.9.4, see the blog post: https://maplair.org/2026/10/19/maplair-4.0.0.html
|
|
11
11
|
|
|
12
12
|
### Maplair
|
|
13
13
|
|
|
@@ -22,6 +22,42 @@ For an overview and a migration guide from Leaflet 1.9.4, see the blog post: htt
|
|
|
22
22
|
* Publish one ES module per source file (`dist/esm`) and declare `sideEffects`, so that bundlers can drop unused features
|
|
23
23
|
* Bring back `L.noConflict()` in the global build `maplair-global.js`
|
|
24
24
|
* New logo, maple leaf marker icon with zigzag outline, and favicon
|
|
25
|
+
* Add `FullscreenControl` with `toggleFullscreen()`, `isFullscreen()` and the events `enterfullscreen`, `exitfullscreen` and `fullscreenchange`
|
|
26
|
+
* Add `SearchControl` with custom geocoders and `SearchControl.nominatim()`, complying with the Nominatim usage policy (`acceptUsagePolicy`)
|
|
27
|
+
* Add `ButtonControl`, `ButtonBarControl` and `TextControl`, and the Control option `order`
|
|
28
|
+
* Add `MiniMapControl` with an overview map
|
|
29
|
+
* Add `SideBySideControl` to compare layers with a divider
|
|
30
|
+
* Add `Classification` and `LegendControl` for classified features with a legend
|
|
31
|
+
* Add `ContextMenu` for menus on right click or long tap
|
|
32
|
+
* Add `Hash` to keep the view and the layers in the URL hash (also as geo URI) or in the query string
|
|
33
|
+
* Add `MapSync` to synchronize the views of several maps, with the options `oneWay` and `fit`
|
|
34
|
+
* Add `SvgIcon` for markers in any color with a glyph
|
|
35
|
+
* Add `HeatLayer` for heatmaps of points
|
|
36
|
+
* Add `DisplaceHandler` for the displacement of overlapping circle markers
|
|
37
|
+
* Add `TapDragZoomHandler` to zoom by double tapping and dragging up/down
|
|
38
|
+
* Add `LatLng.parse()` for coordinates in decimal degrees and geo URIs
|
|
39
|
+
* Add `LatLng.from()`, `Point.from()`, `Bounds.from()` and `LatLngBounds.from()`, which return instances as they are, unlike the constructors
|
|
40
|
+
* Map: add rotation with `bearing`, `setBearing()`, `pinchRotate` and `RotateControl` (optional module `maplair/map-rotation`)
|
|
41
|
+
* Marker: add the options `rotationAngle` and `rotationOrigin` (optional module `maplair/marker-rotation`)
|
|
42
|
+
* Animate markers along routes with `moveTo()`/`moveAlong()` (optional module `maplair/marker-movement`) and dashes along paths with `dashSpeed` (optional module `maplair/dash-animation`)
|
|
43
|
+
* Path: add `arrowheads` and `text` along lines (optional module `maplair/path-decorations`)
|
|
44
|
+
* GeoJSON: add `load()` and the option `url` (optional module `maplair/geojson-loading`)
|
|
45
|
+
* Path: add zoom-dependent `weight` and `radius` (optional module `maplair/zoom-styles`)
|
|
46
|
+
* Map: add the option `continuousZoom` for zooming through fractional zoom levels
|
|
47
|
+
* Map: add `setCrs()` to change the CRS at runtime
|
|
48
|
+
* Map: add the `idle` event, and `originalEvent` to view changes caused by the user
|
|
49
|
+
* Map: follow changes of the `devicePixelRatio` and fire `pixelratiochange`
|
|
50
|
+
* Map: keep the view of a hidden map
|
|
51
|
+
* ScrollWheelZoom: support touchpad gestures, and `scrollWheelZoom: 'trackpad'`
|
|
52
|
+
* DivOverlay: add the option `overflow` to let popups and tooltips extend beyond the map
|
|
53
|
+
* Tooltip: choose the auto direction by the available space
|
|
54
|
+
* Layer: add `setInteractive()`, `setAttribution()` and the option `attributionOrder`
|
|
55
|
+
* TileLayer: add the option `fetchOptions` to load tiles with `fetch()`, swap tiles without flickering on `setUrl()`, and add the option `placeholder`
|
|
56
|
+
* Add the option `pixelated` for nearest-neighbour scaling of tiles and image overlays
|
|
57
|
+
* WMSTileLayer: add `getLegendUrl()`
|
|
58
|
+
* Accessibility: map label (`ariaLabel`), keyboard shortcuts help (<kbd>?</kbd>), `<button>` elements in controls, popup focus
|
|
59
|
+
* Use CSS variables for the colors, borders, shadows, fonts and spacing
|
|
60
|
+
* Ship TypeScript type declarations (`dist/types/`)
|
|
25
61
|
|
|
26
62
|
#### ✨ Refactorings (⚠️ Breaking Changes)
|
|
27
63
|
|
|
@@ -42,11 +78,14 @@ For an overview and a migration guide from Leaflet 1.9.4, see the blog post: htt
|
|
|
42
78
|
* Popup: avoid a second forced layout when opening a popup
|
|
43
79
|
* Events: index listeners by function and context, and store them in Sets, so that adding and removing many layers isn't quadratic
|
|
44
80
|
* Skip unchanged transform and z-index style writes
|
|
81
|
+
* Don't copy points and bounds which are only read, e.g. in the projections and `Point#add()`
|
|
45
82
|
|
|
46
83
|
#### 🐞 Bugfixes
|
|
47
84
|
|
|
48
85
|
* DomEvent.stopPropagation: keep feature detection for DOM events of other windows (e.g. iframes)
|
|
49
86
|
* Fix the `Map.addInitHook` example in the controls tutorial
|
|
87
|
+
* TileLayer: with `detectRetina`, no longer request tiles beyond `maxNativeZoom`
|
|
88
|
+
* Release the pointer capture only if it is still active
|
|
50
89
|
|
|
51
90
|
#### 📝 Docs
|
|
52
91
|
|
|
@@ -55,12 +94,17 @@ For an overview and a migration guide from Leaflet 1.9.4, see the blog post: htt
|
|
|
55
94
|
* Credit major contributors in `CITATION.cff`, `package.json`, `README.md`, `LICENSE` and the website footer
|
|
56
95
|
* Document standard constructors, init hooks and translations
|
|
57
96
|
* Remove the Ukraine appeal, Leaflet's social media links and the "Trusted by the best" logos
|
|
97
|
+
* Replace Leafdoc with JSDoc, and generate the API reference from the type declarations
|
|
98
|
+
* Explain the name Maplair, mention tree-shaking and update the bundle sizes on the homepage
|
|
58
99
|
|
|
59
100
|
#### 🔧 Workflow
|
|
60
101
|
|
|
61
102
|
* Test, build, lint and run commit hooks with Vite+ (`vp test`, `vp pack`, `vp lint`, `vp staged`), replacing Vitest, Rollup, ESLint, husky and lint-staged
|
|
62
103
|
* Serve the debug pages with `vp dev`; remove bundlemon, `http-server` and `ssri`
|
|
63
104
|
* Upgrade `eslint-plugin-baseline-js` to 0.7.5, `@e18e/eslint-plugin` to 0.8.1 and Playwright to 1.64
|
|
105
|
+
* Migrate from npm to pnpm 12, upgrade Vite+ to 1.3.0 and Vitest to 5.0.5
|
|
106
|
+
* Check that optional features are dropped by tree-shaking unless imported (`pnpm run test:tree-shaking`)
|
|
107
|
+
* Type-check the type declarations and the debug pages (`pnpm run types:check`)
|
|
64
108
|
|
|
65
109
|
#### 🧪 Tests
|
|
66
110
|
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
<img width="600" src="src/images/logo.svg" alt="Maplair" />
|
|
2
2
|
|
|
3
|
-
Maplair is
|
|
3
|
+
Maplair is an open-source JavaScript library for **building powerful interactive maps**, a fork of [Leaflet](https://leafletjs.com), the leading library for this.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Since Maplair supports tree-shaking, your bundler shakes off the leaves you don't use 🍁
|
|
6
|
+
A map with just a tile layer weighs about 34 kB of gzipped JS plus 5.3 kB of gzipped CSS code.
|
|
7
|
+
With everything included, about 63 kB of gzipped JS, it has all the mapping [features][] most developers ever need.
|
|
6
8
|
|
|
7
9
|
Maplair is designed with *simplicity*, *performance* and *usability* in mind.
|
|
8
10
|
It works efficiently across all major desktop and mobile platforms out of the box,
|
|
9
|
-
|
|
10
|
-
It
|
|
11
|
+
using only web features that are [Baseline Widely available](https://web.dev/baseline).
|
|
12
|
+
It is easy to [extend][],
|
|
11
13
|
has a beautiful, easy to use and [well-documented][] API
|
|
12
14
|
and a simple, readable [source code][] that is a joy to [contribute][] to.
|
|
13
15
|
|
|
@@ -21,16 +23,17 @@ and push the limits of what's possible with online maps!
|
|
|
21
23
|
|
|
22
24
|
## Authors
|
|
23
25
|
|
|
24
|
-
Maplair is
|
|
26
|
+
Maplair is developed by [Simon Legner](https://github.com/simon04)
|
|
27
|
+
as a fork of [Leaflet](https://leafletjs.com), created in 2010 by [Volodymyr Agafonkin](https://agafonkin.com).
|
|
25
28
|
Major contributors include Iván Sánchez Ortega, Dave Leaver, Yohan Boniface, Jon Koops,
|
|
26
|
-
Florian Bischof, Per Liedman
|
|
29
|
+
Florian Bischof, Per Liedman and John Firebaugh,
|
|
27
30
|
along with [hundreds of other contributors][contributors].
|
|
28
31
|
|
|
29
32
|
[](https://github.com/maplair/maplair/actions/workflows/main.yml)
|
|
30
33
|
|
|
31
34
|
[contributors]: https://github.com/maplair/maplair/graphs/contributors
|
|
32
35
|
[features]: https://maplair.org/#features
|
|
33
|
-
[
|
|
36
|
+
[extend]: https://maplair.org/examples/extending-1-classes/
|
|
34
37
|
[well-documented]: https://maplair.org/reference.html "Maplair API reference"
|
|
35
38
|
[source code]: https://github.com/maplair/maplair "Maplair GitHub repository"
|
|
36
39
|
[hosted on GitHub]: https://github.com/maplair/maplair
|
package/dist/esm/Maplair.js
CHANGED
|
@@ -8,64 +8,83 @@ import { DomUtil_exports } from "./dom/DomUtil.js";
|
|
|
8
8
|
import { Control } from "./control/Control.js";
|
|
9
9
|
import { I18n } from "./core/I18n.js";
|
|
10
10
|
import { AttributionControl } from "./control/AttributionControl.js";
|
|
11
|
-
import {
|
|
12
|
-
import { ScaleControl } from "./control/ScaleControl.js";
|
|
13
|
-
import { ZoomControl } from "./control/ZoomControl.js";
|
|
11
|
+
import { ButtonBarControl, ButtonControl } from "./control/ButtonControl.js";
|
|
14
12
|
import { Evented } from "./core/Events.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
13
|
+
import { Layer } from "./layer/Layer.js";
|
|
14
|
+
import { ContextMenu } from "./control/ContextMenu.js";
|
|
15
|
+
import { FullscreenControl } from "./control/FullscreenControl.js";
|
|
16
|
+
import { LayersControl } from "./control/LayersControl.js";
|
|
17
|
+
import { Path } from "./layer/vector/Path.js";
|
|
18
18
|
import { Bounds } from "./geometry/Bounds.js";
|
|
19
|
-
import { Transformation } from "./geometry/Transformation.js";
|
|
20
19
|
import { LatLngBounds } from "./geo/LatLngBounds.js";
|
|
21
20
|
import { CRS } from "./geo/crs/CRS.js";
|
|
22
21
|
import { EarthCRS } from "./geo/crs/EarthCRS.js";
|
|
23
22
|
import { LatLng } from "./geo/LatLng.js";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import { EPSG3395 } from "./geo/crs/EPSG3395.js";
|
|
23
|
+
import { CircleMarker } from "./layer/vector/CircleMarker.js";
|
|
24
|
+
import { LegendControl } from "./control/LegendControl.js";
|
|
25
|
+
import { Transformation } from "./geometry/Transformation.js";
|
|
28
26
|
import { EPSG3857, EPSG900913 } from "./geo/crs/EPSG3857.js";
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import { Layer } from "./layer/Layer.js";
|
|
27
|
+
import { PosAnimation } from "./dom/PosAnimation.js";
|
|
28
|
+
import { ZoomControl } from "./control/ZoomControl.js";
|
|
32
29
|
import { LayerGroup } from "./layer/LayerGroup.js";
|
|
33
30
|
import { FeatureGroup } from "./layer/FeatureGroup.js";
|
|
34
|
-
import { Icon } from "./layer/marker/Icon.js";
|
|
35
|
-
import { DefaultIcon } from "./layer/marker/DefaultIcon.js";
|
|
36
|
-
import { Marker } from "./layer/marker/Marker.js";
|
|
37
|
-
import { Path } from "./layer/vector/Path.js";
|
|
38
|
-
import { CircleMarker } from "./layer/vector/CircleMarker.js";
|
|
39
|
-
import { Circle } from "./layer/vector/Circle.js";
|
|
40
|
-
import { Polyline } from "./layer/vector/Polyline.js";
|
|
41
|
-
import { Polygon } from "./layer/vector/Polygon.js";
|
|
42
|
-
import { GeoJSON } from "./layer/GeoJSON.js";
|
|
43
|
-
import { BlanketOverlay } from "./layer/BlanketOverlay.js";
|
|
44
|
-
import { ImageOverlay } from "./layer/ImageOverlay.js";
|
|
45
|
-
import { VideoOverlay } from "./layer/VideoOverlay.js";
|
|
46
|
-
import { SVGOverlay } from "./layer/SVGOverlay.js";
|
|
47
31
|
import { DivOverlay } from "./layer/DivOverlay.js";
|
|
48
32
|
import { Popup } from "./layer/Popup.js";
|
|
49
33
|
import { Tooltip } from "./layer/Tooltip.js";
|
|
50
|
-
import {
|
|
51
|
-
import { GridLayer } from "./layer/tile/GridLayer.js";
|
|
52
|
-
import { TileLayer } from "./layer/tile/TileLayer.js";
|
|
53
|
-
import { WMSTileLayer } from "./layer/tile/WMSTileLayer.js";
|
|
34
|
+
import { BlanketOverlay } from "./layer/BlanketOverlay.js";
|
|
54
35
|
import { Renderer } from "./layer/vector/Renderer.js";
|
|
55
36
|
import { Canvas } from "./layer/vector/Canvas.js";
|
|
56
37
|
import { SVG } from "./layer/vector/SVG.js";
|
|
57
|
-
import {
|
|
38
|
+
import { Handler } from "./core/Handler.js";
|
|
58
39
|
import { BoxZoomHandler } from "./map/handler/BoxZoomHandler.js";
|
|
59
40
|
import { DoubleClickZoomHandler } from "./map/handler/DoubleClickZoomHandler.js";
|
|
41
|
+
import { Draggable } from "./dom/Draggable.js";
|
|
60
42
|
import { DragHandler } from "./map/handler/DragHandler.js";
|
|
61
43
|
import { KeyboardHandler } from "./map/handler/KeyboardHandler.js";
|
|
62
44
|
import { PinchZoomHandler } from "./map/handler/PinchZoomHandler.js";
|
|
63
45
|
import { ScrollWheelZoomHandler } from "./map/handler/ScrollWheelZoomHandler.js";
|
|
64
46
|
import { TapHoldHandler } from "./map/handler/TapHoldHandler.js";
|
|
47
|
+
import { TapDragZoomHandler } from "./map/handler/TapDragZoomHandler.js";
|
|
65
48
|
import { Map, MaplairMap } from "./map/Map.js";
|
|
49
|
+
import { PolyUtil_exports } from "./geometry/PolyUtil.js";
|
|
50
|
+
import { LineUtil_exports } from "./geometry/LineUtil.js";
|
|
51
|
+
import { Polyline } from "./layer/vector/Polyline.js";
|
|
52
|
+
import { Polygon } from "./layer/vector/Polygon.js";
|
|
53
|
+
import { MiniMapControl } from "./control/MiniMapControl.js";
|
|
54
|
+
import { ScaleControl } from "./control/ScaleControl.js";
|
|
55
|
+
import { Icon } from "./layer/marker/Icon.js";
|
|
56
|
+
import { DefaultIcon } from "./layer/marker/DefaultIcon.js";
|
|
57
|
+
import { Marker } from "./layer/marker/Marker.js";
|
|
58
|
+
import { SearchControl } from "./control/SearchControl.js";
|
|
59
|
+
import { SideBySideControl } from "./control/SideBySideControl.js";
|
|
60
|
+
import { TextControl } from "./control/TextControl.js";
|
|
61
|
+
import { projection_exports } from "./geo/projection/index.js";
|
|
62
|
+
import { EPSG3395 } from "./geo/crs/EPSG3395.js";
|
|
63
|
+
import { EPSG4326 } from "./geo/crs/EPSG4326.js";
|
|
64
|
+
import { SimpleCRS } from "./geo/crs/SimpleCRS.js";
|
|
65
|
+
import { Circle } from "./layer/vector/Circle.js";
|
|
66
|
+
import { GeoJSON } from "./layer/GeoJSON.js";
|
|
67
|
+
import { Classification } from "./layer/Classification.js";
|
|
68
|
+
import { HeatLayer } from "./layer/HeatLayer.js";
|
|
69
|
+
import { ImageOverlay } from "./layer/ImageOverlay.js";
|
|
70
|
+
import { VideoOverlay } from "./layer/VideoOverlay.js";
|
|
71
|
+
import { SVGOverlay } from "./layer/SVGOverlay.js";
|
|
72
|
+
import { DivIcon } from "./layer/marker/DivIcon.js";
|
|
73
|
+
import { SvgIcon } from "./layer/marker/SvgIcon.js";
|
|
74
|
+
import { GridLayer } from "./layer/tile/GridLayer.js";
|
|
75
|
+
import { TileLayer } from "./layer/tile/TileLayer.js";
|
|
76
|
+
import { WMSTileLayer } from "./layer/tile/WMSTileLayer.js";
|
|
77
|
+
import { Rectangle } from "./layer/vector/Rectangle.js";
|
|
78
|
+
import { Hash } from "./map/Hash.js";
|
|
79
|
+
import { MapSync } from "./map/MapSync.js";
|
|
80
|
+
import { DisplaceHandler, displace } from "./map/handler/DisplaceHandler.js";
|
|
66
81
|
//#region src/Maplair.js
|
|
82
|
+
/**
|
|
83
|
+
* A constant that represents the Maplair version in use.
|
|
84
|
+
* @type {string}
|
|
85
|
+
*/
|
|
67
86
|
const version = version$1;
|
|
68
87
|
//#endregion
|
|
69
|
-
export { AttributionControl, BlanketOverlay, Bounds, BoxZoomHandler, Browser_default as Browser, CRS, Canvas, Circle, CircleMarker, Class, Control, DefaultIcon, DivIcon, DivOverlay, DomEvent_exports as DomEvent, DomUtil_exports as DomUtil, DoubleClickZoomHandler, DragHandler, Draggable, EPSG3395, EPSG3857, EPSG4326, EPSG900913, EarthCRS, Evented, FeatureGroup, GeoJSON, GridLayer, Handler, I18n, Icon, ImageOverlay, KeyboardHandler, LatLng, LatLngBounds, Layer, LayerGroup, LayersControl, LineUtil_exports as LineUtil, Map, MaplairMap, Marker, Path, PinchZoomHandler, Point, PolyUtil_exports as PolyUtil, Polygon, Polyline, Popup, PosAnimation, projection_exports as Projection, Rectangle, Renderer, SVG, SVGOverlay, ScaleControl, ScrollWheelZoomHandler, SimpleCRS, TapHoldHandler, TileLayer, Tooltip, Transformation, Util_exports as Util, VideoOverlay, WMSTileLayer, ZoomControl, version };
|
|
88
|
+
export { AttributionControl, BlanketOverlay, Bounds, BoxZoomHandler, Browser_default as Browser, ButtonBarControl, ButtonControl, CRS, Canvas, Circle, CircleMarker, Class, Classification, ContextMenu, Control, DefaultIcon, DisplaceHandler, DivIcon, DivOverlay, DomEvent_exports as DomEvent, DomUtil_exports as DomUtil, DoubleClickZoomHandler, DragHandler, Draggable, EPSG3395, EPSG3857, EPSG4326, EPSG900913, EarthCRS, Evented, FeatureGroup, FullscreenControl, GeoJSON, GridLayer, Handler, Hash, HeatLayer, I18n, Icon, ImageOverlay, KeyboardHandler, LatLng, LatLngBounds, Layer, LayerGroup, LayersControl, LegendControl, LineUtil_exports as LineUtil, Map, MapSync, MaplairMap, Marker, MiniMapControl, Path, PinchZoomHandler, Point, PolyUtil_exports as PolyUtil, Polygon, Polyline, Popup, PosAnimation, projection_exports as Projection, Rectangle, Renderer, SVG, SVGOverlay, ScaleControl, ScrollWheelZoomHandler, SearchControl, SideBySideControl, SimpleCRS, SvgIcon, TapDragZoomHandler, TapHoldHandler, TextControl, TileLayer, Tooltip, Transformation, Util_exports as Util, VideoOverlay, WMSTileLayer, ZoomControl, displace, version };
|
|
70
89
|
|
|
71
90
|
//# sourceMappingURL=Maplair.js.map
|
package/dist/esm/Maplair.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maplair.js","names":["pkg.version"],"sources":["../../src/Maplair.js"],"sourcesContent":["import pkg from '../package.json' with {type: 'json'};\nexport const version = pkg.version;\n\n// control\nexport * from './control/index.js';\n\n// core\nexport * from './core/index.js';\n\n// dom\nexport * from './dom/index.js';\n\n// geometry\nexport * from './geometry/index.js';\n\n// geo\nexport * from './geo/index.js';\n\n// layer\nexport * from './layer/index.js';\n\n// map\nexport * from './map/index.js';\n\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Maplair.js","names":["pkg.version"],"sources":["../../src/Maplair.js"],"sourcesContent":["import pkg from '../package.json' with {type: 'json'};\n/**\n * A constant that represents the Maplair version in use.\n * @type {string}\n */\nexport const version = pkg.version;\n\n// control\nexport * from './control/index.js';\n\n// core\nexport * from './core/index.js';\n\n// dom\nexport * from './dom/index.js';\n\n// geometry\nexport * from './geometry/index.js';\n\n// geo\nexport * from './geo/index.js';\n\n// layer\nexport * from './layer/index.js';\n\n// map\nexport * from './map/index.js';\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAa,UAAUA"}
|
|
@@ -3,7 +3,41 @@ import { create } from "../dom/DomUtil.js";
|
|
|
3
3
|
import { Control } from "./Control.js";
|
|
4
4
|
import { I18n } from "../core/I18n.js";
|
|
5
5
|
//#region src/control/AttributionControl.js
|
|
6
|
+
/** @import {ControlOptions} from './Control.js' */
|
|
7
|
+
/** @import {MaplairMap} from '../map/Map.js' */
|
|
6
8
|
const mapleLeaf = "<span aria-hidden=\"true\" class=\"maplair-attribution-leaf\">🍁</span>";
|
|
9
|
+
/**
|
|
10
|
+
* Options of `AttributionControl`.
|
|
11
|
+
* @typedef {object} AttributionControlOptions
|
|
12
|
+
* @property {string} [position='bottomright'] The position of the control (one of the
|
|
13
|
+
* map corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or
|
|
14
|
+
* `'bottomright'`.
|
|
15
|
+
* @property {string|false|null} [prefix=null] The HTML text shown before the
|
|
16
|
+
* attributions. Pass `false` to disable. By default (`null`), a link to Maplair.
|
|
17
|
+
* @extends ControlOptions
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Map options of `AttributionControl`.
|
|
21
|
+
* @typedef {object} AttributionControlMapOptions
|
|
22
|
+
* @lends MaplairMapOptions
|
|
23
|
+
* @property {boolean} [attributionControl=true] Whether a
|
|
24
|
+
* [attribution control](#control-attribution) is added to the map by default.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Properties of `MaplairMap` set by `AttributionControl`.
|
|
28
|
+
* @typedef {object} AttributionControlMapProperties
|
|
29
|
+
* @lends MaplairMap
|
|
30
|
+
* @property {AttributionControl} attributionControl The attribution control of the map,
|
|
31
|
+
* the default one (if the [`attributionControl` option](#map-attributioncontrol) was
|
|
32
|
+
* `true` when creating the map) or the one added last.
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* The attribution control allows you to display attribution data in a small text box
|
|
36
|
+
* on a map. It is put on the map by default unless you set its
|
|
37
|
+
* [`attributionControl` option](#map-attributioncontrol) to `false`, and it fetches
|
|
38
|
+
* attribution texts from layers with the [`getAttribution` method](#layer-getattribution)
|
|
39
|
+
* automatically.
|
|
40
|
+
*/
|
|
7
41
|
var AttributionControl = class AttributionControl extends Control {
|
|
8
42
|
static {
|
|
9
43
|
this.setDefaultOptions({
|
|
@@ -11,6 +45,10 @@ var AttributionControl = class AttributionControl extends Control {
|
|
|
11
45
|
prefix: null
|
|
12
46
|
});
|
|
13
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates an attribution control.
|
|
50
|
+
* @param {AttributionControlOptions} [options]
|
|
51
|
+
*/
|
|
14
52
|
constructor(options) {
|
|
15
53
|
super(options);
|
|
16
54
|
if (this.options.prefix === null) {
|
|
@@ -18,38 +56,67 @@ var AttributionControl = class AttributionControl extends Control {
|
|
|
18
56
|
this.options.prefix = `<a target="_blank" href="https://maplair.org" title="${title}">${mapleLeaf}Maplair</a>`;
|
|
19
57
|
}
|
|
20
58
|
this._attributions = {};
|
|
59
|
+
this._orders = {};
|
|
21
60
|
this.callInitHooks(AttributionControl);
|
|
22
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* @internal
|
|
64
|
+
* @param {MaplairMap} map
|
|
65
|
+
* @returns {HTMLElement}
|
|
66
|
+
*/
|
|
23
67
|
onAdd(map) {
|
|
24
68
|
map.attributionControl = this;
|
|
25
69
|
this._container = create("div", "maplair-control-attribution");
|
|
26
70
|
disableClickPropagation(this._container);
|
|
27
|
-
for (const layer of Object.values(map._layers)) if (layer.getAttribution) this.addAttribution(layer.getAttribution());
|
|
71
|
+
for (const layer of Object.values(map._layers)) if (layer.getAttribution) this.addAttribution(layer.getAttribution(), layer.options?.attributionOrder);
|
|
28
72
|
this._update();
|
|
29
73
|
map.on("layeradd", this._addAttribution, this);
|
|
30
74
|
return this._container;
|
|
31
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
* @param {MaplairMap} map
|
|
79
|
+
*/
|
|
32
80
|
onRemove(map) {
|
|
33
81
|
map.off("layeradd", this._addAttribution, this);
|
|
34
82
|
}
|
|
35
83
|
_addAttribution(ev) {
|
|
36
84
|
if (ev.layer.getAttribution) {
|
|
37
|
-
this.addAttribution(ev.layer.getAttribution());
|
|
85
|
+
this.addAttribution(ev.layer.getAttribution(), ev.layer.options?.attributionOrder);
|
|
38
86
|
ev.layer.once("remove", () => this.removeAttribution(ev.layer.getAttribution()));
|
|
39
87
|
}
|
|
40
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* The HTML text shown before the attributions. Pass `false` to disable.
|
|
91
|
+
* @param {string|false} prefix
|
|
92
|
+
* @returns {this}
|
|
93
|
+
*/
|
|
41
94
|
setPrefix(prefix) {
|
|
42
95
|
this.options.prefix = prefix;
|
|
43
96
|
this._update();
|
|
44
97
|
return this;
|
|
45
98
|
}
|
|
46
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Adds an attribution text (e.g. `'© OpenStreetMap contributors'`). Attributions
|
|
101
|
+
* are sorted by `order` (see the layer option `attributionOrder`), then by the order
|
|
102
|
+
* of adding.
|
|
103
|
+
* @param {string} text
|
|
104
|
+
* @param {number} [order=0]
|
|
105
|
+
* @returns {this}
|
|
106
|
+
*/
|
|
107
|
+
addAttribution(text, order = 0) {
|
|
47
108
|
if (!text) return this;
|
|
109
|
+
this._orders[text] = order;
|
|
48
110
|
if (!this._attributions[text]) this._attributions[text] = 0;
|
|
49
111
|
this._attributions[text]++;
|
|
50
112
|
this._update();
|
|
51
113
|
return this;
|
|
52
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Removes an attribution text.
|
|
117
|
+
* @param {string} text
|
|
118
|
+
* @returns {this}
|
|
119
|
+
*/
|
|
53
120
|
removeAttribution(text) {
|
|
54
121
|
if (!text) return this;
|
|
55
122
|
if (this._attributions[text]) {
|
|
@@ -60,12 +127,17 @@ var AttributionControl = class AttributionControl extends Control {
|
|
|
60
127
|
}
|
|
61
128
|
_update() {
|
|
62
129
|
if (!this._map) return;
|
|
63
|
-
const attribs = Object.keys(this._attributions).filter((i) => this._attributions[i]);
|
|
130
|
+
const attribs = Object.keys(this._attributions).filter((i) => this._attributions[i]).sort((a, b) => this._orders[a] - this._orders[b]);
|
|
64
131
|
const prefixAndAttribs = [];
|
|
65
132
|
if (this.options.prefix) prefixAndAttribs.push(this.options.prefix);
|
|
66
133
|
if (attribs.length) prefixAndAttribs.push(attribs.join(", "));
|
|
67
134
|
this._container.innerHTML = prefixAndAttribs.join(" <span aria-hidden=\"true\">|</span> ");
|
|
68
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Registers this default feature on the map class, called by `MaplairMap` itself.
|
|
138
|
+
* @internal
|
|
139
|
+
* @param {typeof MaplairMap} MaplairMap
|
|
140
|
+
*/
|
|
69
141
|
static register(MaplairMap) {
|
|
70
142
|
MaplairMap.mergeOptions({ attributionControl: true });
|
|
71
143
|
MaplairMap.addInitHook(function() {
|
|
@@ -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\nconst mapleLeaf = '<span aria-hidden=\"true\" class=\"maplair-attribution-leaf\">🍁</span>';\n\n
|
|
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 {\n\t\tthis.setDefaultOptions({\n\t\t\tposition: 'bottomright',\n\t\t\tprefix: null\n\t\t});\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\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// TODO ugly, refactor\n\t\tfor (const layer of Object.values(map._layers)) {\n\t\t\tif (layer.getAttribution) {\n\t\t\t\tthis.addAttribution(layer.getAttribution(), layer.options?.attributionOrder);\n\t\t\t}\n\t\t}\n\n\t\tthis._update();\n\n\t\tmap.on('layeradd', this._addAttribution, this);\n\n\t\treturn this._container;\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tmap.off('layeradd', this._addAttribution, this);\n\t}\n\n\t_addAttribution(ev) {\n\t\tif (ev.layer.getAttribution) {\n\t\t\tthis.addAttribution(ev.layer.getAttribution(), ev.layer.options?.attributionOrder);\n\t\t\tev.layer.once('remove', () => this.removeAttribution(ev.layer.getAttribution()));\n\t\t}\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\tif (!this._attributions[text]) {\n\t\t\tthis._attributions[text] = 0;\n\t\t}\n\t\tthis._attributions[text]++;\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;EACC,KAAK,kBAAkB;GACtB,UAAU;GACV,QAAQ;EACT,CAAC;CACF;;;;;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,CAAC;EACtB,KAAK,UAAU,CAAC;EAEhB,KAAK,cAAc,kBAAkB;CACtC;;;;;;CAOA,MAAM,KAAK;EACV,IAAI,qBAAqB;EACzB,KAAK,aAAaA,OAAe,OAAO,6BAA6B;EACrE,wBAAiC,KAAK,UAAU;EAGhD,KAAK,MAAM,SAAS,OAAO,OAAO,IAAI,OAAO,GAC5C,IAAI,MAAM,gBACT,KAAK,eAAe,MAAM,eAAe,GAAG,MAAM,SAAS,gBAAgB;EAI7E,KAAK,QAAQ;EAEb,IAAI,GAAG,YAAY,KAAK,iBAAiB,IAAI;EAE7C,OAAO,KAAK;CACb;;;;;CAMA,SAAS,KAAK;EACb,IAAI,IAAI,YAAY,KAAK,iBAAiB,IAAI;CAC/C;CAEA,gBAAgB,IAAI;EACnB,IAAI,GAAG,MAAM,gBAAgB;GAC5B,KAAK,eAAe,GAAG,MAAM,eAAe,GAAG,GAAG,MAAM,SAAS,gBAAgB;GACjF,GAAG,MAAM,KAAK,gBAAgB,KAAK,kBAAkB,GAAG,MAAM,eAAe,CAAC,CAAC;EAChF;CACD;;;;;;CAOA,UAAU,QAAQ;EACjB,KAAK,QAAQ,SAAS;EACtB,KAAK,QAAQ;EACb,OAAO;CACR;;;;;;;;;CAUA,eAAe,MAAM,QAAQ,GAAG;EAC/B,IAAI,CAAC,MAAQ,OAAO;EAEpB,KAAK,QAAQ,QAAQ;EACrB,IAAI,CAAC,KAAK,cAAc,OACvB,KAAK,cAAc,QAAQ;EAE5B,KAAK,cAAc,KAAK;EAExB,KAAK,QAAQ;EAEb,OAAO;CACR;;;;;;CAOA,kBAAkB,MAAM;EACvB,IAAI,CAAC,MAAQ,OAAO;EAEpB,IAAI,KAAK,cAAc,OAAO;GAC7B,KAAK,cAAc,KAAK;GACxB,KAAK,QAAQ;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"}
|