maplair 4.0.0-alpha.1 → 4.0.0

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