maplair 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/dist/esm/Maplair.js +14 -14
  3. package/dist/esm/control/AttributionControl.js +24 -14
  4. package/dist/esm/control/AttributionControl.js.map +1 -1
  5. package/dist/esm/control/ButtonControl.js +9 -11
  6. package/dist/esm/control/ButtonControl.js.map +1 -1
  7. package/dist/esm/control/ContextMenu.js +1 -3
  8. package/dist/esm/control/ContextMenu.js.map +1 -1
  9. package/dist/esm/control/Control.js +9 -16
  10. package/dist/esm/control/Control.js.map +1 -1
  11. package/dist/esm/control/FullscreenControl.js +5 -7
  12. package/dist/esm/control/FullscreenControl.js.map +1 -1
  13. package/dist/esm/control/LayersControl.js +144 -35
  14. package/dist/esm/control/LayersControl.js.map +1 -1
  15. package/dist/esm/control/LegendControl.js +7 -9
  16. package/dist/esm/control/LegendControl.js.map +1 -1
  17. package/dist/esm/control/MiniMapControl.js +14 -16
  18. package/dist/esm/control/MiniMapControl.js.map +1 -1
  19. package/dist/esm/control/RotateControl.js +1 -3
  20. package/dist/esm/control/RotateControl.js.map +1 -1
  21. package/dist/esm/control/ScaleControl.js +7 -9
  22. package/dist/esm/control/ScaleControl.js.map +1 -1
  23. package/dist/esm/control/SearchControl.js +99 -17
  24. package/dist/esm/control/SearchControl.js.map +1 -1
  25. package/dist/esm/control/SideBySideControl.js +1 -3
  26. package/dist/esm/control/SideBySideControl.js.map +1 -1
  27. package/dist/esm/control/TextControl.js +5 -7
  28. package/dist/esm/control/TextControl.js.map +1 -1
  29. package/dist/esm/control/TimeControl.js +408 -0
  30. package/dist/esm/control/TimeControl.js.map +1 -0
  31. package/dist/esm/control/ZoomControl.js +5 -7
  32. package/dist/esm/control/ZoomControl.js.map +1 -1
  33. package/dist/esm/core/Class.js +28 -37
  34. package/dist/esm/core/Class.js.map +1 -1
  35. package/dist/esm/core/Events.js +21 -8
  36. package/dist/esm/core/Events.js.map +1 -1
  37. package/dist/esm/core/Handler.js +13 -11
  38. package/dist/esm/core/Handler.js.map +1 -1
  39. package/dist/esm/core/Util.js +13 -1
  40. package/dist/esm/core/Util.js.map +1 -1
  41. package/dist/esm/dom/DomEvent.DoubleTap.js +25 -22
  42. package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -1
  43. package/dist/esm/dom/DomEvent.PointerEvents.js +2 -16
  44. package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
  45. package/dist/esm/dom/DomEvent.js +8 -42
  46. package/dist/esm/dom/DomEvent.js.map +1 -1
  47. package/dist/esm/dom/DomUtil.js +14 -68
  48. package/dist/esm/dom/DomUtil.js.map +1 -1
  49. package/dist/esm/dom/Draggable.js +17 -18
  50. package/dist/esm/dom/Draggable.js.map +1 -1
  51. package/dist/esm/dom/PosAnimation.js +3 -25
  52. package/dist/esm/dom/PosAnimation.js.map +1 -1
  53. package/dist/esm/geo/LatLng.js +15 -5
  54. package/dist/esm/geo/LatLng.js.map +1 -1
  55. package/dist/esm/geo/crs/EPSG3395.js +1 -1
  56. package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
  57. package/dist/esm/geo/crs/EPSG3857.js +1 -1
  58. package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
  59. package/dist/esm/geo/crs/EPSG4326.js +1 -1
  60. package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
  61. package/dist/esm/geo/crs/EarthCRS.js +2 -2
  62. package/dist/esm/geo/crs/EarthCRS.js.map +1 -1
  63. package/dist/esm/geo/crs/SimpleCRS.js +1 -1
  64. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
  65. package/dist/esm/geo/projection/Projection.LonLat.js +1 -1
  66. package/dist/esm/geo/projection/Projection.LonLat.js.map +1 -1
  67. package/dist/esm/geo/projection/Projection.Mercator.js +1 -1
  68. package/dist/esm/geo/projection/Projection.Mercator.js.map +1 -1
  69. package/dist/esm/geo/projection/Projection.SphericalMercator.js +1 -1
  70. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +1 -1
  71. package/dist/esm/geometry/LineUtil.js +36 -30
  72. package/dist/esm/geometry/LineUtil.js.map +1 -1
  73. package/dist/esm/geometry/PolyUtil.js +8 -27
  74. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  75. package/dist/esm/layer/BlanketOverlay.js +6 -8
  76. package/dist/esm/layer/BlanketOverlay.js.map +1 -1
  77. package/dist/esm/layer/DivOverlay.js +15 -20
  78. package/dist/esm/layer/DivOverlay.js.map +1 -1
  79. package/dist/esm/layer/GeoJSON.js +9 -145
  80. package/dist/esm/layer/GeoJSON.js.map +1 -1
  81. package/dist/esm/layer/GeoJSONUtil.js +75 -0
  82. package/dist/esm/layer/GeoJSONUtil.js.map +1 -0
  83. package/dist/esm/layer/HeatLayer.js +15 -17
  84. package/dist/esm/layer/HeatLayer.js.map +1 -1
  85. package/dist/esm/layer/ImageOverlay.js +20 -26
  86. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  87. package/dist/esm/layer/Layer.js +8 -10
  88. package/dist/esm/layer/Layer.js.map +1 -1
  89. package/dist/esm/layer/LayerGroup.js +51 -0
  90. package/dist/esm/layer/LayerGroup.js.map +1 -1
  91. package/dist/esm/layer/Popup.js +26 -42
  92. package/dist/esm/layer/Popup.js.map +1 -1
  93. package/dist/esm/layer/SVGOverlay.js +2 -5
  94. package/dist/esm/layer/SVGOverlay.js.map +1 -1
  95. package/dist/esm/layer/Tooltip.js +15 -17
  96. package/dist/esm/layer/Tooltip.js.map +1 -1
  97. package/dist/esm/layer/VideoOverlay.js +12 -15
  98. package/dist/esm/layer/VideoOverlay.js.map +1 -1
  99. package/dist/esm/layer/marker/DefaultIcon.js +15 -48
  100. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
  101. package/dist/esm/layer/marker/DivIcon.js +7 -9
  102. package/dist/esm/layer/marker/DivIcon.js.map +1 -1
  103. package/dist/esm/layer/marker/Icon.js +7 -10
  104. package/dist/esm/layer/marker/Icon.js.map +1 -1
  105. package/dist/esm/layer/marker/Marker.Drag.js +1 -1
  106. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  107. package/dist/esm/layer/marker/Marker.Move.js +1 -2
  108. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  109. package/dist/esm/layer/marker/Marker.js +61 -33
  110. package/dist/esm/layer/marker/Marker.js.map +1 -1
  111. package/dist/esm/layer/marker/MarkerClusterGroup.js +302 -0
  112. package/dist/esm/layer/marker/MarkerClusterGroup.js.map +1 -0
  113. package/dist/esm/layer/marker/SvgIcon.js +6 -8
  114. package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
  115. package/dist/esm/layer/tile/GridLayer.js +85 -97
  116. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  117. package/dist/esm/layer/tile/TileLayer.js +28 -36
  118. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  119. package/dist/esm/layer/tile/WMSTileLayer.js +28 -23
  120. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
  121. package/dist/esm/layer/vector/Canvas.js +1 -3
  122. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  123. package/dist/esm/layer/vector/Circle.js +2 -2
  124. package/dist/esm/layer/vector/Circle.js.map +1 -1
  125. package/dist/esm/layer/vector/CircleMarker.js +17 -7
  126. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  127. package/dist/esm/layer/vector/Path.DashAnimation.js +2 -3
  128. package/dist/esm/layer/vector/Path.DashAnimation.js.map +1 -1
  129. package/dist/esm/layer/vector/Path.js +27 -20
  130. package/dist/esm/layer/vector/Path.js.map +1 -1
  131. package/dist/esm/layer/vector/Polygon.js +20 -4
  132. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  133. package/dist/esm/layer/vector/Polyline.Decorations.js +2 -2
  134. package/dist/esm/layer/vector/Polyline.js +23 -7
  135. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  136. package/dist/esm/layer/vector/Renderer.getRenderer.js +14 -13
  137. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  138. package/dist/esm/layer/vector/SVG.js +5 -5
  139. package/dist/esm/layer/vector/SVG.js.map +1 -1
  140. package/dist/esm/map/Map.Rotation.js +10 -6
  141. package/dist/esm/map/Map.Rotation.js.map +1 -1
  142. package/dist/esm/map/Map.js +116 -110
  143. package/dist/esm/map/Map.js.map +1 -1
  144. package/dist/esm/map/handler/BoxZoomHandler.js +5 -7
  145. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  146. package/dist/esm/map/handler/DisplaceHandler.js +6 -8
  147. package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
  148. package/dist/esm/map/handler/DragHandler.js +19 -19
  149. package/dist/esm/map/handler/DragHandler.js.map +1 -1
  150. package/dist/esm/map/handler/KeyboardHandler.js +35 -35
  151. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  152. package/dist/esm/map/handler/PinchZoomHandler.js +12 -3
  153. package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
  154. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +3 -4
  155. package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
  156. package/dist/esm/map/handler/TapHoldHandler.js +12 -5
  157. package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
  158. package/dist/esm/package.js +1 -1
  159. package/dist/maplair-global-src.js +8009 -7369
  160. package/dist/maplair-global-src.js.map +1 -1
  161. package/dist/maplair-global.js +2 -2
  162. package/dist/maplair-global.js.map +1 -1
  163. package/dist/maplair-src.js +10040 -9381
  164. package/dist/maplair-src.js.map +1 -1
  165. package/dist/maplair.css +148 -98
  166. package/dist/maplair.js +2 -2
  167. package/dist/maplair.js.map +1 -1
  168. package/i18n/cs.json +6 -0
  169. package/i18n/de.json +6 -0
  170. package/i18n/en.json +6 -0
  171. package/i18n/es.json +6 -0
  172. package/i18n/fr.json +6 -0
  173. package/i18n/hu.json +6 -0
  174. package/i18n/it.json +6 -0
  175. package/i18n/rm.json +6 -0
  176. package/i18n/sk.json +6 -0
  177. package/i18n/sl.json +6 -0
  178. package/package.json +9 -11
  179. package/src/control/AttributionControl.js +25 -18
  180. package/src/control/ButtonControl.js +9 -11
  181. package/src/control/ContextMenu.js +3 -5
  182. package/src/control/Control.js +9 -19
  183. package/src/control/FullscreenControl.js +5 -7
  184. package/src/control/LayersControl.js +159 -36
  185. package/src/control/LegendControl.js +7 -9
  186. package/src/control/MiniMapControl.js +9 -11
  187. package/src/control/RotateControl.js +3 -5
  188. package/src/control/ScaleControl.js +7 -9
  189. package/src/control/SearchControl.js +102 -19
  190. package/src/control/SideBySideControl.js +3 -5
  191. package/src/control/TextControl.js +5 -7
  192. package/src/control/TimeControl.js +471 -0
  193. package/src/control/ZoomControl.js +5 -7
  194. package/src/control/index.js +1 -0
  195. package/src/core/Class.js +35 -34
  196. package/src/core/Events.js +22 -3
  197. package/src/core/Handler.js +14 -12
  198. package/src/core/Util.js +19 -1
  199. package/src/core/index.js +0 -1
  200. package/src/dom/DomEvent.DoubleTap.js +18 -10
  201. package/src/dom/DomEvent.PointerEvents.js +3 -26
  202. package/src/dom/DomEvent.js +8 -66
  203. package/src/dom/DomUtil.js +22 -78
  204. package/src/dom/Draggable.js +27 -22
  205. package/src/dom/PosAnimation.js +3 -25
  206. package/src/dom/index.js +0 -1
  207. package/src/geo/LatLng.js +20 -3
  208. package/src/geo/crs/EPSG3395.js +1 -1
  209. package/src/geo/crs/EPSG3857.js +1 -1
  210. package/src/geo/crs/EPSG4326.js +1 -1
  211. package/src/geo/crs/EarthCRS.js +2 -8
  212. package/src/geo/crs/SimpleCRS.js +1 -1
  213. package/src/geo/projection/Projection.LonLat.js +1 -1
  214. package/src/geo/projection/Projection.Mercator.js +1 -1
  215. package/src/geo/projection/Projection.SphericalMercator.js +1 -1
  216. package/src/geometry/LineUtil.js +47 -48
  217. package/src/geometry/PolyUtil.js +14 -43
  218. package/src/layer/BlanketOverlay.js +6 -10
  219. package/src/layer/DivOverlay.js +15 -26
  220. package/src/layer/GeoJSON.js +7 -205
  221. package/src/layer/GeoJSONUtil.js +85 -0
  222. package/src/layer/HeatLayer.js +9 -11
  223. package/src/layer/ImageOverlay.js +19 -30
  224. package/src/layer/Layer.js +8 -10
  225. package/src/layer/LayerGroup.js +71 -0
  226. package/src/layer/Popup.js +28 -43
  227. package/src/layer/SVGOverlay.js +1 -5
  228. package/src/layer/Tooltip.js +15 -19
  229. package/src/layer/VideoOverlay.js +12 -15
  230. package/src/layer/marker/DefaultIcon.js +15 -61
  231. package/src/layer/marker/DivIcon.js +9 -11
  232. package/src/layer/marker/Icon.js +7 -10
  233. package/src/layer/marker/Marker.Drag.js +1 -1
  234. package/src/layer/marker/Marker.Move.js +1 -2
  235. package/src/layer/marker/Marker.js +81 -39
  236. package/src/layer/marker/MarkerClusterGroup.js +370 -0
  237. package/src/layer/marker/SvgIcon.js +7 -9
  238. package/src/layer/marker/index.js +1 -0
  239. package/src/layer/tile/GridLayer.js +103 -133
  240. package/src/layer/tile/TileLayer.js +35 -43
  241. package/src/layer/tile/WMSTileLayer.js +26 -24
  242. package/src/layer/vector/Canvas.js +3 -5
  243. package/src/layer/vector/Circle.js +5 -2
  244. package/src/layer/vector/CircleMarker.js +17 -6
  245. package/src/layer/vector/Path.DashAnimation.js +1 -2
  246. package/src/layer/vector/Path.js +30 -21
  247. package/src/layer/vector/Polygon.js +28 -5
  248. package/src/layer/vector/Polyline.js +25 -6
  249. package/src/layer/vector/Renderer.getRenderer.js +17 -17
  250. package/src/layer/vector/SVG.js +5 -5
  251. package/src/map/Map.Rotation.js +12 -4
  252. package/src/map/Map.js +142 -133
  253. package/src/map/handler/BoxZoomHandler.js +9 -8
  254. package/src/map/handler/DisplaceHandler.js +6 -8
  255. package/src/map/handler/DragHandler.js +25 -28
  256. package/src/map/handler/KeyboardHandler.js +42 -48
  257. package/src/map/handler/PinchZoomHandler.js +16 -5
  258. package/src/map/handler/ScrollWheelZoomHandler.js +6 -4
  259. package/src/map/handler/TapHoldHandler.js +15 -4
  260. package/src/map/index.js +1 -1
  261. package/src/maplair.css +148 -98
  262. package/dist/esm/core/Browser.js +0 -100
  263. package/dist/esm/core/Browser.js.map +0 -1
  264. package/dist/images/layers.svg +0 -1
  265. package/dist/images/marker-icon.svg +0 -1
  266. package/dist/images/marker-shadow.svg +0 -1
  267. package/src/core/Browser.js +0 -110
  268. package/src/images/layers.svg +0 -1
  269. package/src/images/marker-icon.svg +0 -1
  270. package/src/images/marker-shadow.svg +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,124 @@ Maplair Changelog
3
3
 
4
4
  (all changes of Leaflet without author notice are by [@mourner](https://github.com/mourner))
5
5
 
6
+ ## 4.1.0 (2026-10-28)
7
+
8
+ ⚠️ Despite the minor version, this release contains breaking changes ported from Leaflet, see the refactorings below.
9
+
10
+ ### Maplair
11
+
12
+ (changes without author notice are by [@simon04](https://github.com/simon04))
13
+
14
+ #### ❇️ New Features
15
+
16
+ * LayersControl: add the options `inline`, `groupBy` and `toggleContent`, the methods `getLayers()` and `selectLayer()`, and `originalEvent` to `baselayerchange`, `overlayadd` and `overlayremove` for changes by the user
17
+ * SearchControl: new static method `SearchControl.layers()` to search the layers of a layer group (e.g. GeoJSON features) by a property or a label function, the results contain the found `layer`
18
+ * Add `MarkerClusterGroup` clustering nearby markers, with zooming to and spiderfying clusters on click
19
+ * Add `TimeControl` to step through or play the times of time-dependent layers, e.g. a WMS with a `TIME` dimension, with ISO 8601 intervals and periods
20
+ * WMSTileLayer: swap the tiles without flickering on `setParams()`
21
+ * SearchControl: the option `marker` accepts a function returning the layer to show at the selected result, new options `clearOnMapClick` and `noResultsText`
22
+ * Export `LeafletMap` as an alias of `MaplairMap`, like `Map`, for compatibility with code written for Leaflet 2
23
+
24
+ ### Leaflet, since the fork
25
+
26
+ Ported from Leaflet (changes without author notice are by [@mourner](https://github.com/mourner))
27
+
28
+ #### ✨ Refactorings (⚠️ Breaking Changes)
29
+
30
+ * Replace static blocks with `static defaultOptions`; `setDefaultOptions()` is a deprecated alias of `mergeOptions()` in https://github.com/Leaflet/Leaflet/pull/10432
31
+ * Throw on classes still defining `initialize()` (from https://github.com/Leaflet/Leaflet/pull/10433)
32
+ * Drop the `preferCanvas` option, use `renderer: new Canvas()`; custom panes get a renderer of the same kind as the map's in https://github.com/Leaflet/Leaflet/pull/10438
33
+ * Move `toGeoJSON()` into each layer class, available without importing `GeoJSON` in https://github.com/Leaflet/Leaflet/pull/10439
34
+ * Make `PosAnimation` internal in https://github.com/Leaflet/Leaflet/pull/10446
35
+ * Remove browser sniffing and the `Browser` namespace (`Browser.reducedMotion` is `DomUtil.reducedMotion`), enable `tapHold` everywhere in https://github.com/Leaflet/Leaflet/pull/10447
36
+ * Inline the built-in SVG icons, dropping the option `imagePath` of `DefaultIcon` and the images in `dist` in https://github.com/Leaflet/Leaflet/pull/10450
37
+ * Remove `DomUtil.preventOutline()` and `restoreOutline()`, `Draggable` takes options as its third argument in https://github.com/Leaflet/Leaflet/pull/10455
38
+ * Remove dead legacy DOM event and CSS code, including `DomEvent.getPropagationPath()` and `--maplair-size-control-touch` (the touch styles are the default) in https://github.com/Leaflet/Leaflet/pull/10431
39
+ * Remove `DomEvent.PointerEvents.cleanupPointers()` in https://github.com/Leaflet/Leaflet/commit/cfae2c15eb66833f9260820e2d692e10f4a6c263
40
+ * Fix remaining side effects and import cycles in https://github.com/Leaflet/Leaflet/pull/10442
41
+ * Simplify some core code for a smaller bundle in https://github.com/Leaflet/Leaflet/pull/10452
42
+ * Simplify the center calculation of polylines and polygons in https://github.com/Leaflet/Leaflet/pull/10451
43
+ * Simplify `flyTo()` in https://github.com/Leaflet/Leaflet/commit/3dc172b57175994f152d6fe512b0131869ee30cb
44
+ * The global build has plain, patchable namespaces (from https://github.com/Leaflet/Leaflet/pull/10443)
45
+ * Zoom by the typed character for non-US keyboard layouts, `KeyboardHandler.keyCodes` is replaced by `KeyboardHandler.keys`, `aria-keyshortcuts` is opt-in with the new map option `ariaKeyShortcuts` (with [@babielmam](https://github.com/babielmam)) in https://github.com/Leaflet/Leaflet/pull/10469
46
+ * Stop restyling the whole page on map and marker drags, remove `DomUtil.disableTextSelection()` and `enableTextSelection()` in https://github.com/Leaflet/Leaflet/pull/10470
47
+ * Respect reduced motion through options instead of overrides, replacing `DomUtil.reducedMotion`, in https://github.com/Leaflet/Leaflet/pull/10466, and reduce rather than remove motion in https://github.com/Leaflet/Leaflet/pull/10479; the default `inertiaMaxSpeed` is 1400
48
+ * Improve the keyboard accessibility of markers (Enter and Space click interactive markers), remove the `keypress` event in https://github.com/Leaflet/Leaflet/pull/10473
49
+ * Export `Map` as an alias of `MaplairMap` more idiomatically in https://github.com/Leaflet/Leaflet/commit/4bc93b605f043cb2ff6bbe0615c03109fd0b6723
50
+
51
+ #### 🐞 Bugfixes
52
+
53
+ * Load tiles during panning unless reduced motion is preferred in https://github.com/Leaflet/Leaflet/commit/2550ebfa7513ed65e8b6febb4be8d68992b847ec
54
+ * Fix the http to https upgrade of OSM URLs in https://github.com/Leaflet/Leaflet/pull/10444
55
+ * Read the Leaflet 1 option `bubblingMouseEvents`, log removed `mouse*` events once in https://github.com/Leaflet/Leaflet/commit/2cac72a01fe1b43eb158156bf10158877a9be716
56
+ * Fix seams between tiles when dragging the map in https://github.com/Leaflet/Leaflet/pull/10445
57
+ * Fix Popup autoPan crash when stopping the pan removes the popup by [@DeanNorman](https://github.com/DeanNorman) in https://github.com/Leaflet/Leaflet/pull/10416
58
+ * Wrap non-square tile columns by the tile width, not the tile height by [@Jaybhade](https://github.com/Jaybhade) in https://github.com/Leaflet/Leaflet/pull/10333
59
+ * Fix infinite loop in `clipSegment()` with fractional clip bounds by [@spokodev](https://github.com/spokodev) in https://github.com/Leaflet/Leaflet/pull/10284
60
+ * Keep GridLayer tiles during worldCopyJump by [@leijurv](https://github.com/leijurv) in https://github.com/Leaflet/Leaflet/pull/10353 and https://github.com/Leaflet/Leaflet/commit/39d5b54331dc96e8ac30de2c610e28003bb21901
61
+ * Fix map jumping when dragging after pointerdown during inertia by [@Yahiro025](https://github.com/Yahiro025) in https://github.com/Leaflet/Leaflet/pull/10386
62
+ * Fix small Circle radii coming out as ellipses by [@haranishi](https://github.com/haranishi) in https://github.com/Leaflet/Leaflet/pull/10454
63
+ * Fix worldCopyJump throwing with an infinite CRS by [@haranishi](https://github.com/haranishi) in https://github.com/Leaflet/Leaflet/pull/10453
64
+ * Fix attribution control keeping the credits of its initial layers by [@haranishi](https://github.com/haranishi) in https://github.com/Leaflet/Leaflet/pull/10458, and make the attribution handling more robust in https://github.com/Leaflet/Leaflet/commit/6de8f8a9ec5702642d8bfff2eb59e448668df588
65
+ * Keep dragging switched off when a marker is removed and added again by [@haranishi](https://github.com/haranishi) in https://github.com/Leaflet/Leaflet/pull/10456
66
+ * Keep dragging a marker when its icon is changed by [@haranishi](https://github.com/haranishi) in https://github.com/Leaflet/Leaflet/pull/10457
67
+ * Fix DOM API misuse in https://github.com/Leaflet/Leaflet/pull/10460
68
+ * Fix tiles, markers and tooltips being selectable in Safari in https://github.com/Leaflet/Leaflet/pull/10462
69
+ * Fix a small `flyTo()` glitch in https://github.com/Leaflet/Leaflet/commit/3a809320007a3cad0efd920c8216bdb11ff1988a
70
+ * Fix hover breaking on `bringToFront()` in Chrome in https://github.com/Leaflet/Leaflet/commit/0609413eb7f5d12e8dc59a15fd3058657c3897a0
71
+ * Fix page scrolling on map refocus in https://github.com/Leaflet/Leaflet/commit/dd71a7849294265140d5d32aebbb8e1ddc7de199
72
+ * Fix an edge case with a tiny box zoom in https://github.com/Leaflet/Leaflet/commit/a82d3832c9b803fdc74029ed6093c2dd924a64f6
73
+ * Fix VideoOverlay throwing when created from a video element by [@Enesuygurs](https://github.com/Enesuygurs) in https://github.com/Leaflet/Leaflet/pull/10464
74
+ * Fix the global build throwing without `navigator` (from https://github.com/Leaflet/Leaflet/pull/10443)
75
+ * Fix usability on maps with `zoomAnimation` disabled in https://github.com/Leaflet/Leaflet/pull/10465
76
+ * Avoid relayouts on wheel zoom and pinch zoom in https://github.com/Leaflet/Leaflet/commit/9c0cef035e695650964786af63f3222f42f15f1f and https://github.com/Leaflet/Leaflet/commit/0f8f2fb008900f05b5b614b6e76a2ea7a426eb9f
77
+ * Fix `toGeoJSON()` dropping MultiPoint members of a GeometryCollection by [@nk-batman21](https://github.com/nk-batman21) in https://github.com/Leaflet/Leaflet/pull/10468
78
+ * Fix WMSTileLayer throwing on relative service URLs by [@nk-batman21](https://github.com/nk-batman21) in https://github.com/Leaflet/Leaflet/pull/10474
79
+ * Fix VideoOverlay ignoring `keepAspectRatio: false` in Firefox and Safari by [@nk-batman21](https://github.com/nk-batman21) in https://github.com/Leaflet/Leaflet/pull/10475
80
+ * Limit the destination of `flyTo()` to `maxBounds` by [@Don-Yin](https://github.com/Don-Yin) in https://github.com/Leaflet/Leaflet/pull/10477
81
+ * Fix a drag sometimes getting stuck after a quick pan outside the window in https://github.com/Leaflet/Leaflet/commit/cdff2a590004f604db7ef44f69b0ea02073cfea6
82
+ * Fix the tile zoom of GridLayer `redraw()` on a fractional map zoom (with [@adamnson](https://github.com/adamnson)) in https://github.com/Leaflet/Leaflet/commit/199eae85af7534f17ab119f4c830c500b6b9e49f
83
+ * Fix light seams between tiles during a zoom animation in Chrome, tiles fade in with the Web Animations API in https://github.com/Leaflet/Leaflet/pull/10471
84
+ * Return the layer from `closeTooltip()`, fix `isTooltipOpen()` throwing without a bound tooltip in https://github.com/Leaflet/Leaflet/commit/7f89a0681e6e33e25edfefb1586cae7b42948e35
85
+
86
+ #### 📝 Docs
87
+
88
+ * Update leaflet.sidepanel plugin links by [@m-altaifi](https://github.com/m-altaifi) in https://github.com/Leaflet/Leaflet/pull/10389
89
+ * Fix accuracy radius in the mobile geolocation example by [@xvodddwannaG](https://github.com/xvodddwannaG) in https://github.com/Leaflet/Leaflet/pull/10332
90
+ * Evergreen language on zoom-levels and handlers tutorials by [@SatvikMishra08](https://github.com/SatvikMishra08) in https://github.com/Leaflet/Leaflet/pull/10398
91
+ * Note that `setStyle()` does not update `className` by [@lux-in-tenebris-lucet](https://github.com/lux-in-tenebris-lucet) in https://github.com/Leaflet/Leaflet/pull/10327
92
+ * Fix missing front matter delimiter in city-autocomplete-usa.md by [@slbarriosdev](https://github.com/slbarriosdev) in https://github.com/Leaflet/Leaflet/pull/10258
93
+ * Fix spelling errors in Joomla plugin documentation by [@Fran-cruz](https://github.com/Fran-cruz) in https://github.com/Leaflet/Leaflet/pull/10298
94
+ * Remove `!important` in the CSS of the website in https://github.com/Leaflet/Leaflet/commit/e2036455408de5b6dc1e6c60f10888c1f34af49b
95
+ * Clarify the stacking of layers within a pane by [@VisakanM-bit](https://github.com/VisakanM-bit) in https://github.com/Leaflet/Leaflet/pull/10297
96
+ * Add the Leaflet WebGL Markers plugin by [@tang-tc](https://github.com/tang-tc) in https://github.com/Leaflet/Leaflet/pull/10349
97
+ * Add the PartiallyEditablePolyline plugin by [@hiroaki](https://github.com/hiroaki) in https://github.com/Leaflet/Leaflet/pull/10395
98
+ * Add the @s57-parser/leaflet plugin by [@devladpopov](https://github.com/devladpopov) in https://github.com/Leaflet/Leaflet/pull/10394
99
+ * Add the leaflet-daynight plugin by [@LoganD900](https://github.com/LoganD900) in https://github.com/Leaflet/Leaflet/pull/10388
100
+ * Add the Leaflet.GridLayer.Relief plugin by [@glandais](https://github.com/glandais) in https://github.com/Leaflet/Leaflet/pull/10348
101
+ * Update the maptiler-geocoding-control plugin for v2 by [@katemihalikova](https://github.com/katemihalikova) in https://github.com/Leaflet/Leaflet/pull/10195
102
+ * Add the Leaflet.WorldWrap plugin by [@EricDalnas](https://github.com/EricDalnas) in https://github.com/Leaflet/Leaflet/pull/10188
103
+ * Add the leaflet-draggable-tooltips plugin by [@georiv](https://github.com/georiv) in https://github.com/Leaflet/Leaflet/pull/10243 and https://github.com/Leaflet/Leaflet/pull/10481
104
+ * Add the leaflet-india-boundary plugin by [@lux-in-tenebris-lucet](https://github.com/lux-in-tenebris-lucet) in https://github.com/Leaflet/Leaflet/pull/10328
105
+ * Add the leaflet-floating-measure plugin by [@ringraham](https://github.com/ringraham) in https://github.com/Leaflet/Leaflet/pull/10345
106
+
107
+ #### 🔧 Workflow
108
+
109
+ * Consolidate CI jobs in https://github.com/Leaflet/Leaflet/commit/43f310b53c2632699f6a6a3679d14a3f717aacf8
110
+ * Report the bundle size in a tiny CI job in https://github.com/Leaflet/Leaflet/pull/10430
111
+ * Check the global build and the self-contained CSS in CI (from https://github.com/Leaflet/Leaflet/pull/10443)
112
+ * Name the test jobs, publish the development snapshot with `gh` in https://github.com/Leaflet/Leaflet/commit/40c052b0d0fe1d7159f55d87089f24e2ed422e0d and https://github.com/Leaflet/Leaflet/commit/ac7b690b1b5d727c219fd4ef6c347b4f38fe26dd
113
+ * Remove the stale AMD debug page in https://github.com/Leaflet/Leaflet/commit/9adfc0ac0d3a62a5b4af292f637fcb15c5e534dd
114
+ * Remove CSS fallbacks and leftovers, explain the `!important` in https://github.com/Leaflet/Leaflet/pull/10462
115
+ * Build the website with a small Node script instead of Jekyll in https://github.com/Leaflet/Leaflet/pull/10484
116
+
117
+ #### 🧪 Tests
118
+
119
+ * Simplify, improve and speed up the test setup in https://github.com/Leaflet/Leaflet/pull/10463
120
+ * Add specs of the layer lifecycle and of extending layers (from https://github.com/Leaflet/Leaflet/pull/10441)
121
+ * Speed up a slow `flyTo()` test and fix a flaky DragHandler test in https://github.com/Leaflet/Leaflet/commit/051c4a65082dd3259858f9000189faf7d351522a and https://github.com/Leaflet/Leaflet/commit/a8a1904c390540735d7906f152e628971df0e0b6
122
+ * Replace prosthetic-hand with a small built-in `Finger` helper in https://github.com/Leaflet/Leaflet/pull/10476
123
+
6
124
  ## 4.0.0 (2026-10-19) 🍁 Maplair, a fork of Leaflet
7
125
 
8
126
  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.
@@ -2,7 +2,6 @@ import { version as version$1 } from "./package.js";
2
2
  import { Util_exports } from "./core/Util.js";
3
3
  import { Class } from "./core/Class.js";
4
4
  import { Point } from "./geometry/Point.js";
5
- import Browser_default from "./core/Browser.js";
6
5
  import { DomEvent_exports } from "./dom/DomEvent.js";
7
6
  import { DomUtil_exports } from "./dom/DomUtil.js";
8
7
  import { Control } from "./control/Control.js";
@@ -14,27 +13,26 @@ import { Layer } from "./layer/Layer.js";
14
13
  import { ContextMenu } from "./control/ContextMenu.js";
15
14
  import { FullscreenControl } from "./control/FullscreenControl.js";
16
15
  import { LayersControl } from "./control/LayersControl.js";
17
- import { Path } from "./layer/vector/Path.js";
18
16
  import { Bounds } from "./geometry/Bounds.js";
17
+ import { BlanketOverlay } from "./layer/BlanketOverlay.js";
18
+ import { Renderer } from "./layer/vector/Renderer.js";
19
+ import { SVG } from "./layer/vector/SVG.js";
20
+ import { Path } from "./layer/vector/Path.js";
19
21
  import { LatLngBounds } from "./geo/LatLngBounds.js";
20
- import { CRS } from "./geo/crs/CRS.js";
21
- import { EarthCRS } from "./geo/crs/EarthCRS.js";
22
22
  import { LatLng } from "./geo/LatLng.js";
23
+ import { LineUtil_exports } from "./geometry/LineUtil.js";
23
24
  import { CircleMarker } from "./layer/vector/CircleMarker.js";
24
25
  import { LegendControl } from "./control/LegendControl.js";
26
+ import { CRS } from "./geo/crs/CRS.js";
27
+ import { EarthCRS } from "./geo/crs/EarthCRS.js";
25
28
  import { Transformation } from "./geometry/Transformation.js";
26
29
  import { EPSG3857, EPSG900913 } from "./geo/crs/EPSG3857.js";
27
- import { PosAnimation } from "./dom/PosAnimation.js";
28
30
  import { ZoomControl } from "./control/ZoomControl.js";
29
31
  import { LayerGroup } from "./layer/LayerGroup.js";
30
32
  import { FeatureGroup } from "./layer/FeatureGroup.js";
31
33
  import { DivOverlay } from "./layer/DivOverlay.js";
32
34
  import { Popup } from "./layer/Popup.js";
33
35
  import { Tooltip } from "./layer/Tooltip.js";
34
- import { BlanketOverlay } from "./layer/BlanketOverlay.js";
35
- import { Renderer } from "./layer/vector/Renderer.js";
36
- import { Canvas } from "./layer/vector/Canvas.js";
37
- import { SVG } from "./layer/vector/SVG.js";
38
36
  import { Handler } from "./core/Handler.js";
39
37
  import { BoxZoomHandler } from "./map/handler/BoxZoomHandler.js";
40
38
  import { DoubleClickZoomHandler } from "./map/handler/DoubleClickZoomHandler.js";
@@ -45,10 +43,9 @@ import { PinchZoomHandler } from "./map/handler/PinchZoomHandler.js";
45
43
  import { ScrollWheelZoomHandler } from "./map/handler/ScrollWheelZoomHandler.js";
46
44
  import { TapHoldHandler } from "./map/handler/TapHoldHandler.js";
47
45
  import { TapDragZoomHandler } from "./map/handler/TapDragZoomHandler.js";
48
- import { Map, MaplairMap } from "./map/Map.js";
49
- import { PolyUtil_exports } from "./geometry/PolyUtil.js";
50
- import { LineUtil_exports } from "./geometry/LineUtil.js";
46
+ import { LeafletMap as MaplairMap } from "./map/Map.js";
51
47
  import { Polyline } from "./layer/vector/Polyline.js";
48
+ import { PolyUtil_exports } from "./geometry/PolyUtil.js";
52
49
  import { Polygon } from "./layer/vector/Polygon.js";
53
50
  import { MiniMapControl } from "./control/MiniMapControl.js";
54
51
  import { ScaleControl } from "./control/ScaleControl.js";
@@ -58,11 +55,11 @@ import { Marker } from "./layer/marker/Marker.js";
58
55
  import { SearchControl } from "./control/SearchControl.js";
59
56
  import { SideBySideControl } from "./control/SideBySideControl.js";
60
57
  import { TextControl } from "./control/TextControl.js";
58
+ import { TimeControl } from "./control/TimeControl.js";
61
59
  import { projection_exports } from "./geo/projection/index.js";
62
60
  import { EPSG3395 } from "./geo/crs/EPSG3395.js";
63
61
  import { EPSG4326 } from "./geo/crs/EPSG4326.js";
64
62
  import { SimpleCRS } from "./geo/crs/SimpleCRS.js";
65
- import { Circle } from "./layer/vector/Circle.js";
66
63
  import { GeoJSON } from "./layer/GeoJSON.js";
67
64
  import { Classification } from "./layer/Classification.js";
68
65
  import { HeatLayer } from "./layer/HeatLayer.js";
@@ -71,9 +68,12 @@ import { VideoOverlay } from "./layer/VideoOverlay.js";
71
68
  import { SVGOverlay } from "./layer/SVGOverlay.js";
72
69
  import { DivIcon } from "./layer/marker/DivIcon.js";
73
70
  import { SvgIcon } from "./layer/marker/SvgIcon.js";
71
+ import { MarkerClusterGroup } from "./layer/marker/MarkerClusterGroup.js";
74
72
  import { GridLayer } from "./layer/tile/GridLayer.js";
75
73
  import { TileLayer } from "./layer/tile/TileLayer.js";
76
74
  import { WMSTileLayer } from "./layer/tile/WMSTileLayer.js";
75
+ import { Canvas } from "./layer/vector/Canvas.js";
76
+ import { Circle } from "./layer/vector/Circle.js";
77
77
  import { Rectangle } from "./layer/vector/Rectangle.js";
78
78
  import { Hash } from "./map/Hash.js";
79
79
  import { MapSync } from "./map/MapSync.js";
@@ -85,6 +85,6 @@ import { DisplaceHandler, displace } from "./map/handler/DisplaceHandler.js";
85
85
  */
86
86
  const version = version$1;
87
87
  //#endregion
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 };
88
+ export { AttributionControl, BlanketOverlay, Bounds, BoxZoomHandler, 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, MaplairMap as LeafletMap, LegendControl, LineUtil_exports as LineUtil, MaplairMap as Map, MapSync, MaplairMap, Marker, MarkerClusterGroup, MiniMapControl, Path, PinchZoomHandler, Point, PolyUtil_exports as PolyUtil, Polygon, Polyline, Popup, projection_exports as Projection, Rectangle, Renderer, SVG, SVGOverlay, ScaleControl, ScrollWheelZoomHandler, SearchControl, SideBySideControl, SimpleCRS, SvgIcon, TapDragZoomHandler, TapHoldHandler, TextControl, TileLayer, TimeControl, Tooltip, Transformation, Util_exports as Util, VideoOverlay, WMSTileLayer, ZoomControl, displace, version };
89
89
 
90
90
  //# sourceMappingURL=Maplair.js.map
@@ -39,12 +39,10 @@ const mapleLeaf = "<span aria-hidden=\"true\" class=\"maplair-attribution-leaf\"
39
39
  * automatically.
40
40
  */
41
41
  var AttributionControl = class AttributionControl extends Control {
42
- static {
43
- this.setDefaultOptions({
44
- position: "bottomright",
45
- prefix: null
46
- });
47
- }
42
+ static defaultOptions = {
43
+ position: "bottomright",
44
+ prefix: null
45
+ };
48
46
  /**
49
47
  * Creates an attribution control.
50
48
  * @param {AttributionControlOptions} [options]
@@ -57,6 +55,7 @@ var AttributionControl = class AttributionControl extends Control {
57
55
  }
58
56
  this._attributions = {};
59
57
  this._orders = {};
58
+ this._layerAttributions = /* @__PURE__ */ new Map();
60
59
  this.callInitHooks(AttributionControl);
61
60
  }
62
61
  /**
@@ -68,9 +67,12 @@ var AttributionControl = class AttributionControl extends Control {
68
67
  map.attributionControl = this;
69
68
  this._container = create("div", "maplair-control-attribution");
70
69
  disableClickPropagation(this._container);
71
- for (const layer of Object.values(map._layers)) if (layer.getAttribution) this.addAttribution(layer.getAttribution(), layer.options?.attributionOrder);
70
+ if (map._loaded) map.eachLayer((layer) => this._addLayer({ layer }));
72
71
  this._update();
73
- map.on("layeradd", this._addAttribution, this);
72
+ map.on({
73
+ layeradd: this._addLayer,
74
+ layerremove: this._removeLayer
75
+ }, this);
74
76
  return this._container;
75
77
  }
76
78
  /**
@@ -78,13 +80,21 @@ var AttributionControl = class AttributionControl extends Control {
78
80
  * @param {MaplairMap} map
79
81
  */
80
82
  onRemove(map) {
81
- map.off("layeradd", this._addAttribution, this);
83
+ map.off({
84
+ layeradd: this._addLayer,
85
+ layerremove: this._removeLayer
86
+ }, this);
87
+ for (const layer of this._layerAttributions.keys()) this._removeLayer({ layer });
82
88
  }
83
- _addAttribution(ev) {
84
- if (ev.layer.getAttribution) {
85
- this.addAttribution(ev.layer.getAttribution(), ev.layer.options?.attributionOrder);
86
- ev.layer.once("remove", () => this.removeAttribution(ev.layer.getAttribution()));
87
- }
89
+ _addLayer({ layer }) {
90
+ const text = layer.getAttribution?.();
91
+ if (!text || this._layerAttributions.has(layer)) return;
92
+ this._layerAttributions.set(layer, text);
93
+ this.addAttribution(text, layer.options?.attributionOrder);
94
+ }
95
+ _removeLayer({ layer }) {
96
+ this.removeAttribution(this._layerAttributions.get(layer));
97
+ this._layerAttributions.delete(layer);
88
98
  }
89
99
  /**
90
100
  * The HTML text shown before the attributions. Pass `false` to disable.
@@ -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\">&#x1F341;</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,kBAAk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AAK,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"}
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\">&#x1F341;</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\tmap.on({layeradd: this._addLayer, layerremove: this._removeLayer}, 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._addLayer, layerremove: this._removeLayer}, this);\n\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\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,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,CAAC;EACtB,KAAK,UAAU,CAAC;EAChB,KAAK,qCAAqB,IAAI,IAAI;EAElC,KAAK,cAAc,kBAAkB;CACtC;;;;;;CAOA,MAAM,KAAK;EACV,IAAI,qBAAqB;EACzB,KAAK,aAAaA,OAAe,OAAO,6BAA6B;EACrE,wBAAiC,KAAK,UAAU;EAGhD,IAAI,IAAI,SACP,IAAI,WAAU,UAAS,KAAK,UAAU,EAAC,MAAK,CAAC,CAAC;EAG/C,KAAK,QAAQ;EAEb,IAAI,GAAG;GAAC,UAAU,KAAK;GAAW,aAAa,KAAK;EAAY,GAAG,IAAI;EAEvE,OAAO,KAAK;CACb;;;;;CAMA,SAAS,KAAK;EACb,IAAI,IAAI;GAAC,UAAU,KAAK;GAAW,aAAa,KAAK;EAAY,GAAG,IAAI;EAExE,KAAK,MAAM,SAAS,KAAK,mBAAmB,KAAK,GAChD,KAAK,aAAa,EAAC,MAAK,CAAC;CAE3B;CAEA,UAAU,EAAC,SAAQ;EAClB,MAAM,OAAO,MAAM,iBAAiB;EACp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IAAI,KAAK,QAAQ,oBAChB,IAAI,mBAAmB,CAAC,CAAC,MAAM,IAAI;EAErC,CAAC;CACF;AACD"}
@@ -65,17 +65,15 @@ import { Control } from "./Control.js";
65
65
  * ```
66
66
  */
67
67
  var ButtonControl = class ButtonControl extends Control {
68
- static {
69
- this.setDefaultOptions({
70
- position: "topleft",
71
- content: "",
72
- title: "",
73
- onClick: void 0,
74
- states: void 0,
75
- className: "",
76
- accessKey: ""
77
- });
78
- }
68
+ static defaultOptions = {
69
+ position: "topleft",
70
+ content: "",
71
+ title: "",
72
+ onClick: void 0,
73
+ states: void 0,
74
+ className: "",
75
+ accessKey: ""
76
+ };
79
77
  /**
80
78
  * Creates a button control.
81
79
  * @param {...ButtonControlOptions} args The options.
@@ -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 {\n\t\tthis.setDefaultOptions({\n\t\t\tposition: 'topleft',\n\t\t\tcontent: '',\n\t\t\ttitle: '',\n\t\t\tonClick: undefined,\n\t\t\tstates: undefined,\n\t\t\tclassName: '',\n\t\t\taccessKey: ''\n\t\t});\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\t\tDomEvent.on(button, 'click', this._refocusOnMap, 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) {\n\t\t\tbutton._map = null;\n\t\t}\n\t}\n\n\t/**\n\t * Returns the buttons of the bar.\n\t * @returns {ButtonControl[]}\n\t */\n\tgetButtons() {\n\t\treturn this._buttons;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AClE,OAAO,aAAa,cAAc,SAAS,EAAE;EAC7C,IAAI,KAAK,QACR,OAAO,QAAQ,QAAQ,KAAK,OAAO;EAEpC,OAAO,UAAU,OAAO,oBAAoB,CAAC,CAAC,KAAK,SAAS;EAC5D,OAAO,aAAa,iBAAiB,CAAC,CAAC,KAAK,SAAS;CACtD;;;;;;CAOA,SAAS,MAAM;EACd,MAAM,QAAQ,KAAK,QAAQ,QAAQ,MAAK,MAAK,EAAE,SAAS,IAAI;EAC5D,IAAI,CAAC,OACJ,MAAM,IAAI,MAAM,yBAAyB,KAAK,GAAG;EAElD,KAAK,SAAS;EACd,KAAK,QAAQ;EACb,OAAO;CACR;;;;;CAMA,WAAW;EACV,OAAO,KAAK,QAAQ;CACrB;;;;;CAMA,UAAU;EACT,KAAK,YAAY;EACjB,KAAK,QAAQ;EACb,OAAO;CACR;;;;;CAMA,SAAS;EACR,KAAK,YAAY;EACjB,KAAK,QAAQ;EACb,OAAO;CACR;;;;;CAMA,YAAY;EACX,OAAO,KAAK;CACb;AACD;;;;;;;;;;;;;;AAeA,IAAa,mBAAb,MAAa,yBAAyB,QAAQ;;;;;;CAM7C,YAAY,SAAS,SAAS;EAC7B,MAAM,OAAO;EACb,KAAK,WAAW;EAChB,KAAK,cAAc,gBAAgB;CACpC;;;;;;CAOA,MAAM,KAAK;EACV,MAAM,YAAYD,OAAe,OAAO,wCAAwC;EAChF,KAAK,MAAM,UAAU,KAAK,UAAU;GACnC,OAAO,OAAO;GACd,OAAO,cAAc,SAAS;EAC/B;EACA,OAAO;CACR;;CAGA,WAAW;EACV,KAAK,MAAM,UAAU,KAAK,UACzB,OAAO,OAAO;CAEhB;;;;;CAMA,aAAa;EACZ,OAAO,KAAK;CACb;AACD"}
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\t\tDomEvent.on(button, 'click', this._refocusOnMap, 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) {\n\t\t\tbutton._map = null;\n\t\t}\n\t}\n\n\t/**\n\t * Returns the buttons of the bar.\n\t * @returns {ButtonControl[]}\n\t */\n\tgetButtons() {\n\t\treturn this._buttons;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,IAAa,gBAAb,MAAa,sBAAsB,QAAQ;CAE1C,OAAO,iBAAiB;EACvB,UAAU;EACV,SAAS;EACT,OAAO;EACP,SAAS,KAAA;EACT,QAAQ,KAAA;EACR,WAAW;EACX,WAAW;CACZ;;;;;CAMA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,SAAS,KAAK,QAAQ,SAAS;EACpC,KAAK,cAAc,aAAa;CACjC;;;;;CAMA,QAAQ;EACP,MAAM,YAAYA,OAAe,OAAO,oCAAoC;EAC5E,KAAK,cAAc,SAAS;EAC5B,OAAO;CACR;CAGA,cAAc,WAAW;EACxB,MAAM,SAAS,KAAK,UAAUA,OAAe,UAAU,iCAAiC,KAAK,QAAQ,aAAa,SAAS;EAC3H,OAAO,OAAO;EACd,OAAO,YAAY,KAAK,QAAQ;EAEhC,wBAAiC,MAAM;EACvC,GAAY,QAAQ,SAASC,IAAa;EAC1C,GAAY,QAAQ,SAAS,KAAK,UAAU,IAAI;EAChD,GA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B,QAAQ;;;;;;CAM7C,YAAY,SAAS,SAAS;EAC7B,MAAM,OAAO;EACb,KAAK,WAAW;EAChB,KAAK,cAAc,gBAAgB;CACpC;;;;;;CAOA,MAAM,KAAK;EACV,MAAM,YAAYD,OAAe,OAAO,wCAAwC;EAChF,KAAK,MAAM,UAAU,KAAK,UAAU;GACnC,OAAO,OAAO;GACd,OAAO,cAAc,SAAS;EAC/B;EACA,OAAO;CACR;;CAGA,WAAW;EACV,KAAK,MAAM,UAAU,KAAK,UACzB,OAAO,OAAO;CAEhB;;;;;CAMA,aAAa;EACZ,OAAO,KAAK;CACb;AACD"}
@@ -54,9 +54,7 @@ import { Layer } from "../layer/Layer.js";
54
54
  * ```
55
55
  */
56
56
  var ContextMenu = class ContextMenu extends Class {
57
- static {
58
- this.setDefaultOptions({ className: "" });
59
- }
57
+ static defaultOptions = { className: "" };
60
58
  /**
61
59
  * Creates a context menu. Each item is an object with `text`, `callback` and the
62
60
  * optional `disabled`, or `'-'` for a separator. The `callback` gets an event with
@@ -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 {\n\t\tthis.setDefaultOptions({\n\t\t\tclassName: ''\n\t\t});\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.appendChild(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;EACC,KAAK,kBAAkB,EACtB,WAAW,GACZ,CAAC;CACF;;;;;;;;;CAUA,YAAY,OAAO,SAAS;EAC3B,MAAM;EACN,WAAgB,MAAM,OAAO;EAC7B,KAAK,SAAS;EACd,KAAK,cAAc,WAA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ent":["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.appendChild(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,QAAQ;EACb,KAAK,OAAO;EACZ,KAAK,UAAU;EACf,OAAO,GAAG,eAAe,KAAK,OAAO,IAAI;EACzC,OAAO;CACR;;;;;CAMA,SAAS;EACR,KAAK,MAAM;EACX,KAAK,SAAS,IAAI,eAAe,KAAK,OAAO,IAAI;EACjD,KAAK,UAAU;EACf,KAAK,YAAY,OAAO;EACxB,KAAK,aAAa;EAClB,OAAO;CACR;;;;;CAMA,QAAQ;EACP,IAAI,KAAK,YAAY,QAAQ,eAAe,GAC3C,KAAK,WAAW,YAAY;EAE7B,OAAO;CACR;;;;;CAMA,SAAS;EACR,OAAO,CAAC,CAAC,KAAK,YAAY,QAAQ,eAAe;CAClD;CAEA,MAAM,GAAG;EAER,KAAc,CAAC;EACf,MAAM,MAAM,KAAK,mBAAmB,QAAQ,KAAK,QAAQ,OAAO,KAAK;EACrE,IAAI,CAAC,KAAO;EAEZ,KAAK,OAAO;EACZ,KAAK,SAAS;GACb,QAAQ,EAAE;GACV,gBAAgB,EAAE;GAClB,YAAY,EAAE;GACd,eAAe,EAAE;GACjB,eAAe,KAAK,mBAAmB,QAAQ,KAAK,UAAU,KAAA;EAC/D;EAEA,MAAM,YAAY,KAAK,YAA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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"}
@@ -40,17 +40,9 @@ const mapControlMethods = {
40
40
  },
41
41
  _initControlPos() {
42
42
  const corners = this._controlCorners = {}, l = "maplair-", container = this._controlContainer = create("div", `${l}control-container`, this._container);
43
- function createCorner(vSide, hSide) {
44
- const className = `${l + vSide} ${l}${hSide}`;
45
- corners[vSide + hSide] = create("div", className, container);
46
- }
47
- createCorner("top", "left");
48
- createCorner("top", "right");
49
- createCorner("bottom", "left");
50
- createCorner("bottom", "right");
43
+ for (const v of ["top", "bottom"]) for (const h of ["left", "right"]) corners[v + h] = create("div", `${l + v} ${l}${h}`, container);
51
44
  },
52
45
  _clearControlPos() {
53
- for (const c of Object.values(this._controlCorners)) c.remove();
54
46
  this._controlContainer.remove();
55
47
  delete this._controlCorners;
56
48
  delete this._controlContainer;
@@ -83,12 +75,10 @@ const controlOrders = /* @__PURE__ */ new WeakMap();
83
75
  * [`control.remove()`](#control-remove).
84
76
  */
85
77
  var Control = class Control extends Class {
86
- static {
87
- this.setDefaultOptions({
88
- position: "topright",
89
- order: 0
90
- });
91
- }
78
+ static defaultOptions = {
79
+ position: "topright",
80
+ order: 0
81
+ };
92
82
  /**
93
83
  * @param {ControlOptions} [options]
94
84
  */
@@ -152,7 +142,10 @@ var Control = class Control extends Class {
152
142
  return this;
153
143
  }
154
144
  _refocusOnMap(e) {
155
- if (this._map && e && !(e.screenX === 0 && e.screenY === 0)) this._map.getContainer().focus();
145
+ if (this._map && e && !(e.screenX === 0 && e.screenY === 0)) this._map.getContainer().focus({
146
+ preventScroll: true,
147
+ focusVisible: false
148
+ });
156
149
  }
157
150
  /**
158
151
  * Registers this default feature on the map class, called by `MaplairMap` itself.
@@ -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\tfunction createCorner(vSide, hSide) {\n\t\t\tconst className = `${l + vSide} ${l}${hSide}`;\n\n\t\t\tcorners[vSide + hSide] = DomUtil.create('div', className, container);\n\t\t}\n\n\t\tcreateCorner('top', 'left');\n\t\tcreateCorner('top', 'right');\n\t\tcreateCorner('bottom', 'left');\n\t\tcreateCorner('bottom', 'right');\n\t},\n\n\t_clearControlPos() {\n\t\tfor (const c of Object.values(this._controlCorners)) {\n\t\t\tc.remove();\n\t\t}\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 * Control is a base class for implementing map controls. Handles positioning.\n * All other controls extend from this class.\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 */\nexport class Control extends Class {\n\n\tstatic {\n\t\tthis.setDefaultOptions({\n\t\t\tposition: 'topright',\n\t\t\torder: 0\n\t\t});\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._map.on('unload', this.remove, 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\n\t\tif (this.onRemove) {\n\t\t\tthis.onRemove(this._map);\n\t\t}\n\n\t\tthis._map.off('unload', this.remove, this);\n\t\tthis._map = null;\n\n\t\treturn this;\n\t}\n\n\t_refocusOnMap(e) {\n\t\t// We exclude keyboard-click event to keep the focus on the control for accessibility.\n\t\t// The position of keyboard-click events are x=0 and y=0.\n\t\tif (this._map && e && !(e.screenX === 0 && e.screenY === 0)) {\n\t\t\tthis._map.getContainer().focus();\n\t\t}\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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AAY,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,KAAK,GAAG,UAAU,KAAK,QAAQ,IAAI;EAExC,OAAO;CACR;;;;;CAMA,SAAS;EACR,IAAI,CAAC,KAAK,MACT,OAAO;EAGR,KAAK,WAAW,OAAO;EAEvB,IAAI,KAAK,UACR,KAAK,SAAS,KAAK,IAAI;EAGxB,KAAK,KAAK,IAAI,UAAU,KAAK,QAAQ,IAAI;EACzC,KAAK,OAAO;EAEZ,OAAO;CACR;CAEA,cAAc,GAAG;EAGhB,IAAI,KAAK,QAAQ,KAAK,EAAE,EAAE,YAAY,KAAK,EAAE,YAAY,IACxD,KAAK,KAAK,aAAa,CAAC,CAAC,MAAM;CAEjC;;;;;;CAOA,OAAO,SAAS,YAAY;EAC3B,WAAW,QAAQ,iBAAiB;CACrC;AACD"}
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 * Control is a base class for implementing map controls. Handles positioning.\n * All other controls extend from this class.\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 */\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._map.on('unload', this.remove, 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\n\t\tif (this.onRemove) {\n\t\t\tthis.onRemove(this._map);\n\t\t}\n\n\t\tthis._map.off('unload', this.remove, this);\n\t\tthis._map = null;\n\n\t\treturn this;\n\t}\n\n\t_refocusOnMap(e) {\n\t\t// We exclude keyboard-click event to keep the focus on the control for accessibility.\n\t\t// The position of keyboard-click events are x=0 and y=0.\n\t\tif (this._map && e && !(e.screenX === 0 && e.screenY === 0)) {\n\t\t\tthis._map.getContainer().focus({preventScroll: true, focusVisible: false});\n\t\t}\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;;;;;;;;;;;;;AAgBA,MAAM,gCAAgB,IAAI,QAAQ;;;;;;;;;;;;;;AAelC,IAAa,UAAb,MAAa,gBAAgB,MAAM;CAElC,OAAO,iBAAiB;EACvB,UAAU;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AK,CAAC;CAE3E;;;;;;CAOA,OAAO,SAAS,YAAY;EAC3B,WAAW,QAAQ,iBAAiB;CACrC;AACD"}
@@ -107,13 +107,11 @@ const mapFullscreenMethods = {
107
107
  * ```
108
108
  */
109
109
  var FullscreenControl = class FullscreenControl extends Control {
110
- static {
111
- this.setDefaultOptions({
112
- position: "topleft",
113
- enterText: enterIcon,
114
- exitText: exitIcon
115
- });
116
- }
110
+ static defaultOptions = {
111
+ position: "topleft",
112
+ enterText: enterIcon,
113
+ exitText: exitIcon
114
+ };
117
115
  /**
118
116
  * Creates a fullscreen control.
119
117
  * @param {...FullscreenControlOptions} args The options.