maplair 4.0.0-alpha.2 → 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 (284) hide show
  1. package/CHANGELOG.md +140 -38
  2. package/LICENSE +1 -1
  3. package/README.md +10 -9
  4. package/dist/esm/Maplair.js +14 -14
  5. package/dist/esm/control/AttributionControl.js +24 -14
  6. package/dist/esm/control/AttributionControl.js.map +1 -1
  7. package/dist/esm/control/ButtonControl.js +9 -11
  8. package/dist/esm/control/ButtonControl.js.map +1 -1
  9. package/dist/esm/control/ContextMenu.js +1 -3
  10. package/dist/esm/control/ContextMenu.js.map +1 -1
  11. package/dist/esm/control/Control.js +9 -16
  12. package/dist/esm/control/Control.js.map +1 -1
  13. package/dist/esm/control/FullscreenControl.js +5 -7
  14. package/dist/esm/control/FullscreenControl.js.map +1 -1
  15. package/dist/esm/control/LayersControl.js +144 -35
  16. package/dist/esm/control/LayersControl.js.map +1 -1
  17. package/dist/esm/control/LegendControl.js +7 -9
  18. package/dist/esm/control/LegendControl.js.map +1 -1
  19. package/dist/esm/control/MiniMapControl.js +14 -16
  20. package/dist/esm/control/MiniMapControl.js.map +1 -1
  21. package/dist/esm/control/RotateControl.js +1 -3
  22. package/dist/esm/control/RotateControl.js.map +1 -1
  23. package/dist/esm/control/ScaleControl.js +7 -9
  24. package/dist/esm/control/ScaleControl.js.map +1 -1
  25. package/dist/esm/control/SearchControl.js +100 -18
  26. package/dist/esm/control/SearchControl.js.map +1 -1
  27. package/dist/esm/control/SideBySideControl.js +1 -3
  28. package/dist/esm/control/SideBySideControl.js.map +1 -1
  29. package/dist/esm/control/TextControl.js +5 -7
  30. package/dist/esm/control/TextControl.js.map +1 -1
  31. package/dist/esm/control/TimeControl.js +408 -0
  32. package/dist/esm/control/TimeControl.js.map +1 -0
  33. package/dist/esm/control/ZoomControl.js +5 -7
  34. package/dist/esm/control/ZoomControl.js.map +1 -1
  35. package/dist/esm/core/Class.js +28 -37
  36. package/dist/esm/core/Class.js.map +1 -1
  37. package/dist/esm/core/Events.js +21 -8
  38. package/dist/esm/core/Events.js.map +1 -1
  39. package/dist/esm/core/Handler.js +13 -11
  40. package/dist/esm/core/Handler.js.map +1 -1
  41. package/dist/esm/core/Util.js +13 -1
  42. package/dist/esm/core/Util.js.map +1 -1
  43. package/dist/esm/dom/DomEvent.DoubleTap.js +25 -22
  44. package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -1
  45. package/dist/esm/dom/DomEvent.PointerEvents.js +2 -16
  46. package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
  47. package/dist/esm/dom/DomEvent.js +8 -42
  48. package/dist/esm/dom/DomEvent.js.map +1 -1
  49. package/dist/esm/dom/DomUtil.js +14 -68
  50. package/dist/esm/dom/DomUtil.js.map +1 -1
  51. package/dist/esm/dom/Draggable.js +17 -18
  52. package/dist/esm/dom/Draggable.js.map +1 -1
  53. package/dist/esm/dom/PosAnimation.js +3 -25
  54. package/dist/esm/dom/PosAnimation.js.map +1 -1
  55. package/dist/esm/geo/LatLng.js +34 -6
  56. package/dist/esm/geo/LatLng.js.map +1 -1
  57. package/dist/esm/geo/LatLngBounds.js +19 -7
  58. package/dist/esm/geo/LatLngBounds.js.map +1 -1
  59. package/dist/esm/geo/crs/CRS.js +4 -3
  60. package/dist/esm/geo/crs/CRS.js.map +1 -1
  61. package/dist/esm/geo/crs/EPSG3395.js +1 -1
  62. package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
  63. package/dist/esm/geo/crs/EPSG3857.js +1 -1
  64. package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
  65. package/dist/esm/geo/crs/EPSG4326.js +1 -1
  66. package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
  67. package/dist/esm/geo/crs/EarthCRS.js +2 -2
  68. package/dist/esm/geo/crs/EarthCRS.js.map +1 -1
  69. package/dist/esm/geo/crs/SimpleCRS.js +1 -1
  70. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
  71. package/dist/esm/geo/projection/Projection.LonLat.js +3 -3
  72. package/dist/esm/geo/projection/Projection.LonLat.js.map +1 -1
  73. package/dist/esm/geo/projection/Projection.Mercator.js +3 -3
  74. package/dist/esm/geo/projection/Projection.Mercator.js.map +1 -1
  75. package/dist/esm/geo/projection/Projection.SphericalMercator.js +3 -3
  76. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +1 -1
  77. package/dist/esm/geometry/Bounds.js +19 -7
  78. package/dist/esm/geometry/Bounds.js.map +1 -1
  79. package/dist/esm/geometry/LineUtil.js +36 -30
  80. package/dist/esm/geometry/LineUtil.js.map +1 -1
  81. package/dist/esm/geometry/Point.js +23 -5
  82. package/dist/esm/geometry/Point.js.map +1 -1
  83. package/dist/esm/geometry/PolyUtil.js +9 -28
  84. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  85. package/dist/esm/layer/BlanketOverlay.js +6 -8
  86. package/dist/esm/layer/BlanketOverlay.js.map +1 -1
  87. package/dist/esm/layer/DivOverlay.js +15 -20
  88. package/dist/esm/layer/DivOverlay.js.map +1 -1
  89. package/dist/esm/layer/GeoJSON.js +9 -145
  90. package/dist/esm/layer/GeoJSON.js.map +1 -1
  91. package/dist/esm/layer/GeoJSONUtil.js +75 -0
  92. package/dist/esm/layer/GeoJSONUtil.js.map +1 -0
  93. package/dist/esm/layer/HeatLayer.js +15 -17
  94. package/dist/esm/layer/HeatLayer.js.map +1 -1
  95. package/dist/esm/layer/ImageOverlay.js +20 -26
  96. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  97. package/dist/esm/layer/Layer.js +8 -10
  98. package/dist/esm/layer/Layer.js.map +1 -1
  99. package/dist/esm/layer/LayerGroup.js +51 -0
  100. package/dist/esm/layer/LayerGroup.js.map +1 -1
  101. package/dist/esm/layer/Popup.js +27 -43
  102. package/dist/esm/layer/Popup.js.map +1 -1
  103. package/dist/esm/layer/SVGOverlay.js +2 -5
  104. package/dist/esm/layer/SVGOverlay.js.map +1 -1
  105. package/dist/esm/layer/Tooltip.js +15 -17
  106. package/dist/esm/layer/Tooltip.js.map +1 -1
  107. package/dist/esm/layer/VideoOverlay.js +12 -15
  108. package/dist/esm/layer/VideoOverlay.js.map +1 -1
  109. package/dist/esm/layer/marker/DefaultIcon.js +15 -48
  110. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
  111. package/dist/esm/layer/marker/DivIcon.js +8 -10
  112. package/dist/esm/layer/marker/DivIcon.js.map +1 -1
  113. package/dist/esm/layer/marker/Icon.js +9 -12
  114. package/dist/esm/layer/marker/Icon.js.map +1 -1
  115. package/dist/esm/layer/marker/Marker.Drag.js +1 -1
  116. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  117. package/dist/esm/layer/marker/Marker.Move.js +2 -3
  118. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  119. package/dist/esm/layer/marker/Marker.js +63 -35
  120. package/dist/esm/layer/marker/Marker.js.map +1 -1
  121. package/dist/esm/layer/marker/MarkerClusterGroup.js +302 -0
  122. package/dist/esm/layer/marker/MarkerClusterGroup.js.map +1 -0
  123. package/dist/esm/layer/marker/SvgIcon.js +6 -8
  124. package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
  125. package/dist/esm/layer/tile/GridLayer.js +86 -98
  126. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  127. package/dist/esm/layer/tile/TileLayer.js +28 -36
  128. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  129. package/dist/esm/layer/tile/WMSTileLayer.js +28 -23
  130. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
  131. package/dist/esm/layer/vector/Canvas.js +1 -3
  132. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  133. package/dist/esm/layer/vector/Circle.js +2 -2
  134. package/dist/esm/layer/vector/Circle.js.map +1 -1
  135. package/dist/esm/layer/vector/CircleMarker.js +17 -7
  136. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  137. package/dist/esm/layer/vector/Path.DashAnimation.js +2 -3
  138. package/dist/esm/layer/vector/Path.DashAnimation.js.map +1 -1
  139. package/dist/esm/layer/vector/Path.js +27 -20
  140. package/dist/esm/layer/vector/Path.js.map +1 -1
  141. package/dist/esm/layer/vector/Polygon.js +20 -4
  142. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  143. package/dist/esm/layer/vector/Polyline.Decorations.js +2 -2
  144. package/dist/esm/layer/vector/Polyline.js +24 -8
  145. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  146. package/dist/esm/layer/vector/Renderer.getRenderer.js +14 -13
  147. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  148. package/dist/esm/layer/vector/SVG.js +5 -5
  149. package/dist/esm/layer/vector/SVG.js.map +1 -1
  150. package/dist/esm/map/Map.Rotation.js +15 -11
  151. package/dist/esm/map/Map.Rotation.js.map +1 -1
  152. package/dist/esm/map/Map.js +135 -129
  153. package/dist/esm/map/Map.js.map +1 -1
  154. package/dist/esm/map/handler/BoxZoomHandler.js +5 -7
  155. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  156. package/dist/esm/map/handler/DisplaceHandler.js +6 -8
  157. package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
  158. package/dist/esm/map/handler/DragHandler.js +20 -20
  159. package/dist/esm/map/handler/DragHandler.js.map +1 -1
  160. package/dist/esm/map/handler/KeyboardHandler.js +37 -37
  161. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  162. package/dist/esm/map/handler/PinchZoomHandler.js +12 -3
  163. package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
  164. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +3 -4
  165. package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
  166. package/dist/esm/map/handler/TapHoldHandler.js +12 -5
  167. package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
  168. package/dist/esm/package.js +1 -1
  169. package/dist/maplair-global-src.js +6326 -5625
  170. package/dist/maplair-global-src.js.map +1 -1
  171. package/dist/maplair-global.js +3 -3
  172. package/dist/maplair-global.js.map +1 -1
  173. package/dist/maplair-src.js +9010 -8290
  174. package/dist/maplair-src.js.map +1 -1
  175. package/dist/maplair.css +148 -98
  176. package/dist/maplair.js +3 -3
  177. package/dist/maplair.js.map +1 -1
  178. package/i18n/cs.json +6 -0
  179. package/i18n/de.json +6 -0
  180. package/i18n/en.json +6 -0
  181. package/i18n/es.json +6 -0
  182. package/i18n/fr.json +6 -0
  183. package/i18n/hu.json +6 -0
  184. package/i18n/it.json +6 -0
  185. package/i18n/rm.json +6 -0
  186. package/i18n/sk.json +6 -0
  187. package/i18n/sl.json +6 -0
  188. package/package.json +12 -14
  189. package/src/control/AttributionControl.js +25 -18
  190. package/src/control/ButtonControl.js +9 -11
  191. package/src/control/ContextMenu.js +3 -5
  192. package/src/control/Control.js +9 -19
  193. package/src/control/FullscreenControl.js +5 -7
  194. package/src/control/LayersControl.js +159 -36
  195. package/src/control/LegendControl.js +7 -9
  196. package/src/control/MiniMapControl.js +9 -11
  197. package/src/control/RotateControl.js +3 -5
  198. package/src/control/ScaleControl.js +7 -9
  199. package/src/control/SearchControl.js +104 -21
  200. package/src/control/SideBySideControl.js +3 -5
  201. package/src/control/TextControl.js +5 -7
  202. package/src/control/TimeControl.js +471 -0
  203. package/src/control/ZoomControl.js +5 -7
  204. package/src/control/index.js +1 -0
  205. package/src/core/Class.js +35 -34
  206. package/src/core/Events.js +22 -3
  207. package/src/core/Handler.js +14 -12
  208. package/src/core/Util.js +19 -1
  209. package/src/core/index.js +0 -1
  210. package/src/dom/DomEvent.DoubleTap.js +18 -10
  211. package/src/dom/DomEvent.PointerEvents.js +3 -26
  212. package/src/dom/DomEvent.js +8 -66
  213. package/src/dom/DomUtil.js +22 -78
  214. package/src/dom/Draggable.js +27 -22
  215. package/src/dom/PosAnimation.js +3 -25
  216. package/src/dom/index.js +0 -1
  217. package/src/geo/LatLng.js +40 -4
  218. package/src/geo/LatLngBounds.js +20 -7
  219. package/src/geo/crs/CRS.js +4 -3
  220. package/src/geo/crs/EPSG3395.js +1 -1
  221. package/src/geo/crs/EPSG3857.js +1 -1
  222. package/src/geo/crs/EPSG4326.js +1 -1
  223. package/src/geo/crs/EarthCRS.js +2 -8
  224. package/src/geo/crs/SimpleCRS.js +1 -1
  225. package/src/geo/projection/Projection.LonLat.js +3 -3
  226. package/src/geo/projection/Projection.Mercator.js +3 -3
  227. package/src/geo/projection/Projection.SphericalMercator.js +3 -3
  228. package/src/geometry/Bounds.js +20 -7
  229. package/src/geometry/LineUtil.js +47 -48
  230. package/src/geometry/Point.js +24 -5
  231. package/src/geometry/PolyUtil.js +15 -44
  232. package/src/layer/BlanketOverlay.js +6 -10
  233. package/src/layer/DivOverlay.js +15 -26
  234. package/src/layer/GeoJSON.js +7 -205
  235. package/src/layer/GeoJSONUtil.js +85 -0
  236. package/src/layer/HeatLayer.js +9 -11
  237. package/src/layer/ImageOverlay.js +19 -30
  238. package/src/layer/Layer.js +8 -10
  239. package/src/layer/LayerGroup.js +71 -0
  240. package/src/layer/Popup.js +31 -46
  241. package/src/layer/SVGOverlay.js +1 -5
  242. package/src/layer/Tooltip.js +15 -19
  243. package/src/layer/VideoOverlay.js +12 -15
  244. package/src/layer/marker/DefaultIcon.js +15 -61
  245. package/src/layer/marker/DivIcon.js +10 -12
  246. package/src/layer/marker/Icon.js +9 -12
  247. package/src/layer/marker/Marker.Drag.js +1 -1
  248. package/src/layer/marker/Marker.Move.js +2 -3
  249. package/src/layer/marker/Marker.js +83 -41
  250. package/src/layer/marker/MarkerClusterGroup.js +370 -0
  251. package/src/layer/marker/SvgIcon.js +7 -9
  252. package/src/layer/marker/index.js +1 -0
  253. package/src/layer/tile/GridLayer.js +104 -134
  254. package/src/layer/tile/TileLayer.js +35 -43
  255. package/src/layer/tile/WMSTileLayer.js +26 -24
  256. package/src/layer/vector/Canvas.js +3 -5
  257. package/src/layer/vector/Circle.js +5 -2
  258. package/src/layer/vector/CircleMarker.js +17 -6
  259. package/src/layer/vector/Path.DashAnimation.js +1 -2
  260. package/src/layer/vector/Path.js +30 -21
  261. package/src/layer/vector/Polygon.js +28 -5
  262. package/src/layer/vector/Polyline.js +26 -7
  263. package/src/layer/vector/Renderer.getRenderer.js +17 -17
  264. package/src/layer/vector/SVG.js +5 -5
  265. package/src/map/Map.Rotation.js +19 -11
  266. package/src/map/Map.js +163 -154
  267. package/src/map/handler/BoxZoomHandler.js +9 -8
  268. package/src/map/handler/DisplaceHandler.js +6 -8
  269. package/src/map/handler/DragHandler.js +26 -29
  270. package/src/map/handler/KeyboardHandler.js +44 -50
  271. package/src/map/handler/PinchZoomHandler.js +16 -5
  272. package/src/map/handler/ScrollWheelZoomHandler.js +6 -4
  273. package/src/map/handler/TapHoldHandler.js +15 -4
  274. package/src/map/index.js +1 -1
  275. package/src/maplair.css +148 -98
  276. package/dist/esm/core/Browser.js +0 -100
  277. package/dist/esm/core/Browser.js.map +0 -1
  278. package/dist/images/layers.svg +0 -1
  279. package/dist/images/marker-icon.svg +0 -1
  280. package/dist/images/marker-shadow.svg +0 -1
  281. package/src/core/Browser.js +0 -110
  282. package/src/images/layers.svg +0 -1
  283. package/src/images/marker-icon.svg +0 -1
  284. package/src/images/marker-shadow.svg +0 -1
@@ -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,kB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,GAAG,OAAO,QAAQ,MAAM,CAAC,EAAE,MAAM;CAC1C;AACD"}
1
+ {"version":3,"file":"ContextMenu.js","names":["DomUtil.create","DomEvent.stop"],"sources":["../../../src/control/ContextMenu.js"],"sourcesContent":["import {Class} from '../core/Class.js';\nimport * as Util from '../core/Util.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport {Layer} from '../layer/Layer.js';\n/** @import {MaplairMap} from '../map/Map.js' */\n/** @import {LatLng} from '../geo/LatLng.js' */\n/** @import {Point} from '../geometry/Point.js' */\n\n/**\n * Options of `ContextMenu`.\n * @typedef {object} ContextMenuOptions\n * @property {string} [className=''] A custom CSS class name to assign to the menu.\n */\n\n/**\n * The argument of the `callback` of a `ContextMenu` item, with the location of the\n * `contextmenu` event.\n * @typedef {object} ContextMenuEvent\n * @property {LatLng} latlng The geographical point of the event.\n * @property {Point} containerPoint Pixel coordinates of the event relative to the map\n * container.\n * @property {Point} layerPoint Pixel coordinates of the event relative to the map layer.\n * @property {MouseEvent|PointerEvent} originalEvent The original DOM event.\n * @property {Layer} [relatedTarget] The layer, for menus of layers.\n */\n\n/**\n * An item of a `ContextMenu`.\n * @typedef {object} ContextMenuItem\n * @property {string} text The text of the item.\n * @property {(this: ContextMenu, event: ContextMenuEvent) => void} [callback] Called\n * when the item is chosen.\n * @property {boolean} [disabled] Whether the item is disabled.\n */\n\n/**\n * A menu opened with the `contextmenu` event (right click, or long tap on touch\n * screens) on the map or on a layer. Each item calls a function with the location\n * of the event. The menu is a [popover](https://developer.mozilla.org/docs/Web/API/Popover_API),\n * closed by clicking outside of it or pressing Escape, and can be used with the\n * keyboard (arrow keys, Enter).\n *\n * Inspired by the [Leaflet.contextmenu](https://github.com/aratcliffe/Leaflet.contextmenu) plugin.\n *\n * @example\n * ```js\n * new ContextMenu([\n * \t{text: 'Center the map here', callback: e => map.panTo(e.latlng)},\n * \t'-',\n * \t{text: 'Zoom in', callback: () => map.zoomIn()}\n * ]).addTo(map);\n *\n * new ContextMenu([\n * \t{text: 'Remove', callback: e => e.relatedTarget.remove()}\n * ]).addTo(marker);\n * ```\n */\nexport class ContextMenu extends Class {\n\n\tstatic defaultOptions = {\n\t\tclassName: ''\n\t};\n\n\t/**\n\t * Creates a context menu. Each item is an object with `text`, `callback` and the\n\t * optional `disabled`, or `'-'` for a separator. The `callback` gets an event with\n\t * `latlng`, `containerPoint`, `layerPoint`, `originalEvent` and `relatedTarget`\n\t * (the layer, for menus of layers).\n\t * @param {(ContextMenuItem|'-')[]} items\n\t * @param {ContextMenuOptions} [options]\n\t */\n\tconstructor(items, options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\t\tthis._items = items;\n\t\tthis.callInitHooks(ContextMenu);\n\t}\n\n\t/**\n\t * Opens the menu on `contextmenu` events of the map or the layer.\n\t * @param {MaplairMap|Layer} target\n\t * @returns {this}\n\t */\n\taddTo(target) {\n\t\tthis.remove();\n\t\tthis._target = target;\n\t\ttarget.on('contextmenu', this._open, this);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes the menu from its map or layer.\n\t * @returns {this}\n\t */\n\tremove() {\n\t\tthis.close();\n\t\tthis._target?.off('contextmenu', this._open, this);\n\t\tthis._target = null;\n\t\tthis._container?.remove();\n\t\tthis._container = null;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Closes the menu.\n\t * @returns {this}\n\t */\n\tclose() {\n\t\tif (this._container?.matches(':popover-open')) {\n\t\t\tthis._container.hidePopover();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns `true` if the menu is open.\n\t * @returns {boolean}\n\t */\n\tisOpen() {\n\t\treturn !!this._container?.matches(':popover-open');\n\t}\n\n\t_open(e) {\n\t\t// a menu of a layer replaces the one of the map\n\t\tDomEvent.stop(e);\n\t\tconst map = this._target instanceof Layer ? this._target._map : this._target;\n\t\tif (!map) { return; }\n\n\t\tthis._map = map;\n\t\tthis._event = {\n\t\t\tlatlng: e.latlng,\n\t\t\tcontainerPoint: e.containerPoint,\n\t\t\tlayerPoint: e.layerPoint,\n\t\t\toriginalEvent: e.originalEvent,\n\t\t\trelatedTarget: this._target instanceof Layer ? this._target : undefined\n\t\t};\n\n\t\tconst container = this._createMenu(map._container);\n\t\tif (!container.matches(':popover-open')) {\n\t\t\tcontainer.showPopover();\n\t\t}\n\t\tthis._position(e.originalEvent);\n\t\tcontainer.querySelector('button:not([disabled])')?.focus({preventScroll: true});\n\t\tmap.once('movestart', this.close, this);\n\t}\n\n\t_createMenu(parent) {\n\t\tconst container = this._container ??= DomUtil.create('div', `maplair-contextmenu ${this.options.className}`);\n\t\tif (container.parentNode !== parent) {\n\t\t\tparent.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,E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,cAAc,UAAU,WAAW,GACpE,IAAI,KAAK,IAAI,EAAE,SAAS,SAAS,eAAe,UAAU,YAAY;EACtE,UAAU,MAAM,OAAO,GAAG,KAAK,IAAI,GAAG,CAAC,EAAE;EACzC,UAAU,MAAM,MAAM,GAAG,KAAK,IAAI,GAAG,CAAC,EAAE;CACzC;CAEA,WAAW,GAAG;EACb,IAAI,EAAE,QAAQ,eAAe,EAAE,QAAQ,WAAa;EACpD,KAAc,CAAC;EACf,MAAM,UAAU,CAAC,GAAG,KAAK,WAAW,iBAAiB,wBAAwB,CAAC,GAC9E,QAAQ,QAAQ,QAAQ,SAAS,aAAa,GAC9C,OAAO,EAAE,QAAQ,cAAc,QAAQ,IAAI,QAAQ;EACnD,QAAQ,GAAG,OAAO,QAAQ,MAAM,CAAC,EAAE,MAAM;CAC1C;AACD"}
@@ -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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AK,WAAW,IAAI;EAEpB,OAAO;CACR;;;;;CAMA,eAAe;EACd,OAAO,KAAK;CACb;;;;;;CAOA,MAAM,KAAK;EACV,KAAK,OAAO;EACZ,KAAK,OAAO;EAEZ,MAAM,YAAY,KAAK,aAAa,KAAK,MAAM,GAAG,GAClD,MAAM,KAAK,YAAY,GACvB,SAAS,IAAI,gBAAgB;EAE7B,UAAU,UAAU,IAAI,iBAAiB;EAIzC,MAAM,QAAQ,KAAK,QAAQ,SAAS,GACpC,SAAS,IAAI,SAAS,QAAQ,GAC9B,WAAW,CAAC,GAAG,OAAO,QAAQ;EAC9B,cAAc,IAAI,WAAW,KAAK;EAClC,OAAO,aAAa,WAAW,SAAS,MAAK,OAAM,UACjD,cAAc,IAAI,EAAE,KAAK,MAAM,SAC/B,cAAc,IAAI,EAAE,KAAK,KAAK,KAAK,KAAK,IAAI;EAE9C,KAAK,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;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c,GAAG;EAGhB,IAAI,KAAK,QAAQ,KAAK,EAAE,EAAE,YAAY,KAAK,EAAE,YAAY,IACxD,KAAK,KAAK,aAAa,CAAC,CAAC,MAAM;GAAC,eAAe;GAAM,cAAc;EAAK,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.
@@ -1 +1 @@
1
- {"version":3,"file":"FullscreenControl.js","names":["DomUtil.create","DomEvent.stop"],"sources":["../../../src/control/FullscreenControl.js"],"sourcesContent":["import {Control} from './Control.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport {I18n} from '../core/I18n.js';\n/** @import {ControlOptions} from './Control.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n/** @import {MaplairEvent} from '../core/Events.js' */\n\nconst enterIcon = '<svg aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\"><path d=\"M2 2h5v2H4v3H2zm7 0h5v5h-2V4H9zM2 9h2v3h3v2H2zm10 0h2v5H9v-2h3z\"/></svg>';\nconst exitIcon = '<svg aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\"><path d=\"M5 2h2v5H2V5h3zm4 0h2v3h3v2H9zM2 9h5v5H5v-3H2zm7 0h5v2h-3v3H9z\"/></svg>';\n\n/**\n * Options of `FullscreenControl`.\n * @typedef {object} FullscreenControlOptions\n * @property {string} [position='topleft'] The position of the control (one of the map\n * corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or\n * `'bottomright'`.\n * @property {string} [enterText] The HTML content of the button while the map is not in\n * fullscreen, by default an expand icon.\n * @property {string} [exitText] The HTML content of the button while the map is in\n * fullscreen, by default a collapse icon.\n * @extends ControlOptions\n */\n\n/**\n * Map options of `FullscreenControl`.\n * @typedef {object} FullscreenControlMapOptions\n * @lends MaplairMapOptions\n * @property {boolean} [fullscreenControl=false] Whether a\n * [fullscreen control](#fullscreencontrol) is added to the map by default.\n */\n\n/**\n * Properties of `MaplairMap` set by `FullscreenControl`.\n * @typedef {object} FullscreenControlMapProperties\n * @lends MaplairMap\n * @property {FullscreenControl} fullscreenControl The default fullscreen control (only\n * available if the [`fullscreenControl` option](#map-fullscreencontrol) was `true` when\n * creating the map).\n */\n\n/**\n * Methods of `MaplairMap` for the fullscreen view.\n * @lends MaplairMap.prototype\n * @fires MaplairMap#enterfullscreen {MaplairEvent} Fired when the map enters fullscreen.\n * @fires MaplairMap#exitfullscreen {MaplairEvent} Fired when the map exits fullscreen.\n * @fires MaplairMap#fullscreenchange {MaplairEvent} Fired when the map enters or exits\n * fullscreen.\n */\nconst mapFullscreenMethods = {\n\t/**\n\t * Enters or exits the fullscreen view of the map, see `FullscreenControl`.\n\t * Browsers allow entering fullscreen only in response to a user interaction,\n\t * e.g. a click.\n\t * @group Methods for modifying map state\n\t * @returns {this}\n\t */\n\ttoggleFullscreen() {\n\t\tconst container = this._container;\n\n\t\tif (this._fullscreen === 'pseudo') {\n\t\t\tthis._setFullscreen(false);\n\t\t} else if (this._fullscreen) {\n\t\t\tdocument.exitFullscreen();\n\t\t} else if (document.fullscreenEnabled && container.requestFullscreen) {\n\t\t\tDomEvent.on(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t\tcontainer.requestFullscreen().catch(() => {\n\t\t\t\tDomEvent.off(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t\t\tthis._setFullscreen('pseudo');\n\t\t\t});\n\t\t} else {\n\t\t\tthis._setFullscreen('pseudo');\n\t\t}\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` if the map is viewed in fullscreen.\n\t * @group Other methods\n\t * @returns {boolean}\n\t */\n\tisFullscreen() {\n\t\treturn !!this._fullscreen;\n\t},\n\n\t_onFullscreenChange() {\n\t\tconst fullscreen = document.fullscreenElement === this._container;\n\t\tif (!fullscreen) {\n\t\t\tDomEvent.off(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t}\n\t\tif (fullscreen !== this.isFullscreen()) {\n\t\t\tthis._setFullscreen(fullscreen && 'native');\n\t\t}\n\t},\n\n\t_onFullscreenKeyDown(e) {\n\t\tif (e.key === 'Escape') {\n\t\t\tthis._setFullscreen(false);\n\t\t}\n\t},\n\n\t// `mode` is `'native'` (Fullscreen API), `'pseudo'` (CSS) or `false`\n\t_setFullscreen(mode) {\n\t\tconst container = this._container;\n\t\tthis._fullscreen = mode;\n\n\t\tcontainer.classList.toggle('maplair-fullscreen', !!mode);\n\t\tcontainer.classList.toggle('maplair-pseudo-fullscreen', mode === 'pseudo');\n\t\tif (mode === 'pseudo') {\n\t\t\tDomEvent.on(document, 'keydown', this._onFullscreenKeyDown, this);\n\t\t} else {\n\t\t\tDomEvent.off(document, 'keydown', this._onFullscreenKeyDown, this);\n\t\t}\n\n\t\tthis.invalidateSize();\n\n\t\tthis.fire(mode ? 'enterfullscreen' : 'exitfullscreen');\n\t\tthis.fire('fullscreenchange');\n\t}\n};\n/** @typedef {typeof mapFullscreenMethods} MapFullscreenMethods */\n\n/**\n * A control with a button to view the map in fullscreen and to exit it again. It is\n * put on the map if you set its [`fullscreenControl` option](#map-fullscreencontrol)\n * to `true`. Where the browser does not support the\n * [Fullscreen API](https://developer.mozilla.org/docs/Web/API/Fullscreen_API)\n * (e.g. Safari on iPhone) or refuses fullscreen (e.g. in an iframe without\n * `allow=\"fullscreen\"`), the map is enlarged to the size of the window instead.\n *\n * @example\n * ```js\n * new FullscreenControl({position: 'topright'}).addTo(map);\n * ```\n */\nexport class FullscreenControl extends Control {\n\n\tstatic {\n\t\tthis.setDefaultOptions({\n\t\t\tposition: 'topleft',\n\t\t\tenterText: enterIcon,\n\t\t\texitText: exitIcon\n\t\t});\n\t}\n\n\t/**\n\t * Creates a fullscreen control.\n\t * @param {...FullscreenControlOptions} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(FullscreenControl);\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t * @returns {HTMLElement}\n\t */\n\tonAdd(map) {\n\t\tconst container = DomUtil.create('div', 'maplair-control-fullscreen maplair-bar'),\n\t\tbutton = this._button = DomUtil.create('button', 'maplair-control-fullscreen-button', container);\n\t\tbutton.type = 'button';\n\n\t\tDomEvent.disableClickPropagation(button);\n\t\tDomEvent.on(button, 'click', DomEvent.stop);\n\t\tDomEvent.on(button, 'click', this._toggleFullscreen, this);\n\t\tDomEvent.on(button, 'click', this._refocusOnMap, this);\n\n\t\tthis._update();\n\t\tmap.on('fullscreenchange', this._update, this);\n\n\t\treturn container;\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tmap.off('fullscreenchange', this._update, this);\n\t}\n\n\t_toggleFullscreen() {\n\t\tthis._map.toggleFullscreen();\n\t}\n\n\t_update() {\n\t\tconst fullscreen = this._map.isFullscreen(),\n\t\ttitle = fullscreen ? I18n.translate('Exit fullscreen') : I18n.translate('View fullscreen');\n\n\t\tthis._button.innerHTML = fullscreen ? this.options.exitText : this.options.enterText;\n\t\tthis._button.title = title;\n\t\tthis._button.setAttribute('aria-label', title);\n\t\tthis._button.setAttribute('aria-pressed', fullscreen);\n\t}\n\n\t/**\n\t * Registers this default feature on the map class, called by `MaplairMap` itself.\n\t * @internal\n\t * @param {typeof MaplairMap} MaplairMap\n\t */\n\tstatic register(MaplairMap) {\n\t\tMaplairMap.mergeOptions({\n\t\t\tfullscreenControl: false\n\t\t});\n\n\t\tMaplairMap.include(mapFullscreenMethods);\n\n\t\tMaplairMap.addInitHook(function () {\n\t\t\tthis.on('unload', function () {\n\t\t\t\tif (this._fullscreen === 'native') {\n\t\t\t\t\tDomEvent.off(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t\t\t\tdocument.exitFullscreen();\n\t\t\t\t}\n\t\t\t\tthis._container.classList.remove('maplair-fullscreen', 'maplair-pseudo-fullscreen');\n\t\t\t\tDomEvent.off(document, 'keydown', this._onFullscreenKeyDown, this);\n\t\t\t\tthis._fullscreen = false;\n\t\t\t});\n\n\t\t\tif (this.options.fullscreenControl) {\n\t\t\t\tthis.fullscreenControl = new FullscreenControl();\n\t\t\t\tthis.addControl(this.fullscreenControl);\n\t\t\t}\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,YAAY;AAClB,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCjB,MAAM,uBAAuB;;;;;;;;CAQ5B,mBAAmB;EAClB,MAAM,YAAY,KAAK;EAEvB,IAAI,KAAK,gBAAgB,UACxB,KAAK,eAAe,KAAK;OACnB,IAAI,KAAK,aACf,SAAS,eAAe;OAClB,IAAI,SAAS,qBAAqB,UAAU,mBAAmB;GACrE,GAAY,UAAU,oBAAoB,KAAK,qBAAqB,IAAI;GACxE,UAAU,kBAAkB,CAAC,CAAC,YAAY;IACzC,IAAa,UAAU,oBAAoB,KAAK,qBAAqB,IAAI;IACzE,KAAK,eAAe,QAAQ;GAC7B,CAAC;EACF,OACC,KAAK,eAAe,QAAQ;EAE7B,OAAO;CACR;;;;;;CAOA,eAAe;EACd,OAAO,CAAC,CAAC,KAAK;CACf;CAEA,sBAAsB;EACrB,MAAM,aAAa,SAAS,sBAAsB,KAAK;EACvD,IAAI,CAAC,YACJ,IAAa,UAAU,oBAAoB,KAAK,qBAAqB,IAAI;EAE1E,IAAI,eAAe,KAAK,aAA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,QAAQ,aAAa,KAAK,UAAU,iBAAiB,IAAI,KAAK,UAAU,iBAAiB;EAEzF,KAAK,QAAQ,YAAY,aAAa,KAAK,QAAQ,WAAW,KAAK,QAAQ;EAC3E,KAAK,QAAQ,QAAQ;EACrB,KAAK,QAAQ,aAAa,cAAc,KAAK;EAC7C,KAAK,QAAQ,aAAa,gBAAgB,UAAU;CACrD;;;;;;CAOA,OAAO,SAAS,YAAY;EAC3B,WAAW,aAAa,EACvB,mBAAmB,MACpB,CAAC;EAED,WAAW,QAAQ,oBAAoB;EAEvC,WAAW,YAAY,WAAY;GAClC,KAAK,GAAG,UAAU,WAAY;IAC7B,IAAI,KAAK,gBAAgB,UAAU;KAClC,IAAa,UAAU,oBAAoB,KAAK,qBAAqB,IAAI;KACzE,SAAS,eAAe;IACzB;IACA,KAAK,WAAW,UAAU,OAAO,sBAAsB,2BAA2B;IAClF,IAAa,UAAU,WAAW,KAAK,sBAAsB,IAAI;IACjE,KAAK,cAAc;GACpB,CAAC;GAED,IAAI,KAAK,QAAQ,mBAAmB;IACnC,KAAK,oBAAoB,IAAI,kBAAkB;IAC/C,KAAK,WAAW,KAAK,iBAAiB;GACvC;EACD,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"FullscreenControl.js","names":["DomUtil.create","DomEvent.stop"],"sources":["../../../src/control/FullscreenControl.js"],"sourcesContent":["import {Control} from './Control.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport {I18n} from '../core/I18n.js';\n/** @import {ControlOptions} from './Control.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n/** @import {MaplairEvent} from '../core/Events.js' */\n\nconst enterIcon = '<svg aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\"><path d=\"M2 2h5v2H4v3H2zm7 0h5v5h-2V4H9zM2 9h2v3h3v2H2zm10 0h2v5H9v-2h3z\"/></svg>';\nconst exitIcon = '<svg aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\"><path d=\"M5 2h2v5H2V5h3zm4 0h2v3h3v2H9zM2 9h5v5H5v-3H2zm7 0h5v2h-3v3H9z\"/></svg>';\n\n/**\n * Options of `FullscreenControl`.\n * @typedef {object} FullscreenControlOptions\n * @property {string} [position='topleft'] The position of the control (one of the map\n * corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or\n * `'bottomright'`.\n * @property {string} [enterText] The HTML content of the button while the map is not in\n * fullscreen, by default an expand icon.\n * @property {string} [exitText] The HTML content of the button while the map is in\n * fullscreen, by default a collapse icon.\n * @extends ControlOptions\n */\n\n/**\n * Map options of `FullscreenControl`.\n * @typedef {object} FullscreenControlMapOptions\n * @lends MaplairMapOptions\n * @property {boolean} [fullscreenControl=false] Whether a\n * [fullscreen control](#fullscreencontrol) is added to the map by default.\n */\n\n/**\n * Properties of `MaplairMap` set by `FullscreenControl`.\n * @typedef {object} FullscreenControlMapProperties\n * @lends MaplairMap\n * @property {FullscreenControl} fullscreenControl The default fullscreen control (only\n * available if the [`fullscreenControl` option](#map-fullscreencontrol) was `true` when\n * creating the map).\n */\n\n/**\n * Methods of `MaplairMap` for the fullscreen view.\n * @lends MaplairMap.prototype\n * @fires MaplairMap#enterfullscreen {MaplairEvent} Fired when the map enters fullscreen.\n * @fires MaplairMap#exitfullscreen {MaplairEvent} Fired when the map exits fullscreen.\n * @fires MaplairMap#fullscreenchange {MaplairEvent} Fired when the map enters or exits\n * fullscreen.\n */\nconst mapFullscreenMethods = {\n\t/**\n\t * Enters or exits the fullscreen view of the map, see `FullscreenControl`.\n\t * Browsers allow entering fullscreen only in response to a user interaction,\n\t * e.g. a click.\n\t * @group Methods for modifying map state\n\t * @returns {this}\n\t */\n\ttoggleFullscreen() {\n\t\tconst container = this._container;\n\n\t\tif (this._fullscreen === 'pseudo') {\n\t\t\tthis._setFullscreen(false);\n\t\t} else if (this._fullscreen) {\n\t\t\tdocument.exitFullscreen();\n\t\t} else if (document.fullscreenEnabled && container.requestFullscreen) {\n\t\t\tDomEvent.on(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t\tcontainer.requestFullscreen().catch(() => {\n\t\t\t\tDomEvent.off(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t\t\tthis._setFullscreen('pseudo');\n\t\t\t});\n\t\t} else {\n\t\t\tthis._setFullscreen('pseudo');\n\t\t}\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` if the map is viewed in fullscreen.\n\t * @group Other methods\n\t * @returns {boolean}\n\t */\n\tisFullscreen() {\n\t\treturn !!this._fullscreen;\n\t},\n\n\t_onFullscreenChange() {\n\t\tconst fullscreen = document.fullscreenElement === this._container;\n\t\tif (!fullscreen) {\n\t\t\tDomEvent.off(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t}\n\t\tif (fullscreen !== this.isFullscreen()) {\n\t\t\tthis._setFullscreen(fullscreen && 'native');\n\t\t}\n\t},\n\n\t_onFullscreenKeyDown(e) {\n\t\tif (e.key === 'Escape') {\n\t\t\tthis._setFullscreen(false);\n\t\t}\n\t},\n\n\t// `mode` is `'native'` (Fullscreen API), `'pseudo'` (CSS) or `false`\n\t_setFullscreen(mode) {\n\t\tconst container = this._container;\n\t\tthis._fullscreen = mode;\n\n\t\tcontainer.classList.toggle('maplair-fullscreen', !!mode);\n\t\tcontainer.classList.toggle('maplair-pseudo-fullscreen', mode === 'pseudo');\n\t\tif (mode === 'pseudo') {\n\t\t\tDomEvent.on(document, 'keydown', this._onFullscreenKeyDown, this);\n\t\t} else {\n\t\t\tDomEvent.off(document, 'keydown', this._onFullscreenKeyDown, this);\n\t\t}\n\n\t\tthis.invalidateSize();\n\n\t\tthis.fire(mode ? 'enterfullscreen' : 'exitfullscreen');\n\t\tthis.fire('fullscreenchange');\n\t}\n};\n/** @typedef {typeof mapFullscreenMethods} MapFullscreenMethods */\n\n/**\n * A control with a button to view the map in fullscreen and to exit it again. It is\n * put on the map if you set its [`fullscreenControl` option](#map-fullscreencontrol)\n * to `true`. Where the browser does not support the\n * [Fullscreen API](https://developer.mozilla.org/docs/Web/API/Fullscreen_API)\n * (e.g. Safari on iPhone) or refuses fullscreen (e.g. in an iframe without\n * `allow=\"fullscreen\"`), the map is enlarged to the size of the window instead.\n *\n * @example\n * ```js\n * new FullscreenControl({position: 'topright'}).addTo(map);\n * ```\n */\nexport class FullscreenControl extends Control {\n\n\tstatic defaultOptions = {\n\t\tposition: 'topleft',\n\t\tenterText: enterIcon,\n\t\texitText: exitIcon\n\t};\n\n\t/**\n\t * Creates a fullscreen control.\n\t * @param {...FullscreenControlOptions} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(FullscreenControl);\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t * @returns {HTMLElement}\n\t */\n\tonAdd(map) {\n\t\tconst container = DomUtil.create('div', 'maplair-control-fullscreen maplair-bar'),\n\t\tbutton = this._button = DomUtil.create('button', 'maplair-control-fullscreen-button', container);\n\t\tbutton.type = 'button';\n\n\t\tDomEvent.disableClickPropagation(button);\n\t\tDomEvent.on(button, 'click', DomEvent.stop);\n\t\tDomEvent.on(button, 'click', this._toggleFullscreen, this);\n\t\tDomEvent.on(button, 'click', this._refocusOnMap, this);\n\n\t\tthis._update();\n\t\tmap.on('fullscreenchange', this._update, this);\n\n\t\treturn container;\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tmap.off('fullscreenchange', this._update, this);\n\t}\n\n\t_toggleFullscreen() {\n\t\tthis._map.toggleFullscreen();\n\t}\n\n\t_update() {\n\t\tconst fullscreen = this._map.isFullscreen(),\n\t\ttitle = fullscreen ? I18n.translate('Exit fullscreen') : I18n.translate('View fullscreen');\n\n\t\tthis._button.innerHTML = fullscreen ? this.options.exitText : this.options.enterText;\n\t\tthis._button.title = title;\n\t\tthis._button.setAttribute('aria-label', title);\n\t\tthis._button.setAttribute('aria-pressed', fullscreen);\n\t}\n\n\t/**\n\t * Registers this default feature on the map class, called by `MaplairMap` itself.\n\t * @internal\n\t * @param {typeof MaplairMap} MaplairMap\n\t */\n\tstatic register(MaplairMap) {\n\t\tMaplairMap.mergeOptions({\n\t\t\tfullscreenControl: false\n\t\t});\n\n\t\tMaplairMap.include(mapFullscreenMethods);\n\n\t\tMaplairMap.addInitHook(function () {\n\t\t\tthis.on('unload', function () {\n\t\t\t\tif (this._fullscreen === 'native') {\n\t\t\t\t\tDomEvent.off(document, 'fullscreenchange', this._onFullscreenChange, this);\n\t\t\t\t\tdocument.exitFullscreen();\n\t\t\t\t}\n\t\t\t\tthis._container.classList.remove('maplair-fullscreen', 'maplair-pseudo-fullscreen');\n\t\t\t\tDomEvent.off(document, 'keydown', this._onFullscreenKeyDown, this);\n\t\t\t\tthis._fullscreen = false;\n\t\t\t});\n\n\t\t\tif (this.options.fullscreenControl) {\n\t\t\t\tthis.fullscreenControl = new FullscreenControl();\n\t\t\t\tthis.addControl(this.fullscreenControl);\n\t\t\t}\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,YAAY;AAClB,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCjB,MAAM,uBAAuB;;;;;;;;CAQ5B,mBAAmB;EAClB,MAAM,YAAY,KAAK;EAEvB,IAAI,KAAK,gBAAgB,UACxB,KAAK,eAAe,KAAK;OACnB,IAAI,KAAK,aACf,SAAS,eAAe;OAClB,IAAI,SAAS,qBAAqB,UAAU,mBAAmB;GACrE,GAAY,UAAU,oBAAoB,KAAK,qBAAqB,IAAI;GACxE,UAAU,kBAAkB,CAAC,CAAC,YAAY;IACzC,IAAa,UAAU,oBAAoB,KAAK,qBAAqB,IAAI;IACzE,KAAK,eAAe,QAAQ;GAC7B,CAAC;EACF,OACC,KAAK,eAAe,QAAQ;EAE7B,OAAO;CACR;;;;;;CAOA,eAAe;EACd,OAAO,CAA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ACb,IAAI,IAAI,oBAAoB,KAAK,SAAS,IAAI;CAC/C;CAEA,oBAAoB;EACnB,KAAK,KAAK,iBAAiB;CAC5B;CAEA,UAAU;EACT,MAAM,aAAa,KAAK,KAAK,aAAa,GAC1C,QAAQ,aAAa,KAAK,UAAU,iBAAiB,IAAI,KAAK,UAAU,iBAAiB;EAEzF,KAAK,QAAQ,YAAY,aAAa,KAAK,QAAQ,WAAW,KAAK,QAAQ;EAC3E,KAAK,QAAQ,QAAQ;EACrB,KAAK,QAAQ,aAAa,cAAc,KAAK;EAC7C,KAAK,QAAQ,aAAa,gBAAgB,UAAU;CACrD;;;;;;CAOA,OAAO,SAAS,YAAY;EAC3B,WAAW,aAAa,EACvB,mBAAmB,MACpB,CAAC;EAED,WAAW,QAAQ,oBAAoB;EAEvC,WAAW,YAAY,WAAY;GAClC,KAAK,GAAG,UAAU,WAAY;IAC7B,IAAI,KAAK,gBAAgB,UAAU;KAClC,IAAa,UAAU,oBAAoB,KAAK,qBAAqB,IAAI;KACzE,SAAS,eAAe;IACzB;IACA,KAAK,WAAW,UAAU,OAAO,sBAAsB,2BAA2B;IAClF,IAAa,UAAU,WAAW,KAAK,sBAAsB,IAAI;IACjE,KAAK,cAAc;GACpB,CAAC;GAED,IAAI,KAAK,QAAQ,mBAAmB;IACnC,KAAK,oBAAoB,IAAI,kBAAkB;IAC/C,KAAK,WAAW,KAAK,iBAAiB;GACvC;EACD,CAAC;CACF;AACD"}
@@ -9,10 +9,40 @@ import { I18n } from "../core/I18n.js";
9
9
  /** @import {Layer} from '../layer/Layer.js' */
10
10
  /** @import {LayersControlEvent} from '../core/Events.js' */
11
11
  /**
12
+ * An entry of `LayersControl`, as returned by `getLayers()`.
13
+ * @typedef {object} LayersControlEntry
14
+ * @property {Layer} layer The layer.
15
+ * @property {string} name The name of the layer, as given to the control.
16
+ * @property {boolean} overlay Whether the layer is an overlay (checkbox) or a base layer
17
+ * (radio button).
18
+ */
19
+ /**
20
+ * The group of an entry of `LayersControl`, as returned by the option `groupBy`.
21
+ * @typedef {object} LayersControlGroup
22
+ * @property {string} group The name of the group, rendered as text.
23
+ * @property {string} label The label of the entry within the group, may contain HTML
24
+ * (like layer names).
25
+ */
26
+ /**
12
27
  * Options of `LayersControl`.
13
28
  * @typedef {object} LayersControlOptions
14
29
  * @property {boolean} [collapsed=true] If `true`, the control will be collapsed into an
15
- * icon and expanded on pointer hover, touch, or keyboard activation.
30
+ * icon and expanded on pointer hover, touch, or keyboard activation. Ignored if `inline`
31
+ * is `true`.
32
+ * @property {boolean} [inline=false] If `true`, the control is laid out like the
33
+ * attribution control: it is always expanded (without toggle button) and all entries are
34
+ * placed next to each other, wrapping onto multiple lines if necessary.
35
+ * @property {(name: string, layer: Layer, overlay: boolean) => LayersControlGroup | undefined} [groupBy]
36
+ * A function to group the entries. For each entry, it returns the name of its group and
37
+ * its label within the group, or `undefined` for an ungrouped entry. Consecutive entries
38
+ * of the same group (base layers and overlays separately) are rendered within one
39
+ * `maplair-control-layers-group` container, starting with the group name in a
40
+ * `maplair-control-layers-group-name` element, and each entry shows only its label.
41
+ * Events like `baselayerchange` still carry the full `name`. When combined with
42
+ * `sortLayers`, the entries are sorted first and grouped afterwards.
43
+ * @property {string|HTMLElement} [toggleContent] The content of the toggle button of a
44
+ * collapsed control instead of the layers icon: HTML (e.g. an icon or a character) or an
45
+ * element. String content is rendered as HTML; do not pass untrusted input.
16
46
  * @property {number} [collapseDelay=0] Collapse delay in milliseconds. If greater than 0,
17
47
  * the control will remain open longer, making it easier to scroll through long layer
18
48
  * lists.
@@ -69,6 +99,19 @@ import { I18n } from "../core/I18n.js";
69
99
  * {"<img src='my-layer-icon' /> <span class='my-layer-item'>My Layer</span>": myLayer}
70
100
  * ```
71
101
  *
102
+ * Layers can be grouped using the option `groupBy`, for example layer names of the form
103
+ * `"Group (label)"`:
104
+ *
105
+ * ```js
106
+ * new LayersControl(baseLayers, overlays, {
107
+ * inline: true,
108
+ * groupBy(name) {
109
+ * const [, group, label] = /^([^<>()]+) \((.+)\)$/.exec(name) ?? [];
110
+ * return group ? {group: `${group}:`, label} : undefined;
111
+ * }
112
+ * }).addTo(map);
113
+ * ```
114
+ *
72
115
  * @fires MaplairMap#baselayerchange {LayersControlEvent} Fired when the base layer is
73
116
  * changed through the [layers control](#control-layers).
74
117
  * @fires MaplairMap#overlayadd {LayersControlEvent} Fired when an overlay is selected
@@ -77,19 +120,20 @@ import { I18n } from "../core/I18n.js";
77
120
  * deselected through the [layers control](#control-layers).
78
121
  */
79
122
  var LayersControl = class LayersControl extends Control {
80
- static {
81
- this.setDefaultOptions({
82
- collapsed: true,
83
- collapseDelay: 0,
84
- position: "topright",
85
- autoZIndex: true,
86
- hideSingleBase: false,
87
- sortLayers: false,
88
- sortFunction(layerA, layerB, nameA, nameB) {
89
- return nameA < nameB ? -1 : nameB < nameA ? 1 : 0;
90
- }
91
- });
92
- }
123
+ static defaultOptions = {
124
+ collapsed: true,
125
+ inline: false,
126
+ groupBy: void 0,
127
+ toggleContent: void 0,
128
+ collapseDelay: 0,
129
+ position: "topright",
130
+ autoZIndex: true,
131
+ hideSingleBase: false,
132
+ sortLayers: false,
133
+ sortFunction(layerA, layerB, nameA, nameB) {
134
+ return nameA < nameB ? -1 : nameB < nameA ? 1 : 0;
135
+ }
136
+ };
93
137
  /**
94
138
  * Creates a layers control with the given layers. Base layers will be switched with
95
139
  * radio buttons, while overlays will be switched with checkboxes. Note that all base
@@ -121,7 +165,7 @@ var LayersControl = class LayersControl extends Control {
121
165
  this._map = map;
122
166
  map.on("zoomend", this._checkDisabledLayers, this);
123
167
  for (const layer of this._layers) layer.layer.on("add remove", this._onLayerChange, this);
124
- if (!this.options.collapsed) map.on("resize", this._expandIfNotCollapsed, this);
168
+ if (!this._isCollapsible()) map.on("resize", this._expandIfNotCollapsed, this);
125
169
  return this._container;
126
170
  }
127
171
  /**
@@ -171,13 +215,41 @@ var LayersControl = class LayersControl extends Control {
171
215
  return this._map ? this._update() : this;
172
216
  }
173
217
  /**
218
+ * Returns the entries of the control in the order they are displayed.
219
+ * @returns {LayersControlEntry[]}
220
+ */
221
+ getLayers() {
222
+ return this._layers.map(({ layer, name, overlay }) => ({
223
+ layer,
224
+ name,
225
+ overlay
226
+ }));
227
+ }
228
+ /**
229
+ * Selects the given layer of the control like a click on its entry: a base layer
230
+ * replaces the current base layer, an overlay is added to the map. The events
231
+ * `baselayerchange` and `overlayadd` are fired as for a click, but without
232
+ * `originalEvent`. Has no effect if the control is not on a map or does not contain
233
+ * the layer.
234
+ * @param {Layer} layer
235
+ * @returns {this}
236
+ */
237
+ selectLayer(layer) {
238
+ const input = this._layerControlInputs.find((input) => input.layerId === stamp(layer));
239
+ if (input && !input.checked) {
240
+ input.checked = true;
241
+ this._onInputClick();
242
+ }
243
+ return this;
244
+ }
245
+ /**
174
246
  * Expand the control container if collapsed.
175
247
  * @returns {this}
176
248
  */
177
249
  expand() {
178
250
  clearTimeout(this._collapseDelayTimeout);
179
251
  this._container.classList.add("maplair-control-layers-expanded");
180
- this._section.style.height = null;
252
+ this._section.style.height = "";
181
253
  const acceptableHeight = this._map.getSize().y - (this._container.offsetTop + 50);
182
254
  if (acceptableHeight < this._section.clientHeight) {
183
255
  this._section.classList.add("maplair-control-layers-scrollbar");
@@ -193,6 +265,7 @@ var LayersControl = class LayersControl extends Control {
193
265
  * @returns {this}
194
266
  */
195
267
  collapse(ev) {
268
+ if (this.options.inline) return this;
196
269
  if (!ev || !((ev.type === "pointerleave" || ev.type === "pointerout") && ev.pointerType === "touch")) {
197
270
  if (this.options.collapseDelay > 0) {
198
271
  this._collapseDelayTimeout = setTimeout(() => {
@@ -205,10 +278,12 @@ var LayersControl = class LayersControl extends Control {
205
278
  return this;
206
279
  }
207
280
  _initLayout() {
208
- const className = "maplair-control-layers", container = this._container = create("div", className), collapsed = this.options.collapsed;
281
+ const className = "maplair-control-layers", container = this._container = create("div", className), collapsed = this._isCollapsible();
282
+ if (this.options.inline) container.classList.add(`${className}-inline`);
209
283
  disableClickPropagation(container);
210
284
  disableScrollPropagation(container);
211
285
  const section = this._section = create("fieldset", `${className}-list`);
286
+ section.setAttribute("aria-label", I18n.translate("Layers"));
212
287
  if (collapsed) {
213
288
  this._map.on("click", this.collapse, this);
214
289
  on(container, {
@@ -216,19 +291,24 @@ var LayersControl = class LayersControl extends Control {
216
291
  pointerleave: this.collapse
217
292
  }, this);
218
293
  }
219
- const link = this._layersLink = create("button", `${className}-toggle`, container);
220
- link.type = "button";
221
- link.title = I18n.translate("Layers");
222
- link.setAttribute("aria-label", I18n.translate("Layers"));
223
- on(link, {
224
- keydown(e) {
225
- if (e.code === "Enter") this._expandSafely();
226
- },
227
- click(e) {
228
- e.preventDefault();
229
- this._expandSafely();
230
- }
231
- }, this);
294
+ if (!this.options.inline) {
295
+ const link = this._layersLink = create("button", `${className}-toggle`, container);
296
+ link.type = "button";
297
+ link.title = I18n.translate("Layers");
298
+ link.setAttribute("aria-label", I18n.translate("Layers"));
299
+ const { toggleContent } = this.options;
300
+ if (typeof toggleContent === "string") link.innerHTML = toggleContent;
301
+ else if (toggleContent) link.replaceChildren(toggleContent);
302
+ on(link, {
303
+ keydown(e) {
304
+ if (e.code === "Enter") this._expandSafely();
305
+ },
306
+ click(e) {
307
+ e.preventDefault();
308
+ this._expandSafely();
309
+ }
310
+ }, this);
311
+ }
232
312
  if (!collapsed) this.expand();
233
313
  this._baseLayersList = create("div", `${className}-base`, section);
234
314
  this._separator = create("div", `${className}-separator`, section);
@@ -243,7 +323,7 @@ var LayersControl = class LayersControl extends Control {
243
323
  this._layers.push({
244
324
  layer,
245
325
  name,
246
- overlay
326
+ overlay: !!overlay
247
327
  });
248
328
  if (this.options.sortLayers) this._layers.sort(((a, b) => this.options.sortFunction(a.layer, b.layer, a.name, b.name)));
249
329
  if (this.options.autoZIndex && layer.setZIndex) {
@@ -257,6 +337,7 @@ var LayersControl = class LayersControl extends Control {
257
337
  this._baseLayersList.replaceChildren();
258
338
  this._overlaysList.replaceChildren();
259
339
  this._layerControlInputs = [];
340
+ this._groupCount = 0;
260
341
  let baseLayersPresent, overlaysPresent, baseLayersCount = 0;
261
342
  for (const obj of this._layers) {
262
343
  this._addItem(obj);
@@ -275,7 +356,10 @@ var LayersControl = class LayersControl extends Control {
275
356
  if (!this._handlingClick) this._update();
276
357
  const obj = this._getLayer(stamp(e.target));
277
358
  const type = obj.overlay ? e.type === "add" ? "overlayadd" : "overlayremove" : e.type === "add" ? "baselayerchange" : null;
278
- if (type) this._map.fire(type, obj);
359
+ if (type) this._map.fire(type, this._clickEvent ? {
360
+ ...obj,
361
+ originalEvent: this._clickEvent
362
+ } : obj);
279
363
  }
280
364
  _addItem(obj) {
281
365
  const label = document.createElement("label"), checked = this._map.hasLayer(obj.layer);
@@ -287,20 +371,41 @@ var LayersControl = class LayersControl extends Control {
287
371
  this._layerControlInputs.push(input);
288
372
  input.layerId = stamp(obj.layer);
289
373
  on(input, "click", this._onInputClick, this);
374
+ const group = this.options.groupBy?.(obj.name, obj.layer, obj.overlay);
290
375
  const name = document.createElement("span");
291
- name.innerHTML = ` ${obj.name}`;
376
+ name.innerHTML = ` ${group ? group.label : obj.name}`;
292
377
  const holder = document.createElement("span");
293
378
  label.appendChild(holder);
294
379
  holder.appendChild(input);
295
380
  holder.appendChild(name);
296
- (obj.overlay ? this._overlaysList : this._baseLayersList).appendChild(label);
381
+ const list = obj.overlay ? this._overlaysList : this._baseLayersList;
382
+ (group ? this._getGroupContainer(list, group.group) : list).appendChild(label);
297
383
  this._checkDisabledLayers();
298
384
  return label;
299
385
  }
386
+ /**
387
+ * Returns the container of the given group if it is the last element in `list`
388
+ * (continuing the group), otherwise appends a new group container to `list`.
389
+ * @param {HTMLElement} list
390
+ * @param {string} group
391
+ * @returns {HTMLElement}
392
+ */
393
+ _getGroupContainer(list, group) {
394
+ const last = list.lastElementChild;
395
+ if (last?._maplairGroup === group) return last;
396
+ const className = "maplair-control-layers-group", container = create("div", className, list), name = create("span", `${className}-name`, container);
397
+ name.id = `${className}_${stamp(this)}_${++this._groupCount}`;
398
+ name.textContent = group;
399
+ container.setAttribute("role", "group");
400
+ container.setAttribute("aria-labelledby", name.id);
401
+ container._maplairGroup = group;
402
+ return container;
403
+ }
300
404
  _onInputClick(e) {
301
405
  if (this._preventClick) return;
302
406
  const inputs = this._layerControlInputs, addedLayers = [], removedLayers = [];
303
407
  this._handlingClick = true;
408
+ this._clickEvent = e;
304
409
  for (const input of inputs) {
305
410
  const layer = this._getLayer(input.layerId).layer;
306
411
  if (input.checked) addedLayers.push(layer);
@@ -309,6 +414,7 @@ var LayersControl = class LayersControl extends Control {
309
414
  for (const layer of removedLayers) if (this._map.hasLayer(layer)) this._map.removeLayer(layer);
310
415
  for (const layer of addedLayers) if (!this._map.hasLayer(layer)) this._map.addLayer(layer);
311
416
  this._handlingClick = false;
417
+ this._clickEvent = void 0;
312
418
  this._refocusOnMap(e);
313
419
  }
314
420
  _checkDisabledLayers() {
@@ -318,8 +424,11 @@ var LayersControl = class LayersControl extends Control {
318
424
  input.disabled = layer.options.minZoom !== void 0 && zoom < layer.options.minZoom || layer.options.maxZoom !== void 0 && zoom > layer.options.maxZoom;
319
425
  }
320
426
  }
427
+ _isCollapsible() {
428
+ return this.options.collapsed && !this.options.inline;
429
+ }
321
430
  _expandIfNotCollapsed() {
322
- if (this._map && !this.options.collapsed) this.expand();
431
+ if (this._map && !this._isCollapsible()) this.expand();
323
432
  return this;
324
433
  }
325
434
  _expandSafely() {
@@ -1 +1 @@
1
- {"version":3,"file":"LayersControl.js","names":["Util.stamp","DomUtil.create","DomEvent.preventDefault"],"sources":["../../../src/control/LayersControl.js"],"sourcesContent":["\nimport {Control} from './Control.js';\nimport * as Util from '../core/Util.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/** @import {Layer} from '../layer/Layer.js' */\n/** @import {LayersControlEvent} from '../core/Events.js' */\n\n/**\n * Options of `LayersControl`.\n * @typedef {object} LayersControlOptions\n * @property {boolean} [collapsed=true] If `true`, the control will be collapsed into an\n * icon and expanded on pointer hover, touch, or keyboard activation.\n * @property {number} [collapseDelay=0] Collapse delay in milliseconds. If greater than 0,\n * the control will remain open longer, making it easier to scroll through long layer\n * lists.\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 {boolean} [autoZIndex=true] If `true`, the control will assign zIndexes in\n * increasing order to all of its layers so that the order is preserved when switching\n * them on/off.\n * @property {boolean} [hideSingleBase=false] If `true`, the base layers in the control\n * will be hidden when there is only one.\n * @property {boolean} [sortLayers=false] Whether to sort the layers. When `false`, layers\n * will keep the order in which they were added to the control.\n * @property {(layerA: Layer, layerB: Layer, nameA: string, nameB: string) => number} [sortFunction]\n * A [compare function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)\n * that will be used for sorting the layers, when `sortLayers` is `true`. The function\n * receives both the `Layer` instances and their names, as in\n * `sortFunction(layerA, layerB, nameA, nameB)`. By default, it sorts layers\n * alphabetically by their name.\n * @extends ControlOptions\n */\n\n/**\n * The layers control gives users the ability to switch between different base layers\n * and switch overlays on/off (check out the\n * [detailed example](https://maplair.org/examples/layers-control/)).\n *\n * @example\n * ```js\n * const baseLayers = {\n * \t\"Mapbox\": mapbox,\n * \t\"OpenStreetMap\": osm\n * };\n *\n * const overlays = {\n * \t\"Marker\": marker,\n * \t\"Roads\": roadsLayer\n * };\n *\n * new LayersControl(baseLayers, overlays).addTo(map);\n * ```\n *\n * The `baseLayers` and `overlays` parameters are object literals with layer names as keys and `Layer` objects as values:\n *\n * ```js\n * {\n * \"<someName1>\": layer1,\n * \"<someName2>\": layer2\n * }\n * ```\n *\n * The layer names can contain HTML, which allows you to add additional styling to the items:\n *\n * ```js\n * {\"<img src='my-layer-icon' /> <span class='my-layer-item'>My Layer</span>\": myLayer}\n * ```\n *\n * @fires MaplairMap#baselayerchange {LayersControlEvent} Fired when the base layer is\n * changed through the [layers control](#control-layers).\n * @fires MaplairMap#overlayadd {LayersControlEvent} Fired when an overlay is selected\n * through the [layers control](#control-layers).\n * @fires MaplairMap#overlayremove {LayersControlEvent} Fired when an overlay is\n * deselected through the [layers control](#control-layers).\n */\nexport class LayersControl extends Control {\n\n\tstatic {\n\t\tthis.setDefaultOptions({\n\t\t\tcollapsed: true,\n\t\t\tcollapseDelay: 0,\n\t\t\tposition: 'topright',\n\t\t\tautoZIndex: true,\n\t\t\thideSingleBase: false,\n\t\t\tsortLayers: false,\n\t\t\tsortFunction(layerA, layerB, nameA, nameB) {\n\t\t\t\treturn nameA < nameB ? -1 : (nameB < nameA ? 1 : 0);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Creates a layers control with the given layers. Base layers will be switched with\n\t * radio buttons, while overlays will be switched with checkboxes. Note that all base\n\t * layers should be passed in the base layers object, but only one should be added to\n\t * the map during map instantiation.\n\t * @param {Record<string, Layer>} [baseLayers]\n\t * @param {Record<string, Layer>} [overlays]\n\t * @param {LayersControlOptions} [options]\n\t */\n\tconstructor(baseLayers, overlays, options) {\n\t\tsuper(options);\n\n\t\tthis._layerControlInputs = [];\n\t\tthis._layers = [];\n\t\tthis._lastZIndex = 0;\n\t\tthis._handlingClick = false;\n\t\tthis._preventClick = false;\n\n\t\tfor (const [name, layer] of Object.entries(baseLayers ?? {})) {\n\t\t\tthis._addLayer(layer, name);\n\t\t}\n\n\t\tfor (const [name, layer] of Object.entries(overlays ?? {})) {\n\t\t\tthis._addLayer(layer, name, true);\n\t\t}\n\n\t\tthis.callInitHooks(LayersControl);\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t * @returns {HTMLElement}\n\t */\n\tonAdd(map) {\n\t\tthis._initLayout();\n\t\tthis._update();\n\n\t\tthis._map = map;\n\t\tmap.on('zoomend', this._checkDisabledLayers, this);\n\n\t\tfor (const layer of this._layers) {\n\t\t\tlayer.layer.on('add remove', this._onLayerChange, this);\n\t\t}\n\n\t\tif (!this.options.collapsed) {\n\t\t\t// update the height of the container after resizing the window\n\t\t\tmap.on('resize', this._expandIfNotCollapsed, this);\n\t\t}\n\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\tsuper.addTo(map);\n\t\t// Trigger expand after Layers Control has been inserted into DOM so that is now has an actual height.\n\t\treturn this._expandIfNotCollapsed();\n\t}\n\n\t/** @internal */\n\tonRemove() {\n\t\tthis._map.off('zoomend', this._checkDisabledLayers, this);\n\n\t\tfor (const layer of this._layers) {\n\t\t\tlayer.layer.off('add remove', this._onLayerChange, this);\n\t\t}\n\n\t\tthis._map.off('resize', this._expandIfNotCollapsed, this);\n\t}\n\n\t/**\n\t * Adds a base layer (radio button entry) with the given name to the control.\n\t * @param {Layer} layer\n\t * @param {string} name\n\t * @returns {this}\n\t */\n\taddBaseLayer(layer, name) {\n\t\tthis._addLayer(layer, name);\n\t\treturn (this._map) ? this._update() : this;\n\t}\n\n\t/**\n\t * Adds an overlay (checkbox entry) with the given name to the control.\n\t * @param {Layer} layer\n\t * @param {string} name\n\t * @returns {this}\n\t */\n\taddOverlay(layer, name) {\n\t\tthis._addLayer(layer, name, true);\n\t\treturn (this._map) ? this._update() : this;\n\t}\n\n\t/**\n\t * Remove the given layer from the control.\n\t * @param {Layer} layer\n\t * @returns {this}\n\t */\n\tremoveLayer(layer) {\n\t\tlayer.off('add remove', this._onLayerChange, this);\n\n\t\tconst obj = this._getLayer(Util.stamp(layer));\n\t\tif (obj) {\n\t\t\tthis._layers.splice(this._layers.indexOf(obj), 1);\n\t\t}\n\t\treturn (this._map) ? this._update() : this;\n\t}\n\n\t/**\n\t * Expand the control container if collapsed.\n\t * @returns {this}\n\t */\n\texpand() {\n\t\tclearTimeout(this._collapseDelayTimeout);\n\n\t\tthis._container.classList.add('maplair-control-layers-expanded');\n\t\tthis._section.style.height = null;\n\t\tconst acceptableHeight = this._map.getSize().y - (this._container.offsetTop + 50);\n\t\tif (acceptableHeight < this._section.clientHeight) {\n\t\t\tthis._section.classList.add('maplair-control-layers-scrollbar');\n\t\t\tthis._section.style.height = `${acceptableHeight}px`;\n\t\t} else {\n\t\t\tthis._section.classList.remove('maplair-control-layers-scrollbar');\n\t\t}\n\t\tthis._checkDisabledLayers();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Collapse the control container if expanded.\n\t * @param {Event} [ev] The event causing the collapse, if any (collapsing is skipped\n\t * for `pointerleave` and `pointerout` of touch).\n\t * @returns {this}\n\t */\n\tcollapse(ev) {\n\t\t// On touch devices `pointerleave` & `pointerout` is fired while clicking on a checkbox.\n\t\t// The control was collapsed instead of adding the layer to the map.\n\t\t// So we allow collapse only if it is not touch.\n\t\tif (!ev || !((ev.type === 'pointerleave' || ev.type === 'pointerout') && ev.pointerType === 'touch')) {\n\t\t\tif (this.options.collapseDelay > 0) {\n\t\t\t\t// Collapse delayed\n\t\t\t\tthis._collapseDelayTimeout = setTimeout(() => {\n\t\t\t\t\tthis._container.classList.remove('maplair-control-layers-expanded');\n\t\t\t\t}, this.options.collapseDelay);\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\t// Collapse immediately\n\t\t\tthis._container.classList.remove('maplair-control-layers-expanded');\n\t\t}\n\t\treturn this;\n\t}\n\n\t_initLayout() {\n\t\tconst className = 'maplair-control-layers',\n\t\tcontainer = this._container = DomUtil.create('div', className),\n\t\tcollapsed = this.options.collapsed;\n\n\t\tDomEvent.disableClickPropagation(container);\n\t\tDomEvent.disableScrollPropagation(container);\n\n\t\tconst section = this._section = DomUtil.create('fieldset', `${className}-list`);\n\n\t\tif (collapsed) {\n\t\t\tthis._map.on('click', this.collapse, this);\n\n\t\t\tDomEvent.on(container, {\n\t\t\t\tpointerenter: this._expandSafely,\n\t\t\t\tpointerleave: this.collapse\n\t\t\t}, this);\n\t\t}\n\n\t\tconst link = this._layersLink = DomUtil.create('button', `${className}-toggle`, container);\n\t\tlink.type = 'button';\n\t\tlink.title = I18n.translate('Layers');\n\t\tlink.setAttribute('aria-label', I18n.translate('Layers'));\n\n\t\tDomEvent.on(link, {\n\t\t\tkeydown(e) {\n\t\t\t\tif (e.code === 'Enter') {\n\t\t\t\t\tthis._expandSafely();\n\t\t\t\t}\n\t\t\t},\n\t\t\t// Certain screen readers intercept the key event and instead send a click event\n\t\t\tclick(e) {\n\t\t\t\te.preventDefault();\n\t\t\t\tthis._expandSafely();\n\t\t\t}\n\t\t}, this);\n\n\t\tif (!collapsed) {\n\t\t\tthis.expand();\n\t\t}\n\n\t\tthis._baseLayersList = DomUtil.create('div', `${className}-base`, section);\n\t\tthis._separator = DomUtil.create('div', `${className}-separator`, section);\n\t\tthis._overlaysList = DomUtil.create('div', `${className}-overlays`, section);\n\n\t\tcontainer.appendChild(section);\n\t}\n\n\t_getLayer(id) {\n\t\tfor (const layer of this._layers) {\n\t\t\tif (layer && Util.stamp(layer.layer) === id) {\n\t\t\t\treturn layer;\n\t\t\t}\n\t\t}\n\t}\n\n\t_addLayer(layer, name, overlay) {\n\t\tif (this._map) {\n\t\t\tlayer.on('add remove', this._onLayerChange, this);\n\t\t}\n\n\t\tthis._layers.push({\n\t\t\tlayer,\n\t\t\tname,\n\t\t\toverlay\n\t\t});\n\n\t\tif (this.options.sortLayers) {\n\t\t\tthis._layers.sort(((a, b) => this.options.sortFunction(a.layer, b.layer, a.name, b.name)));\n\t\t}\n\n\t\tif (this.options.autoZIndex && layer.setZIndex) {\n\t\t\tthis._lastZIndex++;\n\t\t\tlayer.setZIndex(this._lastZIndex);\n\t\t}\n\n\t\tthis._expandIfNotCollapsed();\n\t}\n\n\t_update() {\n\t\tif (!this._container) { return this; }\n\n\t\tthis._baseLayersList.replaceChildren();\n\t\tthis._overlaysList.replaceChildren();\n\n\t\tthis._layerControlInputs = [];\n\t\tlet baseLayersPresent, overlaysPresent, baseLayersCount = 0;\n\n\t\tfor (const obj of this._layers) {\n\t\t\tthis._addItem(obj);\n\t\t\toverlaysPresent ||= obj.overlay;\n\t\t\tbaseLayersPresent ||= !obj.overlay;\n\t\t\tbaseLayersCount += !obj.overlay ? 1 : 0;\n\t\t}\n\n\t\t// Hide base layers section if there's only one layer.\n\t\tif (this.options.hideSingleBase) {\n\t\t\tbaseLayersPresent = baseLayersPresent && baseLayersCount > 1;\n\t\t\tthis._baseLayersList.style.display = baseLayersPresent ? '' : 'none';\n\t\t}\n\n\t\tthis._separator.style.display = overlaysPresent && baseLayersPresent ? '' : 'none';\n\n\t\treturn this;\n\t}\n\n\t_onLayerChange(e) {\n\t\tif (!this._handlingClick) {\n\t\t\tthis._update();\n\t\t}\n\n\t\tconst obj = this._getLayer(Util.stamp(e.target));\n\n\t\tconst type = obj.overlay ?\n\t\t\t(e.type === 'add' ? 'overlayadd' : 'overlayremove') :\n\t\t\t(e.type === 'add' ? 'baselayerchange' : null);\n\n\t\tif (type) {\n\t\t\tthis._map.fire(type, obj);\n\t\t}\n\t}\n\n\t_addItem(obj) {\n\t\tconst label = document.createElement('label'),\n\t\tchecked = this._map.hasLayer(obj.layer);\n\n\t\tconst input = document.createElement('input');\n\t\tinput.type = obj.overlay ? 'checkbox' : 'radio';\n\t\tinput.className = 'maplair-control-layers-selector';\n\t\tinput.defaultChecked = checked;\n\t\tif (!obj.overlay) {\n\t\t\tinput.name = `maplair-base-layers_${Util.stamp(this)}`;\n\t\t}\n\n\t\tthis._layerControlInputs.push(input);\n\t\tinput.layerId = Util.stamp(obj.layer);\n\n\t\tDomEvent.on(input, 'click', this._onInputClick, this);\n\n\t\tconst name = document.createElement('span');\n\t\tname.innerHTML = ` ${obj.name}`;\n\n\t\t// Helps from preventing layer control flicker when checkboxes are disabled\n\t\t// https://github.com/Leaflet/Leaflet/issues/2771\n\t\tconst holder = document.createElement('span');\n\n\t\tlabel.appendChild(holder);\n\t\tholder.appendChild(input);\n\t\tholder.appendChild(name);\n\n\t\tconst container = obj.overlay ? this._overlaysList : this._baseLayersList;\n\t\tcontainer.appendChild(label);\n\n\t\tthis._checkDisabledLayers();\n\t\treturn label;\n\t}\n\n\t_onInputClick(e) {\n\t\t// expanding the control on mobile with a click can cause adding a layer - we don't want this\n\t\tif (this._preventClick) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst inputs = this._layerControlInputs,\n\t\taddedLayers = [],\n\t\tremovedLayers = [];\n\n\t\tthis._handlingClick = true;\n\n\t\tfor (const input of inputs) {\n\t\t\tconst layer = this._getLayer(input.layerId).layer;\n\n\t\t\tif (input.checked) {\n\t\t\t\taddedLayers.push(layer);\n\t\t\t} else if (!input.checked) {\n\t\t\t\tremovedLayers.push(layer);\n\t\t\t}\n\t\t}\n\n\t\t// Bugfix issue 2318: Should remove all old layers before readding new ones\n\t\tfor (const layer of removedLayers) {\n\t\t\tif (this._map.hasLayer(layer)) {\n\t\t\t\tthis._map.removeLayer(layer);\n\t\t\t}\n\t\t}\n\t\tfor (const layer of addedLayers) {\n\t\t\tif (!this._map.hasLayer(layer)) {\n\t\t\t\tthis._map.addLayer(layer);\n\t\t\t}\n\t\t}\n\n\t\tthis._handlingClick = false;\n\n\t\tthis._refocusOnMap(e);\n\t}\n\n\t_checkDisabledLayers() {\n\t\tconst inputs = this._layerControlInputs,\n\t\tzoom = this._map.getZoom();\n\n\t\tfor (const input of inputs) {\n\t\t\tconst layer = this._getLayer(input.layerId).layer;\n\t\t\tinput.disabled = (layer.options.minZoom !== undefined && zoom < layer.options.minZoom) ||\n\t\t\t (layer.options.maxZoom !== undefined && zoom > layer.options.maxZoom);\n\n\t\t}\n\t}\n\n\t_expandIfNotCollapsed() {\n\t\tif (this._map && !this.options.collapsed) {\n\t\t\tthis.expand();\n\t\t}\n\t\treturn this;\n\t}\n\n\t_expandSafely() {\n\t\tconst section = this._section;\n\t\tthis._preventClick = true;\n\t\tDomEvent.on(section, 'click', DomEvent.preventDefault);\n\t\tthis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,OAAO,KAAK,KAAK,QAAQ;EAEzB,KAAK,MAAM,SAAS,QAAQ;GAC3B,MAAM,QAAQ,KAAK,UAAU,MAAM,OAAO,CAAC,CAAC;GAC5C,MAAM,WAAY,MAAM,QAAQ,YAAY,KAAA,KAAa,OAAO,MAAM,QAAQ,WAC5D,MAAM,QAAQ,YAAY,KAAA,KAAa,OAAO,MAAM,QAAQ;EAE/E;CACD;CAEA,wBAAwB;EACvB,IAAI,KAAK,QAAQ,CAAC,KAAK,QAAQ,WAC9B,KAAK,OAAO;EAEb,OAAO;CACR;CAEA,gBAAgB;EACf,MAAM,UAAU,KAAK;EACrB,KAAK,gBAAgB;EACrB,GAAY,SAAS,SAASE,cAAuB;EACrD,KAAK,OAAO;EACZ,iBAAiB;GAChB,IAAa,SAAS,SAASA,cAAuB;GACtD,KAAK,gBAAgB;EACtB,CAAC;CACF;AAED"}
1
+ {"version":3,"file":"LayersControl.js","names":["Util.stamp","DomUtil.create","DomEvent.preventDefault"],"sources":["../../../src/control/LayersControl.js"],"sourcesContent":["\nimport {Control} from './Control.js';\nimport * as Util from '../core/Util.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/** @import {Layer} from '../layer/Layer.js' */\n/** @import {LayersControlEvent} from '../core/Events.js' */\n\n/**\n * An entry of `LayersControl`, as returned by `getLayers()`.\n * @typedef {object} LayersControlEntry\n * @property {Layer} layer The layer.\n * @property {string} name The name of the layer, as given to the control.\n * @property {boolean} overlay Whether the layer is an overlay (checkbox) or a base layer\n * (radio button).\n */\n\n/**\n * The group of an entry of `LayersControl`, as returned by the option `groupBy`.\n * @typedef {object} LayersControlGroup\n * @property {string} group The name of the group, rendered as text.\n * @property {string} label The label of the entry within the group, may contain HTML\n * (like layer names).\n */\n\n/**\n * Options of `LayersControl`.\n * @typedef {object} LayersControlOptions\n * @property {boolean} [collapsed=true] If `true`, the control will be collapsed into an\n * icon and expanded on pointer hover, touch, or keyboard activation. Ignored if `inline`\n * is `true`.\n * @property {boolean} [inline=false] If `true`, the control is laid out like the\n * attribution control: it is always expanded (without toggle button) and all entries are\n * placed next to each other, wrapping onto multiple lines if necessary.\n * @property {(name: string, layer: Layer, overlay: boolean) => LayersControlGroup | undefined} [groupBy]\n * A function to group the entries. For each entry, it returns the name of its group and\n * its label within the group, or `undefined` for an ungrouped entry. Consecutive entries\n * of the same group (base layers and overlays separately) are rendered within one\n * `maplair-control-layers-group` container, starting with the group name in a\n * `maplair-control-layers-group-name` element, and each entry shows only its label.\n * Events like `baselayerchange` still carry the full `name`. When combined with\n * `sortLayers`, the entries are sorted first and grouped afterwards.\n * @property {string|HTMLElement} [toggleContent] The content of the toggle button of a\n * collapsed control instead of the layers icon: HTML (e.g. an icon or a character) or an\n * element. String content is rendered as HTML; do not pass untrusted input.\n * @property {number} [collapseDelay=0] Collapse delay in milliseconds. If greater than 0,\n * the control will remain open longer, making it easier to scroll through long layer\n * lists.\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 {boolean} [autoZIndex=true] If `true`, the control will assign zIndexes in\n * increasing order to all of its layers so that the order is preserved when switching\n * them on/off.\n * @property {boolean} [hideSingleBase=false] If `true`, the base layers in the control\n * will be hidden when there is only one.\n * @property {boolean} [sortLayers=false] Whether to sort the layers. When `false`, layers\n * will keep the order in which they were added to the control.\n * @property {(layerA: Layer, layerB: Layer, nameA: string, nameB: string) => number} [sortFunction]\n * A [compare function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)\n * that will be used for sorting the layers, when `sortLayers` is `true`. The function\n * receives both the `Layer` instances and their names, as in\n * `sortFunction(layerA, layerB, nameA, nameB)`. By default, it sorts layers\n * alphabetically by their name.\n * @extends ControlOptions\n */\n\n/**\n * The layers control gives users the ability to switch between different base layers\n * and switch overlays on/off (check out the\n * [detailed example](https://maplair.org/examples/layers-control/)).\n *\n * @example\n * ```js\n * const baseLayers = {\n * \t\"Mapbox\": mapbox,\n * \t\"OpenStreetMap\": osm\n * };\n *\n * const overlays = {\n * \t\"Marker\": marker,\n * \t\"Roads\": roadsLayer\n * };\n *\n * new LayersControl(baseLayers, overlays).addTo(map);\n * ```\n *\n * The `baseLayers` and `overlays` parameters are object literals with layer names as keys and `Layer` objects as values:\n *\n * ```js\n * {\n * \"<someName1>\": layer1,\n * \"<someName2>\": layer2\n * }\n * ```\n *\n * The layer names can contain HTML, which allows you to add additional styling to the items:\n *\n * ```js\n * {\"<img src='my-layer-icon' /> <span class='my-layer-item'>My Layer</span>\": myLayer}\n * ```\n *\n * Layers can be grouped using the option `groupBy`, for example layer names of the form\n * `\"Group (label)\"`:\n *\n * ```js\n * new LayersControl(baseLayers, overlays, {\n * \tinline: true,\n * \tgroupBy(name) {\n * \t\tconst [, group, label] = /^([^<>()]+) \\((.+)\\)$/.exec(name) ?? [];\n * \t\treturn group ? {group: `${group}:`, label} : undefined;\n * \t}\n * }).addTo(map);\n * ```\n *\n * @fires MaplairMap#baselayerchange {LayersControlEvent} Fired when the base layer is\n * changed through the [layers control](#control-layers).\n * @fires MaplairMap#overlayadd {LayersControlEvent} Fired when an overlay is selected\n * through the [layers control](#control-layers).\n * @fires MaplairMap#overlayremove {LayersControlEvent} Fired when an overlay is\n * deselected through the [layers control](#control-layers).\n */\nexport class LayersControl extends Control {\n\n\tstatic defaultOptions = {\n\t\tcollapsed: true,\n\t\tinline: false,\n\t\tgroupBy: undefined,\n\t\ttoggleContent: undefined,\n\t\tcollapseDelay: 0,\n\t\tposition: 'topright',\n\t\tautoZIndex: true,\n\t\thideSingleBase: false,\n\t\tsortLayers: false,\n\t\tsortFunction(layerA, layerB, nameA, nameB) {\n\t\t\treturn nameA < nameB ? -1 : (nameB < nameA ? 1 : 0);\n\t\t}\n\t};\n\n\t/**\n\t * Creates a layers control with the given layers. Base layers will be switched with\n\t * radio buttons, while overlays will be switched with checkboxes. Note that all base\n\t * layers should be passed in the base layers object, but only one should be added to\n\t * the map during map instantiation.\n\t * @param {Record<string, Layer>} [baseLayers]\n\t * @param {Record<string, Layer>} [overlays]\n\t * @param {LayersControlOptions} [options]\n\t */\n\tconstructor(baseLayers, overlays, options) {\n\t\tsuper(options);\n\n\t\tthis._layerControlInputs = [];\n\t\tthis._layers = [];\n\t\tthis._lastZIndex = 0;\n\t\tthis._handlingClick = false;\n\t\tthis._preventClick = false;\n\n\t\tfor (const [name, layer] of Object.entries(baseLayers ?? {})) {\n\t\t\tthis._addLayer(layer, name);\n\t\t}\n\n\t\tfor (const [name, layer] of Object.entries(overlays ?? {})) {\n\t\t\tthis._addLayer(layer, name, true);\n\t\t}\n\n\t\tthis.callInitHooks(LayersControl);\n\t}\n\n\t/**\n\t * @internal\n\t * @param {MaplairMap} map\n\t * @returns {HTMLElement}\n\t */\n\tonAdd(map) {\n\t\tthis._initLayout();\n\t\tthis._update();\n\n\t\tthis._map = map;\n\t\tmap.on('zoomend', this._checkDisabledLayers, this);\n\n\t\tfor (const layer of this._layers) {\n\t\t\tlayer.layer.on('add remove', this._onLayerChange, this);\n\t\t}\n\n\t\tif (!this._isCollapsible()) {\n\t\t\t// update the height of the container after resizing the window\n\t\t\tmap.on('resize', this._expandIfNotCollapsed, this);\n\t\t}\n\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\tsuper.addTo(map);\n\t\t// Trigger expand after Layers Control has been inserted into DOM so that is now has an actual height.\n\t\treturn this._expandIfNotCollapsed();\n\t}\n\n\t/** @internal */\n\tonRemove() {\n\t\tthis._map.off('zoomend', this._checkDisabledLayers, this);\n\n\t\tfor (const layer of this._layers) {\n\t\t\tlayer.layer.off('add remove', this._onLayerChange, this);\n\t\t}\n\n\t\tthis._map.off('resize', this._expandIfNotCollapsed, this);\n\t}\n\n\t/**\n\t * Adds a base layer (radio button entry) with the given name to the control.\n\t * @param {Layer} layer\n\t * @param {string} name\n\t * @returns {this}\n\t */\n\taddBaseLayer(layer, name) {\n\t\tthis._addLayer(layer, name);\n\t\treturn (this._map) ? this._update() : this;\n\t}\n\n\t/**\n\t * Adds an overlay (checkbox entry) with the given name to the control.\n\t * @param {Layer} layer\n\t * @param {string} name\n\t * @returns {this}\n\t */\n\taddOverlay(layer, name) {\n\t\tthis._addLayer(layer, name, true);\n\t\treturn (this._map) ? this._update() : this;\n\t}\n\n\t/**\n\t * Remove the given layer from the control.\n\t * @param {Layer} layer\n\t * @returns {this}\n\t */\n\tremoveLayer(layer) {\n\t\tlayer.off('add remove', this._onLayerChange, this);\n\n\t\tconst obj = this._getLayer(Util.stamp(layer));\n\t\tif (obj) {\n\t\t\tthis._layers.splice(this._layers.indexOf(obj), 1);\n\t\t}\n\t\treturn (this._map) ? this._update() : this;\n\t}\n\n\t/**\n\t * Returns the entries of the control in the order they are displayed.\n\t * @returns {LayersControlEntry[]}\n\t */\n\tgetLayers() {\n\t\treturn this._layers.map(({layer, name, overlay}) => ({layer, name, overlay}));\n\t}\n\n\t/**\n\t * Selects the given layer of the control like a click on its entry: a base layer\n\t * replaces the current base layer, an overlay is added to the map. The events\n\t * `baselayerchange` and `overlayadd` are fired as for a click, but without\n\t * `originalEvent`. Has no effect if the control is not on a map or does not contain\n\t * the layer.\n\t * @param {Layer} layer\n\t * @returns {this}\n\t */\n\tselectLayer(layer) {\n\t\tconst input = this._layerControlInputs.find(input => input.layerId === Util.stamp(layer));\n\t\tif (input && !input.checked) {\n\t\t\tinput.checked = true;\n\t\t\tthis._onInputClick();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Expand the control container if collapsed.\n\t * @returns {this}\n\t */\n\texpand() {\n\t\tclearTimeout(this._collapseDelayTimeout);\n\n\t\tthis._container.classList.add('maplair-control-layers-expanded');\n\t\tthis._section.style.height = '';\n\t\tconst acceptableHeight = this._map.getSize().y - (this._container.offsetTop + 50);\n\t\tif (acceptableHeight < this._section.clientHeight) {\n\t\t\tthis._section.classList.add('maplair-control-layers-scrollbar');\n\t\t\tthis._section.style.height = `${acceptableHeight}px`;\n\t\t} else {\n\t\t\tthis._section.classList.remove('maplair-control-layers-scrollbar');\n\t\t}\n\t\tthis._checkDisabledLayers();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Collapse the control container if expanded.\n\t * @param {Event} [ev] The event causing the collapse, if any (collapsing is skipped\n\t * for `pointerleave` and `pointerout` of touch).\n\t * @returns {this}\n\t */\n\tcollapse(ev) {\n\t\tif (this.options.inline) {\n\t\t\treturn this;\n\t\t}\n\t\t// On touch devices `pointerleave` & `pointerout` is fired while clicking on a checkbox.\n\t\t// The control was collapsed instead of adding the layer to the map.\n\t\t// So we allow collapse only if it is not touch.\n\t\tif (!ev || !((ev.type === 'pointerleave' || ev.type === 'pointerout') && ev.pointerType === 'touch')) {\n\t\t\tif (this.options.collapseDelay > 0) {\n\t\t\t\t// Collapse delayed\n\t\t\t\tthis._collapseDelayTimeout = setTimeout(() => {\n\t\t\t\t\tthis._container.classList.remove('maplair-control-layers-expanded');\n\t\t\t\t}, this.options.collapseDelay);\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\t// Collapse immediately\n\t\t\tthis._container.classList.remove('maplair-control-layers-expanded');\n\t\t}\n\t\treturn this;\n\t}\n\n\t_initLayout() {\n\t\tconst className = 'maplair-control-layers',\n\t\tcontainer = this._container = DomUtil.create('div', className),\n\t\tcollapsed = this._isCollapsible();\n\n\t\tif (this.options.inline) {\n\t\t\tcontainer.classList.add(`${className}-inline`);\n\t\t}\n\n\t\tDomEvent.disableClickPropagation(container);\n\t\tDomEvent.disableScrollPropagation(container);\n\n\t\tconst section = this._section = DomUtil.create('fieldset', `${className}-list`);\n\t\tsection.setAttribute('aria-label', I18n.translate('Layers'));\n\n\t\tif (collapsed) {\n\t\t\tthis._map.on('click', this.collapse, this);\n\n\t\t\tDomEvent.on(container, {\n\t\t\t\tpointerenter: this._expandSafely,\n\t\t\t\tpointerleave: this.collapse\n\t\t\t}, this);\n\t\t}\n\n\t\tif (!this.options.inline) {\n\t\t\tconst link = this._layersLink = DomUtil.create('button', `${className}-toggle`, container);\n\t\t\tlink.type = 'button';\n\t\t\tlink.title = I18n.translate('Layers');\n\t\t\tlink.setAttribute('aria-label', I18n.translate('Layers'));\n\n\t\t\tconst {toggleContent} = this.options;\n\t\t\tif (typeof toggleContent === 'string') {\n\t\t\t\tlink.innerHTML = toggleContent;\n\t\t\t} else if (toggleContent) {\n\t\t\t\tlink.replaceChildren(toggleContent);\n\t\t\t}\n\n\t\t\tDomEvent.on(link, {\n\t\t\t\tkeydown(e) {\n\t\t\t\t\tif (e.code === 'Enter') {\n\t\t\t\t\t\tthis._expandSafely();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t// Certain screen readers intercept the key event and instead send a click event\n\t\t\t\tclick(e) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tthis._expandSafely();\n\t\t\t\t}\n\t\t\t}, this);\n\t\t}\n\n\t\tif (!collapsed) {\n\t\t\tthis.expand();\n\t\t}\n\n\t\tthis._baseLayersList = DomUtil.create('div', `${className}-base`, section);\n\t\tthis._separator = DomUtil.create('div', `${className}-separator`, section);\n\t\tthis._overlaysList = DomUtil.create('div', `${className}-overlays`, section);\n\n\t\tcontainer.appendChild(section);\n\t}\n\n\t_getLayer(id) {\n\t\tfor (const layer of this._layers) {\n\t\t\tif (layer && Util.stamp(layer.layer) === id) {\n\t\t\t\treturn layer;\n\t\t\t}\n\t\t}\n\t}\n\n\t_addLayer(layer, name, overlay) {\n\t\tif (this._map) {\n\t\t\tlayer.on('add remove', this._onLayerChange, this);\n\t\t}\n\n\t\tthis._layers.push({\n\t\t\tlayer,\n\t\t\tname,\n\t\t\toverlay: !!overlay\n\t\t});\n\n\t\tif (this.options.sortLayers) {\n\t\t\tthis._layers.sort(((a, b) => this.options.sortFunction(a.layer, b.layer, a.name, b.name)));\n\t\t}\n\n\t\tif (this.options.autoZIndex && layer.setZIndex) {\n\t\t\tthis._lastZIndex++;\n\t\t\tlayer.setZIndex(this._lastZIndex);\n\t\t}\n\n\t\tthis._expandIfNotCollapsed();\n\t}\n\n\t_update() {\n\t\tif (!this._container) { return this; }\n\n\t\tthis._baseLayersList.replaceChildren();\n\t\tthis._overlaysList.replaceChildren();\n\n\t\tthis._layerControlInputs = [];\n\t\tthis._groupCount = 0;\n\t\tlet baseLayersPresent, overlaysPresent, baseLayersCount = 0;\n\n\t\tfor (const obj of this._layers) {\n\t\t\tthis._addItem(obj);\n\t\t\toverlaysPresent ||= obj.overlay;\n\t\t\tbaseLayersPresent ||= !obj.overlay;\n\t\t\tbaseLayersCount += !obj.overlay ? 1 : 0;\n\t\t}\n\n\t\t// Hide base layers section if there's only one layer.\n\t\tif (this.options.hideSingleBase) {\n\t\t\tbaseLayersPresent = baseLayersPresent && baseLayersCount > 1;\n\t\t\tthis._baseLayersList.style.display = baseLayersPresent ? '' : 'none';\n\t\t}\n\n\t\tthis._separator.style.display = overlaysPresent && baseLayersPresent ? '' : 'none';\n\n\t\treturn this;\n\t}\n\n\t_onLayerChange(e) {\n\t\tif (!this._handlingClick) {\n\t\t\tthis._update();\n\t\t}\n\n\t\tconst obj = this._getLayer(Util.stamp(e.target));\n\n\t\tconst type = obj.overlay ?\n\t\t\t(e.type === 'add' ? 'overlayadd' : 'overlayremove') :\n\t\t\t(e.type === 'add' ? 'baselayerchange' : null);\n\n\t\tif (type) {\n\t\t\tthis._map.fire(type, this._clickEvent ? {...obj, originalEvent: this._clickEvent} : obj);\n\t\t}\n\t}\n\n\t_addItem(obj) {\n\t\tconst label = document.createElement('label'),\n\t\tchecked = this._map.hasLayer(obj.layer);\n\n\t\tconst input = document.createElement('input');\n\t\tinput.type = obj.overlay ? 'checkbox' : 'radio';\n\t\tinput.className = 'maplair-control-layers-selector';\n\t\tinput.defaultChecked = checked;\n\t\tif (!obj.overlay) {\n\t\t\tinput.name = `maplair-base-layers_${Util.stamp(this)}`;\n\t\t}\n\n\t\tthis._layerControlInputs.push(input);\n\t\tinput.layerId = Util.stamp(obj.layer);\n\n\t\tDomEvent.on(input, 'click', this._onInputClick, this);\n\n\t\tconst group = this.options.groupBy?.(obj.name, obj.layer, obj.overlay);\n\n\t\tconst name = document.createElement('span');\n\t\tname.innerHTML = ` ${group ? group.label : obj.name}`;\n\n\t\t// Helps from preventing layer control flicker when checkboxes are disabled\n\t\t// https://github.com/Leaflet/Leaflet/issues/2771\n\t\tconst holder = document.createElement('span');\n\n\t\tlabel.appendChild(holder);\n\t\tholder.appendChild(input);\n\t\tholder.appendChild(name);\n\n\t\tconst list = obj.overlay ? this._overlaysList : this._baseLayersList;\n\t\tconst container = group ? this._getGroupContainer(list, group.group) : list;\n\t\tcontainer.appendChild(label);\n\n\t\tthis._checkDisabledLayers();\n\t\treturn label;\n\t}\n\n\t/**\n\t * Returns the container of the given group if it is the last element in `list`\n\t * (continuing the group), otherwise appends a new group container to `list`.\n\t * @param {HTMLElement} list\n\t * @param {string} group\n\t * @returns {HTMLElement}\n\t */\n\t_getGroupContainer(list, group) {\n\t\tconst last = list.lastElementChild;\n\t\tif (last?._maplairGroup === group) {\n\t\t\treturn last;\n\t\t}\n\n\t\tconst className = 'maplair-control-layers-group',\n\t\tcontainer = DomUtil.create('div', className, list),\n\t\tname = DomUtil.create('span', `${className}-name`, container);\n\t\tname.id = `${className}_${Util.stamp(this)}_${++this._groupCount}`;\n\t\tname.textContent = group;\n\t\tcontainer.setAttribute('role', 'group');\n\t\tcontainer.setAttribute('aria-labelledby', name.id);\n\t\tcontainer._maplairGroup = group;\n\t\treturn container;\n\t}\n\n\t_onInputClick(e) {\n\t\t// expanding the control on mobile with a click can cause adding a layer - we don't want this\n\t\tif (this._preventClick) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst inputs = this._layerControlInputs,\n\t\taddedLayers = [],\n\t\tremovedLayers = [];\n\n\t\tthis._handlingClick = true;\n\t\tthis._clickEvent = e;\n\n\t\tfor (const input of inputs) {\n\t\t\tconst layer = this._getLayer(input.layerId).layer;\n\n\t\t\tif (input.checked) {\n\t\t\t\taddedLayers.push(layer);\n\t\t\t} else if (!input.checked) {\n\t\t\t\tremovedLayers.push(layer);\n\t\t\t}\n\t\t}\n\n\t\t// Bugfix issue 2318: Should remove all old layers before readding new ones\n\t\tfor (const layer of removedLayers) {\n\t\t\tif (this._map.hasLayer(layer)) {\n\t\t\t\tthis._map.removeLayer(layer);\n\t\t\t}\n\t\t}\n\t\tfor (const layer of addedLayers) {\n\t\t\tif (!this._map.hasLayer(layer)) {\n\t\t\t\tthis._map.addLayer(layer);\n\t\t\t}\n\t\t}\n\n\t\tthis._handlingClick = false;\n\t\tthis._clickEvent = undefined;\n\n\t\tthis._refocusOnMap(e);\n\t}\n\n\t_checkDisabledLayers() {\n\t\tconst inputs = this._layerControlInputs,\n\t\tzoom = this._map.getZoom();\n\n\t\tfor (const input of inputs) {\n\t\t\tconst layer = this._getLayer(input.layerId).layer;\n\t\t\tinput.disabled = (layer.options.minZoom !== undefined && zoom < layer.options.minZoom) ||\n\t\t\t (layer.options.maxZoom !== undefined && zoom > layer.options.maxZoom);\n\n\t\t}\n\t}\n\n\t_isCollapsible() {\n\t\treturn this.options.collapsed && !this.options.inline;\n\t}\n\n\t_expandIfNotCollapsed() {\n\t\tif (this._map && !this._isCollapsible()) {\n\t\t\tthis.expand();\n\t\t}\n\t\treturn this;\n\t}\n\n\t_expandSafely() {\n\t\tconst section = this._section;\n\t\tthis._preventClick = true;\n\t\tDomEvent.on(section, 'click', DomEvent.preventDefault);\n\t\tthis.expand();\n\t\tsetTimeout(() => {\n\t\t\tDomEvent.off(section, 'click', DomEvent.preventDefault);\n\t\t\tthis._preventClick = false;\n\t\t});\n\t}\n\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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