maplair 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/dist/esm/Maplair.js +14 -14
  3. package/dist/esm/control/AttributionControl.js +24 -14
  4. package/dist/esm/control/AttributionControl.js.map +1 -1
  5. package/dist/esm/control/ButtonControl.js +9 -11
  6. package/dist/esm/control/ButtonControl.js.map +1 -1
  7. package/dist/esm/control/ContextMenu.js +1 -3
  8. package/dist/esm/control/ContextMenu.js.map +1 -1
  9. package/dist/esm/control/Control.js +9 -16
  10. package/dist/esm/control/Control.js.map +1 -1
  11. package/dist/esm/control/FullscreenControl.js +5 -7
  12. package/dist/esm/control/FullscreenControl.js.map +1 -1
  13. package/dist/esm/control/LayersControl.js +144 -35
  14. package/dist/esm/control/LayersControl.js.map +1 -1
  15. package/dist/esm/control/LegendControl.js +7 -9
  16. package/dist/esm/control/LegendControl.js.map +1 -1
  17. package/dist/esm/control/MiniMapControl.js +14 -16
  18. package/dist/esm/control/MiniMapControl.js.map +1 -1
  19. package/dist/esm/control/RotateControl.js +1 -3
  20. package/dist/esm/control/RotateControl.js.map +1 -1
  21. package/dist/esm/control/ScaleControl.js +7 -9
  22. package/dist/esm/control/ScaleControl.js.map +1 -1
  23. package/dist/esm/control/SearchControl.js +99 -17
  24. package/dist/esm/control/SearchControl.js.map +1 -1
  25. package/dist/esm/control/SideBySideControl.js +1 -3
  26. package/dist/esm/control/SideBySideControl.js.map +1 -1
  27. package/dist/esm/control/TextControl.js +5 -7
  28. package/dist/esm/control/TextControl.js.map +1 -1
  29. package/dist/esm/control/TimeControl.js +408 -0
  30. package/dist/esm/control/TimeControl.js.map +1 -0
  31. package/dist/esm/control/ZoomControl.js +5 -7
  32. package/dist/esm/control/ZoomControl.js.map +1 -1
  33. package/dist/esm/core/Class.js +28 -37
  34. package/dist/esm/core/Class.js.map +1 -1
  35. package/dist/esm/core/Events.js +21 -8
  36. package/dist/esm/core/Events.js.map +1 -1
  37. package/dist/esm/core/Handler.js +13 -11
  38. package/dist/esm/core/Handler.js.map +1 -1
  39. package/dist/esm/core/Util.js +13 -1
  40. package/dist/esm/core/Util.js.map +1 -1
  41. package/dist/esm/dom/DomEvent.DoubleTap.js +25 -22
  42. package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -1
  43. package/dist/esm/dom/DomEvent.PointerEvents.js +2 -16
  44. package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
  45. package/dist/esm/dom/DomEvent.js +8 -42
  46. package/dist/esm/dom/DomEvent.js.map +1 -1
  47. package/dist/esm/dom/DomUtil.js +14 -68
  48. package/dist/esm/dom/DomUtil.js.map +1 -1
  49. package/dist/esm/dom/Draggable.js +17 -18
  50. package/dist/esm/dom/Draggable.js.map +1 -1
  51. package/dist/esm/dom/PosAnimation.js +3 -25
  52. package/dist/esm/dom/PosAnimation.js.map +1 -1
  53. package/dist/esm/geo/LatLng.js +15 -5
  54. package/dist/esm/geo/LatLng.js.map +1 -1
  55. package/dist/esm/geo/crs/EPSG3395.js +1 -1
  56. package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
  57. package/dist/esm/geo/crs/EPSG3857.js +1 -1
  58. package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
  59. package/dist/esm/geo/crs/EPSG4326.js +1 -1
  60. package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
  61. package/dist/esm/geo/crs/EarthCRS.js +2 -2
  62. package/dist/esm/geo/crs/EarthCRS.js.map +1 -1
  63. package/dist/esm/geo/crs/SimpleCRS.js +1 -1
  64. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
  65. package/dist/esm/geo/projection/Projection.LonLat.js +1 -1
  66. package/dist/esm/geo/projection/Projection.LonLat.js.map +1 -1
  67. package/dist/esm/geo/projection/Projection.Mercator.js +1 -1
  68. package/dist/esm/geo/projection/Projection.Mercator.js.map +1 -1
  69. package/dist/esm/geo/projection/Projection.SphericalMercator.js +1 -1
  70. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +1 -1
  71. package/dist/esm/geometry/LineUtil.js +36 -30
  72. package/dist/esm/geometry/LineUtil.js.map +1 -1
  73. package/dist/esm/geometry/PolyUtil.js +8 -27
  74. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  75. package/dist/esm/layer/BlanketOverlay.js +6 -8
  76. package/dist/esm/layer/BlanketOverlay.js.map +1 -1
  77. package/dist/esm/layer/DivOverlay.js +15 -20
  78. package/dist/esm/layer/DivOverlay.js.map +1 -1
  79. package/dist/esm/layer/GeoJSON.js +9 -145
  80. package/dist/esm/layer/GeoJSON.js.map +1 -1
  81. package/dist/esm/layer/GeoJSONUtil.js +75 -0
  82. package/dist/esm/layer/GeoJSONUtil.js.map +1 -0
  83. package/dist/esm/layer/HeatLayer.js +15 -17
  84. package/dist/esm/layer/HeatLayer.js.map +1 -1
  85. package/dist/esm/layer/ImageOverlay.js +20 -26
  86. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  87. package/dist/esm/layer/Layer.js +8 -10
  88. package/dist/esm/layer/Layer.js.map +1 -1
  89. package/dist/esm/layer/LayerGroup.js +51 -0
  90. package/dist/esm/layer/LayerGroup.js.map +1 -1
  91. package/dist/esm/layer/Popup.js +26 -42
  92. package/dist/esm/layer/Popup.js.map +1 -1
  93. package/dist/esm/layer/SVGOverlay.js +2 -5
  94. package/dist/esm/layer/SVGOverlay.js.map +1 -1
  95. package/dist/esm/layer/Tooltip.js +15 -17
  96. package/dist/esm/layer/Tooltip.js.map +1 -1
  97. package/dist/esm/layer/VideoOverlay.js +12 -15
  98. package/dist/esm/layer/VideoOverlay.js.map +1 -1
  99. package/dist/esm/layer/marker/DefaultIcon.js +15 -48
  100. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
  101. package/dist/esm/layer/marker/DivIcon.js +7 -9
  102. package/dist/esm/layer/marker/DivIcon.js.map +1 -1
  103. package/dist/esm/layer/marker/Icon.js +7 -10
  104. package/dist/esm/layer/marker/Icon.js.map +1 -1
  105. package/dist/esm/layer/marker/Marker.Drag.js +1 -1
  106. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  107. package/dist/esm/layer/marker/Marker.Move.js +1 -2
  108. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  109. package/dist/esm/layer/marker/Marker.js +61 -33
  110. package/dist/esm/layer/marker/Marker.js.map +1 -1
  111. package/dist/esm/layer/marker/MarkerClusterGroup.js +302 -0
  112. package/dist/esm/layer/marker/MarkerClusterGroup.js.map +1 -0
  113. package/dist/esm/layer/marker/SvgIcon.js +6 -8
  114. package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
  115. package/dist/esm/layer/tile/GridLayer.js +85 -97
  116. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  117. package/dist/esm/layer/tile/TileLayer.js +28 -36
  118. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  119. package/dist/esm/layer/tile/WMSTileLayer.js +28 -23
  120. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
  121. package/dist/esm/layer/vector/Canvas.js +1 -3
  122. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  123. package/dist/esm/layer/vector/Circle.js +2 -2
  124. package/dist/esm/layer/vector/Circle.js.map +1 -1
  125. package/dist/esm/layer/vector/CircleMarker.js +17 -7
  126. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  127. package/dist/esm/layer/vector/Path.DashAnimation.js +2 -3
  128. package/dist/esm/layer/vector/Path.DashAnimation.js.map +1 -1
  129. package/dist/esm/layer/vector/Path.js +27 -20
  130. package/dist/esm/layer/vector/Path.js.map +1 -1
  131. package/dist/esm/layer/vector/Polygon.js +20 -4
  132. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  133. package/dist/esm/layer/vector/Polyline.Decorations.js +2 -2
  134. package/dist/esm/layer/vector/Polyline.js +23 -7
  135. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  136. package/dist/esm/layer/vector/Renderer.getRenderer.js +14 -13
  137. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  138. package/dist/esm/layer/vector/SVG.js +5 -5
  139. package/dist/esm/layer/vector/SVG.js.map +1 -1
  140. package/dist/esm/map/Map.Rotation.js +10 -6
  141. package/dist/esm/map/Map.Rotation.js.map +1 -1
  142. package/dist/esm/map/Map.js +116 -110
  143. package/dist/esm/map/Map.js.map +1 -1
  144. package/dist/esm/map/handler/BoxZoomHandler.js +5 -7
  145. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  146. package/dist/esm/map/handler/DisplaceHandler.js +6 -8
  147. package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
  148. package/dist/esm/map/handler/DragHandler.js +19 -19
  149. package/dist/esm/map/handler/DragHandler.js.map +1 -1
  150. package/dist/esm/map/handler/KeyboardHandler.js +35 -35
  151. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  152. package/dist/esm/map/handler/PinchZoomHandler.js +12 -3
  153. package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
  154. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +3 -4
  155. package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
  156. package/dist/esm/map/handler/TapHoldHandler.js +12 -5
  157. package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
  158. package/dist/esm/package.js +1 -1
  159. package/dist/maplair-global-src.js +8009 -7369
  160. package/dist/maplair-global-src.js.map +1 -1
  161. package/dist/maplair-global.js +2 -2
  162. package/dist/maplair-global.js.map +1 -1
  163. package/dist/maplair-src.js +10040 -9381
  164. package/dist/maplair-src.js.map +1 -1
  165. package/dist/maplair.css +148 -98
  166. package/dist/maplair.js +2 -2
  167. package/dist/maplair.js.map +1 -1
  168. package/i18n/cs.json +6 -0
  169. package/i18n/de.json +6 -0
  170. package/i18n/en.json +6 -0
  171. package/i18n/es.json +6 -0
  172. package/i18n/fr.json +6 -0
  173. package/i18n/hu.json +6 -0
  174. package/i18n/it.json +6 -0
  175. package/i18n/rm.json +6 -0
  176. package/i18n/sk.json +6 -0
  177. package/i18n/sl.json +6 -0
  178. package/package.json +9 -11
  179. package/src/control/AttributionControl.js +25 -18
  180. package/src/control/ButtonControl.js +9 -11
  181. package/src/control/ContextMenu.js +3 -5
  182. package/src/control/Control.js +9 -19
  183. package/src/control/FullscreenControl.js +5 -7
  184. package/src/control/LayersControl.js +159 -36
  185. package/src/control/LegendControl.js +7 -9
  186. package/src/control/MiniMapControl.js +9 -11
  187. package/src/control/RotateControl.js +3 -5
  188. package/src/control/ScaleControl.js +7 -9
  189. package/src/control/SearchControl.js +102 -19
  190. package/src/control/SideBySideControl.js +3 -5
  191. package/src/control/TextControl.js +5 -7
  192. package/src/control/TimeControl.js +471 -0
  193. package/src/control/ZoomControl.js +5 -7
  194. package/src/control/index.js +1 -0
  195. package/src/core/Class.js +35 -34
  196. package/src/core/Events.js +22 -3
  197. package/src/core/Handler.js +14 -12
  198. package/src/core/Util.js +19 -1
  199. package/src/core/index.js +0 -1
  200. package/src/dom/DomEvent.DoubleTap.js +18 -10
  201. package/src/dom/DomEvent.PointerEvents.js +3 -26
  202. package/src/dom/DomEvent.js +8 -66
  203. package/src/dom/DomUtil.js +22 -78
  204. package/src/dom/Draggable.js +27 -22
  205. package/src/dom/PosAnimation.js +3 -25
  206. package/src/dom/index.js +0 -1
  207. package/src/geo/LatLng.js +20 -3
  208. package/src/geo/crs/EPSG3395.js +1 -1
  209. package/src/geo/crs/EPSG3857.js +1 -1
  210. package/src/geo/crs/EPSG4326.js +1 -1
  211. package/src/geo/crs/EarthCRS.js +2 -8
  212. package/src/geo/crs/SimpleCRS.js +1 -1
  213. package/src/geo/projection/Projection.LonLat.js +1 -1
  214. package/src/geo/projection/Projection.Mercator.js +1 -1
  215. package/src/geo/projection/Projection.SphericalMercator.js +1 -1
  216. package/src/geometry/LineUtil.js +47 -48
  217. package/src/geometry/PolyUtil.js +14 -43
  218. package/src/layer/BlanketOverlay.js +6 -10
  219. package/src/layer/DivOverlay.js +15 -26
  220. package/src/layer/GeoJSON.js +7 -205
  221. package/src/layer/GeoJSONUtil.js +85 -0
  222. package/src/layer/HeatLayer.js +9 -11
  223. package/src/layer/ImageOverlay.js +19 -30
  224. package/src/layer/Layer.js +8 -10
  225. package/src/layer/LayerGroup.js +71 -0
  226. package/src/layer/Popup.js +28 -43
  227. package/src/layer/SVGOverlay.js +1 -5
  228. package/src/layer/Tooltip.js +15 -19
  229. package/src/layer/VideoOverlay.js +12 -15
  230. package/src/layer/marker/DefaultIcon.js +15 -61
  231. package/src/layer/marker/DivIcon.js +9 -11
  232. package/src/layer/marker/Icon.js +7 -10
  233. package/src/layer/marker/Marker.Drag.js +1 -1
  234. package/src/layer/marker/Marker.Move.js +1 -2
  235. package/src/layer/marker/Marker.js +81 -39
  236. package/src/layer/marker/MarkerClusterGroup.js +370 -0
  237. package/src/layer/marker/SvgIcon.js +7 -9
  238. package/src/layer/marker/index.js +1 -0
  239. package/src/layer/tile/GridLayer.js +103 -133
  240. package/src/layer/tile/TileLayer.js +35 -43
  241. package/src/layer/tile/WMSTileLayer.js +26 -24
  242. package/src/layer/vector/Canvas.js +3 -5
  243. package/src/layer/vector/Circle.js +5 -2
  244. package/src/layer/vector/CircleMarker.js +17 -6
  245. package/src/layer/vector/Path.DashAnimation.js +1 -2
  246. package/src/layer/vector/Path.js +30 -21
  247. package/src/layer/vector/Polygon.js +28 -5
  248. package/src/layer/vector/Polyline.js +25 -6
  249. package/src/layer/vector/Renderer.getRenderer.js +17 -17
  250. package/src/layer/vector/SVG.js +5 -5
  251. package/src/map/Map.Rotation.js +12 -4
  252. package/src/map/Map.js +142 -133
  253. package/src/map/handler/BoxZoomHandler.js +9 -8
  254. package/src/map/handler/DisplaceHandler.js +6 -8
  255. package/src/map/handler/DragHandler.js +25 -28
  256. package/src/map/handler/KeyboardHandler.js +42 -48
  257. package/src/map/handler/PinchZoomHandler.js +16 -5
  258. package/src/map/handler/ScrollWheelZoomHandler.js +6 -4
  259. package/src/map/handler/TapHoldHandler.js +15 -4
  260. package/src/map/index.js +1 -1
  261. package/src/maplair.css +148 -98
  262. package/dist/esm/core/Browser.js +0 -100
  263. package/dist/esm/core/Browser.js.map +0 -1
  264. package/dist/images/layers.svg +0 -1
  265. package/dist/images/marker-icon.svg +0 -1
  266. package/dist/images/marker-shadow.svg +0 -1
  267. package/src/core/Browser.js +0 -110
  268. package/src/images/layers.svg +0 -1
  269. package/src/images/marker-icon.svg +0 -1
  270. package/src/images/marker-shadow.svg +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Marker.Drag.js","names":["DomUtil.getPosition"],"sources":["../../../../src/layer/marker/Marker.Drag.js"],"sourcesContent":["import {Handler} from '../../core/Handler.js';\nimport * as DomUtil from '../../dom/DomUtil.js';\nimport {Draggable} from '../../dom/Draggable.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {Point} from '../../geometry/Point.js';\n\n/** @import {Marker, MarkerMoveEvent} from './Marker.js' */\n/** @import {MaplairEvent, DragEndEvent} from '../../core/Events.js' */\n\n/**\n * The handler of `Marker` which makes the markers draggable, see the\n * [`dragging`](#marker-dragging) property of markers and its `draggable` option.\n *\n * @fires Marker#dragstart {MaplairEvent} Fired when the user starts dragging the marker.\n * @fires Marker#movestart {MaplairEvent} Fired when the marker starts moving (because of\n * dragging).\n * @fires Marker#drag {MarkerMoveEvent} Fired repeatedly while the user drags the marker.\n * @fires Marker#dragend {DragEndEvent} Fired when the user stops dragging the marker.\n * @fires Marker#moveend {MaplairEvent} Fired when the marker stops moving (because of\n * dragging).\n */\nexport class MarkerDrag extends Handler {\n\t/**\n\t * Creates the dragging handler of the given marker.\n\t * @param {Marker} marker\n\t */\n\tconstructor(marker) {\n\t\tsuper(marker._map);\n\t\tthis._marker = marker;\n\n\t\tthis.callInitHooks(MarkerDrag);\n\t}\n\n\t/**\n\t * Makes the icon of the marker draggable, called by `enable()`.\n\t */\n\taddHooks() {\n\t\tconst icon = this._marker._icon;\n\n\t\tif (!this._draggable) {\n\t\t\tthis._draggable = new Draggable(icon, icon, true);\n\t\t}\n\n\t\tthis._draggable.on({\n\t\t\tdragstart: this._onDragStart,\n\t\t\tpredrag: this._onPreDrag,\n\t\t\tdrag: this._onDrag,\n\t\t\tdragend: this._onDragEnd\n\t\t}, this).enable();\n\n\t\ticon.classList.add('maplair-marker-draggable');\n\t}\n\n\t/**\n\t * Makes the icon of the marker undraggable, called by `disable()`.\n\t */\n\tremoveHooks() {\n\t\tthis._draggable.off({\n\t\t\tdragstart: this._onDragStart,\n\t\t\tpredrag: this._onPreDrag,\n\t\t\tdrag: this._onDrag,\n\t\t\tdragend: this._onDragEnd\n\t\t}, this).disable();\n\n\t\tthis._marker._icon?.classList.remove('maplair-marker-draggable');\n\t}\n\n\t/**\n\t * Returns `true` if the marker has been moved by the current or last drag.\n\t * @returns {boolean}\n\t */\n\tmoved() {\n\t\treturn this._draggable?._moved;\n\t}\n\n\t_adjustPan(e) {\n\t\tconst marker = this._marker,\n\t\tmap = marker._map,\n\t\tspeed = this._marker.options.autoPanSpeed,\n\t\tpadding = this._marker.options.autoPanPadding,\n\t\ticonPos = DomUtil.getPosition(marker._icon),\n\t\tbounds = map.getPixelBounds(),\n\t\torigin = map.getPixelOrigin();\n\n\t\tconst panBounds = new Bounds(\n\t\t\tbounds.min._subtract(origin).add(padding),\n\t\t\tbounds.max._subtract(origin).subtract(padding)\n\t\t);\n\n\t\tif (!panBounds.contains(iconPos)) {\n\t\t\t// Compute incremental movement\n\t\t\tconst movement = new Point(\n\t\t\t\t(Math.max(panBounds.max.x, iconPos.x) - panBounds.max.x) / (bounds.max.x - panBounds.max.x) -\n\t\t\t\t(Math.min(panBounds.min.x, iconPos.x) - panBounds.min.x) / (bounds.min.x - panBounds.min.x),\n\n\t\t\t\t(Math.max(panBounds.max.y, iconPos.y) - panBounds.max.y) / (bounds.max.y - panBounds.max.y) -\n\t\t\t\t(Math.min(panBounds.min.y, iconPos.y) - panBounds.min.y) / (bounds.min.y - panBounds.min.y)\n\t\t\t).multiplyBy(speed);\n\n\t\t\tmap.panBy(movement, {animate: false});\n\n\t\t\tthis._draggable._newPos._add(movement);\n\t\t\tthis._draggable._startPos._add(movement);\n\n\t\t\tDomUtil.setPosition(marker._icon, this._draggable._newPos);\n\t\t\tthis._onDrag(e);\n\n\t\t\tthis._panRequest = requestAnimationFrame(this._adjustPan.bind(this, e));\n\t\t}\n\t}\n\n\t_onDragStart() {\n\t\tthis._oldLatLng = this._marker.getLatLng();\n\n\t\t// When using ES6 imports it could not be set when `Popup` was not imported as well\n\t\tthis._marker.closePopup?.();\n\n\t\tthis._marker\n\t\t\t.fire('movestart')\n\t\t\t.fire('dragstart');\n\t}\n\n\t_onPreDrag(e) {\n\t\tif (this._marker.options.autoPan) {\n\t\t\tcancelAnimationFrame(this._panRequest);\n\t\t\tthis._panRequest = requestAnimationFrame(this._adjustPan.bind(this, e));\n\t\t}\n\t}\n\n\t_onDrag(e) {\n\t\tconst marker = this._marker,\n\t\tshadow = marker._shadow,\n\t\ticonPos = DomUtil.getPosition(marker._icon),\n\t\tlatlng = marker._map.layerPointToLatLng(iconPos);\n\n\t\t// update shadow position\n\t\tif (shadow) {\n\t\t\tDomUtil.setPosition(shadow, iconPos);\n\t\t}\n\n\t\tmarker._latlng = latlng;\n\t\te.latlng = latlng;\n\t\te.oldLatLng = this._oldLatLng;\n\n\t\tmarker\n\t\t\t.fire('move', e)\n\t\t\t.fire('drag', e);\n\t}\n\n\t_onDragEnd(e) {\n\t\tcancelAnimationFrame(this._panRequest);\n\n\t\tdelete this._oldLatLng;\n\t\tthis._marker\n\t\t\t.fire('moveend')\n\t\t\t.fire('dragend', e);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,aAAb,MAAa,mBAAmB,QAAQ;;;;;CAKvC,YAAY,QAAQ;EACnB,MAAM,OAAO,IAAI;EACjB,KAAK,UAAU;EAEf,KAAK,cAAc,UAAU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ker.Drag.js"],"sourcesContent":["import {Handler} from '../../core/Handler.js';\nimport * as DomUtil from '../../dom/DomUtil.js';\nimport {Draggable} from '../../dom/Draggable.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {Point} from '../../geometry/Point.js';\n\n/** @import {Marker, MarkerMoveEvent} from './Marker.js' */\n/** @import {MaplairEvent, DragEndEvent} from '../../core/Events.js' */\n\n/**\n * The handler of `Marker` which makes the markers draggable, see the\n * [`dragging`](#marker-dragging) property of markers and its `draggable` option.\n *\n * @fires Marker#dragstart {MaplairEvent} Fired when the user starts dragging the marker.\n * @fires Marker#movestart {MaplairEvent} Fired when the marker starts moving (because of\n * dragging).\n * @fires Marker#drag {MarkerMoveEvent} Fired repeatedly while the user drags the marker.\n * @fires Marker#dragend {DragEndEvent} Fired when the user stops dragging the marker.\n * @fires Marker#moveend {MaplairEvent} Fired when the marker stops moving (because of\n * dragging).\n */\nexport class MarkerDrag extends Handler {\n\t/**\n\t * Creates the dragging handler of the given marker.\n\t * @param {Marker} marker\n\t */\n\tconstructor(marker) {\n\t\tsuper(marker._map);\n\t\tthis._marker = marker;\n\n\t\tthis.callInitHooks(MarkerDrag);\n\t}\n\n\t/**\n\t * Makes the icon of the marker draggable, called by `enable()`.\n\t */\n\taddHooks() {\n\t\tconst icon = this._marker._icon;\n\n\t\tif (!this._draggable) {\n\t\t\tthis._draggable = new Draggable(icon);\n\t\t}\n\n\t\tthis._draggable.on({\n\t\t\tdragstart: this._onDragStart,\n\t\t\tpredrag: this._onPreDrag,\n\t\t\tdrag: this._onDrag,\n\t\t\tdragend: this._onDragEnd\n\t\t}, this).enable();\n\n\t\ticon.classList.add('maplair-marker-draggable');\n\t}\n\n\t/**\n\t * Makes the icon of the marker undraggable, called by `disable()`.\n\t */\n\tremoveHooks() {\n\t\tthis._draggable.off({\n\t\t\tdragstart: this._onDragStart,\n\t\t\tpredrag: this._onPreDrag,\n\t\t\tdrag: this._onDrag,\n\t\t\tdragend: this._onDragEnd\n\t\t}, this).disable();\n\n\t\tthis._marker._icon?.classList.remove('maplair-marker-draggable');\n\t}\n\n\t/**\n\t * Returns `true` if the marker has been moved by the current or last drag.\n\t * @returns {boolean}\n\t */\n\tmoved() {\n\t\treturn this._draggable?._moved;\n\t}\n\n\t_adjustPan(e) {\n\t\tconst marker = this._marker,\n\t\tmap = marker._map,\n\t\tspeed = this._marker.options.autoPanSpeed,\n\t\tpadding = this._marker.options.autoPanPadding,\n\t\ticonPos = DomUtil.getPosition(marker._icon),\n\t\tbounds = map.getPixelBounds(),\n\t\torigin = map.getPixelOrigin();\n\n\t\tconst panBounds = new Bounds(\n\t\t\tbounds.min._subtract(origin).add(padding),\n\t\t\tbounds.max._subtract(origin).subtract(padding)\n\t\t);\n\n\t\tif (!panBounds.contains(iconPos)) {\n\t\t\t// Compute incremental movement\n\t\t\tconst movement = new Point(\n\t\t\t\t(Math.max(panBounds.max.x, iconPos.x) - panBounds.max.x) / (bounds.max.x - panBounds.max.x) -\n\t\t\t\t(Math.min(panBounds.min.x, iconPos.x) - panBounds.min.x) / (bounds.min.x - panBounds.min.x),\n\n\t\t\t\t(Math.max(panBounds.max.y, iconPos.y) - panBounds.max.y) / (bounds.max.y - panBounds.max.y) -\n\t\t\t\t(Math.min(panBounds.min.y, iconPos.y) - panBounds.min.y) / (bounds.min.y - panBounds.min.y)\n\t\t\t).multiplyBy(speed);\n\n\t\t\tmap.panBy(movement, {animate: false});\n\n\t\t\tthis._draggable._newPos._add(movement);\n\t\t\tthis._draggable._startPos._add(movement);\n\n\t\t\tDomUtil.setPosition(marker._icon, this._draggable._newPos);\n\t\t\tthis._onDrag(e);\n\n\t\t\tthis._panRequest = requestAnimationFrame(this._adjustPan.bind(this, e));\n\t\t}\n\t}\n\n\t_onDragStart() {\n\t\tthis._oldLatLng = this._marker.getLatLng();\n\n\t\t// When using ES6 imports it could not be set when `Popup` was not imported as well\n\t\tthis._marker.closePopup?.();\n\n\t\tthis._marker\n\t\t\t.fire('movestart')\n\t\t\t.fire('dragstart');\n\t}\n\n\t_onPreDrag(e) {\n\t\tif (this._marker.options.autoPan) {\n\t\t\tcancelAnimationFrame(this._panRequest);\n\t\t\tthis._panRequest = requestAnimationFrame(this._adjustPan.bind(this, e));\n\t\t}\n\t}\n\n\t_onDrag(e) {\n\t\tconst marker = this._marker,\n\t\tshadow = marker._shadow,\n\t\ticonPos = DomUtil.getPosition(marker._icon),\n\t\tlatlng = marker._map.layerPointToLatLng(iconPos);\n\n\t\t// update shadow position\n\t\tif (shadow) {\n\t\t\tDomUtil.setPosition(shadow, iconPos);\n\t\t}\n\n\t\tmarker._latlng = latlng;\n\t\te.latlng = latlng;\n\t\te.oldLatLng = this._oldLatLng;\n\n\t\tmarker\n\t\t\t.fire('move', e)\n\t\t\t.fire('drag', e);\n\t}\n\n\t_onDragEnd(e) {\n\t\tcancelAnimationFrame(this._panRequest);\n\n\t\tdelete this._oldLatLng;\n\t\tthis._marker\n\t\t\t.fire('moveend')\n\t\t\t.fire('dragend', e);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,aAAb,MAAa,mBAAmB,QAAQ;;;;;CAKvC,YAAY,QAAQ;EACnB,MAAM,OAAO,IAAI;EACjB,KAAK,UAAU;EAEf,KAAK,cAAc,UAAU;CAC9B;;;;CAKA,WAAW;EACV,MAAM,OAAO,KAAK,QAAQ;EAE1B,IAAI,CAAC,KAAK,YACT,KAAK,aAAa,IAAI,UAAU,IAAI;EAGrC,KAAK,WAAW,GAAG;GAClB,WAAW,KAAK;GAChB,SAAS,KAAK;GACd,MAAM,KAAK;GACX,SAAS,KAAK;EACf,GAAG,IAAI,CAAC,CAAC,OAAO;EAEhB,KAAK,UAAU,IAAI,0BAA0B;CAC9C;;;;CAKA,cAAc;EACb,KAAK,WAAW,IAAI;GACnB,WAAW,KAAK;GAChB,SAAS,KAAK;GACd,MAAM,KAAK;GACX,SAAS,KAAK;EACf,GAAG,IAAI,CAAC,CAAC,QAAQ;EAEjB,KA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e;EACd,KAAK,aAAa,KAAK,QAAQ,UAAU;EAGzC,KAAK,QAAQ,aAAa;EAE1B,KAAK,QACH,KAAK,WAAW,CAAC,CACjB,KAAK,WAAW;CACnB;CAEA,WAAW,GAAG;EACb,IAAI,KAAK,QAAQ,QAAQ,SAAS;GACjC,qBAAqB,KAAK,WAAW;GACrC,KAAK,cAAc,sBAAsB,KAAK,WAAW,KAAK,MAAM,CAAC,CAAC;EACvE;CACD;CAEA,QAAQ,GAAG;EACV,MAAM,SAAS,KAAK,SACpB,SAAS,OAAO,SAChB,UAAUA,YAAoB,OAAO,KAAK,GAC1C,SAAS,OAAO,KAAK,mBAAmB,OAAO;EAG/C,IAAI,QACH,YAAoB,QAAQ,OAAO;EAGpC,OAAO,UAAU;EACjB,EAAE,SAAS;EACX,EAAE,YAAY,KAAK;EAEnB,OACE,KAAK,QAAQ,CAAC,CAAC,CACf,KAAK,QAAQ,CAAC;CACjB;CAEA,WAAW,GAAG;EACb,qBAAqB,KAAK,WAAW;EAErC,OAAO,KAAK;EACZ,KAAK,QACH,KAAK,SAAS,CAAC,CACf,KAAK,WAAW,CAAC;CACpB;AACD"}
@@ -1,5 +1,4 @@
1
1
  import { Point } from "../../geometry/Point.js";
2
- import Browser_default from "../../core/Browser.js";
3
2
  import { LatLng } from "../../geo/LatLng.js";
4
3
  import { Marker } from "./Marker.js";
5
4
  //#region src/layer/marker/Marker.Move.js
@@ -46,7 +45,7 @@ Marker.include({
46
45
  this.stopMoving();
47
46
  const points = [this._latlng, ...latlngs.map((latlng) => LatLng.from(latlng))], lengths = points.slice(1).map((point, i) => this._map?.distance(points[i], point) ?? points[i].distanceTo(point)), total = lengths.reduce((sum, length) => sum + length, 0), duration = options.speed ? total / options.speed * 1e3 : options.duration ?? 1e3, start = performance.now();
48
47
  const frame = () => {
49
- let distance = duration && !Browser_default.reducedMotion ? Math.min(1, (performance.now() - start) / duration) * total : total, i = 0;
48
+ let distance = duration && !this._map?._prefersReducedMotion() ? Math.min(1, (performance.now() - start) / duration) * total : total, i = 0;
50
49
  const moved = distance;
51
50
  while (i < lengths.length - 1 && distance > lengths[i]) {
52
51
  distance -= lengths[i];
@@ -1 +1 @@
1
- {"version":3,"file":"Marker.Move.js","names":["Browser"],"sources":["../../../../src/layer/marker/Marker.Move.js"],"sourcesContent":["import {Marker} from './Marker.js';\nimport {LatLng} from '../../geo/LatLng.js';\nimport {Point} from '../../geometry/Point.js';\nimport Browser from '../../core/Browser.js';\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {MaplairEvent} from '../../core/Events.js' */\n\n/**\n * Options of the movement of markers, see `moveAlong()`.\n * @typedef {object} MarkerMovementOptions\n * @property {number} [duration=1000] The duration of the movement in milliseconds.\n * @property {number} [speed] The speed in meters (or units of the CRS) per second\n * instead of the `duration`.\n * @property {boolean} [rotate=false] Whether to set the `rotationAngle` of the icon to\n * the heading of the movement (for icons pointing up; needs the marker rotation, see\n * `rotationAngle`).\n */\n\n// The methods extended below\nconst {onRemove} = Marker.prototype;\n\n/**\n * Methods of `Marker` for the animated movement of markers, an optional feature: import\n * this module to add `moveTo()`, `moveAlong()`, `stopMoving()` and `isMoving()` to\n * `Marker`.\n *\n * ```js\n * import 'maplair/marker-movement';\n *\n * marker.moveAlong([[47.27, 11.40], [47.28, 11.42]], {duration: 5000});\n * ```\n *\n * Inspired by the [Leaflet.MovingMarker](https://github.com/ewoken/Leaflet.MovingMarker)\n * and [Leaflet.AnimatedMarker](https://github.com/openplans/Leaflet.AnimatedMarker) plugins.\n * @lends Marker.prototype\n * @fires Marker#moveend {MaplairEvent} Fired when the marker stops moving (after dragging\n * or `moveAlong()`).\n */\nconst markerMoveMethods = {\n\t/**\n\t * Moves the marker smoothly to `latlng`, see `moveAlong()`.\n\t * @group Marker movement\n\t * @param {LatLngExpression} latlng\n\t * @param {MarkerMovementOptions} [options]\n\t * @returns {this}\n\t */\n\tmoveTo(latlng, options) {\n\t\treturn this.moveAlong([latlng], options);\n\t},\n\n\t/**\n\t * Moves the marker smoothly along the given points, frame by frame at a constant\n\t * speed, e.g. to follow a vehicle or to replay a track. Fires `move` with each\n\t * frame and `moveend` at the end. A new movement or `stopMoving()` stops it; with\n\t * [reduced motion](https://developer.mozilla.org/docs/Web/CSS/@media/prefers-reduced-motion),\n\t * the marker jumps to the end.\n\t * Inspired by the [Leaflet.MovingMarker](https://github.com/ewoken/Leaflet.MovingMarker)\n\t * and [Leaflet.AnimatedMarker](https://github.com/openplans/Leaflet.AnimatedMarker) plugins.\n\t * @group Marker movement\n\t * @param {LatLngExpression[]} latlngs\n\t * @param {MarkerMovementOptions} [options]\n\t * @returns {this}\n\t */\n\tmoveAlong(latlngs, options = {}) {\n\t\tthis.stopMoving();\n\n\t\tconst points = [this._latlng, ...latlngs.map(latlng => LatLng.from(latlng))],\n\t\tlengths = points.slice(1).map((point, i) => this._map?.distance(points[i], point) ?? points[i].distanceTo(point)),\n\t\ttotal = lengths.reduce((sum, length) => sum + length, 0),\n\t\tduration = options.speed ? total / options.speed * 1000 : (options.duration ?? 1000),\n\t\tstart = performance.now();\n\n\t\tconst frame = () => {\n\t\t\t// the distance moved, at a constant speed\n\t\t\tlet distance = duration && !Browser.reducedMotion ? Math.min(1, (performance.now() - start) / duration) * total : total,\n\t\t\ti = 0;\n\t\t\tconst moved = distance;\n\t\t\twhile (i < lengths.length - 1 && distance > lengths[i]) {\n\t\t\t\tdistance -= lengths[i];\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tconst from = points[i], to = points[i + 1];\n\t\t\tif (options.rotate && !from.equals(to)) {\n\t\t\t\tthis.options.rotationAngle = this._heading(from, to);\n\t\t\t}\n\t\t\tthis.setLatLng(this._interpolate(from, to, lengths[i] ? Math.min(1, distance / lengths[i]) : 1));\n\n\t\t\tif (moved < total) {\n\t\t\t\tthis._moveFrame = requestAnimationFrame(frame);\n\t\t\t} else {\n\t\t\t\tthis._moveFrame = null;\n\t\t\t\tthis.fire('moveend');\n\t\t\t}\n\t\t};\n\t\tthis._moveFrame = requestAnimationFrame(frame);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Stops the movement of `moveTo()` or `moveAlong()`.\n\t * @group Marker movement\n\t * @returns {this}\n\t */\n\tstopMoving() {\n\t\tcancelAnimationFrame(this._moveFrame);\n\t\tthis._moveFrame = null;\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` while the marker moves with `moveTo()` or `moveAlong()`.\n\t * @group Marker movement\n\t * @returns {boolean}\n\t */\n\tisMoving() {\n\t\treturn !!this._moveFrame;\n\t},\n\n\t// A straight line in the projection of the map (if any)\n\t_interpolate(from, to, t) {\n\t\tconst crs = this._map?.options.crs;\n\t\tif (!crs) {\n\t\t\treturn new LatLng(from.lat + (to.lat - from.lat) * t, from.lng + (to.lng - from.lng) * t);\n\t\t}\n\t\tconst a = crs.projection.project(from),\n\t\tb = crs.projection.project(to);\n\t\treturn crs.projection.unproject(a.add(b.subtract(a).multiplyBy(t)));\n\t},\n\n\t// The heading from `from` to `to` in degrees clockwise from north, relative to\n\t// the screen unless the icon rotates with the view\n\t_heading(from, to) {\n\t\tconst crs = this._map?.options.crs,\n\t\ta = crs ? crs.latLngToPoint(from, 0) : new Point(from.lng, -from.lat),\n\t\tb = crs ? crs.latLngToPoint(to, 0) : new Point(to.lng, -to.lat),\n\t\theading = Math.atan2(b.x - a.x, a.y - b.y) * 180 / Math.PI;\n\t\treturn heading - (this.options.rotateWithView ? 0 : (this._map?.getBearing?.() ?? 0));\n\t},\n\n\t/**\n\t * Stops the movement when the marker is removed from the map.\n\t * @internal\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tthis.stopMoving();\n\t\treturn onRemove.call(this, map);\n\t}\n};\n/** @typedef {typeof markerMoveMethods} MarkerMoveMethods */\n\nMarker.include(markerMoveMethods);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoBA,MAAM,EAAC,aAAY,OAAO;;AAoI1B,OAAO,QAAQ;;;;;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AqB,KAAK,UAAU;EACpC,KAAK,aAAa;EAClB,OAAO;CACR;;;;;;CAOA,WAAW;EACV,OAAO,CAAC,CAAC,KAAK;CACf;CAGA,aAAa,MAAM,IAAI,GAAG;EACzB,MAAM,MAAM,KAAK,MAAM,QAAQ;EAC/B,IAAI,CAAC,KACJ,OAAO,IAAI,OAAO,KAAK,OAAO,GAAG,MAAM,KAAK,OAAO,GAAG,KAAK,OAAO,GAAG,MAAM,KAAK,OAAO,CAAC;EAEzF,MAAM,IAAI,IAAI,WAAW,QAAQ,IAAI,GACrC,IAAI,IAAI,WAAW,QAAQ,EAAE;EAC7B,OAAO,IAAI,WAAW,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;CACnE;CAIA,SAAS,MAAM,IAAI;EAClB,MAAM,MAAM,KAAK,MAAM,QAAQ,KAC/B,IAAI,MAAM,IAAI,cAAc,MAAM,CAAC,IAAI,IAAI,MAAM,KAAK,KAAK,CAAC,KAAK,GAAG,GACpE,IAAI,MAAM,IAAI,cAAc,IAAI,CAAC,IAAI,IAAI,MAAM,GAAG,KAAK,CAAC,GAAG,GAAG;EAE9D,OADU,KAAK,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,IAAI,MAAM,KAAK,MACtC,KAAK,QAAQ,iBAAiB,IAAK,KAAK,MAAM,aAAa,KAAK;CACnF;;;;;;CAOA,SAAS,KAAK;EACb,KAAK,WAAW;EAChB,OAAO,SAAS,KAAK,MAAM,GAAG;CAC/B;AAI8B,CAAC"}
1
+ {"version":3,"file":"Marker.Move.js","names":[],"sources":["../../../../src/layer/marker/Marker.Move.js"],"sourcesContent":["import {Marker} from './Marker.js';\nimport {LatLng} from '../../geo/LatLng.js';\nimport {Point} from '../../geometry/Point.js';\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {MaplairEvent} from '../../core/Events.js' */\n\n/**\n * Options of the movement of markers, see `moveAlong()`.\n * @typedef {object} MarkerMovementOptions\n * @property {number} [duration=1000] The duration of the movement in milliseconds.\n * @property {number} [speed] The speed in meters (or units of the CRS) per second\n * instead of the `duration`.\n * @property {boolean} [rotate=false] Whether to set the `rotationAngle` of the icon to\n * the heading of the movement (for icons pointing up; needs the marker rotation, see\n * `rotationAngle`).\n */\n\n// The methods extended below\nconst {onRemove} = Marker.prototype;\n\n/**\n * Methods of `Marker` for the animated movement of markers, an optional feature: import\n * this module to add `moveTo()`, `moveAlong()`, `stopMoving()` and `isMoving()` to\n * `Marker`.\n *\n * ```js\n * import 'maplair/marker-movement';\n *\n * marker.moveAlong([[47.27, 11.40], [47.28, 11.42]], {duration: 5000});\n * ```\n *\n * Inspired by the [Leaflet.MovingMarker](https://github.com/ewoken/Leaflet.MovingMarker)\n * and [Leaflet.AnimatedMarker](https://github.com/openplans/Leaflet.AnimatedMarker) plugins.\n * @lends Marker.prototype\n * @fires Marker#moveend {MaplairEvent} Fired when the marker stops moving (after dragging\n * or `moveAlong()`).\n */\nconst markerMoveMethods = {\n\t/**\n\t * Moves the marker smoothly to `latlng`, see `moveAlong()`.\n\t * @group Marker movement\n\t * @param {LatLngExpression} latlng\n\t * @param {MarkerMovementOptions} [options]\n\t * @returns {this}\n\t */\n\tmoveTo(latlng, options) {\n\t\treturn this.moveAlong([latlng], options);\n\t},\n\n\t/**\n\t * Moves the marker smoothly along the given points, frame by frame at a constant\n\t * speed, e.g. to follow a vehicle or to replay a track. Fires `move` with each\n\t * frame and `moveend` at the end. A new movement or `stopMoving()` stops it; with\n\t * [reduced motion](https://developer.mozilla.org/docs/Web/CSS/@media/prefers-reduced-motion),\n\t * the marker jumps to the end.\n\t * Inspired by the [Leaflet.MovingMarker](https://github.com/ewoken/Leaflet.MovingMarker)\n\t * and [Leaflet.AnimatedMarker](https://github.com/openplans/Leaflet.AnimatedMarker) plugins.\n\t * @group Marker movement\n\t * @param {LatLngExpression[]} latlngs\n\t * @param {MarkerMovementOptions} [options]\n\t * @returns {this}\n\t */\n\tmoveAlong(latlngs, options = {}) {\n\t\tthis.stopMoving();\n\n\t\tconst points = [this._latlng, ...latlngs.map(latlng => LatLng.from(latlng))],\n\t\tlengths = points.slice(1).map((point, i) => this._map?.distance(points[i], point) ?? points[i].distanceTo(point)),\n\t\ttotal = lengths.reduce((sum, length) => sum + length, 0),\n\t\tduration = options.speed ? total / options.speed * 1000 : (options.duration ?? 1000),\n\t\tstart = performance.now();\n\n\t\tconst frame = () => {\n\t\t\t// the distance moved, at a constant speed\n\t\t\tlet distance = duration && !this._map?._prefersReducedMotion() ? Math.min(1, (performance.now() - start) / duration) * total : total,\n\t\t\ti = 0;\n\t\t\tconst moved = distance;\n\t\t\twhile (i < lengths.length - 1 && distance > lengths[i]) {\n\t\t\t\tdistance -= lengths[i];\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tconst from = points[i], to = points[i + 1];\n\t\t\tif (options.rotate && !from.equals(to)) {\n\t\t\t\tthis.options.rotationAngle = this._heading(from, to);\n\t\t\t}\n\t\t\tthis.setLatLng(this._interpolate(from, to, lengths[i] ? Math.min(1, distance / lengths[i]) : 1));\n\n\t\t\tif (moved < total) {\n\t\t\t\tthis._moveFrame = requestAnimationFrame(frame);\n\t\t\t} else {\n\t\t\t\tthis._moveFrame = null;\n\t\t\t\tthis.fire('moveend');\n\t\t\t}\n\t\t};\n\t\tthis._moveFrame = requestAnimationFrame(frame);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Stops the movement of `moveTo()` or `moveAlong()`.\n\t * @group Marker movement\n\t * @returns {this}\n\t */\n\tstopMoving() {\n\t\tcancelAnimationFrame(this._moveFrame);\n\t\tthis._moveFrame = null;\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` while the marker moves with `moveTo()` or `moveAlong()`.\n\t * @group Marker movement\n\t * @returns {boolean}\n\t */\n\tisMoving() {\n\t\treturn !!this._moveFrame;\n\t},\n\n\t// A straight line in the projection of the map (if any)\n\t_interpolate(from, to, t) {\n\t\tconst crs = this._map?.options.crs;\n\t\tif (!crs) {\n\t\t\treturn new LatLng(from.lat + (to.lat - from.lat) * t, from.lng + (to.lng - from.lng) * t);\n\t\t}\n\t\tconst a = crs.projection.project(from),\n\t\tb = crs.projection.project(to);\n\t\treturn crs.projection.unproject(a.add(b.subtract(a).multiplyBy(t)));\n\t},\n\n\t// The heading from `from` to `to` in degrees clockwise from north, relative to\n\t// the screen unless the icon rotates with the view\n\t_heading(from, to) {\n\t\tconst crs = this._map?.options.crs,\n\t\ta = crs ? crs.latLngToPoint(from, 0) : new Point(from.lng, -from.lat),\n\t\tb = crs ? crs.latLngToPoint(to, 0) : new Point(to.lng, -to.lat),\n\t\theading = Math.atan2(b.x - a.x, a.y - b.y) * 180 / Math.PI;\n\t\treturn heading - (this.options.rotateWithView ? 0 : (this._map?.getBearing?.() ?? 0));\n\t},\n\n\t/**\n\t * Stops the movement when the marker is removed from the map.\n\t * @internal\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tthis.stopMoving();\n\t\treturn onRemove.call(this, map);\n\t}\n};\n/** @typedef {typeof markerMoveMethods} MarkerMoveMethods */\n\nMarker.include(markerMoveMethods);\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,MAAM,EAAC,aAAY,OAAO;;AAoI1B,OAAO,QAAQ;;;;;;;;CAzGd,OAAO,QAAQ,SAAS;EACvB,OAAO,KAAK,UAAU,CAAC,MAAM,GAAG,OAAO;CACxC;;;;;;;;;;;;;;CAeA,UAAU,SAAS,UAAU,CAAC,GAAG;EAChC,KAAK,WAAW;EAEhB,MAAM,SAAS,CAAC,KAAK,SAAS,GAAG,QAAQ,KAAI,WAAU,OAAO,KAAK,MAAM,CAAC,CAAC,GAC3E,UAAU,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,KAAK,MAAM,SAAS,OAAO,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC,WAAW,KAAK,CAAC,G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AE;EAC7B,OAAO,IAAI,WAAW,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;CACnE;CAIA,SAAS,MAAM,IAAI;EAClB,MAAM,MAAM,KAAK,MAAM,QAAQ,KAC/B,IAAI,MAAM,IAAI,cAAc,MAAM,CAAC,IAAI,IAAI,MAAM,KAAK,KAAK,CAAC,KAAK,GAAG,GACpE,IAAI,MAAM,IAAI,cAAc,IAAI,CAAC,IAAI,IAAI,MAAM,GAAG,KAAK,CAAC,GAAG,GAAG;EAE9D,OADU,KAAK,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,IAAI,MAAM,KAAK,MACtC,KAAK,QAAQ,iBAAiB,IAAK,KAAK,MAAM,aAAa,KAAK;CACnF;;;;;;CAOA,SAAS,KAAK;EACb,KAAK,WAAW;EAChB,OAAO,SAAS,KAAK,MAAM,GAAG;CAC/B;AAI8B,CAAC"}
@@ -4,9 +4,11 @@ import { off, on } from "../../dom/DomEvent.js";
4
4
  import { setPosition } from "../../dom/DomUtil.js";
5
5
  import { Layer } from "../Layer.js";
6
6
  import { LatLng } from "../../geo/LatLng.js";
7
+ import { pointToGeoJSON } from "../GeoJSONUtil.js";
7
8
  import { DefaultIcon } from "./DefaultIcon.js";
8
9
  import { MarkerDrag } from "./Marker.Drag.js";
9
10
  //#region src/layer/marker/Marker.js
11
+ /** @import {Feature} from 'geojson' */
10
12
  /** @import {Icon} from './Icon.js' */
11
13
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
12
14
  /** @import {PointExpression} from '../../geometry/Point.js' */
@@ -20,7 +22,7 @@ import { MarkerDrag } from "./Marker.Drag.js";
20
22
  * marker. See [Icon documentation](#Icon) for details on how to customize the marker
21
23
  * icon. If not specified, a common instance of `DefaultIcon` is used.
22
24
  * @property {boolean} [keyboard=true] Whether the marker can be tabbed to with a keyboard
23
- * and clicked by pressing enter.
25
+ * and, if interactive, clicked by pressing Enter or Space.
24
26
  * @property {string} [title=''] Text for the browser tooltip that appear on marker hover
25
27
  * (no tooltip by default).
26
28
  * [Useful for accessibility](https://maplair.org/examples/accessibility/#markers-must-be-labelled).
@@ -81,28 +83,26 @@ import { MarkerDrag } from "./Marker.Drag.js";
81
83
  * coordinates are included in event arguments as `oldLatLng`, `latlng`.
82
84
  */
83
85
  var Marker = class Marker extends Layer {
84
- static {
85
- this.setDefaultOptions({
86
- icon: new DefaultIcon(),
87
- interactive: true,
88
- keyboard: true,
89
- title: "",
90
- alt: "Marker",
91
- zIndexOffset: 0,
92
- opacity: 1,
93
- riseOnHover: false,
94
- riseOffset: 250,
95
- pane: "markerPane",
96
- shadowPane: "shadowPane",
97
- shadow: true,
98
- bubblingPointerEvents: false,
99
- autoPanOnFocus: true,
100
- draggable: false,
101
- autoPan: false,
102
- autoPanPadding: [50, 50],
103
- autoPanSpeed: 10
104
- });
105
- }
86
+ static defaultOptions = {
87
+ icon: /* @__PURE__ */ new DefaultIcon(),
88
+ interactive: true,
89
+ keyboard: true,
90
+ title: "",
91
+ alt: "Marker",
92
+ zIndexOffset: 0,
93
+ opacity: 1,
94
+ riseOnHover: false,
95
+ riseOffset: 250,
96
+ pane: "markerPane",
97
+ shadowPane: "shadowPane",
98
+ shadow: true,
99
+ bubblingPointerEvents: false,
100
+ autoPanOnFocus: true,
101
+ draggable: false,
102
+ autoPan: false,
103
+ autoPanPadding: [50, 50],
104
+ autoPanSpeed: 10
105
+ };
106
106
  /**
107
107
  * Instantiates a Marker object given a geographical point and optionally an options
108
108
  * object.
@@ -131,9 +131,9 @@ var Marker = class Marker extends Layer {
131
131
  * @param {MaplairMap} map
132
132
  */
133
133
  onRemove(map) {
134
- if (this.dragging?.enabled()) {
135
- this.options.draggable = true;
136
- this.dragging.removeHooks();
134
+ if (this.dragging) {
135
+ this.options.draggable = this.dragging.enabled();
136
+ if (this.options.draggable) this.dragging.removeHooks();
137
137
  }
138
138
  delete this.dragging;
139
139
  if (this._zoomAnimated) map.off("zoomanim", this._animateZoom, this);
@@ -202,7 +202,6 @@ var Marker = class Marker extends Layer {
202
202
  this._initIcon();
203
203
  this.update();
204
204
  }
205
- if (this._popup) this.bindPopup(this._popup, this._popup.options);
206
205
  return this;
207
206
  }
208
207
  /**
@@ -232,12 +231,13 @@ var Marker = class Marker extends Layer {
232
231
  if (this._icon) this._removeIcon();
233
232
  addIcon = true;
234
233
  if (options.title) icon.title = options.title;
235
- if (icon.tagName === "IMG") icon.alt = options.alt ?? "";
234
+ if (icon instanceof HTMLImageElement) icon.alt = options.alt ?? "";
236
235
  }
237
236
  icon.classList.add(classToAdd);
238
237
  if (options.keyboard) {
239
- icon.tabIndex = "0";
240
- icon.setAttribute("role", "button");
238
+ icon.tabIndex = 0;
239
+ if (options.interactive) icon.setAttribute("role", "button");
240
+ on(icon, "keydown", this._onKeyDown, this);
241
241
  }
242
242
  this._icon = icon;
243
243
  if (options.riseOnHover) this.on({
@@ -267,13 +267,14 @@ var Marker = class Marker extends Layer {
267
267
  pointerout: this._resetZIndex
268
268
  });
269
269
  if (this.options.autoPanOnFocus) off(this._icon, "focus", this._panOnFocus, this);
270
+ off(this._icon, "keydown", this._onKeyDown, this);
270
271
  this._icon.remove();
271
272
  this.removeInteractiveTarget(this._icon);
272
273
  this._icon = null;
273
274
  }
274
275
  _updateCulling() {
275
276
  if (!this._icon || !this._map) return;
276
- const visible = this._map.getBounds().pad(.5).contains(this._latlng) || !!this.dragging?._draggable?._moving || this._icon.contains(document.activeElement);
277
+ const map = this._map, visible = (map._cullingBounds ??= map.getBounds().pad(.5)).contains(this._latlng) || !!this.dragging?._draggable?._moving || this._icon.contains(document.activeElement);
277
278
  if (visible === !this._culled) return;
278
279
  this._culled = !visible;
279
280
  if (visible) {
@@ -306,6 +307,10 @@ var Marker = class Marker extends Layer {
306
307
  }
307
308
  _updateInteractive() {
308
309
  if (!this._icon) return;
310
+ if (this.options.keyboard) {
311
+ if (this.options.interactive) this._icon.setAttribute("role", "button");
312
+ else this._icon.removeAttribute("role");
313
+ }
309
314
  if (this.options.interactive) {
310
315
  this._initInteraction();
311
316
  if (this._draggableBeforeNonInteractive) this.dragging?.enable();
@@ -321,6 +326,10 @@ var Marker = class Marker extends Layer {
321
326
  this._icon.classList.add("maplair-interactive");
322
327
  this.addInteractiveTarget(this._icon);
323
328
  if (MarkerDrag) {
329
+ if (this.dragging?._draggable?._element === this._icon) {
330
+ this._icon.classList.toggle("maplair-marker-draggable", this.dragging.enabled());
331
+ return;
332
+ }
324
333
  let draggable = this.options.draggable;
325
334
  if (this.dragging) {
326
335
  draggable = this.dragging.enabled();
@@ -356,8 +365,8 @@ var Marker = class Marker extends Layer {
356
365
  }
357
366
  _updateOpacity() {
358
367
  const opacity = this.options.opacity;
359
- if (this._icon) this._icon.style.opacity = opacity;
360
- if (this._shadow) this._shadow.style.opacity = opacity;
368
+ if (this._icon) this._icon.style.opacity = `${opacity}`;
369
+ if (this._shadow) this._shadow.style.opacity = `${opacity}`;
361
370
  }
362
371
  _bringToFront() {
363
372
  this._updateZIndex(this.options.riseOffset);
@@ -365,6 +374,14 @@ var Marker = class Marker extends Layer {
365
374
  _resetZIndex() {
366
375
  this._updateZIndex(0);
367
376
  }
377
+ _onKeyDown(e) {
378
+ if (this.options.interactive && e.target === this._icon && !e.repeat && (e.key === "Enter" || e.key === " ")) {
379
+ e.preventDefault();
380
+ this._clickedByKeyboard = true;
381
+ this._icon.click();
382
+ this._clickedByKeyboard = false;
383
+ }
384
+ }
368
385
  _panOnFocus() {
369
386
  const map = this._map;
370
387
  if (!map) return;
@@ -382,6 +399,17 @@ var Marker = class Marker extends Layer {
382
399
  _getTooltipAnchor() {
383
400
  return this.options.icon.options.tooltipAnchor;
384
401
  }
402
+ /**
403
+ * Coordinates values are rounded with [`formatNum`](#util-formatnum) to the
404
+ * given `precision`. Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON)
405
+ * representation of the marker (as a GeoJSON `Point` Feature).
406
+ * @group Other methods
407
+ * @param {number|false} [precision]
408
+ * @returns {Feature}
409
+ */
410
+ toGeoJSON(precision) {
411
+ return pointToGeoJSON(this, precision);
412
+ }
385
413
  };
386
414
  //#endregion
387
415
  export { Marker };
@@ -1 +1 @@
1
- {"version":3,"file":"Marker.js","names":[],"sources":["../../../../src/layer/marker/Marker.js"],"sourcesContent":["import {Layer} from '../Layer.js';\nimport {DefaultIcon} from './DefaultIcon.js';\nimport * as Util from '../../core/Util.js';\nimport {LatLng} from '../../geo/LatLng.js';\nimport {Point} from '../../geometry/Point.js';\nimport * as DomUtil from '../../dom/DomUtil.js';\nimport * as DomEvent from '../../dom/DomEvent.js';\nimport {MarkerDrag} from './Marker.Drag.js';\n/** @import {Icon} from './Icon.js' */\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {PointExpression} from '../../geometry/Point.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {MaplairEvent} from '../../core/Events.js' */\n/** @import {InteractiveLayerOptions} from '../Layer.js' */\n\n/**\n * Options of `Marker`.\n * @typedef {object} MarkerOptions\n * @property {Icon} [icon=new DefaultIcon()] Icon instance to use for rendering the\n * marker. See [Icon documentation](#Icon) for details on how to customize the marker\n * icon. If not specified, a common instance of `DefaultIcon` is used.\n * @property {boolean} [keyboard=true] Whether the marker can be tabbed to with a keyboard\n * and clicked by pressing enter.\n * @property {string} [title=''] Text for the browser tooltip that appear on marker hover\n * (no tooltip by default).\n * [Useful for accessibility](https://maplair.org/examples/accessibility/#markers-must-be-labelled).\n * @property {string} [alt='Marker'] Text for the `alt` attribute of the icon image.\n * [Useful for accessibility](https://maplair.org/examples/accessibility/#markers-must-be-labelled).\n * @property {number} [zIndexOffset=0] By default, marker images zIndex is set\n * automatically based on its latitude. Use this option if you want to put the marker on\n * top of all others (or below), specifying a high value like `1000` (or high negative\n * value, respectively).\n * @property {number} [opacity=1] The opacity of the marker.\n * @property {boolean} [riseOnHover=false] If `true`, the marker will get on top of\n * others when you hover the pointer over it.\n * @property {number} [riseOffset=250] The z-index offset used for the `riseOnHover`\n * feature.\n * @property {string} [pane='markerPane'] `Map pane` where the markers icon will be added.\n * @property {string} [shadowPane='shadowPane'] `Map pane` where the markers shadow will\n * be added.\n * @property {boolean} [shadow=true] Whether to show the shadow of the marker's icon. Each\n * shadow is an additional element on the page, so disabling shadows noticeably reduces\n * the browser's rendering work when showing many markers (e.g. several thousands),\n * especially while panning and zooming. To disable shadows for all markers, use\n * `Marker.mergeOptions({shadow: false})`.\n * @property {boolean} [bubblingPointerEvents=false] When `true`, a pointer event on this\n * marker will trigger the same event on the map (unless\n * [`DomEvent.stopPropagation`](#domevent-stoppropagation) is used).\n * @property {boolean} [autoPanOnFocus=true] When `true`, the map will pan whenever the\n * marker is focused (via e.g. pressing `tab` on the keyboard) to ensure the marker is\n * visible within the map's bounds.\n * @property {boolean} [draggable=false] Whether the marker is draggable with pointer or\n * not.\n * @property {boolean} [autoPan=false] Whether to pan the map when dragging this marker\n * near its edge or not.\n * @property {PointExpression} [autoPanPadding=[50, 50]] Distance (in pixels to the\n * left/right and to the top/bottom) of the map edge to start panning the map.\n * @property {number} [autoPanSpeed=10] Number of pixels the map should pan by.\n * @extends InteractiveLayerOptions\n */\n\n/**\n * The event object of `move` and `drag` of markers.\n * @typedef {object} MarkerMoveEvent\n * @property {LatLng} latlng The new position of the marker.\n * @property {LatLng} [oldLatLng] The previous position of the marker.\n * @extends MaplairEvent\n */\n\n/**\n * Marker is used to display clickable/draggable icons on the map. Extends `Layer`.\n *\n * In addition to [shared layer methods](#Layer) like `addTo()` and `remove()` and\n * [popup methods](#Popup) like `bindPopup()` you can also use the methods below.\n *\n * @example\n * ```js\n * new Marker([50.5, 30.5]).addTo(map);\n * ```\n *\n * @fires move {MarkerMoveEvent} Fired when the marker is moved via\n * [`setLatLng`](#marker-setlatlng) or by [dragging](#marker-dragging). Old and new\n * coordinates are included in event arguments as `oldLatLng`, `latlng`.\n */\nexport class Marker extends Layer {\n\n\tstatic {\n\t\tthis.setDefaultOptions({\n\t\t\ticon: new DefaultIcon(),\n\n\t\t\t// Option inherited from \"Interactive layer\" abstract class\n\t\t\tinteractive: true,\n\n\t\t\tkeyboard: true,\n\t\t\ttitle: '',\n\t\t\talt: 'Marker',\n\t\t\tzIndexOffset: 0,\n\t\t\topacity: 1,\n\t\t\triseOnHover: false,\n\t\t\triseOffset: 250,\n\t\t\tpane: 'markerPane',\n\t\t\tshadowPane: 'shadowPane',\n\t\t\tshadow: true,\n\t\t\tbubblingPointerEvents: false,\n\t\t\tautoPanOnFocus: true,\n\t\t\tdraggable: false,\n\t\t\tautoPan: false,\n\t\t\tautoPanPadding: [50, 50],\n\t\t\tautoPanSpeed: 10\n\t\t});\n\t}\n\n\t/**\n\t * Instantiates a Marker object given a geographical point and optionally an options\n\t * object.\n\t * @param {LatLngExpression} latlng\n\t * @param {MarkerOptions} [options]\n\t */\n\tconstructor(latlng, options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\t\tthis._latlng = new LatLng(latlng);\n\n\t\tthis.callInitHooks(Marker);\n\t}\n\n\t/**\n\t * Adds the icon (and shadow) of the marker to the map.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\tthis._zoomAnimated = this._zoomAnimated && map.options.markerZoomAnimation;\n\n\t\tif (this._zoomAnimated) {\n\t\t\tmap.on('zoomanim', this._animateZoom, this);\n\t\t}\n\n\t\tthis._initIcon();\n\t\tthis.update();\n\n\t\tif (map.options.markerCulling) {\n\t\t\tthis._updateCulling();\n\t\t}\n\t}\n\n\t/**\n\t * Removes the icon (and shadow) of the marker from the map.\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tif (this.dragging?.enabled()) {\n\t\t\tthis.options.draggable = true;\n\t\t\tthis.dragging.removeHooks();\n\t\t}\n\t\tdelete this.dragging;\n\n\t\tif (this._zoomAnimated) {\n\t\t\tmap.off('zoomanim', this._animateZoom, this);\n\t\t}\n\n\t\tthis._removeIcon();\n\t\tthis._removeShadow();\n\t\tthis._culled = false;\n\t}\n\n\t/**\n\t * Returns the map events the marker listens to, see `Layer`.\n\t * @returns {Record<string, Function>}\n\t */\n\tgetEvents() {\n\t\tconst events = {\n\t\t\tzoom: this.update,\n\t\t\tviewreset: this.update\n\t\t};\n\t\tif (this._map?.options.markerCulling) {\n\t\t\tevents.moveend = this._updateCulling;\n\t\t}\n\t\treturn events;\n\t}\n\n\t/**\n\t * Returns the current geographical position of the marker.\n\t * @returns {LatLng}\n\t */\n\tgetLatLng() {\n\t\treturn this._latlng;\n\t}\n\n\t/**\n\t * Changes the marker position to the given point.\n\t * @param {LatLngExpression} latlng\n\t * @returns {this}\n\t */\n\tsetLatLng(latlng) {\n\t\tconst oldLatLng = this._latlng;\n\t\tthis._latlng = new LatLng(latlng);\n\t\tif (this._map?.options.markerCulling) {\n\t\t\tthis._updateCulling();\n\t\t}\n\t\tthis.update();\n\n\t\treturn this.fire('move', {oldLatLng, latlng: this._latlng});\n\t}\n\n\t/**\n\t * Changes the [zIndex offset](#markeroptions-zindexoffset) of the marker.\n\t * @param {number} offset\n\t * @returns {this}\n\t */\n\tsetZIndexOffset(offset) {\n\t\tthis.options.zIndexOffset = offset;\n\t\treturn this.update();\n\t}\n\n\t/**\n\t * Returns the current icon used by the marker.\n\t * @returns {Icon}\n\t */\n\tgetIcon() {\n\t\treturn this.options.icon;\n\t}\n\n\t/**\n\t * Changes the marker icon.\n\t * @param {Icon} icon\n\t * @returns {this}\n\t */\n\tsetIcon(icon) {\n\n\t\tthis.options.icon = icon;\n\n\t\tif (this._map) {\n\t\t\tthis._initIcon();\n\t\t\tthis.update();\n\t\t}\n\n\t\tif (this._popup) {\n\t\t\tthis.bindPopup(this._popup, this._popup.options);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the instance of [`HTMLElement`](https://developer.mozilla.org/docs/Web/API/HTMLElement)\n\t * used by Marker layer.\n\t * @returns {HTMLElement}\n\t */\n\tgetElement() {\n\t\treturn this._icon;\n\t}\n\n\t/**\n\t * Updates the position of the marker on the map, e.g. after a change of its options.\n\t * @returns {this}\n\t */\n\tupdate() {\n\n\t\tif (this._icon && this._map && !this._culled) {\n\t\t\tconst pos = this._map.latLngToLayerPoint(this._latlng).round();\n\t\t\tthis._setPos(pos);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t_initIcon() {\n\t\tconst options = this.options,\n\t\tclassToAdd = `maplair-zoom-${this._zoomAnimated ? 'animated' : 'hide'}`;\n\n\t\tconst icon = options.icon.createIcon(this._icon);\n\t\tlet addIcon = false;\n\n\t\t// if we're not reusing the icon, remove the old one and init new one\n\t\tif (icon !== this._icon) {\n\t\t\tif (this._icon) {\n\t\t\t\tthis._removeIcon();\n\t\t\t}\n\t\t\taddIcon = true;\n\n\t\t\tif (options.title) {\n\t\t\t\ticon.title = options.title;\n\t\t\t}\n\n\t\t\tif (icon.tagName === 'IMG') {\n\t\t\t\ticon.alt = options.alt ?? '';\n\t\t\t}\n\t\t}\n\n\t\ticon.classList.add(classToAdd);\n\n\t\tif (options.keyboard) {\n\t\t\ticon.tabIndex = '0';\n\t\t\ticon.setAttribute('role', 'button');\n\t\t}\n\n\t\tthis._icon = icon;\n\n\t\tif (options.riseOnHover) {\n\t\t\tthis.on({\n\t\t\t\tpointerover: this._bringToFront,\n\t\t\t\tpointerout: this._resetZIndex\n\t\t\t});\n\t\t}\n\n\t\tif (this.options.autoPanOnFocus) {\n\t\t\tDomEvent.on(icon, 'focus', this._panOnFocus, this);\n\t\t}\n\n\t\tconst newShadow = options.shadow ? options.icon.createShadow(this._shadow) : null;\n\t\tlet addShadow = false;\n\n\t\tif (newShadow !== this._shadow) {\n\t\t\tthis._removeShadow();\n\t\t\taddShadow = true;\n\t\t}\n\n\t\tif (newShadow) {\n\t\t\tnewShadow.classList.add(classToAdd);\n\t\t\tnewShadow.alt = '';\n\t\t}\n\t\tthis._shadow = newShadow;\n\n\n\t\tif (options.opacity < 1) {\n\t\t\tthis._updateOpacity();\n\t\t}\n\n\n\t\tif (addIcon) {\n\t\t\tthis.getPane().appendChild(this._icon);\n\t\t}\n\t\tthis._initInteraction();\n\t\tif (newShadow && addShadow) {\n\t\t\tthis.getPane(options.shadowPane).appendChild(this._shadow);\n\t\t}\n\t}\n\n\t_removeIcon() {\n\t\tif (this.options.riseOnHover) {\n\t\t\tthis.off({\n\t\t\t\tpointerover: this._bringToFront,\n\t\t\t\tpointerout: this._resetZIndex\n\t\t\t});\n\t\t}\n\n\t\tif (this.options.autoPanOnFocus) {\n\t\t\tDomEvent.off(this._icon, 'focus', this._panOnFocus, this);\n\t\t}\n\n\t\tthis._icon.remove();\n\t\tthis.removeInteractiveTarget(this._icon);\n\n\t\tthis._icon = null;\n\t}\n\n\t// With the map's `markerCulling` option, takes the icon and shadow of a marker\n\t// far outside of the map view off the page (and puts them back when needed),\n\t// so that the browser doesn't need to render, and the marker doesn't need\n\t// to reposition, them while panning and zooming.\n\t_updateCulling() {\n\t\tif (!this._icon || !this._map) { return; }\n\n\t\tconst visible = this._map.getBounds().pad(0.5).contains(this._latlng) ||\n\t\t\t!!this.dragging?._draggable?._moving ||\n\t\t\tthis._icon.contains(document.activeElement);\n\n\t\tif (visible === !this._culled) { return; }\n\t\tthis._culled = !visible;\n\n\t\tif (visible) {\n\t\t\tthis.getPane().appendChild(this._icon);\n\t\t\tif (this._shadow) {\n\t\t\t\tthis.getPane(this.options.shadowPane).appendChild(this._shadow);\n\t\t\t}\n\t\t\tthis.update();\n\t\t} else {\n\t\t\tthis._icon.remove();\n\t\t\tthis._shadow?.remove();\n\t\t}\n\t}\n\n\t_removeShadow() {\n\t\tthis._shadow?.remove();\n\t\tthis._shadow = null;\n\t}\n\n\t_setPos(pos) {\n\n\t\tif (this._icon) {\n\t\t\tDomUtil.setPosition(this._icon, pos);\n\t\t}\n\n\t\tif (this._shadow) {\n\t\t\tDomUtil.setPosition(this._shadow, pos);\n\t\t}\n\n\t\tthis._zIndex = pos.y + this.options.zIndexOffset;\n\n\t\tthis._resetZIndex();\n\t}\n\n\t_updateZIndex(offset) {\n\t\tconst zIndex = String(this._zIndex + offset);\n\t\tif (this._icon && this._icon.style.zIndex !== zIndex) {\n\t\t\tthis._icon.style.zIndex = zIndex;\n\t\t}\n\t}\n\n\t_animateZoom(opt) {\n\t\tif (this._culled) { return; }\n\t\tconst pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round();\n\n\t\tthis._setPos(pos);\n\t}\n\n\t_updateInteractive() {\n\t\tif (!this._icon) { return; }\n\t\tif (this.options.interactive) {\n\t\t\tthis._initInteraction();\n\t\t\tif (this._draggableBeforeNonInteractive) {\n\t\t\t\tthis.dragging?.enable();\n\t\t\t}\n\t\t} else {\n\t\t\tthis._icon.classList.remove('maplair-interactive');\n\t\t\tthis.removeInteractiveTarget(this._icon);\n\t\t\tthis._draggableBeforeNonInteractive = this.dragging?.enabled();\n\t\t\tthis.dragging?.disable();\n\t\t}\n\t}\n\n\t_initInteraction() {\n\n\t\tif (!this.options.interactive) { return; }\n\n\t\tthis._icon.classList.add('maplair-interactive');\n\n\t\tthis.addInteractiveTarget(this._icon);\n\n\t\tif (MarkerDrag) {\n\t\t\tlet draggable = this.options.draggable;\n\t\t\tif (this.dragging) {\n\t\t\t\tdraggable = this.dragging.enabled();\n\t\t\t\tthis.dragging.disable();\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Marker dragging handler, see `Handler`. Only valid when the marker is on the\n\t\t\t * map (otherwise set [`marker.options.draggable`](#markeroptions-draggable)).\n\t\t\t *\n\t\t\t * Interaction handlers are properties of a marker instance that allow you to\n\t\t\t * control interaction behavior in runtime, enabling or disabling certain\n\t\t\t * features such as dragging (see `Handler` methods). Example:\n\t\t\t *\n\t\t\t * ```js\n\t\t\t * marker.dragging.disable();\n\t\t\t * ```\n\t\t\t * @group Interaction handlers\n\t\t\t * @type {MarkerDrag}\n\t\t\t */\n\t\t\tthis.dragging = new MarkerDrag(this);\n\n\t\t\tif (draggable) {\n\t\t\t\tthis.dragging.enable();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Changes the opacity of the marker.\n\t * @param {number} opacity\n\t * @returns {this}\n\t */\n\tsetOpacity(opacity) {\n\t\tthis.options.opacity = opacity;\n\t\tif (this._map) {\n\t\t\tthis._updateOpacity();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t_updateOpacity() {\n\t\tconst opacity = this.options.opacity;\n\n\t\tif (this._icon) {\n\t\t\tthis._icon.style.opacity = opacity;\n\t\t}\n\n\t\tif (this._shadow) {\n\t\t\tthis._shadow.style.opacity = opacity;\n\t\t}\n\t}\n\n\t_bringToFront() {\n\t\tthis._updateZIndex(this.options.riseOffset);\n\t}\n\n\t_resetZIndex() {\n\t\tthis._updateZIndex(0);\n\t}\n\n\t_panOnFocus() {\n\t\tconst map = this._map;\n\t\tif (!map) { return; }\n\n\t\tconst iconOpts = this.options.icon.options;\n\t\tconst size = iconOpts.iconSize ? Point.from(iconOpts.iconSize) : new Point(0, 0);\n\t\tconst anchor = iconOpts.iconAnchor ? Point.from(iconOpts.iconAnchor) : new Point(0, 0);\n\n\t\tmap.panInside(this._latlng, {\n\t\t\tpaddingTopLeft: anchor,\n\t\t\tpaddingBottomRight: size.subtract(anchor)\n\t\t});\n\t}\n\n\t_getPopupAnchor() {\n\t\treturn this.options.icon.options.popupAnchor;\n\t}\n\n\t_getTooltipAnchor() {\n\t\treturn this.options.icon.options.tooltipAnchor;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,IAAa,SAAb,MAAa,eAAe,MAAM;CAEjC;EACC,KAAK,kBAAkB;GACtB,MAAM,IAAI,YAAY;GAGtB,aAAa;GAEb,UAAU;GACV,OAAO;GACP,KAAK;GACL,cAAc;GACd,SAAS;GACT,aAAa;GACb,YAAY;GACZ,MAAM;GACN,YAAY;GACZ,QAAQ;GACR,uBAAu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7B,IAAI,KAAK,OACR,KAAK,MAAM,MAAM,UAAU;EAG5B,IAAI,KAAK,SACR,KAAK,QAAQ,MAAM,UAAU;CAE/B;CAEA,gBAAgB;EACf,KAAK,cAAc,KAAK,QAAQ,UAAU;CAC3C;CAEA,eAAe;EACd,KAAK,cAAc,CAAC;CACrB;CAEA,cAAc;EACb,MAAM,MAAM,KAAK;EACjB,IAAI,CAAC,KAAO;EAEZ,MAAM,WAAW,KAAK,QAAQ,KAAK;EACnC,MAAM,OAAO,SAAS,WAAW,MAAM,KAAK,SAAS,QAAQ,IAAI,IAAI,MAAM,GAAG,CAAC;EAC/E,MAAM,SAAS,SAAS,aAAa,MAAM,KAAK,SAAS,UAAU,IAAI,IAAI,MAAM,GAAG,CAAC;EAErF,IAAI,UAAU,KAAK,SAAS;GAC3B,gBAAgB;GAChB,oBAAoB,KAAK,SAAS,MAAM;EACzC,CAAC;CACF;CAEA,kBAAkB;EACjB,OAAO,KAAK,QAAQ,KAAK,QAAQ;CAClC;CAEA,oBAAoB;EACnB,OAAO,KAAK,QAAQ,KAAK,QAAQ;CAClC;AACD"}
1
+ {"version":3,"file":"Marker.js","names":[],"sources":["../../../../src/layer/marker/Marker.js"],"sourcesContent":["import {Layer} from '../Layer.js';\nimport {DefaultIcon} from './DefaultIcon.js';\nimport * as Util from '../../core/Util.js';\nimport {LatLng} from '../../geo/LatLng.js';\nimport {Point} from '../../geometry/Point.js';\nimport * as DomUtil from '../../dom/DomUtil.js';\nimport * as DomEvent from '../../dom/DomEvent.js';\nimport {MarkerDrag} from './Marker.Drag.js';\nimport {pointToGeoJSON} from '../GeoJSONUtil.js';\n/** @import {Feature} from 'geojson' */\n/** @import {Icon} from './Icon.js' */\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {PointExpression} from '../../geometry/Point.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {MaplairEvent} from '../../core/Events.js' */\n/** @import {InteractiveLayerOptions} from '../Layer.js' */\n\n/**\n * Options of `Marker`.\n * @typedef {object} MarkerOptions\n * @property {Icon} [icon=new DefaultIcon()] Icon instance to use for rendering the\n * marker. See [Icon documentation](#Icon) for details on how to customize the marker\n * icon. If not specified, a common instance of `DefaultIcon` is used.\n * @property {boolean} [keyboard=true] Whether the marker can be tabbed to with a keyboard\n * and, if interactive, clicked by pressing Enter or Space.\n * @property {string} [title=''] Text for the browser tooltip that appear on marker hover\n * (no tooltip by default).\n * [Useful for accessibility](https://maplair.org/examples/accessibility/#markers-must-be-labelled).\n * @property {string} [alt='Marker'] Text for the `alt` attribute of the icon image.\n * [Useful for accessibility](https://maplair.org/examples/accessibility/#markers-must-be-labelled).\n * @property {number} [zIndexOffset=0] By default, marker images zIndex is set\n * automatically based on its latitude. Use this option if you want to put the marker on\n * top of all others (or below), specifying a high value like `1000` (or high negative\n * value, respectively).\n * @property {number} [opacity=1] The opacity of the marker.\n * @property {boolean} [riseOnHover=false] If `true`, the marker will get on top of\n * others when you hover the pointer over it.\n * @property {number} [riseOffset=250] The z-index offset used for the `riseOnHover`\n * feature.\n * @property {string} [pane='markerPane'] `Map pane` where the markers icon will be added.\n * @property {string} [shadowPane='shadowPane'] `Map pane` where the markers shadow will\n * be added.\n * @property {boolean} [shadow=true] Whether to show the shadow of the marker's icon. Each\n * shadow is an additional element on the page, so disabling shadows noticeably reduces\n * the browser's rendering work when showing many markers (e.g. several thousands),\n * especially while panning and zooming. To disable shadows for all markers, use\n * `Marker.mergeOptions({shadow: false})`.\n * @property {boolean} [bubblingPointerEvents=false] When `true`, a pointer event on this\n * marker will trigger the same event on the map (unless\n * [`DomEvent.stopPropagation`](#domevent-stoppropagation) is used).\n * @property {boolean} [autoPanOnFocus=true] When `true`, the map will pan whenever the\n * marker is focused (via e.g. pressing `tab` on the keyboard) to ensure the marker is\n * visible within the map's bounds.\n * @property {boolean} [draggable=false] Whether the marker is draggable with pointer or\n * not.\n * @property {boolean} [autoPan=false] Whether to pan the map when dragging this marker\n * near its edge or not.\n * @property {PointExpression} [autoPanPadding=[50, 50]] Distance (in pixels to the\n * left/right and to the top/bottom) of the map edge to start panning the map.\n * @property {number} [autoPanSpeed=10] Number of pixels the map should pan by.\n * @extends InteractiveLayerOptions\n */\n\n/**\n * The event object of `move` and `drag` of markers.\n * @typedef {object} MarkerMoveEvent\n * @property {LatLng} latlng The new position of the marker.\n * @property {LatLng} [oldLatLng] The previous position of the marker.\n * @extends MaplairEvent\n */\n\n/**\n * Marker is used to display clickable/draggable icons on the map. Extends `Layer`.\n *\n * In addition to [shared layer methods](#Layer) like `addTo()` and `remove()` and\n * [popup methods](#Popup) like `bindPopup()` you can also use the methods below.\n *\n * @example\n * ```js\n * new Marker([50.5, 30.5]).addTo(map);\n * ```\n *\n * @fires move {MarkerMoveEvent} Fired when the marker is moved via\n * [`setLatLng`](#marker-setlatlng) or by [dragging](#marker-dragging). Old and new\n * coordinates are included in event arguments as `oldLatLng`, `latlng`.\n */\nexport class Marker extends Layer {\n\n\tstatic defaultOptions = {\n\t\ticon: /* @__PURE__ */ new DefaultIcon(),\n\n\t\t// Option inherited from \"Interactive layer\" abstract class\n\t\tinteractive: true,\n\n\t\tkeyboard: true,\n\t\ttitle: '',\n\t\talt: 'Marker',\n\t\tzIndexOffset: 0,\n\t\topacity: 1,\n\t\triseOnHover: false,\n\t\triseOffset: 250,\n\t\tpane: 'markerPane',\n\t\tshadowPane: 'shadowPane',\n\t\tshadow: true,\n\t\tbubblingPointerEvents: false,\n\t\tautoPanOnFocus: true,\n\t\tdraggable: false,\n\t\tautoPan: false,\n\t\tautoPanPadding: [50, 50],\n\t\tautoPanSpeed: 10\n\t};\n\n\t/**\n\t * Instantiates a Marker object given a geographical point and optionally an options\n\t * object.\n\t * @param {LatLngExpression} latlng\n\t * @param {MarkerOptions} [options]\n\t */\n\tconstructor(latlng, options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\t\tthis._latlng = new LatLng(latlng);\n\n\t\tthis.callInitHooks(Marker);\n\t}\n\n\t/**\n\t * Adds the icon (and shadow) of the marker to the map.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\tthis._zoomAnimated = this._zoomAnimated && map.options.markerZoomAnimation;\n\n\t\tif (this._zoomAnimated) {\n\t\t\tmap.on('zoomanim', this._animateZoom, this);\n\t\t}\n\n\t\tthis._initIcon();\n\t\tthis.update();\n\n\t\tif (map.options.markerCulling) {\n\t\t\tthis._updateCulling();\n\t\t}\n\t}\n\n\t/**\n\t * Removes the icon (and shadow) of the marker from the map.\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tif (this.dragging) {\n\t\t\t// remember whether dragging is on or off (`dragging.disable()`) for when the marker is added again\n\t\t\tthis.options.draggable = this.dragging.enabled();\n\t\t\tif (this.options.draggable) { this.dragging.removeHooks(); }\n\t\t}\n\t\tdelete this.dragging;\n\n\t\tif (this._zoomAnimated) {\n\t\t\tmap.off('zoomanim', this._animateZoom, this);\n\t\t}\n\n\t\tthis._removeIcon();\n\t\tthis._removeShadow();\n\t\tthis._culled = false;\n\t}\n\n\t/**\n\t * Returns the map events the marker listens to, see `Layer`.\n\t * @returns {Record<string, Function>}\n\t */\n\tgetEvents() {\n\t\tconst events = {\n\t\t\tzoom: this.update,\n\t\t\tviewreset: this.update\n\t\t};\n\t\tif (this._map?.options.markerCulling) {\n\t\t\tevents.moveend = this._updateCulling;\n\t\t}\n\t\treturn events;\n\t}\n\n\t/**\n\t * Returns the current geographical position of the marker.\n\t * @returns {LatLng}\n\t */\n\tgetLatLng() {\n\t\treturn this._latlng;\n\t}\n\n\t/**\n\t * Changes the marker position to the given point.\n\t * @param {LatLngExpression} latlng\n\t * @returns {this}\n\t */\n\tsetLatLng(latlng) {\n\t\tconst oldLatLng = this._latlng;\n\t\tthis._latlng = new LatLng(latlng);\n\t\tif (this._map?.options.markerCulling) {\n\t\t\tthis._updateCulling();\n\t\t}\n\t\tthis.update();\n\n\t\treturn this.fire('move', {oldLatLng, latlng: this._latlng});\n\t}\n\n\t/**\n\t * Changes the [zIndex offset](#markeroptions-zindexoffset) of the marker.\n\t * @param {number} offset\n\t * @returns {this}\n\t */\n\tsetZIndexOffset(offset) {\n\t\tthis.options.zIndexOffset = offset;\n\t\treturn this.update();\n\t}\n\n\t/**\n\t * Returns the current icon used by the marker.\n\t * @returns {Icon}\n\t */\n\tgetIcon() {\n\t\treturn this.options.icon;\n\t}\n\n\t/**\n\t * Changes the marker icon.\n\t * @param {Icon} icon\n\t * @returns {this}\n\t */\n\tsetIcon(icon) {\n\n\t\tthis.options.icon = icon;\n\n\t\tif (this._map) {\n\t\t\tthis._initIcon();\n\t\t\tthis.update();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the instance of [`HTMLElement`](https://developer.mozilla.org/docs/Web/API/HTMLElement)\n\t * used by Marker layer.\n\t * @returns {HTMLElement}\n\t */\n\tgetElement() {\n\t\treturn this._icon;\n\t}\n\n\t/**\n\t * Updates the position of the marker on the map, e.g. after a change of its options.\n\t * @returns {this}\n\t */\n\tupdate() {\n\n\t\tif (this._icon && this._map && !this._culled) {\n\t\t\tconst pos = this._map.latLngToLayerPoint(this._latlng).round();\n\t\t\tthis._setPos(pos);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t_initIcon() {\n\t\tconst options = this.options,\n\t\tclassToAdd = `maplair-zoom-${this._zoomAnimated ? 'animated' : 'hide'}`;\n\n\t\tconst icon = options.icon.createIcon(this._icon);\n\t\tlet addIcon = false;\n\n\t\t// if we're not reusing the icon, remove the old one and init new one\n\t\tif (icon !== this._icon) {\n\t\t\tif (this._icon) {\n\t\t\t\tthis._removeIcon();\n\t\t\t}\n\t\t\taddIcon = true;\n\n\t\t\tif (options.title) {\n\t\t\t\ticon.title = options.title;\n\t\t\t}\n\n\t\t\tif (icon instanceof HTMLImageElement) {\n\t\t\t\ticon.alt = options.alt ?? '';\n\t\t\t}\n\t\t}\n\n\t\ticon.classList.add(classToAdd);\n\n\t\tif (options.keyboard) {\n\t\t\ticon.tabIndex = 0;\n\t\t\tif (options.interactive) {\n\t\t\t\ticon.setAttribute('role', 'button');\n\t\t\t}\n\t\t\tDomEvent.on(icon, 'keydown', this._onKeyDown, this);\n\t\t}\n\n\t\tthis._icon = icon;\n\n\t\tif (options.riseOnHover) {\n\t\t\tthis.on({\n\t\t\t\tpointerover: this._bringToFront,\n\t\t\t\tpointerout: this._resetZIndex\n\t\t\t});\n\t\t}\n\n\t\tif (this.options.autoPanOnFocus) {\n\t\t\tDomEvent.on(icon, 'focus', this._panOnFocus, this);\n\t\t}\n\n\t\tconst newShadow = options.shadow ? options.icon.createShadow(this._shadow) : null;\n\t\tlet addShadow = false;\n\n\t\tif (newShadow !== this._shadow) {\n\t\t\tthis._removeShadow();\n\t\t\taddShadow = true;\n\t\t}\n\n\t\tif (newShadow) {\n\t\t\tnewShadow.classList.add(classToAdd);\n\t\t\tnewShadow.alt = '';\n\t\t}\n\t\tthis._shadow = newShadow;\n\n\n\t\tif (options.opacity < 1) {\n\t\t\tthis._updateOpacity();\n\t\t}\n\n\n\t\tif (addIcon) {\n\t\t\tthis.getPane().appendChild(this._icon);\n\t\t}\n\t\tthis._initInteraction();\n\t\tif (newShadow && addShadow) {\n\t\t\tthis.getPane(options.shadowPane).appendChild(this._shadow);\n\t\t}\n\t}\n\n\t_removeIcon() {\n\t\tif (this.options.riseOnHover) {\n\t\t\tthis.off({\n\t\t\t\tpointerover: this._bringToFront,\n\t\t\t\tpointerout: this._resetZIndex\n\t\t\t});\n\t\t}\n\n\t\tif (this.options.autoPanOnFocus) {\n\t\t\tDomEvent.off(this._icon, 'focus', this._panOnFocus, this);\n\t\t}\n\t\tDomEvent.off(this._icon, 'keydown', this._onKeyDown, this);\n\n\t\tthis._icon.remove();\n\t\tthis.removeInteractiveTarget(this._icon);\n\n\t\tthis._icon = null;\n\t}\n\n\t// With the map's `markerCulling` option, takes the icon and shadow of a marker\n\t// far outside of the map view off the page (and puts them back when needed),\n\t// so that the browser doesn't need to render, and the marker doesn't need\n\t// to reposition, them while panning and zooming.\n\t_updateCulling() {\n\t\tif (!this._icon || !this._map) { return; }\n\n\t\tconst map = this._map,\n\t\t// computed once per view for all markers, reset by the map on `move`\n\t\tbounds = map._cullingBounds ??= map.getBounds().pad(0.5),\n\t\tvisible = bounds.contains(this._latlng) ||\n\t\t\t!!this.dragging?._draggable?._moving ||\n\t\t\tthis._icon.contains(document.activeElement);\n\n\t\tif (visible === !this._culled) { return; }\n\t\tthis._culled = !visible;\n\n\t\tif (visible) {\n\t\t\tthis.getPane().appendChild(this._icon);\n\t\t\tif (this._shadow) {\n\t\t\t\tthis.getPane(this.options.shadowPane).appendChild(this._shadow);\n\t\t\t}\n\t\t\tthis.update();\n\t\t} else {\n\t\t\tthis._icon.remove();\n\t\t\tthis._shadow?.remove();\n\t\t}\n\t}\n\n\t_removeShadow() {\n\t\tthis._shadow?.remove();\n\t\tthis._shadow = null;\n\t}\n\n\t_setPos(pos) {\n\n\t\tif (this._icon) {\n\t\t\tDomUtil.setPosition(this._icon, pos);\n\t\t}\n\n\t\tif (this._shadow) {\n\t\t\tDomUtil.setPosition(this._shadow, pos);\n\t\t}\n\n\t\tthis._zIndex = pos.y + this.options.zIndexOffset;\n\n\t\tthis._resetZIndex();\n\t}\n\n\t_updateZIndex(offset) {\n\t\tconst zIndex = String(this._zIndex + offset);\n\t\tif (this._icon && this._icon.style.zIndex !== zIndex) {\n\t\t\tthis._icon.style.zIndex = zIndex;\n\t\t}\n\t}\n\n\t_animateZoom(opt) {\n\t\tif (this._culled) { return; }\n\t\tconst pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round();\n\n\t\tthis._setPos(pos);\n\t}\n\n\t_updateInteractive() {\n\t\tif (!this._icon) { return; }\n\t\tif (this.options.keyboard) {\n\t\t\tif (this.options.interactive) {\n\t\t\t\tthis._icon.setAttribute('role', 'button');\n\t\t\t} else {\n\t\t\t\tthis._icon.removeAttribute('role');\n\t\t\t}\n\t\t}\n\t\tif (this.options.interactive) {\n\t\t\tthis._initInteraction();\n\t\t\tif (this._draggableBeforeNonInteractive) {\n\t\t\t\tthis.dragging?.enable();\n\t\t\t}\n\t\t} else {\n\t\t\tthis._icon.classList.remove('maplair-interactive');\n\t\t\tthis.removeInteractiveTarget(this._icon);\n\t\t\tthis._draggableBeforeNonInteractive = this.dragging?.enabled();\n\t\t\tthis.dragging?.disable();\n\t\t}\n\t}\n\n\t_initInteraction() {\n\n\t\tif (!this.options.interactive) { return; }\n\n\t\tthis._icon.classList.add('maplair-interactive');\n\n\t\tthis.addInteractiveTarget(this._icon);\n\n\t\tif (MarkerDrag) {\n\t\t\t// When the icon element is reused, the drag handler still refers to it. Keep that handler, because\n\t\t\t// replacing it ends a drag in progress and forgets that the marker has just been dragged.\n\t\t\tif (this.dragging?._draggable?._element === this._icon) {\n\t\t\t\t// the icon has reset the class names of the element\n\t\t\t\tthis._icon.classList.toggle('maplair-marker-draggable', this.dragging.enabled());\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet draggable = this.options.draggable;\n\t\t\tif (this.dragging) {\n\t\t\t\tdraggable = this.dragging.enabled();\n\t\t\t\tthis.dragging.disable();\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Marker dragging handler, see `Handler`. Only valid when the marker is on the\n\t\t\t * map (otherwise set [`marker.options.draggable`](#markeroptions-draggable)).\n\t\t\t *\n\t\t\t * Interaction handlers are properties of a marker instance that allow you to\n\t\t\t * control interaction behavior in runtime, enabling or disabling certain\n\t\t\t * features such as dragging (see `Handler` methods). Example:\n\t\t\t *\n\t\t\t * ```js\n\t\t\t * marker.dragging.disable();\n\t\t\t * ```\n\t\t\t * @group Interaction handlers\n\t\t\t * @type {MarkerDrag}\n\t\t\t */\n\t\t\tthis.dragging = new MarkerDrag(this);\n\n\t\t\tif (draggable) {\n\t\t\t\tthis.dragging.enable();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Changes the opacity of the marker.\n\t * @param {number} opacity\n\t * @returns {this}\n\t */\n\tsetOpacity(opacity) {\n\t\tthis.options.opacity = opacity;\n\t\tif (this._map) {\n\t\t\tthis._updateOpacity();\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t_updateOpacity() {\n\t\tconst opacity = this.options.opacity;\n\n\t\tif (this._icon) {\n\t\t\tthis._icon.style.opacity = `${opacity}`;\n\t\t}\n\n\t\tif (this._shadow) {\n\t\t\tthis._shadow.style.opacity = `${opacity}`;\n\t\t}\n\t}\n\n\t_bringToFront() {\n\t\tthis._updateZIndex(this.options.riseOffset);\n\t}\n\n\t_resetZIndex() {\n\t\tthis._updateZIndex(0);\n\t}\n\n\t_onKeyDown(e) {\n\t\t// a key pressed on a focusable element inside a DivIcon (e.g. a <button>) already clicks it natively\n\t\tif (this.options.interactive && e.target === this._icon && !e.repeat && (e.key === 'Enter' || e.key === ' ')) {\n\t\t\te.preventDefault(); // stop Space from scrolling the page\n\t\t\t// lets a popup opened by the click take the focus, see Popup.onAdd()\n\t\t\tthis._clickedByKeyboard = true;\n\t\t\tthis._icon.click();\n\t\t\tthis._clickedByKeyboard = false;\n\t\t}\n\t}\n\n\t_panOnFocus() {\n\t\tconst map = this._map;\n\t\tif (!map) { return; }\n\n\t\tconst iconOpts = this.options.icon.options;\n\t\tconst size = iconOpts.iconSize ? Point.from(iconOpts.iconSize) : new Point(0, 0);\n\t\tconst anchor = iconOpts.iconAnchor ? Point.from(iconOpts.iconAnchor) : new Point(0, 0);\n\n\t\tmap.panInside(this._latlng, {\n\t\t\tpaddingTopLeft: anchor,\n\t\t\tpaddingBottomRight: size.subtract(anchor)\n\t\t});\n\t}\n\n\t_getPopupAnchor() {\n\t\treturn this.options.icon.options.popupAnchor;\n\t}\n\n\t_getTooltipAnchor() {\n\t\treturn this.options.icon.options.tooltipAnchor;\n\t}\n\n\t/**\n\t * Coordinates values are rounded with [`formatNum`](#util-formatnum) to the\n\t * given `precision`. Returns a [`GeoJSON`](https://en.wikipedia.org/wiki/GeoJSON)\n\t * representation of the marker (as a GeoJSON `Point` Feature).\n\t * @group Other methods\n\t * @param {number|false} [precision]\n\t * @returns {Feature}\n\t */\n\ttoGeoJSON(precision) {\n\t\treturn pointToGeoJSON(this, precision);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,IAAa,SAAb,MAAa,eAAe,MAAM;CAEjC,OAAO,iBAAiB;EACvB,sBAAsB,IAAI,YAAY;EAGtC,aAAa;EAEb,UAAU;EACV,OAAO;EACP,KAAK;EACL,cAAc;EACd,SAAS;EACT,aAAa;EACb,YAAY;EACZ,MAAM;EACN,YAAY;EACZ,QAAQ;EACR,uBAAuB;EACvB,gBAAgB;EAChB,WAAW;EACX,SAAS;EACT,gBAAgB,CAAC,IAAI,EAAE;EACvB,cAAc;CACf;;;;;;;CAQA,YAAY,QAAQ,SAAS;EAC5B,MAAM;EACN,WAAgB,MAAM,OAAO;EAC7B,KAAK,UAAU,IAAI,OAAO,MAAM;EAEhC,KAAK,cAAc,MAAM;CAC1B;;;;;CAMA,MAAM,KAAK;EACV,KAAK,gBAAgB,KAAK,iBAAiB,IAAI,QAAQ;EAEvD,IAAI,KAAK,eACR,IAAI,GAAG,YAAY,KAAK,cAAc,IAAI;EAG3C,KAAK,UAAU;EACf,KAAK,OAAO;EAEZ,IAAI,IAAI,QAAQ,eACf,KAAK,eAAe;CAEtB;;;;;CAMA,SAAS,KAAK;EACb,IAAI,KAAK,UAAU;GAElB,KAAK,QAAQ,YAAY,KAAK,SAAS,QAAQ;GAC/C,IAAI,KAAK,QAAQ,WAAa,KAAK,SAAS,YAAY;EACzD;EACA,OAAO,KAAK;EAEZ,IAAI,KAAK,eACR,IAAI,IAAI,YAAY,KAAK,cAAc,IAAI;EAG5C,KAAK,YAAY;EACjB,KAAK,cAAc;EACnB,KAAK,UAAU;CAChB;;;;;CAMA,YAAY;EACX,MAAM,SAAS;GACd,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