maplair 4.2.0 → 4.4.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 (179) hide show
  1. package/CHANGELOG.md +106 -8
  2. package/dist/esm/control/AttributionControl.js +10 -10
  3. package/dist/esm/control/AttributionControl.js.map +1 -1
  4. package/dist/esm/control/ButtonControl.js +0 -1
  5. package/dist/esm/control/ButtonControl.js.map +1 -1
  6. package/dist/esm/control/ContextMenu.js +1 -1
  7. package/dist/esm/control/ContextMenu.js.map +1 -1
  8. package/dist/esm/control/Control.js +16 -11
  9. package/dist/esm/control/Control.js.map +1 -1
  10. package/dist/esm/control/FullscreenControl.js +0 -1
  11. package/dist/esm/control/FullscreenControl.js.map +1 -1
  12. package/dist/esm/control/LayersControl.js +13 -9
  13. package/dist/esm/control/LayersControl.js.map +1 -1
  14. package/dist/esm/control/RotateControl.js +0 -1
  15. package/dist/esm/control/RotateControl.js.map +1 -1
  16. package/dist/esm/control/ScaleControl.js +4 -5
  17. package/dist/esm/control/ScaleControl.js.map +1 -1
  18. package/dist/esm/control/SideBySideControl.js +3 -2
  19. package/dist/esm/control/SideBySideControl.js.map +1 -1
  20. package/dist/esm/control/ZoomControl.js +13 -13
  21. package/dist/esm/control/ZoomControl.js.map +1 -1
  22. package/dist/esm/core/Events.js +4 -2
  23. package/dist/esm/core/Events.js.map +1 -1
  24. package/dist/esm/core/Util.js +16 -4
  25. package/dist/esm/core/Util.js.map +1 -1
  26. package/dist/esm/dom/DomEvent.PointerEvents.js +55 -2
  27. package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
  28. package/dist/esm/dom/DomEvent.js +4 -7
  29. package/dist/esm/dom/DomEvent.js.map +1 -1
  30. package/dist/esm/dom/DomUtil.js +5 -5
  31. package/dist/esm/dom/DomUtil.js.map +1 -1
  32. package/dist/esm/dom/Draggable.js +4 -6
  33. package/dist/esm/dom/Draggable.js.map +1 -1
  34. package/dist/esm/geo/LatLng.js +23 -34
  35. package/dist/esm/geo/LatLng.js.map +1 -1
  36. package/dist/esm/geo/LatLngBounds.js +6 -3
  37. package/dist/esm/geo/LatLngBounds.js.map +1 -1
  38. package/dist/esm/geometry/Bounds.js +2 -2
  39. package/dist/esm/geometry/Bounds.js.map +1 -1
  40. package/dist/esm/geometry/Point.js +12 -17
  41. package/dist/esm/geometry/Point.js.map +1 -1
  42. package/dist/esm/geometry/Transformation.js +1 -7
  43. package/dist/esm/geometry/Transformation.js.map +1 -1
  44. package/dist/esm/layer/BlanketOverlay.js +1 -1
  45. package/dist/esm/layer/BlanketOverlay.js.map +1 -1
  46. package/dist/esm/layer/DivOverlay.js +23 -23
  47. package/dist/esm/layer/DivOverlay.js.map +1 -1
  48. package/dist/esm/layer/ImageOverlay.js +7 -4
  49. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  50. package/dist/esm/layer/Layer.js +11 -6
  51. package/dist/esm/layer/Layer.js.map +1 -1
  52. package/dist/esm/layer/Popup.js +30 -11
  53. package/dist/esm/layer/Popup.js.map +1 -1
  54. package/dist/esm/layer/Tooltip.js +18 -35
  55. package/dist/esm/layer/Tooltip.js.map +1 -1
  56. package/dist/esm/layer/VideoOverlay.js +2 -2
  57. package/dist/esm/layer/VideoOverlay.js.map +1 -1
  58. package/dist/esm/layer/marker/DivIcon.js +4 -8
  59. package/dist/esm/layer/marker/DivIcon.js.map +1 -1
  60. package/dist/esm/layer/marker/Icon.js +16 -15
  61. package/dist/esm/layer/marker/Icon.js.map +1 -1
  62. package/dist/esm/layer/marker/Marker.Drag.js +6 -7
  63. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  64. package/dist/esm/layer/marker/Marker.js +49 -48
  65. package/dist/esm/layer/marker/Marker.js.map +1 -1
  66. package/dist/esm/layer/marker/SvgIcon.js +1 -1
  67. package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
  68. package/dist/esm/layer/tile/GridLayer.js +18 -16
  69. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  70. package/dist/esm/layer/tile/TileLayer.js +9 -9
  71. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  72. package/dist/esm/layer/vector/Canvas.js +44 -93
  73. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  74. package/dist/esm/layer/vector/Circle.js +8 -7
  75. package/dist/esm/layer/vector/Circle.js.map +1 -1
  76. package/dist/esm/layer/vector/CircleMarker.js +9 -1
  77. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  78. package/dist/esm/layer/vector/Path.js +10 -5
  79. package/dist/esm/layer/vector/Path.js.map +1 -1
  80. package/dist/esm/layer/vector/Polygon.js +10 -11
  81. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  82. package/dist/esm/layer/vector/Polyline.js +19 -26
  83. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  84. package/dist/esm/layer/vector/Renderer.getRenderer.js +2 -1
  85. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  86. package/dist/esm/layer/vector/Renderer.js +16 -0
  87. package/dist/esm/layer/vector/Renderer.js.map +1 -1
  88. package/dist/esm/layer/vector/SVG.js +3 -3
  89. package/dist/esm/layer/vector/SVG.js.map +1 -1
  90. package/dist/esm/map/Map.Rotation.js +6 -9
  91. package/dist/esm/map/Map.Rotation.js.map +1 -1
  92. package/dist/esm/map/Map.js +104 -49
  93. package/dist/esm/map/Map.js.map +1 -1
  94. package/dist/esm/map/MapSync.js +1 -4
  95. package/dist/esm/map/MapSync.js.map +1 -1
  96. package/dist/esm/map/handler/BoxZoomHandler.js +2 -0
  97. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  98. package/dist/esm/map/handler/DisplaceHandler.js +68 -30
  99. package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
  100. package/dist/esm/map/handler/KeyboardHandler.js +3 -5
  101. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  102. package/dist/esm/map/handler/PinchZoomHandler.js +3 -6
  103. package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
  104. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +3 -6
  105. package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
  106. package/dist/esm/map/handler/TapDragZoomHandler.js +1 -4
  107. package/dist/esm/map/handler/TapDragZoomHandler.js.map +1 -1
  108. package/dist/esm/map/handler/TapHoldHandler.js +8 -20
  109. package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
  110. package/dist/esm/package.js +1 -1
  111. package/dist/maplair-global-src.js +700 -687
  112. package/dist/maplair-global-src.js.map +1 -1
  113. package/dist/maplair-global.js +2 -2
  114. package/dist/maplair-global.js.map +1 -1
  115. package/dist/maplair-src.js +700 -687
  116. package/dist/maplair-src.js.map +1 -1
  117. package/dist/maplair.css +1 -1
  118. package/dist/maplair.js +2 -2
  119. package/dist/maplair.js.map +1 -1
  120. package/i18n/en.json +1 -0
  121. package/package.json +2 -1
  122. package/src/control/AttributionControl.js +9 -9
  123. package/src/control/ButtonControl.js +0 -1
  124. package/src/control/ContextMenu.js +1 -1
  125. package/src/control/Control.js +13 -16
  126. package/src/control/FullscreenControl.js +0 -1
  127. package/src/control/LayersControl.js +14 -10
  128. package/src/control/RotateControl.js +0 -1
  129. package/src/control/ScaleControl.js +4 -5
  130. package/src/control/SideBySideControl.js +4 -2
  131. package/src/control/ZoomControl.js +10 -13
  132. package/src/core/Events.js +8 -2
  133. package/src/core/Util.js +16 -3
  134. package/src/dom/DomEvent.PointerEvents.js +47 -1
  135. package/src/dom/DomEvent.js +5 -17
  136. package/src/dom/DomUtil.js +5 -5
  137. package/src/dom/Draggable.js +5 -6
  138. package/src/geo/LatLng.js +22 -36
  139. package/src/geo/LatLngBounds.js +10 -4
  140. package/src/geometry/Bounds.js +3 -3
  141. package/src/geometry/Point.js +18 -26
  142. package/src/geometry/Transformation.js +1 -8
  143. package/src/layer/BlanketOverlay.js +1 -1
  144. package/src/layer/DivOverlay.js +28 -30
  145. package/src/layer/ImageOverlay.js +9 -7
  146. package/src/layer/Layer.js +18 -6
  147. package/src/layer/Popup.js +38 -17
  148. package/src/layer/Tooltip.js +17 -44
  149. package/src/layer/VideoOverlay.js +2 -2
  150. package/src/layer/marker/DivIcon.js +3 -6
  151. package/src/layer/marker/Icon.js +19 -18
  152. package/src/layer/marker/Marker.Drag.js +16 -18
  153. package/src/layer/marker/Marker.js +66 -59
  154. package/src/layer/marker/SvgIcon.js +1 -1
  155. package/src/layer/tile/GridLayer.js +21 -23
  156. package/src/layer/tile/TileLayer.js +17 -14
  157. package/src/layer/vector/Canvas.js +52 -148
  158. package/src/layer/vector/Circle.js +14 -9
  159. package/src/layer/vector/CircleMarker.js +11 -1
  160. package/src/layer/vector/Path.js +11 -5
  161. package/src/layer/vector/Polygon.js +11 -10
  162. package/src/layer/vector/Polyline.js +20 -21
  163. package/src/layer/vector/Renderer.getRenderer.js +2 -1
  164. package/src/layer/vector/Renderer.js +21 -3
  165. package/src/layer/vector/SVG.js +3 -3
  166. package/src/map/Map.Rotation.js +7 -6
  167. package/src/map/Map.js +135 -54
  168. package/src/map/MapSync.js +1 -1
  169. package/src/map/handler/BoxZoomHandler.js +2 -0
  170. package/src/map/handler/DisplaceHandler.js +53 -7
  171. package/src/map/handler/KeyboardHandler.js +5 -10
  172. package/src/map/handler/PinchZoomHandler.js +3 -3
  173. package/src/map/handler/ScrollWheelZoomHandler.js +3 -3
  174. package/src/map/handler/TapDragZoomHandler.js +1 -1
  175. package/src/map/handler/TapHoldHandler.js +13 -25
  176. package/src/maplair.css +38 -9
  177. package/dist/esm/dom/DomEvent.DoubleTap.js +0 -90
  178. package/dist/esm/dom/DomEvent.DoubleTap.js.map +0 -1
  179. package/src/dom/DomEvent.DoubleTap.js +0 -143
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","names":["DomEvent.off","DomEvent.on","DomUtil.create","Util.stamp"],"sources":["../../../src/layer/Tooltip.js"],"sourcesContent":["import {DivOverlay} from './DivOverlay.js';\nimport {Point} from '../geometry/Point.js';\nimport {Layer} from './Layer.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport * as Util from '../core/Util.js';\nimport {FeatureGroup} from './FeatureGroup.js';\n\nconst directions = ['top', 'bottom', 'center', 'right', 'left'];\n\n// The size of the tooltip tip (see `.maplair-tooltip-top` etc. in maplair.css) and\n// the minimum distance of an `auto` tooltip to the edge of the map.\nconst tipSize = 6,\nautoPadding = 4;\n\n// The shift moving a box from `start` with `size` into the range `[min, max]`.\nfunction shiftInto(start, size, min, max) {\n\treturn Math.max(0, min - start) - Math.max(0, start + size - max);\n}\n\n// Keeps the shifted tip off the rounded corners of the tooltip.\nfunction clampTip(tipShift, size) {\n\tconst max = Math.max(0, size / 2 - 2 * tipSize);\n\treturn Math.round(Math.min(max, Math.max(-max, tipShift)));\n}\n\n/** @import {DivOverlayOptions, DivOverlayContent} from './DivOverlay.js' */\n/** @import {LatLngExpression} from '../geo/LatLng.js' */\n/** @import {PointExpression} from '../geometry/Point.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n/** @import {EventListener, TooltipEvent} from '../core/Events.js' */\n\n/**\n * Options of `Tooltip`.\n * @typedef {object} TooltipOptions\n * @property {string} [pane='tooltipPane'] `Map pane` where the tooltip will be added.\n * @property {PointExpression} [offset=[0, 0]] Optional offset of the tooltip position.\n * @property {'right'|'left'|'top'|'bottom'|'center'|'auto'} [direction='auto']\n * Direction where to open the tooltip. Possible values are: `right`, `left`, `top`,\n * `bottom`, `center`, `auto`. `auto` chooses the direction with enough space when\n * opening the tooltip: preferably the side towards the center of the map (`right` or\n * `left`), otherwise the opposite side, `top` or `bottom`. The tooltip is shifted\n * along that side to stay within the map (within the viewport if `overflow` is set),\n * its tip still pointing at the source.\n * @property {boolean} [permanent=false] Whether to open the tooltip permanently or only\n * on pointerover.\n * @property {boolean} [sticky=false] If true, the tooltip will follow the pointer\n * instead of being fixed at the feature center.\n * @property {number} [opacity=0.9] Tooltip container opacity.\n * @extends DivOverlayOptions\n */\n\n/**\n * Methods of `MaplairMap` for tooltips.\n * @lends MaplairMap.prototype\n * @fires MaplairMap#tooltipopen {TooltipEvent} Fired when a tooltip is opened in the map.\n * @fires MaplairMap#tooltipclose {TooltipEvent} Fired when a tooltip in the map is closed.\n */\nconst mapTooltipMethods = {\n\t/**\n\t * Opens the specified tooltip.\n\t *\n\t * Alternatively, creates a tooltip with the specified content and options and\n\t * opens it. String content is rendered as HTML; sanitize untrusted input or pass\n\t * an `HTMLElement` with safe `textContent` instead.\n\t * @group Methods for layers and controls\n\t * @param {Tooltip|DivOverlayContent} tooltip The tooltip, or the content of a new\n\t * tooltip.\n\t * @param {LatLngExpression} [latlng]\n\t * @param {TooltipOptions} [options]\n\t * @returns {this}\n\t */\n\topenTooltip(tooltip, latlng, options) {\n\t\t// eslint-disable-next-line no-use-before-define -- defined below, used when called\n\t\tthis._initOverlay(Tooltip, tooltip, latlng, options)\n\t\t\t.openOn(this);\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * Closes the tooltip given as parameter.\n\t * @group Methods for layers and controls\n\t * @param {Tooltip} tooltip\n\t * @returns {this}\n\t */\n\tcloseTooltip(tooltip) {\n\t\ttooltip.close();\n\t\treturn this;\n\t}\n};\n/** @typedef {typeof mapTooltipMethods} MapTooltipMethods */\n\n/**\n * Methods of `Layer` for tooltips. All layers share a set of methods convenient for\n * binding tooltips to it.\n *\n * ```js\n * const layer = new Polygon(latlngs).bindTooltip('Hi There!').addTo(map);\n * layer.openTooltip();\n * layer.closeTooltip();\n * ```\n *\n * @lends Layer.prototype\n * @fires Layer#tooltipopen {TooltipEvent} Fired when a tooltip bound to this layer is\n * opened.\n * @fires Layer#tooltipclose {TooltipEvent} Fired when a tooltip bound to this layer is\n * closed.\n */\nconst layerTooltipMethods = {\n\t/**\n\t * Binds a tooltip to the layer with the passed `content` and sets up the\n\t * necessary event listeners. A `String` argument is rendered as HTML; if it\n\t * may contain untrusted input, sanitize it (e.g. with DOMPurify) or pass an\n\t * `HTMLElement` with safe `textContent` instead. If a `Function` is passed\n\t * it will receive the layer as the first argument and should return a\n\t * `String` or `HTMLElement`.\n\t * @group Tooltip methods\n\t * @param {DivOverlayContent|Tooltip} content\n\t * @param {TooltipOptions} [options]\n\t * @returns {this}\n\t */\n\tbindTooltip(content, options) {\n\t\t// an open tooltip is replaced, a closed one reused\n\t\tconst old = this.isTooltipOpen() ? null : this._tooltip;\n\n\t\t// the handlers depend on the old options, so they go before the new ones are applied\n\t\tif (this._tooltip) {\n\t\t\tthis.unbindTooltip();\n\t\t}\n\n\t\t// eslint-disable-next-line no-use-before-define -- defined below, used when called\n\t\tthis._tooltip = this._initOverlay(Tooltip, old, content, options);\n\t\tthis._initTooltipInteractions();\n\n\t\tif (this._tooltip.options.permanent && this._map && this._map.hasLayer(this)) {\n\t\t\tthis.openTooltip();\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * Removes the tooltip previously bound with `bindTooltip`.\n\t * @group Tooltip methods\n\t * @returns {this}\n\t */\n\tunbindTooltip() {\n\t\tif (this._tooltip) {\n\t\t\tthis._initTooltipInteractions(true);\n\t\t\tthis.closeTooltip();\n\t\t\tthis._tooltip = null;\n\t\t}\n\t\treturn this;\n\t},\n\n\t_initTooltipInteractions(remove) {\n\t\tconst {permanent, sticky} = this._tooltip.options,\n\t\tevents = {\n\t\t\tremove: this.closeTooltip,\n\t\t\tmove: this._moveTooltip\n\t\t};\n\t\tif (permanent) {\n\t\t\tevents.add = this._openTooltip;\n\t\t} else {\n\t\t\tevents.pointerover = this._openTooltip;\n\t\t\tevents.pointerout = this.closeTooltip;\n\t\t\tevents.click = this._openTooltip;\n\t\t\t// layer elements can be recreated on every add\n\t\t\tevents.add = this._toggleFocusListeners;\n\t\t\tif (this._map) {\n\t\t\t\tthis._toggleFocusListeners(!remove);\n\t\t\t}\n\t\t}\n\t\tif (sticky) {\n\t\t\tevents.pointermove = this._moveTooltip;\n\t\t}\n\t\tthis[remove ? 'off' : 'on'](events);\n\t},\n\n\t/**\n\t * Opens the bound tooltip at the specified `latlng` or at the default tooltip\n\t * anchor if no `latlng` is passed.\n\t * @group Tooltip methods\n\t * @param {LatLngExpression} [latlng]\n\t * @returns {this}\n\t */\n\topenTooltip(latlng) {\n\t\tif (this._tooltip) {\n\t\t\tif (!(this instanceof FeatureGroup)) {\n\t\t\t\tthis._tooltip._source = this;\n\t\t\t}\n\t\t\tif (this._tooltip._prepareOpen(latlng)) {\n\t\t\t\t// open the tooltip on the map\n\t\t\t\tthis._tooltip.openOn(this._map);\n\n\t\t\t\tif (this.getElement) {\n\t\t\t\t\tthis._setAriaDescribedByOnLayer(this);\n\t\t\t\t} else if (this.eachLayer) {\n\t\t\t\t\tthis.eachLayer(this._setAriaDescribedByOnLayer, this);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t},\n\n\t/**\n\t * Closes the tooltip bound to this layer if it is open.\n\t * @group Tooltip methods\n\t * @returns {this}\n\t */\n\tcloseTooltip() {\n\t\tthis._tooltip?.close();\n\t\treturn this;\n\t},\n\n\t/**\n\t * Opens or closes the tooltip bound to this layer depending on its current state.\n\t * @group Tooltip methods\n\t * @returns {this}\n\t */\n\ttoggleTooltip() {\n\t\tthis._tooltip?.toggle(this);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` if the tooltip bound to this layer is currently open.\n\t * @group Tooltip methods\n\t * @returns {boolean}\n\t */\n\tisTooltipOpen() {\n\t\treturn this._tooltip?.isOpen() ?? false;\n\t},\n\n\t/**\n\t * Sets the content of the tooltip bound to this layer. String content is rendered\n\t * as HTML; sanitize untrusted input or pass an `HTMLElement` with safe\n\t * `textContent` instead.\n\t * @group Tooltip methods\n\t * @param {DivOverlayContent} content\n\t * @returns {this}\n\t */\n\tsetTooltipContent(content) {\n\t\tthis._tooltip?.setContent(content);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns the tooltip bound to this layer.\n\t * @group Tooltip methods\n\t * @returns {Tooltip|undefined}\n\t */\n\tgetTooltip() {\n\t\treturn this._tooltip;\n\t},\n\n\t// also the `add` listener, so any truthy argument adds\n\t_toggleFocusListeners(add) {\n\t\tif (this.getElement) {\n\t\t\tthis._addFocusListenersOnLayer(this, !add);\n\t\t} else if (this.eachLayer) {\n\t\t\tthis.eachLayer(layer => this._addFocusListenersOnLayer(layer, !add), this);\n\t\t}\n\t},\n\n\t_addFocusListenersOnLayer(layer, remove) {\n\t\tconst el = typeof layer.getElement === 'function' && layer.getElement();\n\t\tif (el) {\n\t\t\tconst toggle = remove ? DomEvent.off : DomEvent.on;\n\t\t\tif (!remove) {\n\t\t\t\t// Remove focus listener, if already existing\n\t\t\t\tel._maplair_focus_handler && DomEvent.off(el, 'focus', el._maplair_focus_handler, this);\n\n\t\t\t\tel._maplair_focus_handler = () => {\n\t\t\t\t\tif (this._tooltip) {\n\t\t\t\t\t\tthis._tooltip._source = layer;\n\t\t\t\t\t\tthis.openTooltip();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tel._maplair_focus_handler && toggle(el, 'focus', el._maplair_focus_handler, this);\n\t\t\ttoggle(el, 'blur', this.closeTooltip, this);\n\n\t\t\tif (remove) {\n\t\t\t\tdelete el._maplair_focus_handler;\n\t\t\t}\n\t\t}\n\t},\n\n\t_setAriaDescribedByOnLayer(layer) {\n\t\tconst el = typeof layer.getElement === 'function' && layer.getElement();\n\t\tel?.setAttribute?.('aria-describedby', this._tooltip._container.id);\n\t},\n\n\t_openTooltip(e) {\n\t\tif (!this._tooltip || !this._map) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the map is moving, we will show the tooltip after it's done.\n\t\tif (this._map.dragging?.moving()) {\n\t\t\tif (e.type === 'add' && !this._moveEndOpensTooltip) {\n\t\t\t\tthis._moveEndOpensTooltip = true;\n\t\t\t\tthis._map.once('moveend', () => {\n\t\t\t\t\tthis._moveEndOpensTooltip = false;\n\t\t\t\t\tthis._openTooltip(e);\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tthis._tooltip._source = e.propagatedFrom ?? e.target;\n\n\t\tthis.openTooltip(this._tooltip.options.sticky ? e.latlng : undefined);\n\t},\n\n\t_moveTooltip(e) {\n\t\tlet latlng = e.latlng, containerPoint, layerPoint;\n\t\tif (this._tooltip.options.sticky && e.originalEvent) {\n\t\t\tcontainerPoint = this._map.pointerEventToContainerPoint(e.originalEvent);\n\t\t\tlayerPoint = this._map.containerPointToLayerPoint(containerPoint);\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\n\t\t}\n\t\tthis._tooltip.setLatLng(latlng);\n\t}\n};\n/** @typedef {typeof layerTooltipMethods} LayerTooltipMethods */\n\n/**\n * Used to display small texts on top of map layers.\n *\n * @example\n * If you want to just bind a tooltip to marker:\n *\n * ```js\n * marker.bindTooltip(\"my tooltip text\").openTooltip();\n * ```\n * Path overlays like polylines also have a `bindTooltip` method.\n *\n * A tooltip can be also standalone:\n *\n * ```js\n * const tooltip = new Tooltip()\n * \t.setLatLng(latlng)\n * \t.setContent('Hello world!<br />This is a nice tooltip.')\n * \t.addTo(map);\n * ```\n * or\n * ```js\n * const tooltip = new Tooltip(latlng, {content: 'Hello world!<br />This is a nice tooltip.'})\n * \t.addTo(map);\n * ```\n *\n * **Security note.** Tooltip string content is rendered as HTML. If your content\n * may include untrusted input (e.g. data from users or external APIs), sanitize\n * it with a library like [DOMPurify](https://github.com/cure53/DOMPurify), or\n * build a DOM element using `textContent` to render it as plain text:\n *\n * ```js\n * const el = document.createElement('div');\n * el.textContent = untrustedString;\n * marker.bindTooltip(el);\n * ```\n *\n * Note about tooltip offset. Maplair takes two options in consideration\n * for computing tooltip offsetting:\n * - the `offset` Tooltip option: it defaults to [0, 0], and it's specific to one tooltip.\n * Add a positive x offset to move the tooltip to the right, and a positive y offset to\n * move it to the bottom. Negatives will move to the left and top.\n * - the `tooltipAnchor` Icon option: this will only be considered for Marker. You\n * should adapt this value if you use a custom icon.\n */\nexport class Tooltip extends DivOverlay {\n\n\tstatic defaultOptions = {\n\t\tpane: 'tooltipPane',\n\t\toffset: [0, 0],\n\t\tdirection: 'auto',\n\t\tpermanent: false,\n\t\tsticky: false,\n\t\topacity: 0.9\n\t};\n\n\t/**\n\t * Instantiates a `Tooltip` object given an optional `options` object that describes\n\t * its appearance and location and an optional `source` object that is used to tag\n\t * the tooltip with a reference to the Layer to which it refers.\n\t * @overload\n\t * @param {TooltipOptions} [options]\n\t * @param {Layer} [source]\n\t */\n\t/**\n\t * Instantiates a `Tooltip` object given `latlng` where the tooltip will open and an\n\t * optional `options` object that describes its appearance and location.\n\t * @overload\n\t * @param {LatLngExpression} latlng\n\t * @param {TooltipOptions} [options]\n\t */\n\t/**\n\t * @param {...any} args\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(Tooltip);\n\t}\n\n\t/**\n\t * Adds the tooltip to the map.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\tsuper.onAdd(map);\n\t\tthis.setOpacity(this.options.opacity);\n\n\t\tmap.fire('tooltipopen', {tooltip: this});\n\n\t\tif (this._source) {\n\t\t\tthis.addEventParent(this._source);\n\n\t\t\tthis._source.fire('tooltipopen', {tooltip: this}, true);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the tooltip from the map.\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tsuper.onRemove(map);\n\n\t\tmap.fire('tooltipclose', {tooltip: this});\n\n\t\tif (this._source) {\n\t\t\tthis.removeEventParent(this._source);\n\n\t\t\tthis._source.fire('tooltipclose', {tooltip: this}, true);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the map events the tooltip listens to.\n\t * @returns {Record<string, EventListener>}\n\t */\n\tgetEvents() {\n\t\tconst events = super.getEvents();\n\n\t\tif (!this.options.permanent) {\n\t\t\tevents.preclick = this.close;\n\t\t}\n\n\t\treturn events;\n\t}\n\n\t_initLayout() {\n\t\tconst prefix = 'maplair-tooltip',\n\t\tclassName = `${prefix} ${this.options.className || ''} maplair-zoom-animated`;\n\n\t\tthis._contentNode = this._container = DomUtil.create('div', className);\n\n\t\tthis._container.setAttribute('role', 'tooltip');\n\t\tthis._container.setAttribute('id', `maplair-tooltip-${Util.stamp(this)}`);\n\t}\n\n\t_updateLayout() {}\n\n\t_adjustPan() {}\n\n\t/**\n\t * Updates the tooltip content, layout and position.\n\t * @returns {void}\n\t */\n\tupdate() {\n\t\t// The automatic direction is chosen once per opening and content, so that\n\t\t// the tooltip does not flip sides while the map or the pointer moves.\n\t\tthis._autoDirection = undefined;\n\t\tsuper.update();\n\t}\n\n\t_setPosition(pos) {\n\t\tlet direction = this.options.direction,\n\t\tshift = new Point(0, 0);\n\t\tconst container = this._container,\n\t\ttooltipWidth = container.offsetWidth,\n\t\ttooltipHeight = container.offsetHeight,\n\t\toffset = new Point(this.options.offset),\n\t\tanchor = this._getAnchor();\n\n\t\tif (!directions.includes(direction)) {\n\t\t\t({direction, shift} = this._getAutoPlacement(pos, offset, anchor, tooltipWidth, tooltipHeight));\n\t\t\tif (direction === 'left') {\n\t\t\t\t// mirror the offset and anchor, which are meant for the right side\n\t\t\t\toffset.x = -offset.x;\n\t\t\t\tanchor.x = -anchor.x;\n\t\t\t}\n\t\t}\n\n\t\tlet subX = tooltipWidth / 2,\n\t\tsubY = tooltipHeight / 2;\n\t\tif (direction === 'top') {\n\t\t\tsubY = tooltipHeight;\n\t\t} else if (direction === 'bottom') {\n\t\t\tsubY = 0;\n\t\t} else if (direction === 'right') {\n\t\t\tsubX = 0;\n\t\t} else if (direction === 'left') {\n\t\t\tsubX = tooltipWidth;\n\t\t}\n\n\t\tpos = pos.subtract(new Point(subX, subY, true)).add(offset).add(anchor).add(shift);\n\n\t\tcontainer.classList.remove(\n\t\t\t'maplair-tooltip-right',\n\t\t\t'maplair-tooltip-left',\n\t\t\t'maplair-tooltip-top',\n\t\t\t'maplair-tooltip-bottom'\n\t\t);\n\t\tcontainer.classList.add(`maplair-tooltip-${direction}`);\n\n\t\t// Let the tip point at the source despite the shift\n\t\tconst tipShift = direction === 'top' || direction === 'bottom' ?\n\t\t\tclampTip(-shift.x, tooltipWidth) :\n\t\t\tclampTip(-shift.y, tooltipHeight);\n\t\tif (tipShift) {\n\t\t\tcontainer.style.setProperty('--maplair-tooltip-tip-shift', `${tipShift}px`);\n\t\t} else {\n\t\t\tcontainer.style.removeProperty('--maplair-tooltip-tip-shift');\n\t\t}\n\n\t\tthis._setContainerPosition(pos);\n\t}\n\n\t// Chooses the direction of an `auto` tooltip by the available space:\n\t// preferably the side towards the center, otherwise the opposite side,\n\t// above or below. The tooltip is shifted along that side to stay in view.\n\t_getAutoPlacement(pos, offset, anchor, width, height) {\n\t\tconst area = this._getAutoArea(),\n\t\tpoint = this._map.layerPointToContainerPoint(pos),\n\t\tx = point.x + offset.x + anchor.x,\n\t\ty = point.y + offset.y + anchor.y,\n\t\t// the space for each direction, see `direction` for the mirrored left side\n\t\tspace = {\n\t\t\tright: area.max.x - x - width - tipSize,\n\t\t\tleft: point.x - offset.x - anchor.x - area.min.x - width - tipSize,\n\t\t\ttop: y - area.min.y - height - tipSize,\n\t\t\tbottom: area.max.y - y - height - tipSize\n\t\t};\n\n\t\tif (!this._autoDirection) {\n\t\t\tconst sides = point.x < (area.min.x + area.max.x) / 2 ? ['right', 'left'] : ['left', 'right'],\n\t\t\tfallback = space.right >= space.left ? 'right' : 'left';\n\t\t\tthis._autoDirection = [...sides, 'top', 'bottom'].find(d => space[d] >= 0 &&\n\t\t\t\t// above or below, the tooltip has to fit horizontally\n\t\t\t\t(d === 'right' || d === 'left' || width <= area.max.x - area.min.x)) ?? fallback;\n\t\t}\n\n\t\tconst direction = this._autoDirection,\n\t\tshift = direction === 'top' || direction === 'bottom' ?\n\t\t\tnew Point(shiftInto(x - width / 2, width, area.min.x, area.max.x), 0) :\n\t\t\tnew Point(0, shiftInto(y - height / 2, height, area.min.y, area.max.y));\n\n\t\treturn {direction, shift};\n\t}\n\n\t// The area in container points an `auto` tooltip should stay within:\n\t// the map, or the viewport for an overflowing tooltip.\n\t_getAutoArea() {\n\t\tconst map = this._map;\n\t\tlet min = new Point(0, 0),\n\t\tmax = map.getSize();\n\t\tif (this.options.overflow) {\n\t\t\tconst mapContainer = map._container,\n\t\t\trect = mapContainer.getBoundingClientRect(),\n\t\t\torigin = new Point(rect.left + mapContainer.clientLeft, rect.top + mapContainer.clientTop),\n\t\t\tviewport = document.documentElement;\n\t\t\tmin = min.subtract(origin);\n\t\t\tmax = new Point(viewport.clientWidth, viewport.clientHeight).subtract(origin);\n\t\t}\n\t\tconst padding = new Point(autoPadding, autoPadding);\n\t\treturn {min: min.add(padding), max: max.subtract(padding)};\n\t}\n\n\t_updatePosition() {\n\t\tconst pos = this._map.latLngToLayerPoint(this._latlng)._round();\n\t\tthis._setPosition(pos);\n\t}\n\n\t/**\n\t * Sets the opacity of the tooltip.\n\t * @param {number} opacity\n\t * @returns {void}\n\t */\n\tsetOpacity(opacity) {\n\t\tthis.options.opacity = opacity;\n\n\t\tif (this._container) {\n\t\t\tthis._container.style.opacity = `${opacity}`;\n\t\t}\n\t}\n\n\t_animateZoom(e) {\n\t\tconst pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center);\n\t\tthis._setPosition(pos);\n\t}\n\n\t_getAnchor() {\n\t\t// Where should we anchor the tooltip on the source layer?\n\t\treturn new Point(this._source?._getTooltipAnchor && !this.options.sticky ? this._source._getTooltipAnchor() : [0, 0]);\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(mapTooltipMethods);\n\n\t\tLayer.include(layerTooltipMethods);\n\t}\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,aAAa;CAAC;CAAO;CAAU;CAAU;CAAS;AAAM;AAI9D,MAAM,UAAU;AAChB,MAAA,cAAc;AAGd,SAAS,UAAU,O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M,MAAM,KAAK,KAAK,mBAAmB,KAAK,OAAO,CAAC,CAAC,OAAO;EAC9D,KAAK,aAAa,GAAG;CACtB;;;;;;CAOA,WAAW,SAAS;EACnB,KAAK,QAAQ,UAAU;EAEvB,IAAI,KAAK,YACR,KAAK,WAAW,MAAM,UAAU,GAAG;CAErC;CAEA,aAAa,GAAG;EACf,MAAM,MAAM,KAAK,KAAK,uBAAuB,KAAK,SAAS,EAAE,MAAM,EAAE,MAAM;EAC3E,KAAK,aAAa,GAAG;CACtB;CAEA,aAAa;EAEZ,OAAO,IAAI,MAAM,KAAK,SAAS,qBAAqB,CAAC,KAAK,QAAQ,SAAS,KAAK,QAAQ,kBAAkB,IAAI,CAAC,GAAG,CAAC,CAAC;CACrH;;;;;;CAOA,OAAO,SAAS,YAAY;EAC3B,WAAW,QAAQ,iBAAiB;EAEpC,MAAM,QAAQ,mBAAmB;CAClC;AACD"}
1
+ {"version":3,"file":"Tooltip.js","names":["DomEvent.off","DomEvent.on","DomUtil.create","Util.stamp"],"sources":["../../../src/layer/Tooltip.js"],"sourcesContent":["import {DivOverlay} from './DivOverlay.js';\nimport {Point} from '../geometry/Point.js';\nimport {Layer} from './Layer.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport * as Util from '../core/Util.js';\nimport {FeatureGroup} from './FeatureGroup.js';\n\n// which point of the tooltip (as a fraction of its width and height) sits at the anchor, for each direction\nconst directions = {top: [0.5, 1], bottom: [0.5, 0], center: [0.5, 0.5], right: [0, 0.5], left: [1, 0.5]};\n\n// The size of the tooltip tip (see `.maplair-tooltip-top` etc. in maplair.css) and\n// the minimum distance of an `auto` tooltip to the edge of the map.\nconst tipSize = 6,\nautoPadding = 4;\n\n// The shift moving a box from `start` with `size` into the range `[min, max]`.\nfunction shiftInto(start, size, min, max) {\n\treturn Math.max(0, min - start) - Math.max(0, start + size - max);\n}\n\n// Keeps the shifted tip off the rounded corners of the tooltip.\nfunction clampTip(tipShift, size) {\n\tconst max = Math.max(0, size / 2 - 2 * tipSize);\n\treturn Math.round(Math.min(max, Math.max(-max, tipShift)));\n}\n\n/** @import {DivOverlayOptions, DivOverlayContent} from './DivOverlay.js' */\n/** @import {LatLngExpression} from '../geo/LatLng.js' */\n/** @import {PointExpression} from '../geometry/Point.js' */\n/** @import {MaplairMap} from '../map/Map.js' */\n/** @import {EventListener, TooltipEvent} from '../core/Events.js' */\n\n/**\n * Options of `Tooltip`.\n * @typedef {object} TooltipOptions\n * @property {string} [pane='tooltipPane'] `Map pane` where the tooltip will be added.\n * @property {PointExpression} [offset=[0, 0]] Optional offset of the tooltip position.\n * @property {'right'|'left'|'top'|'bottom'|'center'|'auto'} [direction='auto']\n * Direction where to open the tooltip. Possible values are: `right`, `left`, `top`,\n * `bottom`, `center`, `auto`. `auto` chooses the direction with enough space when\n * opening the tooltip: preferably the side towards the center of the map (`right` or\n * `left`), otherwise the opposite side, `top` or `bottom`. The tooltip is shifted\n * along that side to stay within the map (within the viewport if `overflow` is set),\n * its tip still pointing at the source.\n * @property {boolean} [permanent=false] Whether to open the tooltip permanently or only\n * on pointerover.\n * @property {boolean} [sticky=false] If true, the tooltip will follow the pointer\n * instead of being fixed at the feature center.\n * @property {number} [opacity=0.9] Tooltip container opacity.\n * @extends DivOverlayOptions\n */\n\n/**\n * Methods of `MaplairMap` for tooltips.\n * @lends MaplairMap.prototype\n * @fires MaplairMap#tooltipopen {TooltipEvent} Fired when a tooltip is opened in the map.\n * @fires MaplairMap#tooltipclose {TooltipEvent} Fired when a tooltip in the map is closed.\n */\nconst mapTooltipMethods = {\n\t/**\n\t * Opens the specified tooltip.\n\t *\n\t * Alternatively, creates a tooltip with the specified content and options and\n\t * opens it. String content is rendered as HTML; sanitize untrusted input or pass\n\t * an `HTMLElement` with safe `textContent` instead.\n\t * @group Methods for layers and controls\n\t * @param {Tooltip|DivOverlayContent} tooltip The tooltip, or the content of a new\n\t * tooltip.\n\t * @param {LatLngExpression} [latlng]\n\t * @param {TooltipOptions} [options]\n\t * @returns {this}\n\t */\n\topenTooltip(tooltip, latlng, options) {\n\t\t// eslint-disable-next-line no-use-before-define -- defined below, used when called\n\t\tthis._initOverlay(Tooltip, tooltip, latlng, options)\n\t\t\t.openOn(this);\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * Closes the tooltip given as parameter.\n\t * @group Methods for layers and controls\n\t * @param {Tooltip} tooltip\n\t * @returns {this}\n\t */\n\tcloseTooltip(tooltip) {\n\t\ttooltip.close();\n\t\treturn this;\n\t}\n};\n/** @typedef {typeof mapTooltipMethods} MapTooltipMethods */\n\n/**\n * Methods of `Layer` for tooltips. All layers share a set of methods convenient for\n * binding tooltips to it.\n *\n * ```js\n * const layer = new Polygon(latlngs).bindTooltip('Hi There!').addTo(map);\n * layer.openTooltip();\n * layer.closeTooltip();\n * ```\n *\n * @lends Layer.prototype\n * @fires Layer#tooltipopen {TooltipEvent} Fired when a tooltip bound to this layer is\n * opened.\n * @fires Layer#tooltipclose {TooltipEvent} Fired when a tooltip bound to this layer is\n * closed.\n */\nconst layerTooltipMethods = {\n\t/**\n\t * Binds a tooltip to the layer with the passed `content` and sets up the\n\t * necessary event listeners. A `String` argument is rendered as HTML; if it\n\t * may contain untrusted input, sanitize it (e.g. with DOMPurify) or pass an\n\t * `HTMLElement` with safe `textContent` instead. If a `Function` is passed\n\t * it will receive the layer as the first argument and should return a\n\t * `String`, `HTMLElement` or `DocumentFragment`.\n\t * @group Tooltip methods\n\t * @param {DivOverlayContent|Tooltip} content\n\t * @param {TooltipOptions} [options]\n\t * @returns {this}\n\t */\n\tbindTooltip(content, options) {\n\t\t// an open tooltip is replaced, a closed one reused\n\t\tconst old = this.isTooltipOpen() ? null : this._tooltip;\n\n\t\t// the handlers depend on the old options, so they go before the new ones are applied\n\t\tif (this._tooltip) {\n\t\t\tthis.unbindTooltip();\n\t\t}\n\n\t\t// eslint-disable-next-line no-use-before-define -- defined below, used when called\n\t\tthis._tooltip = this._initOverlay(Tooltip, old, content, options);\n\t\tthis._initTooltipInteractions();\n\n\t\tif (this._tooltip.options.permanent && this._map?.hasLayer(this)) {\n\t\t\tthis.openTooltip();\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t/**\n\t * Removes the tooltip previously bound with `bindTooltip`.\n\t * @group Tooltip methods\n\t * @returns {this}\n\t */\n\tunbindTooltip() {\n\t\tif (this._tooltip) {\n\t\t\tthis._initTooltipInteractions(true);\n\t\t\tthis.closeTooltip();\n\t\t\tthis._tooltip = null;\n\t\t}\n\t\treturn this;\n\t},\n\n\t_initTooltipInteractions(remove) {\n\t\tconst {permanent, sticky} = this._tooltip.options,\n\t\tevents = {\n\t\t\tremove: this.closeTooltip,\n\t\t\tmove: this._moveTooltip\n\t\t};\n\t\tif (permanent) {\n\t\t\tevents.add = this._openTooltip;\n\t\t} else {\n\t\t\tevents.pointerover = this._openTooltip;\n\t\t\tevents.pointerout = this.closeTooltip;\n\t\t\tevents.click = this._openTooltip;\n\t\t\t// layer elements can be recreated on every add\n\t\t\tevents.add = this._toggleFocusListeners;\n\t\t\tif (this._map) {\n\t\t\t\tthis._toggleFocusListeners(!remove);\n\t\t\t}\n\t\t}\n\t\tif (sticky) {\n\t\t\tevents.pointermove = this._moveTooltip;\n\t\t}\n\t\tthis[remove ? 'off' : 'on'](events);\n\t},\n\n\t/**\n\t * Opens the bound tooltip at the specified `latlng` or at the default tooltip\n\t * anchor if no `latlng` is passed.\n\t * @group Tooltip methods\n\t * @param {LatLngExpression} [latlng]\n\t * @returns {this}\n\t */\n\topenTooltip(latlng) {\n\t\tif (this._tooltip) {\n\t\t\tif (!(this instanceof FeatureGroup)) {\n\t\t\t\tthis._tooltip._source = this;\n\t\t\t}\n\t\t\tif (this._tooltip._prepareOpen(latlng)) {\n\t\t\t\t// open the tooltip on the map\n\t\t\t\tthis._tooltip.openOn(this._map);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t},\n\n\t/**\n\t * Closes the tooltip bound to this layer if it is open.\n\t * @group Tooltip methods\n\t * @returns {this}\n\t */\n\tcloseTooltip() {\n\t\tthis._tooltip?.close();\n\t\treturn this;\n\t},\n\n\t/**\n\t * Opens or closes the tooltip bound to this layer depending on its current state.\n\t * @group Tooltip methods\n\t * @returns {this}\n\t */\n\ttoggleTooltip() {\n\t\tthis._tooltip?.toggle(this);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` if the tooltip bound to this layer is currently open.\n\t * @group Tooltip methods\n\t * @returns {boolean}\n\t */\n\tisTooltipOpen() {\n\t\treturn this._tooltip?.isOpen() ?? false;\n\t},\n\n\t/**\n\t * Sets the content of the tooltip bound to this layer. String content is rendered\n\t * as HTML; sanitize untrusted input or pass an `HTMLElement` with safe\n\t * `textContent` instead.\n\t * @group Tooltip methods\n\t * @param {DivOverlayContent} content\n\t * @returns {this}\n\t */\n\tsetTooltipContent(content) {\n\t\tthis._tooltip?.setContent(content);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns the tooltip bound to this layer.\n\t * @group Tooltip methods\n\t * @returns {Tooltip|undefined}\n\t */\n\tgetTooltip() {\n\t\treturn this._tooltip;\n\t},\n\n\t// also the `add` listener, so any truthy argument adds\n\t_toggleFocusListeners(add) {\n\t\tif (this.getElement) {\n\t\t\tthis._addFocusListenersOnLayer(this, !add);\n\t\t} else if (this.eachLayer) {\n\t\t\tthis.eachLayer(layer => this._addFocusListenersOnLayer(layer, !add), this);\n\t\t}\n\t},\n\n\t_addFocusListenersOnLayer(layer, remove) {\n\t\tconst el = typeof layer.getElement === 'function' && layer.getElement();\n\t\tif (el) {\n\t\t\tconst toggle = remove ? DomEvent.off : DomEvent.on;\n\t\t\tif (!remove) {\n\t\t\t\t// Remove focus listener, if already existing\n\t\t\t\tel._maplair_focus_handler && DomEvent.off(el, 'focus', el._maplair_focus_handler, this);\n\n\t\t\t\t// open only on keyboard focus: an element clicked with the mouse keeps focus and gets it again whenever\n\t\t\t\t// the window is refocused or a popup closes, which would open the tooltip without the pointer over it\n\t\t\t\tel._maplair_focus_handler = () => {\n\t\t\t\t\tif (this._tooltip && el.matches(':focus-visible')) {\n\t\t\t\t\t\tthis._tooltip._source = layer;\n\t\t\t\t\t\tthis.openTooltip();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tel._maplair_focus_handler && toggle(el, 'focus', el._maplair_focus_handler, this);\n\t\t\ttoggle(el, 'blur', this.closeTooltip, this);\n\n\t\t\tif (remove) {\n\t\t\t\tdelete el._maplair_focus_handler;\n\t\t\t}\n\t\t}\n\t},\n\n\t_openTooltip(e) {\n\t\tif (!this._tooltip || !this._map) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the map is moving, we will show the tooltip after it's done.\n\t\tif (this._map.dragging?.moving()) {\n\t\t\tif (e.type === 'add' && !this._moveEndOpensTooltip) {\n\t\t\t\tthis._moveEndOpensTooltip = true;\n\t\t\t\tthis._map.once('moveend', () => {\n\t\t\t\t\tthis._moveEndOpensTooltip = false;\n\t\t\t\t\tthis._openTooltip(e);\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tthis._tooltip._source = e.propagatedFrom ?? e.target;\n\n\t\tthis.openTooltip(this._tooltip.options.sticky ? e.latlng : undefined);\n\t},\n\n\t_moveTooltip(e) {\n\t\tthis._tooltip.setLatLng(this._tooltip.options.sticky && e.originalEvent ?\n\t\t\tthis._map.pointerEventToLatLng(e.originalEvent) : e.latlng);\n\t}\n};\n/** @typedef {typeof layerTooltipMethods} LayerTooltipMethods */\n\n/**\n * Used to display small texts on top of map layers.\n *\n * @example\n * If you want to just bind a tooltip to marker:\n *\n * ```js\n * marker.bindTooltip(\"my tooltip text\").openTooltip();\n * ```\n * Path overlays like polylines also have a `bindTooltip` method.\n *\n * A tooltip can be also standalone:\n *\n * ```js\n * const tooltip = new Tooltip()\n * \t.setLatLng(latlng)\n * \t.setContent('Hello world!<br />This is a nice tooltip.')\n * \t.addTo(map);\n * ```\n * or\n * ```js\n * const tooltip = new Tooltip(latlng, {content: 'Hello world!<br />This is a nice tooltip.'})\n * \t.addTo(map);\n * ```\n *\n * **Security note.** Tooltip string content is rendered as HTML. If your content\n * may include untrusted input (e.g. data from users or external APIs), sanitize\n * it with a library like [DOMPurify](https://github.com/cure53/DOMPurify), or\n * build a DOM element using `textContent` to render it as plain text:\n *\n * ```js\n * const el = document.createElement('div');\n * el.textContent = untrustedString;\n * marker.bindTooltip(el);\n * ```\n *\n * Note about tooltip offset. Maplair takes two options in consideration\n * for computing tooltip offsetting:\n * - the `offset` Tooltip option: it defaults to [0, 0], and it's specific to one tooltip.\n * Add a positive x offset to move the tooltip to the right, and a positive y offset to\n * move it to the bottom. Negatives will move to the left and top.\n * - the `tooltipAnchor` Icon option: this will only be considered for Marker. You\n * should adapt this value if you use a custom icon.\n */\nexport class Tooltip extends DivOverlay {\n\n\tstatic defaultOptions = {\n\t\tpane: 'tooltipPane',\n\t\toffset: [0, 0],\n\t\tdirection: 'auto',\n\t\tpermanent: false,\n\t\tsticky: false,\n\t\topacity: 0.9\n\t};\n\n\t/**\n\t * Instantiates a `Tooltip` object given an optional `options` object that describes\n\t * its appearance and location and an optional `source` object that is used to tag\n\t * the tooltip with a reference to the Layer to which it refers.\n\t * @overload\n\t * @param {TooltipOptions} [options]\n\t * @param {Layer} [source]\n\t */\n\t/**\n\t * Instantiates a `Tooltip` object given `latlng` where the tooltip will open and an\n\t * optional `options` object that describes its appearance and location.\n\t * @overload\n\t * @param {LatLngExpression} latlng\n\t * @param {TooltipOptions} [options]\n\t */\n\t/**\n\t * @param {...any} args\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(Tooltip);\n\t}\n\n\t/**\n\t * Adds the tooltip to the map.\n\t * @param {MaplairMap} map\n\t */\n\tonAdd(map) {\n\t\tsuper.onAdd(map);\n\t\tthis.setOpacity(this.options.opacity);\n\n\t\tmap.fire('tooltipopen', {tooltip: this});\n\n\t\tif (this._source) {\n\t\t\tthis.addEventParent(this._source);\n\t\t\tthis._source.getElement?.()?.setAttribute('aria-describedby', this._container.id);\n\n\t\t\tthis._source.fire('tooltipopen', {tooltip: this}, true);\n\t\t}\n\t}\n\n\t/**\n\t * Removes the tooltip from the map.\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tsuper.onRemove(map);\n\n\t\tmap.fire('tooltipclose', {tooltip: this});\n\n\t\tif (this._source) {\n\t\t\tthis.removeEventParent(this._source);\n\n\t\t\tthis._source.fire('tooltipclose', {tooltip: this}, true);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the map events the tooltip listens to.\n\t * @returns {Record<string, EventListener>}\n\t */\n\tgetEvents() {\n\t\tconst events = super.getEvents();\n\n\t\tif (!this.options.permanent) {\n\t\t\tevents.preclick = this.close;\n\t\t}\n\n\t\treturn events;\n\t}\n\n\t_initLayout() {\n\t\tconst prefix = 'maplair-tooltip',\n\t\tclassName = `${prefix} ${this.options.className || ''} maplair-zoom-animated`;\n\n\t\tthis._contentNode = this._container = DomUtil.create('div', className);\n\n\t\tthis._container.setAttribute('role', 'tooltip');\n\t\tthis._container.id = `maplair-tooltip-${Util.stamp(this)}`;\n\t}\n\n\t_updateLayout() {}\n\n\t_adjustPan() {}\n\n\t/**\n\t * Updates the tooltip content, layout and position.\n\t * @returns {void}\n\t */\n\tupdate() {\n\t\t// The automatic direction is chosen once per opening and content, so that\n\t\t// the tooltip does not flip sides while the map or the pointer moves.\n\t\tthis._autoDirection = undefined;\n\t\tsuper.update();\n\t}\n\n\t_setPosition(pos) {\n\t\tlet direction = this.options.direction,\n\t\tshift = new Point(0, 0);\n\t\tconst container = this._container,\n\t\ttooltipWidth = container.offsetWidth,\n\t\ttooltipHeight = container.offsetHeight,\n\t\toffset = new Point(this.options.offset),\n\t\tanchor = this._getAnchor();\n\n\t\tif (!(direction in directions)) {\n\t\t\t({direction, shift} = this._getAutoPlacement(pos, offset, anchor, tooltipWidth, tooltipHeight));\n\t\t\tif (direction === 'left') {\n\t\t\t\t// mirror the offset and anchor, which are meant for the right side\n\t\t\t\toffset.x = -offset.x;\n\t\t\t\tanchor.x = -anchor.x;\n\t\t\t}\n\t\t}\n\n\t\tconst [fx, fy] = directions[direction];\n\t\tpos = pos.subtract(new Point(tooltipWidth * fx, tooltipHeight * fy, true)).add(offset).add(anchor).add(shift);\n\n\t\tfor (const d in directions) {\n\t\t\tcontainer.classList.toggle(`maplair-tooltip-${d}`, d === direction);\n\t\t}\n\n\t\t// Let the tip point at the source despite the shift\n\t\tconst tipShift = direction === 'top' || direction === 'bottom' ?\n\t\t\tclampTip(-shift.x, tooltipWidth) :\n\t\t\tclampTip(-shift.y, tooltipHeight);\n\t\tif (tipShift) {\n\t\t\tcontainer.style.setProperty('--maplair-tooltip-tip-shift', `${tipShift}px`);\n\t\t} else {\n\t\t\tcontainer.style.removeProperty('--maplair-tooltip-tip-shift');\n\t\t}\n\n\t\tthis._setContainerPosition(pos);\n\t}\n\n\t// Chooses the direction of an `auto` tooltip by the available space:\n\t// preferably the side towards the center, otherwise the opposite side,\n\t// above or below. The tooltip is shifted along that side to stay in view.\n\t_getAutoPlacement(pos, offset, anchor, width, height) {\n\t\tconst area = this._getAutoArea(),\n\t\tpoint = this._map.layerPointToContainerPoint(pos),\n\t\tx = point.x + offset.x + anchor.x,\n\t\ty = point.y + offset.y + anchor.y,\n\t\t// the space for each direction, see `direction` for the mirrored left side\n\t\tspace = {\n\t\t\tright: area.max.x - x - width - tipSize,\n\t\t\tleft: point.x - offset.x - anchor.x - area.min.x - width - tipSize,\n\t\t\ttop: y - area.min.y - height - tipSize,\n\t\t\tbottom: area.max.y - y - height - tipSize\n\t\t};\n\n\t\tif (!this._autoDirection) {\n\t\t\tconst sides = point.x < (area.min.x + area.max.x) / 2 ? ['right', 'left'] : ['left', 'right'],\n\t\t\tfallback = space.right >= space.left ? 'right' : 'left';\n\t\t\tthis._autoDirection = [...sides, 'top', 'bottom'].find(d => space[d] >= 0 &&\n\t\t\t\t// above or below, the tooltip has to fit horizontally\n\t\t\t\t(d === 'right' || d === 'left' || width <= area.max.x - area.min.x)) ?? fallback;\n\t\t}\n\n\t\tconst direction = this._autoDirection,\n\t\tshift = direction === 'top' || direction === 'bottom' ?\n\t\t\tnew Point(shiftInto(x - width / 2, width, area.min.x, area.max.x), 0) :\n\t\t\tnew Point(0, shiftInto(y - height / 2, height, area.min.y, area.max.y));\n\n\t\treturn {direction, shift};\n\t}\n\n\t// The area in container points an `auto` tooltip should stay within:\n\t// the map, or the viewport for an overflowing tooltip.\n\t_getAutoArea() {\n\t\tconst map = this._map;\n\t\tlet min = new Point(0, 0),\n\t\tmax = map.getSize();\n\t\tif (this.options.overflow) {\n\t\t\tconst mapContainer = map._container,\n\t\t\trect = mapContainer.getBoundingClientRect(),\n\t\t\torigin = new Point(rect.left + mapContainer.clientLeft, rect.top + mapContainer.clientTop),\n\t\t\tviewport = document.documentElement;\n\t\t\tmin = min.subtract(origin);\n\t\t\tmax = new Point(viewport.clientWidth, viewport.clientHeight).subtract(origin);\n\t\t}\n\t\tconst padding = new Point(autoPadding, autoPadding);\n\t\treturn {min: min.add(padding), max: max.subtract(padding)};\n\t}\n\n\t_updatePosition() {\n\t\tconst pos = this._map.latLngToLayerPoint(this._latlng)._round();\n\t\tthis._setPosition(pos);\n\t}\n\n\t/**\n\t * Sets the opacity of the tooltip.\n\t * @param {number} opacity\n\t * @returns {void}\n\t */\n\tsetOpacity(opacity) {\n\t\tthis.options.opacity = opacity;\n\n\t\tif (this._container) {\n\t\t\tthis._container.style.opacity = `${opacity}`;\n\t\t}\n\t}\n\n\t_animateZoom(e) {\n\t\tconst pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center);\n\t\tthis._setPosition(pos);\n\t}\n\n\t_getAnchor() {\n\t\t// Where should we anchor the tooltip on the source layer?\n\t\treturn new Point(this._source?._getTooltipAnchor && !this.options.sticky ? this._source._getTooltipAnchor() : [0, 0]);\n\t}\n\n\t/**\n\t * Registers this default feature on the map class, called by `MaplairMap` itself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AAC,OAAO;EAC9D,KAAK,aAAa,GAAG;CACtB;;;;;;CAOA,WAAW,SAAS;EACnB,KAAK,QAAQ,UAAU;EAEvB,IAAI,KAAK,YACR,KAAK,WAAW,MAAM,UAAU,GAAG;CAErC;CAEA,aAAa,GAAG;EACf,MAAM,MAAM,KAAK,KAAK,uBAAuB,KAAK,SAAS,EAAE,MAAM,EAAE,MAAM;EAC3E,KAAK,aAAa,GAAG;CACtB;CAEA,aAAa;EAEZ,OAAO,IAAI,MAAM,KAAK,SAAS,qBAAqB,CAAC,KAAK,QAAQ,SAAS,KAAK,QAAQ,kBAAkB,IAAI,CAAC,GAAG,CAAC,CAAC;CACrH;;;;;;CAOA,OAAO,SAAS,YAAY;EAC3B,WAAW,QAAQ,iBAAiB;EAEpC,MAAM,QAAQ,mBAAmB;CAClC;AACD"}
@@ -81,7 +81,7 @@ var VideoOverlay = class VideoOverlay extends ImageOverlay {
81
81
  return;
82
82
  }
83
83
  if (!Array.isArray(this._url)) this._url = [this._url];
84
- if (!this.options.keepAspectRatio) vid.style["objectFit"] = "fill";
84
+ if (!this.options.keepAspectRatio) vid.style.objectFit = "fill";
85
85
  vid.autoplay = !!this.options.autoplay;
86
86
  vid.controls = !!this.options.controls;
87
87
  vid.loop = !!this.options.loop;
@@ -90,7 +90,7 @@ var VideoOverlay = class VideoOverlay extends ImageOverlay {
90
90
  for (const url of this._url) {
91
91
  const source = create("source");
92
92
  source.src = url;
93
- vid.appendChild(source);
93
+ vid.append(source);
94
94
  }
95
95
  }
96
96
  };
@@ -1 +1 @@
1
- {"version":3,"file":"VideoOverlay.js","names":["DomUtil.create","Util.splitWords"],"sources":["../../../src/layer/VideoOverlay.js"],"sourcesContent":["import {ImageOverlay} from './ImageOverlay.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport * as Util from '../core/Util.js';\n\n/** @import {ImageOverlayOptions} from './ImageOverlay.js' */\n/** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */\n/** @import {MaplairEvent} from '../core/Events.js' */\n\n/**\n * Options of `VideoOverlay`.\n * @typedef {object} VideoOverlayOptions\n * @property {boolean} [autoplay=true] Whether the video starts playing automatically\n * when loaded. On some browsers autoplay will only work with `muted: true`.\n * @property {boolean} [controls=false] Whether the browser will offer controls to\n * allow the user to control video playback, including volume, seeking, and\n * pause/resume playback.\n * @property {boolean} [loop=true] Whether the video will loop back to the beginning\n * when played.\n * @property {boolean} [keepAspectRatio=true] Whether the video will save aspect ratio\n * after the projection.\n * @property {boolean} [muted=false] Whether the video starts on mute when loaded.\n * @property {boolean} [playsInline=true] Mobile browsers will play the video right\n * where it is instead of open it up in fullscreen mode.\n * @extends ImageOverlayOptions\n */\n\n/**\n * Used to load and display a video player over specific bounds of the map. Extends\n * `ImageOverlay`.\n *\n * A video overlay uses the [`<video>`](https://developer.mozilla.org/docs/Web/HTML/Element/video)\n * HTML element; `getElement()` returns the instance of\n * [`HTMLVideoElement`](https://developer.mozilla.org/docs/Web/API/HTMLVideoElement)\n * used by this overlay.\n *\n * @example\n * ```js\n * const videoUrl = 'https://www.mapbox.com/bites/00188/patricia_nasa.webm',\n * \tvideoBounds = [[ 32, -130], [ 13, -100]];\n * new VideoOverlay(videoUrl, videoBounds ).addTo(map);\n * ```\n *\n * @fires load {MaplairEvent} Fired when the video has finished loading the first frame.\n */\nexport class VideoOverlay extends ImageOverlay {\n\n\tstatic defaultOptions = {\n\t\tautoplay: true,\n\t\tcontrols: false,\n\t\tloop: true,\n\t\tkeepAspectRatio: true,\n\t\tmuted: false,\n\t\tplaysInline: true\n\t};\n\n\t/**\n\t * Instantiates a video overlay object given the URL of the video (or array of\n\t * URLs, or even a video element) and the geographical bounds it is tied to.\n\t * @overload\n\t * @param {string|string[]|HTMLVideoElement} video\n\t * @param {LatLngBoundsExpression} bounds\n\t * @param {VideoOverlayOptions} [options]\n\t */\n\t/**\n\t * @param {...any} args\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(VideoOverlay);\n\t}\n\n\t_initImage() {\n\t\tconst wasElementSupplied = this._url instanceof HTMLVideoElement;\n\t\tconst vid = this._image = wasElementSupplied ? this._url : DomUtil.create('video');\n\n\t\tvid.classList.add('maplair-image-layer', 'maplair-zoom-animated');\n\t\tif (this.options.className) { vid.classList.add(...Util.splitWords(this.options.className)); }\n\n\t\tDomEvent.on(vid, 'pointerdown', (e) => {\n\t\t\tif (vid.controls) {\n\t\t\t\t// Prevent the map from moving when the video or the seekbar is moved\n\t\t\t\tDomEvent.stopPropagation(e);\n\t\t\t}\n\t\t});\n\n\t\tvid.onloadeddata = this.fire.bind(this, 'load');\n\n\t\tif (wasElementSupplied) {\n\t\t\tconst sourceElements = vid.getElementsByTagName('source');\n\t\t\tconst sources = Array.from(sourceElements, e => e.src);\n\t\t\tthis._url = (sourceElements.length > 0) ? sources : [vid.src];\n\t\t\treturn;\n\t\t}\n\n\t\tif (!Array.isArray(this._url)) { this._url = [this._url]; }\n\n\t\tif (!this.options.keepAspectRatio) {\n\t\t\tvid.style['objectFit'] = 'fill';\n\t\t}\n\t\tvid.autoplay = !!this.options.autoplay;\n\t\tvid.controls = !!this.options.controls;\n\t\tvid.loop = !!this.options.loop;\n\t\tvid.muted = !!this.options.muted;\n\t\tvid.playsInline = !!this.options.playsInline;\n\t\tfor (const url of this._url) {\n\t\t\tconst source = DomUtil.create('source');\n\t\t\tsource.src = url;\n\t\t\tvid.appendChild(source);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,IAAa,eAAb,MAAa,qBAAqB,aAAa;CAE9C,OAAO,iBAAiB;EACvB,UAAU;EACV,UAAU;EACV,MAAM;EACN,iBAAiB;EACjB,OAAO;EACP,aAAa;CACd;;;;;;;;;;;;CAaA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,YAAY;CAChC;CAEA,aAAa;EACZ,MAAM,qBAAqB,KAAK,gBAAgB;EAChD,MAAM,MAAM,KAAK,SAAS,qBAAqB,KAAK,OAAOA,OAAe,OAAO;EAEjF,IAAI,UAAU,IAAI,uBAAuB,uBAAuB;EAChE,IAAI,KAAK,QAAQ,WAAa,IAAI,UAAU,IAAI,GAAGC,WAAgB,KAAK,QAAQ,SAAS,CAAC;EAE1F,GAAY,KAAK,gBAAgB,MAAM;GACtC,IAAI,IAAI,UAEP,gBAAyB,CAAC;EAE5B,CAAC;EAED,IAAI,eAAe,KAAK,KAAK,KAAK,MAAM,MAAM;EAE9C,IAAI,oBAAoB;GACvB,MAAM,iBAAiB,IAAI,qBAAqB,QAAQ;GACxD,MAAM,UAAU,MAAM,KAAK,iBAAgB,MAAK,EAAE,GAAG;GACrD,KAAK,OAAQ,eAAe,SAAS,IAAK,UAAU,CAAC,IAAI,GAAG;GAC5D;EACD;EAEA,IAAI,CAAC,MAAM,QAAQ,KAAK,IAAI,GAAK,KAAK,OAAO,CAAC,KAAK,IAAI;EAEvD,IAAI,CAAC,KAAK,QAAQ,iBACjB,IAAI,MAAM,eAAe;EAE1B,IAAI,WAAW,CAAC,CAAC,KAAK,QAAQ;EAC9B,IAAI,WAAW,CAAC,CAAC,KAAK,QAAQ;EAC9B,IAAI,OAAO,CAAC,CAAC,KAAK,QAAQ;EAC1B,IAAI,QAAQ,CAAC,CAAC,KAAK,QAAQ;EAC3B,IAAI,cAAc,CAAC,CAAC,KAAK,QAAQ;EACjC,KAAK,MAAM,OAAO,KAAK,MAAM;GAC5B,MAAM,SAASD,OAAe,QAAQ;GACtC,OAAO,MAAM;GACb,IAAI,YAAY,MAAM;EACvB;CACD;AACD"}
1
+ {"version":3,"file":"VideoOverlay.js","names":["DomUtil.create","Util.splitWords"],"sources":["../../../src/layer/VideoOverlay.js"],"sourcesContent":["import {ImageOverlay} from './ImageOverlay.js';\nimport * as DomUtil from '../dom/DomUtil.js';\nimport * as DomEvent from '../dom/DomEvent.js';\nimport * as Util from '../core/Util.js';\n\n/** @import {ImageOverlayOptions} from './ImageOverlay.js' */\n/** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */\n/** @import {MaplairEvent} from '../core/Events.js' */\n\n/**\n * Options of `VideoOverlay`.\n * @typedef {object} VideoOverlayOptions\n * @property {boolean} [autoplay=true] Whether the video starts playing automatically\n * when loaded. On some browsers autoplay will only work with `muted: true`.\n * @property {boolean} [controls=false] Whether the browser will offer controls to\n * allow the user to control video playback, including volume, seeking, and\n * pause/resume playback.\n * @property {boolean} [loop=true] Whether the video will loop back to the beginning\n * when played.\n * @property {boolean} [keepAspectRatio=true] Whether the video will save aspect ratio\n * after the projection.\n * @property {boolean} [muted=false] Whether the video starts on mute when loaded.\n * @property {boolean} [playsInline=true] Mobile browsers will play the video right\n * where it is instead of open it up in fullscreen mode.\n * @extends ImageOverlayOptions\n */\n\n/**\n * Used to load and display a video player over specific bounds of the map. Extends\n * `ImageOverlay`.\n *\n * A video overlay uses the [`<video>`](https://developer.mozilla.org/docs/Web/HTML/Element/video)\n * HTML element; `getElement()` returns the instance of\n * [`HTMLVideoElement`](https://developer.mozilla.org/docs/Web/API/HTMLVideoElement)\n * used by this overlay.\n *\n * @example\n * ```js\n * const videoUrl = 'https://www.mapbox.com/bites/00188/patricia_nasa.webm',\n * \tvideoBounds = [[ 32, -130], [ 13, -100]];\n * new VideoOverlay(videoUrl, videoBounds ).addTo(map);\n * ```\n *\n * @fires load {MaplairEvent} Fired when the video has finished loading the first frame.\n */\nexport class VideoOverlay extends ImageOverlay {\n\n\tstatic defaultOptions = {\n\t\tautoplay: true,\n\t\tcontrols: false,\n\t\tloop: true,\n\t\tkeepAspectRatio: true,\n\t\tmuted: false,\n\t\tplaysInline: true\n\t};\n\n\t/**\n\t * Instantiates a video overlay object given the URL of the video (or array of\n\t * URLs, or even a video element) and the geographical bounds it is tied to.\n\t * @overload\n\t * @param {string|string[]|HTMLVideoElement} video\n\t * @param {LatLngBoundsExpression} bounds\n\t * @param {VideoOverlayOptions} [options]\n\t */\n\t/**\n\t * @param {...any} args\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(VideoOverlay);\n\t}\n\n\t_initImage() {\n\t\tconst wasElementSupplied = this._url instanceof HTMLVideoElement;\n\t\tconst vid = this._image = wasElementSupplied ? this._url : DomUtil.create('video');\n\n\t\tvid.classList.add('maplair-image-layer', 'maplair-zoom-animated');\n\t\tif (this.options.className) { vid.classList.add(...Util.splitWords(this.options.className)); }\n\n\t\tDomEvent.on(vid, 'pointerdown', (e) => {\n\t\t\tif (vid.controls) {\n\t\t\t\t// Prevent the map from moving when the video or the seekbar is moved\n\t\t\t\tDomEvent.stopPropagation(e);\n\t\t\t}\n\t\t});\n\n\t\tvid.onloadeddata = this.fire.bind(this, 'load');\n\n\t\tif (wasElementSupplied) {\n\t\t\tconst sourceElements = vid.getElementsByTagName('source');\n\t\t\tconst sources = Array.from(sourceElements, e => e.src);\n\t\t\tthis._url = (sourceElements.length > 0) ? sources : [vid.src];\n\t\t\treturn;\n\t\t}\n\n\t\tif (!Array.isArray(this._url)) { this._url = [this._url]; }\n\n\t\tif (!this.options.keepAspectRatio) {\n\t\t\tvid.style.objectFit = 'fill';\n\t\t}\n\t\tvid.autoplay = !!this.options.autoplay;\n\t\tvid.controls = !!this.options.controls;\n\t\tvid.loop = !!this.options.loop;\n\t\tvid.muted = !!this.options.muted;\n\t\tvid.playsInline = !!this.options.playsInline;\n\t\tfor (const url of this._url) {\n\t\t\tconst source = DomUtil.create('source');\n\t\t\tsource.src = url;\n\t\t\tvid.append(source);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,IAAa,eAAb,MAAa,qBAAqB,aAAa;CAE9C,OAAO,iBAAiB;EACvB,UAAU;EACV,UAAU;EACV,MAAM;EACN,iBAAiB;EACjB,OAAO;EACP,aAAa;CACd;;;;;;;;;;;;CAaA,YAAY,GAAG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createElement("div"), options = this.options;
57
- if (options.html instanceof Element) {
58
- div.replaceChildren();
59
- div.appendChild(options.html);
60
- } else div.innerHTML = options.html !== false ? options.html : "";
61
- if (options.bgPos) {
62
- const bgPos = Point.from(options.bgPos);
63
- div.style.backgroundPosition = `${-bgPos.x}px ${-bgPos.y}px`;
64
- }
57
+ if (options.html instanceof Element) div.replaceChildren(options.html);
58
+ else div.innerHTML = options.html !== false ? options.html : "";
59
+ const bgPos = options.bgPos && Point.from(options.bgPos);
60
+ div.style.backgroundPosition = bgPos ? `${-bgPos.x}px ${-bgPos.y}px` : "";
65
61
  this._setIconStyles(div, "icon");
66
62
  return div;
67
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DivIcon.js","names":[],"sources":["../../../../src/layer/marker/DivIcon.js"],"sourcesContent":["import {Icon} from './Icon.js';\nimport {Point} from '../../geometry/Point.js';\n/** @import {IconOptions} from './Icon.js' */\n/** @import {PointExpression} from '../../geometry/Point.js' */\n\n/**\n * Options of `DivIcon`.\n * @typedef {object} DivIconOptions\n * @property {PointExpression|number} [iconSize=[12, 12]] Size of the icon in pixels,\n * also can be set through CSS.\n * @property {string|HTMLElement|false} [html=false] Custom HTML code to put inside the\n * div element, empty by default. Alternatively, an instance of `HTMLElement`.\n * @property {PointExpression|null} [bgPos=null] Optional relative position of the\n * background, in pixels.\n * @property {string} [className='maplair-div-icon']\n * @extends IconOptions\n */\n\n/**\n * Represents a lightweight icon for markers that uses a simple `<div>`\n * element instead of an image. Inherits from `Icon` but ignores the `iconUrl` and\n * shadow options.\n *\n * By default, it has a 'maplair-div-icon' CSS class and is styled as a little white\n * square with a shadow.\n *\n * @example\n * ```js\n * const myIcon = new DivIcon({className: 'my-div-icon'});\n * // you can set .my-div-icon styles in CSS\n *\n * new Marker([50.505, 30.57], {icon: myIcon}).addTo(map);\n * ```\n */\nexport class DivIcon extends Icon {\n\n\tstatic defaultOptions = {\n\t\ticonSize: [12, 12], // also can be set through CSS\n\n\t\t// iconAnchor: (Point),\n\t\t// popupAnchor: (Point),\n\n\t\thtml: false,\n\t\tbgPos: null,\n\t\tclassName: 'maplair-div-icon'\n\t};\n\n\t/**\n\t * Creates a `DivIcon` instance with the given options.\n\t * @param {[options?: DivIconOptions]} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(DivIcon);\n\t}\n\n\t/**\n\t * Called internally when the icon has to be shown, returns a `<div>` element\n\t * styled according to the options.\n\t * @param {HTMLElement} [oldIcon] The current element of the icon, to be reused if possible.\n\t * @returns {HTMLElement}\n\t */\n\tcreateIcon(oldIcon) {\n\t\tconst div = oldIcon instanceof HTMLDivElement ? oldIcon : document.createElement('div'),\n\t\toptions = this.options;\n\n\t\tif (options.html instanceof Element) {\n\t\t\tdiv.replaceChildren();\n\t\t\tdiv.appendChild(options.html);\n\t\t} else {\n\t\t\tdiv.innerHTML = options.html !== false ? options.html : '';\n\t\t}\n\n\t\tif (options.bgPos) {\n\t\t\tconst bgPos = Point.from(options.bgPos);\n\t\t\tdiv.style.backgroundPosition = `${-bgPos.x}px ${-bgPos.y}px`;\n\t\t}\n\t\tthis._setIconStyles(div, 'icon');\n\n\t\treturn div;\n\t}\n\n\t/**\n\t * Returns `null`, a `DivIcon` has no shadow.\n\t * @returns {null}\n\t */\n\tcreateShadow() {\n\t\treturn null;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,UAAb,MAAa,gBAAgB,KAAK;CAEjC,OAAO,iBAAiB;EACvB,UAAU,CAAC,IAAI,EAAE;EAKjB,MAAM;EACN,OAAO;EACP,WAAW;CACZ;;;;;CAMA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,OAAO;CAC3B;;;;;;;CAQA,WAAW,SAAS;EACnB,MAAM,MAAM,mBAAmB,iBAAiB,UAAU,SAAS,cAAc,KAAK,GACtF,UAAU,KAAK;EAEf,IAAI,QAAQ,gBAAgB,SAAS;GACpC,IAAI,gBAAgB;GACpB,IAAI,YAAY,QAAQ,IAAI;EAC7B,OACC,IAAI,YAAY,QAAQ,SAAS,QAAQ,QAAQ,OAAO;EAGzD,IAAI,QAAQ,OAAO;GAClB,MAAM,QAAQ,MAAM,KAAK,QAAQ,KAAK;GACtC,IAAI,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;EAC1D;EACA,KAAK,eAAe,KAAK,MAAM;EAE/B,OAAO;CACR;;;;;CAMA,eAAe;EACd,OAAO;CACR;AACD"}
1
+ {"version":3,"file":"DivIcon.js","names":[],"sources":["../../../../src/layer/marker/DivIcon.js"],"sourcesContent":["import {Icon} from './Icon.js';\nimport {Point} from '../../geometry/Point.js';\n/** @import {IconOptions} from './Icon.js' */\n/** @import {PointExpression} from '../../geometry/Point.js' */\n\n/**\n * Options of `DivIcon`.\n * @typedef {object} DivIconOptions\n * @property {PointExpression|number} [iconSize=[12, 12]] Size of the icon in pixels,\n * also can be set through CSS.\n * @property {string|HTMLElement|false} [html=false] Custom HTML code to put inside the\n * div element, empty by default. Alternatively, an instance of `HTMLElement`.\n * @property {PointExpression|null} [bgPos=null] Optional relative position of the\n * background, in pixels.\n * @property {string} [className='maplair-div-icon']\n * @extends IconOptions\n */\n\n/**\n * Represents a lightweight icon for markers that uses a simple `<div>`\n * element instead of an image. Inherits from `Icon` but ignores the `iconUrl` and\n * shadow options.\n *\n * By default, it has a 'maplair-div-icon' CSS class and is styled as a little white\n * square with a shadow.\n *\n * @example\n * ```js\n * const myIcon = new DivIcon({className: 'my-div-icon'});\n * // you can set .my-div-icon styles in CSS\n *\n * new Marker([50.505, 30.57], {icon: myIcon}).addTo(map);\n * ```\n */\nexport class DivIcon extends Icon {\n\n\tstatic defaultOptions = {\n\t\ticonSize: [12, 12], // also can be set through CSS\n\n\t\t// iconAnchor: (Point),\n\t\t// popupAnchor: (Point),\n\n\t\thtml: false,\n\t\tbgPos: null,\n\t\tclassName: 'maplair-div-icon'\n\t};\n\n\t/**\n\t * Creates a `DivIcon` instance with the given options.\n\t * @param {[options?: DivIconOptions]} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(DivIcon);\n\t}\n\n\t/**\n\t * Called internally when the icon has to be shown, returns a `<div>` element\n\t * styled according to the options.\n\t * @param {HTMLElement} [oldIcon] The current element of the icon, to be reused if possible.\n\t * @returns {HTMLElement}\n\t */\n\tcreateIcon(oldIcon) {\n\t\tconst div = oldIcon instanceof HTMLDivElement ? oldIcon : document.createElement('div'),\n\t\toptions = this.options;\n\n\t\tif (options.html instanceof Element) {\n\t\t\tdiv.replaceChildren(options.html);\n\t\t} else {\n\t\t\tdiv.innerHTML = options.html !== false ? options.html : '';\n\t\t}\n\n\t\tconst bgPos = options.bgPos && Point.from(options.bgPos);\n\t\tdiv.style.backgroundPosition = bgPos ? `${-bgPos.x}px ${-bgPos.y}px` : '';\n\t\tthis._setIconStyles(div, 'icon');\n\n\t\treturn div;\n\t}\n\n\t/**\n\t * Returns `null`, a `DivIcon` has no shadow.\n\t * @returns {null}\n\t */\n\tcreateShadow() {\n\t\treturn null;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,UAAb,MAAa,gBAAgB,KAAK;CAEjC,OAAO,iBAAiB;EACvB,UAAU,CAAC,IAAI,EAAE;EAKjB,MAAM;EACN,OAAO;EACP,WAAW;CACZ;;;;;CAMA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,OAAO;CAC3B;;;;;;;CAQA,WAAW,SAAS;EACnB,MAAM,MAAM,mBAAmB,iBAAiB,UAAU,SAAS,cAAc,KAAK,GACtF,UAAU,KAAK;EAEf,IAAI,QAAQ,gBAAgB,SAC3B,IAAI,gBAAgB,QAAQ,IAAI;OAEhC,IAAI,YAAY,QAAQ,SAAS,QAAQ,QAAQ,OAAO;EAGzD,MAAM,QAAQ,QAAQ,SAAS,MAAM,KAAK,QAAQ,KAAK;EACvD,IAAI,MAAM,qBAAqB,QAAQ,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM;EACvE,KAAK,eAAe,KAAK,MAAM;EAE/B,OAAO;CACR;;;;;CAMA,eAAe;EACd,OAAO;CACR;AACD"}
@@ -1,4 +1,4 @@
1
- import { setOptions } from "../../core/Util.js";
1
+ import { setOptions, toNumber } from "../../core/Util.js";
2
2
  import { Class } from "../../core/Class.js";
3
3
  import { Point } from "../../geometry/Point.js";
4
4
  // src/layer/marker/Icon.js
@@ -99,25 +99,26 @@ var Icon = class Icon extends Class {
99
99
  const img = this._createImg(src, oldIcon instanceof HTMLImageElement ? oldIcon : null);
100
100
  this._setIconStyles(img, name);
101
101
  if (this.options.crossOrigin || this.options.crossOrigin === "") img.crossOrigin = this.options.crossOrigin === true ? "" : this.options.crossOrigin;
102
+ else img.crossOrigin = null;
102
103
  return img;
103
104
  }
104
105
  _setIconStyles(img, name) {
105
106
  const options = this.options;
106
- let sizeOption = options[`${name}Size`];
107
- if (typeof sizeOption === "number") sizeOption = [sizeOption, sizeOption];
108
- const size = Point.validate(sizeOption) && Point.from(sizeOption);
109
- const anchorPosition = name === "shadow" && options.shadowAnchor || options.iconAnchor || size && size.divideBy(2, true);
110
- const anchor = Point.validate(anchorPosition) && Point.from(anchorPosition);
107
+ const sizeOption = options[`${name}Size`];
108
+ const [width, height] = (typeof sizeOption === "number" ? [sizeOption, sizeOption] : Array.isArray(sizeOption) ? sizeOption : [sizeOption?.x, sizeOption?.y]).map(toNumber);
109
+ const anchorOption = name === "shadow" && options.shadowAnchor || options.iconAnchor;
110
+ const anchor = Point.validate(anchorOption) ? Point.from(anchorOption) : {
111
+ x: Math.round(width / 2),
112
+ y: Math.round(height / 2)
113
+ };
111
114
  img.className = `maplair-marker-${name} ${options.className || ""}`;
112
- if (anchor) {
113
- img.style.marginLeft = `${-anchor.x}px`;
114
- img.style.marginTop = `${-anchor.y}px`;
115
- }
116
- img.style.transformOrigin = anchor ? `${anchor.x}px ${anchor.y}px` : "0 0";
117
- if (size) {
118
- img.style.width = `${size.x}px`;
119
- img.style.height = `${size.y}px`;
120
- }
115
+ const { style } = img;
116
+ style.marginLeft = style.marginTop = style.width = style.height = "";
117
+ if (!isNaN(anchor.x)) style.marginLeft = `${-anchor.x}px`;
118
+ if (!isNaN(anchor.y)) style.marginTop = `${-anchor.y}px`;
119
+ style.transformOrigin = !isNaN(anchor.x) && !isNaN(anchor.y) ? `${anchor.x}px ${anchor.y}px` : "0 0";
120
+ if (!isNaN(width)) style.width = `${width}px`;
121
+ if (!isNaN(height)) style.height = `${height}px`;
121
122
  }
122
123
  _createImg(src, el) {
123
124
  el ??= document.createElement("img");
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.js","names":[],"sources":["../../../../src/layer/marker/Icon.js"],"sourcesContent":["import {Class} from '../../core/Class.js';\nimport {setOptions} from '../../core/Util.js';\nimport {Point} from '../../geometry/Point.js';\n\n/** @import {PointExpression} from '../../geometry/Point.js' */\n\n/**\n * Options of `Icon`.\n * @typedef {object} IconOptions\n * @property {string} [iconUrl] **(required)** The URL to the icon image (absolute or\n * relative to your script path).\n * @property {string} [iconRetinaUrl] The URL to a retina sized version of the icon\n * image (absolute or relative to your script path). Used for Retina screen devices.\n * @property {PointExpression|number} [iconSize] Size of the icon image in pixels (a\n * number for square icons).\n * @property {PointExpression} [iconAnchor] The coordinates of the \"tip\" of the icon\n * (relative to its top left corner). The icon will be aligned so that this point is at\n * the marker's geographical location. Centered by default if size is specified, also\n * can be set in CSS with negative margins.\n * @property {PointExpression} [popupAnchor=[0, 0]] The coordinates of the point from\n * which popups will \"open\", relative to the icon anchor.\n * @property {PointExpression} [tooltipAnchor=[0, 0]] The coordinates of the point from\n * which tooltips will \"open\", relative to the icon anchor.\n * @property {string} [shadowUrl] The URL to the icon shadow image. If not specified, no\n * shadow image will be created.\n * @property {string} [shadowRetinaUrl] The URL to a retina sized version of the shadow\n * image. Used for Retina screen devices.\n * @property {PointExpression|number} [shadowSize] Size of the shadow image in pixels.\n * @property {PointExpression} [shadowAnchor] The coordinates of the \"tip\" of the shadow\n * (relative to its top left corner) (the same as iconAnchor if not specified).\n * @property {string} [className] A custom class name to assign to both icon and shadow\n * images. Empty by default.\n * @property {boolean|string} [crossOrigin=false] Whether the crossOrigin attribute will\n * be added to the icon images. If a String is provided, all images will have their\n * crossOrigin attribute set to the String provided. This is needed if you want to\n * access image pixel data. Refer to\n * [CORS Settings](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes)\n * for valid String values.\n */\n\n/**\n * Represents an icon to provide when creating a marker.\n *\n * `DefaultIcon` extends `Icon` and is the blue icon Maplair uses for markers by default.\n *\n * @example\n * ```js\n * const myIcon = new Icon({\n * iconUrl: 'my-icon.png',\n * iconRetinaUrl: 'my-icon@2x.png',\n * iconSize: [38, 95],\n * iconAnchor: [22, 94],\n * popupAnchor: [-3, -76],\n * shadowUrl: 'my-icon-shadow.png',\n * shadowRetinaUrl: 'my-icon-shadow@2x.png',\n * shadowSize: [68, 95],\n * shadowAnchor: [22, 94]\n * });\n *\n * new Marker([50.505, 30.57], {icon: myIcon}).addTo(map);\n * ```\n */\nexport class Icon extends Class {\n\n\tstatic defaultOptions = {\n\t\tpopupAnchor: [0, 0],\n\t\ttooltipAnchor: [0, 0],\n\t\tcrossOrigin: false\n\t};\n\n\t/**\n\t * Creates an icon instance with the given options.\n\t * @param {IconOptions} [options]\n\t */\n\tconstructor(options) {\n\t\tsuper();\n\t\tsetOptions(this, options);\n\n\t\tthis.callInitHooks(Icon);\n\t}\n\n\t/**\n\t * Called internally when the icon has to be shown, returns a `<img>` HTML element\n\t * styled according to the options.\n\t * @param {HTMLElement} [oldIcon] The current element of the icon, to be reused if possible.\n\t * @returns {HTMLElement}\n\t */\n\tcreateIcon(oldIcon) {\n\t\treturn this._createIcon('icon', oldIcon);\n\t}\n\n\t/**\n\t * As `createIcon`, but for the shadow beneath it. Returns `null` without a shadow.\n\t * @param {HTMLElement} [oldIcon] The current element of the shadow, to be reused if possible.\n\t * @returns {HTMLElement|null}\n\t */\n\tcreateShadow(oldIcon) {\n\t\treturn this._createIcon('shadow', oldIcon);\n\t}\n\n\t_createIcon(name, oldIcon) {\n\t\tconst src = this._getIconUrl(name);\n\n\t\tif (!src) {\n\t\t\tif (name === 'icon') {\n\t\t\t\tthrow new Error('iconUrl not set in Icon options (see the docs).');\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\n\t\tconst img = this._createImg(src, oldIcon instanceof HTMLImageElement ? oldIcon : null);\n\t\tthis._setIconStyles(img, name);\n\n\t\tif (this.options.crossOrigin || this.options.crossOrigin === '') {\n\t\t\timg.crossOrigin = this.options.crossOrigin === true ? '' : this.options.crossOrigin;\n\t\t}\n\n\t\treturn img;\n\t}\n\n\t_setIconStyles(img, name) {\n\t\tconst options = this.options;\n\t\tlet sizeOption = options[`${name}Size`];\n\n\t\tif (typeof sizeOption === 'number') {\n\t\t\tsizeOption = [sizeOption, sizeOption];\n\t\t}\n\n\t\tconst size = Point.validate(sizeOption) && Point.from(sizeOption);\n\n\t\tconst anchorPosition = name === 'shadow' && options.shadowAnchor || options.iconAnchor || size && size.divideBy(2, true);\n\t\tconst anchor = Point.validate(anchorPosition) && Point.from(anchorPosition);\n\n\t\timg.className = `maplair-marker-${name} ${options.className || ''}`;\n\n\t\tif (anchor) {\n\t\t\timg.style.marginLeft = `${-anchor.x}px`;\n\t\t\timg.style.marginTop = `${-anchor.y}px`;\n\t\t}\n\t\t// the origin of the marker rotation: the anchor, which is the top left corner without one\n\t\timg.style.transformOrigin = anchor ? `${anchor.x}px ${anchor.y}px` : '0 0';\n\n\t\tif (size) {\n\t\t\timg.style.width = `${size.x}px`;\n\t\t\timg.style.height = `${size.y}px`;\n\t\t}\n\t}\n\n\t_createImg(src, el) {\n\t\tel ??= document.createElement('img');\n\t\tel.src = src;\n\t\treturn el;\n\t}\n\n\t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AM,SAAS,cAAc,KAAK,MAAM,KAAK,cAAc;EAE1E,IAAI,YAAY,kBAAkB,KAAK,GAAG,QAAQ,aAAa;EAE/D,IAAI,QAAQ;GACX,IAAI,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE;GACpC,IAAI,MAAM,YAAa,GAAG,CAAC,OAAO,EAAE;EACrC;EAEA,IAAI,MAAM,kBAAkB,SAAS,GAAG,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM;EAErE,IAAI,MAAM;GACT,IAAI,MAAM,QAAS,GAAG,KAAK,EAAE;GAC7B,IAAI,MAAM,SAAS,GAAG,KAAK,EAAE;EAC9B;CACD;CAEA,WAAW,KAAK,IAAI;EACnB,OAAO,SAAS,cAAc,KAAK;EACnC,GAAG,MAAM;EACT,OAAO;CACR;CAEA,YAAY,MAAM;EACjB,OAAO,OAAO,mBAAmB,KAAK,KAAK,QAAQ,GAAG,KAAK,eAAe,KAAK,QAAQ,GAAG,KAAK;CAChG;AACD"}
1
+ {"version":3,"file":"Icon.js","names":[],"sources":["../../../../src/layer/marker/Icon.js"],"sourcesContent":["import {Class} from '../../core/Class.js';\nimport {setOptions, toNumber} from '../../core/Util.js';\nimport {Point} from '../../geometry/Point.js';\n\n/** @import {PointExpression} from '../../geometry/Point.js' */\n\n/**\n * Options of `Icon`.\n * @typedef {object} IconOptions\n * @property {string} [iconUrl] **(required)** The URL to the icon image (absolute or\n * relative to your script path).\n * @property {string} [iconRetinaUrl] The URL to a retina sized version of the icon\n * image (absolute or relative to your script path). Used for Retina screen devices.\n * @property {PointExpression|number} [iconSize] Size of the icon image in pixels (a\n * number for square icons).\n * @property {PointExpression} [iconAnchor] The coordinates of the \"tip\" of the icon\n * (relative to its top left corner). The icon will be aligned so that this point is at\n * the marker's geographical location. Centered by default if size is specified, also\n * can be set in CSS with negative margins.\n * @property {PointExpression} [popupAnchor=[0, 0]] The coordinates of the point from\n * which popups will \"open\", relative to the icon anchor.\n * @property {PointExpression} [tooltipAnchor=[0, 0]] The coordinates of the point from\n * which tooltips will \"open\", relative to the icon anchor.\n * @property {string} [shadowUrl] The URL to the icon shadow image. If not specified, no\n * shadow image will be created.\n * @property {string} [shadowRetinaUrl] The URL to a retina sized version of the shadow\n * image. Used for Retina screen devices.\n * @property {PointExpression|number} [shadowSize] Size of the shadow image in pixels.\n * @property {PointExpression} [shadowAnchor] The coordinates of the \"tip\" of the shadow\n * (relative to its top left corner) (the same as iconAnchor if not specified).\n * @property {string} [className] A custom class name to assign to both icon and shadow\n * images. Empty by default.\n * @property {boolean|string} [crossOrigin=false] Whether the crossOrigin attribute will\n * be added to the icon images. If a String is provided, all images will have their\n * crossOrigin attribute set to the String provided. This is needed if you want to\n * access image pixel data. Refer to\n * [CORS Settings](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes)\n * for valid String values.\n */\n\n/**\n * Represents an icon to provide when creating a marker.\n *\n * `DefaultIcon` extends `Icon` and is the blue icon Maplair uses for markers by default.\n *\n * @example\n * ```js\n * const myIcon = new Icon({\n * iconUrl: 'my-icon.png',\n * iconRetinaUrl: 'my-icon@2x.png',\n * iconSize: [38, 95],\n * iconAnchor: [22, 94],\n * popupAnchor: [-3, -76],\n * shadowUrl: 'my-icon-shadow.png',\n * shadowRetinaUrl: 'my-icon-shadow@2x.png',\n * shadowSize: [68, 95],\n * shadowAnchor: [22, 94]\n * });\n *\n * new Marker([50.505, 30.57], {icon: myIcon}).addTo(map);\n * ```\n */\nexport class Icon extends Class {\n\n\tstatic defaultOptions = {\n\t\tpopupAnchor: [0, 0],\n\t\ttooltipAnchor: [0, 0],\n\t\tcrossOrigin: false\n\t};\n\n\t/**\n\t * Creates an icon instance with the given options.\n\t * @param {IconOptions} [options]\n\t */\n\tconstructor(options) {\n\t\tsuper();\n\t\tsetOptions(this, options);\n\n\t\tthis.callInitHooks(Icon);\n\t}\n\n\t/**\n\t * Called internally when the icon has to be shown, returns a `<img>` HTML element\n\t * styled according to the options.\n\t * @param {HTMLElement} [oldIcon] The current element of the icon, to be reused if possible.\n\t * @returns {HTMLElement}\n\t */\n\tcreateIcon(oldIcon) {\n\t\treturn this._createIcon('icon', oldIcon);\n\t}\n\n\t/**\n\t * As `createIcon`, but for the shadow beneath it. Returns `null` without a shadow.\n\t * @param {HTMLElement} [oldIcon] The current element of the shadow, to be reused if possible.\n\t * @returns {HTMLElement|null}\n\t */\n\tcreateShadow(oldIcon) {\n\t\treturn this._createIcon('shadow', oldIcon);\n\t}\n\n\t_createIcon(name, oldIcon) {\n\t\tconst src = this._getIconUrl(name);\n\n\t\tif (!src) {\n\t\t\tif (name === 'icon') {\n\t\t\t\tthrow new Error('iconUrl not set in Icon options (see the docs).');\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\n\t\tconst img = this._createImg(src, oldIcon instanceof HTMLImageElement ? oldIcon : null);\n\t\tthis._setIconStyles(img, name);\n\n\t\tif (this.options.crossOrigin || this.options.crossOrigin === '') {\n\t\t\timg.crossOrigin = this.options.crossOrigin === true ? '' : this.options.crossOrigin;\n\t\t} else {\n\t\t\timg.crossOrigin = null;\n\t\t}\n\n\t\treturn img;\n\t}\n\n\t_setIconStyles(img, name) {\n\t\tconst options = this.options;\n\t\tconst sizeOption = options[`${name}Size`];\n\n\t\t// a side that isn't a number, like 'auto' in [100, 'auto'], is left to CSS\n\t\tconst [width, height] = (typeof sizeOption === 'number' ? [sizeOption, sizeOption] :\n\t\t\tArray.isArray(sizeOption) ? sizeOption : [sizeOption?.x, sizeOption?.y]).map(toNumber);\n\n\t\tconst anchorOption = name === 'shadow' && options.shadowAnchor || options.iconAnchor;\n\t\tconst anchor = Point.validate(anchorOption) ? Point.from(anchorOption) :\n\t\t\t{x: Math.round(width / 2), y: Math.round(height / 2)};\n\n\t\timg.className = `maplair-marker-${name} ${options.className || ''}`;\n\n\t\t// a marker reuses the element of its previous icon, which may have set any of these\n\t\tconst {style} = img;\n\t\tstyle.marginLeft = style.marginTop = style.width = style.height = '';\n\n\t\tif (!isNaN(anchor.x)) { style.marginLeft = `${-anchor.x}px`; }\n\t\tif (!isNaN(anchor.y)) { style.marginTop = `${-anchor.y}px`; }\n\t\t// the origin of the marker rotation: the anchor, which is the top left corner without one\n\t\tstyle.transformOrigin = !isNaN(anchor.x) && !isNaN(anchor.y) ? `${anchor.x}px ${anchor.y}px` : '0 0';\n\n\t\tif (!isNaN(width)) { style.width = `${width}px`; }\n\t\tif (!isNaN(height)) { style.height = `${height}px`; }\n\t}\n\n\t_createImg(src, el) {\n\t\tel ??= document.createElement('img');\n\t\tel.src = src;\n\t\treturn el;\n\t}\n\n\t_getIconUrl(name) {\n\t\treturn window.devicePixelRatio > 1 && this.options[`${name}RetinaUrl`] || this.options[`${name}Url`];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,IAAa,OAAb,MAAa,aAAa,MAAM;CAE/B,OAAO,iBAAiB;EACvB,aAAa,CAAC,GAAG,CAAC;EAClB,eAAe,CAAC,GAAG,CAAC;EACpB,aAAa;CACd;;;;;CAMA,YAAY,SAAS;EACpB,MAAM;EACN,WAAW,MAAM,OAAO;EAExB,KAAK,cAAc,IAAI;CACxB;;;;;;;CAQA,WAAW,SAAS;EACnB,OAAO,KAAK,YAAY,QAAQ,OAAO;CACxC;;;;;;CAOA,aAAa,SAAS;EACrB,OAAO,KAAK,YAAY,UAAU,OAAO;CAC1C;CAEA,YAAY,MAAM,SAAS;EAC1B,MAAM,MAAM,KAAK,YAAY,IAAI;EAEjC,IAAI,CAAC,KAAK;GACT,IAAI,SAAS,QACZ,MAAM,IAAI,MAAM,iDAAiD;GAElE,OAAO;EACR;EAEA,MAAM,MAAM,KAAK,WAAW,KAAK,mBAAmB,mBAAmB,UAAU,IAAI;EACrF,KAAK,eAAe,KAAK,IAAI;EAE7B,IAAI,KAAK,QAAQ,eAAe,KAAK,QAAQ,gBAAgB,IAC5D,IAAI,cAAc,KAAK,QAAQ,gBAAgB,O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GAAG,KAAK;CAChG;AACD"}
@@ -1,7 +1,6 @@
1
1
  import { Point } from "../../geometry/Point.js";
2
2
  import { off, on } from "../../dom/DomEvent.js";
3
3
  import { getPosition, setPosition } from "../../dom/DomUtil.js";
4
- import { Bounds } from "../../geometry/Bounds.js";
5
4
  import { Handler } from "../../core/Handler.js";
6
5
  import { Draggable } from "../../dom/Draggable.js";
7
6
  // src/layer/marker/Marker.Drag.js
@@ -73,10 +72,10 @@ var MarkerDrag = class MarkerDrag extends Handler {
73
72
  return this._draggable?._moved;
74
73
  }
75
74
  _adjustPan(e) {
76
- const marker = this._marker, map = marker._map, speed = this._marker.options.autoPanSpeed, padding = this._marker.options.autoPanPadding, iconPos = getPosition(marker._icon), bounds = map.getPixelBounds(), origin = map.getPixelOrigin();
77
- const panBounds = new Bounds(bounds.min._subtract(origin).add(padding), bounds.max._subtract(origin).subtract(padding));
78
- if (!panBounds.contains(iconPos)) {
79
- const movement = new Point((Math.max(panBounds.max.x, iconPos.x) - panBounds.max.x) / (bounds.max.x - panBounds.max.x) - (Math.min(panBounds.min.x, iconPos.x) - panBounds.min.x) / (bounds.min.x - panBounds.min.x), (Math.max(panBounds.max.y, iconPos.y) - panBounds.max.y) / (bounds.max.y - panBounds.max.y) - (Math.min(panBounds.min.y, iconPos.y) - panBounds.min.y) / (bounds.min.y - panBounds.min.y)).multiplyBy(speed);
75
+ const marker = this._marker, map = marker._map, speed = this._marker.options.autoPanSpeed, padding = new Point(this._marker.options.autoPanPadding), iconPos = getPosition(marker._icon), bounds = map.getPixelBounds(), origin = map.getPixelOrigin(), min = bounds.min._subtract(origin)._add(padding), max = bounds.max._subtract(origin)._subtract(padding), dx = Math.max(iconPos.x - max.x, 0) + Math.min(iconPos.x - min.x, 0), dy = Math.max(iconPos.y - max.y, 0) + Math.min(iconPos.y - min.y, 0);
76
+ if (dx || dy) {
77
+ const movement = map._limitOffset(new Point(dx / padding.x * speed, dy / padding.y * speed), map.options.maxBounds)._round();
78
+ if (!movement.x && !movement.y) return;
80
79
  map.panBy(movement, { animate: false });
81
80
  this._draggable._newPos._add(movement);
82
81
  this._draggable._startPos._add(movement);
@@ -97,7 +96,8 @@ var MarkerDrag = class MarkerDrag extends Handler {
97
96
  }
98
97
  }
99
98
  _onDrag(e) {
100
- const marker = this._marker, iconPos = getPosition(marker._icon), latlng = marker._map.layerPointToLatLng(iconPos);
99
+ const marker = this._marker, iconPos = getPosition(marker._icon), latlng = marker._map.layerPointToLatLng(iconPos), { alt } = this._oldLatLng;
100
+ if (alt !== void 0) latlng.alt = alt;
101
101
  marker._positionElements(iconPos);
102
102
  marker._latlng = latlng;
103
103
  e.latlng = latlng;
@@ -106,7 +106,6 @@ var MarkerDrag = class MarkerDrag extends Handler {
106
106
  }
107
107
  _onDragEnd(e) {
108
108
  cancelAnimationFrame(this._panRequest);
109
- delete this._oldLatLng;
110
109
  this._marker.fire("moveend").fire("dragend", e);
111
110
  }
112
111
  /** @param {KeyboardEvent|FocusEvent} e */
@@ -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 DomEvent from '../../dom/DomEvent.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/** @type {Record<string, [number, number]>} */\nconst arrows = {ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1]};\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\tDomEvent.on(icon, 'keydown keyup blur', this._onKey, this);\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._keyOffset = null; // disabling the Draggable below ends a keyboard drag in progress, as it does a pointer drag\n\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\tDomEvent.off(this._draggable._element, 'keydown keyup blur', this._onKey, this);\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\ticonPos = DomUtil.getPosition(marker._icon),\n\t\tlatlng = marker._map.layerPointToLatLng(iconPos);\n\n\t\t// Draggable only moved the icon and dropped its rotation\n\t\tmarker._positionElements(iconPos);\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\t// Arrow keys move a focused marker. Holding a key down is one drag, driven through the Draggable like a pointer\n\t// drag (so the two can't overlap), and ends on keyup or blur.\n\t/** @param {KeyboardEvent|FocusEvent} e */\n\t_onKey(e) {\n\t\tconst k = /** @type {KeyboardEvent} */ (e), // all but blur\n\t\tdir = arrows[k.key],\n\t\tdraggable = this._draggable,\n\t\t{options, _map: map} = this._marker;\n\n\t\tif (e.type !== 'keydown') {\n\t\t\tif (this._keyOffset) {\n\t\t\t\tthis._keyOffset = null;\n\t\t\t\tdraggable.finishDrag();\n\t\t\t}\n\n\t\t} else if (dir && k.target === draggable._element && !(k.altKey || k.ctrlKey || k.metaKey)) {\n\t\t\te.preventDefault(); // don't scroll the page\n\n\t\t\tif (!this._keyOffset) {\n\t\t\t\tif (Draggable._dragging) { return; }\n\t\t\t\tDraggable._dragging = draggable;\n\t\t\t\tdraggable._startPos = DomUtil.getPosition(draggable._element);\n\t\t\t\tdraggable._moved = draggable._moving = true;\n\t\t\t\tthis._keyOffset = new Point(0, 0);\n\t\t\t\tdraggable.fire('dragstart');\n\t\t\t}\n\n\t\t\t// in container pixels, which the map rotation (if any) turns to the frame of the rotated pane\n\t\t\tconst offset = new Point(...dir).multiplyBy(k.shiftKey ? 30 : 10);\n\t\t\tthis._keyOffset = this._keyOffset.add(map._rotateToPane?.(offset) ?? offset);\n\t\t\t// not through _updatePosition, whose predrag would start the pointer autoPan loop\n\t\t\tdraggable._newPos = draggable._startPos.add(this._keyOffset);\n\t\t\tDomUtil.setPosition(draggable._element, draggable._newPos);\n\t\t\tdraggable.fire('drag', {originalEvent: k});\n\n\t\t\tif (options.autoPan) {\n\t\t\t\tmap.panInside(this._marker._latlng, {padding: options.autoPanPadding, animate: false});\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAM,SAAS;CAAC,WAAW,CAAC,IAAI,CAAC;CAAG,YAAY,CAAC,GAAG,CAAC;CAAG,SAAS,CAAC,GAAG,EAAE;CAAG,WAAW,CAAC,GAAG,CAAC;AAAC;;;;;;;;;;;;;AAc3F,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,GAAY,MAAM,sBAAsB,KAAK,QAAQ,IAAI;EAEzD,KAAK,UAAU,IAAI,0BAA0B;CAC9C;;;;CAKA,cAAc;EACb,KAAK,aAAa;EAElB,KAAK,WAAW,IAAI;GACnB,WAAW,KAAK;GAChB,SAAS,KAAK;GACd,MAAM,KAAK;GACX,SAAS,KAAK;EACf,GAAG,IAAI,CAAC,CAAC,QAAQ;EAEjB,IAAa,KAAK,WAAW,UAAU,sBAAsB,KAAK,QAAQ,IAAI;EAE9E,KAAK,QAAQ,OAAO,UAAU,OAAO,0BAA0B;CAChE;;;;;CAMA,QAAQ;EACP,OAAO,KAAK,YAAY;CACzB;CAEA,WAAW,GAAG;EACb,MAAM,SAAS,KAAK,SACpB,MAAM,OAAO,MACb,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IAAI,KAAK,UAAU;GAC3D,YAAoB,UAAU,UAAU,UAAU,OAAO;GACzD,UAAU,KAAK,QAAQ,EAAC,eAAe,EAAC,CAAC;GAEzC,IAAI,QAAQ,SACX,IAAI,UAAU,KAAK,QAAQ,SAAS;IAAC,SAAS,QAAQ;IAAgB,SAAS;GAAK,CAAC;EAEvF;CACD;AACD"}
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 DomEvent from '../../dom/DomEvent.js';\nimport * as DomUtil from '../../dom/DomUtil.js';\nimport {Draggable} from '../../dom/Draggable.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/** @type {Record<string, [number, number]>} */\nconst arrows = {ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1]};\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\tDomEvent.on(icon, 'keydown keyup blur', this._onKey, this);\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._keyOffset = null; // disabling the Draggable below ends a keyboard drag in progress, as it does a pointer drag\n\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\tDomEvent.off(this._draggable._element, 'keydown keyup blur', this._onKey, this);\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 = new Point(this._marker.options.autoPanPadding),\n\t\ticonPos = DomUtil.getPosition(marker._icon),\n\t\tbounds = map.getPixelBounds(),\n\t\torigin = map.getPixelOrigin(),\n\t\tmin = bounds.min._subtract(origin)._add(padding),\n\t\tmax = bounds.max._subtract(origin)._subtract(padding),\n\t\t// how far the icon is past the padded bounds on each axis (0 if within)\n\t\tdx = Math.max(iconPos.x - max.x, 0) + Math.min(iconPos.x - min.x, 0),\n\t\tdy = Math.max(iconPos.y - max.y, 0) + Math.min(iconPos.y - min.y, 0);\n\n\t\tif (dx || dy) {\n\t\t\t// pan faster the deeper the icon goes into the padding, but not past maxBounds\n\t\t\tconst movement = map._limitOffset(new Point(dx / padding.x * speed, dy / padding.y * speed),\n\t\t\t\tmap.options.maxBounds)._round();\n\n\t\t\tif (!movement.x && !movement.y) { return; }\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\ticonPos = DomUtil.getPosition(marker._icon),\n\t\tlatlng = marker._map.layerPointToLatLng(iconPos),\n\t\t{alt} = this._oldLatLng;\n\n\t\tif (alt !== undefined) { latlng.alt = alt; }\n\n\t\t// Draggable only moved the icon and dropped its rotation\n\t\tmarker._positionElements(iconPos);\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\tthis._marker\n\t\t\t.fire('moveend')\n\t\t\t.fire('dragend', e);\n\t}\n\n\t// Arrow keys move a focused marker. Holding a key down is one drag, driven through the Draggable like a pointer\n\t// drag (so the two can't overlap), and ends on keyup or blur.\n\t/** @param {KeyboardEvent|FocusEvent} e */\n\t_onKey(e) {\n\t\tconst k = /** @type {KeyboardEvent} */ (e), // all but blur\n\t\tdir = arrows[k.key],\n\t\tdraggable = this._draggable,\n\t\t{options, _map: map} = this._marker;\n\n\t\tif (e.type !== 'keydown') {\n\t\t\tif (this._keyOffset) {\n\t\t\t\tthis._keyOffset = null;\n\t\t\t\tdraggable.finishDrag();\n\t\t\t}\n\n\t\t} else if (dir && k.target === draggable._element && !(k.altKey || k.ctrlKey || k.metaKey)) {\n\t\t\te.preventDefault(); // don't scroll the page\n\n\t\t\tif (!this._keyOffset) {\n\t\t\t\tif (Draggable._dragging) { return; }\n\t\t\t\tDraggable._dragging = draggable;\n\t\t\t\tdraggable._startPos = DomUtil.getPosition(draggable._element);\n\t\t\t\tdraggable._moved = draggable._moving = true;\n\t\t\t\tthis._keyOffset = new Point(0, 0);\n\t\t\t\tdraggable.fire('dragstart');\n\t\t\t}\n\n\t\t\t// in container pixels, which the map rotation (if any) turns to the frame of the rotated pane\n\t\t\tconst offset = new Point(...dir).multiplyBy(k.shiftKey ? 30 : 10);\n\t\t\tthis._keyOffset = this._keyOffset.add(map._rotateToPane?.(offset) ?? offset);\n\t\t\t// not through _updatePosition, whose predrag would start the pointer autoPan loop\n\t\t\tdraggable._newPos = draggable._startPos.add(this._keyOffset);\n\t\t\tDomUtil.setPosition(draggable._element, draggable._newPos);\n\t\t\tdraggable.fire('drag', {originalEvent: k});\n\n\t\t\tif (options.autoPan) {\n\t\t\t\tmap.panInside(this._marker._latlng, {padding: options.autoPanPadding, animate: false});\n\t\t\t}\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;AAUA,MAAM,SAAS;CAAC,WAAW,CAAC,IAAI,CAAC;CAAG,YAAY,CAAC,GAAG,CAAC;CAAG,SAAS,CAAC,GAAG,EAAE;CAAG,WAAW,CAAC,GAAG,CAAC;AAAC;;;;;;;;;;;;;AAc3F,IAAa,aAAb,MAAa,mBAAmB,QAAQ;;;;;CAKvC,YAAY,QAAQ;EACnB,MAAM,OAAO,IAAI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ACpB;;CAKA,OAAO,GAAG;EACT,MAAM,IAAkC,GACxC,MAAM,OAAO,EAAE,MACf,YAAY,KAAK,YACjB,EAAC,SAAS,MAAM,QAAO,KAAK;EAE5B,IAAI,EAAE,SAAS,WACV;OAAA,KAAK,YAAY;IACpB,KAAK,aAAa;IAClB,UAAU,WAAW;GACtB;SAEM,IAAI,OAAO,EAAE,WAAW,UAAU,YAAY,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU;GAC3F,EAAE,eAAe;GAEjB,IAAI,CAAC,KAAK,YAAY;IACrB,IAAI,UAAU,WAAa;IAC3B,UAAU,YAAY;IACtB,UAAU,YAAYA,YAAoB,UAAU,QAAQ;IAC5D,UAAU,SAAS,UAAU,UAAU;IACvC,KAAK,aAAa,IAAI,MAAM,GAAG,CAAC;IAChC,UAAU,KAAK,WAAW;GAC3B;GAGA,MAAM,SAAS,IAAI,MAAM,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,KAAK,EAAE;GAChE,KAAK,aAAa,KAAK,WAAW,IAAI,IAAI,gBAAgB,MAAM,KAAK,MAAM;GAE3E,UAAU,UAAU,UAAU,UAAU,IAAI,KAAK,UAAU;GAC3D,YAAoB,UAAU,UAAU,UAAU,OAAO;GACzD,UAAU,KAAK,QAAQ,EAAC,eAAe,EAAC,CAAC;GAEzC,IAAI,QAAQ,SACX,IAAI,UAAU,KAAK,QAAQ,SAAS;IAAC,SAAS,QAAQ;IAAgB,SAAS;GAAK,CAAC;EAEvF;CACD;AACD"}
@@ -2,6 +2,7 @@ import { setOptions } from "../../core/Util.js";
2
2
  import { Point } from "../../geometry/Point.js";
3
3
  import { off, on } from "../../dom/DomEvent.js";
4
4
  import { getPosition, setPosition } from "../../dom/DomUtil.js";
5
+ import { I18n } from "../../core/I18n.js";
5
6
  import { Layer } from "../Layer.js";
6
7
  import { LatLng } from "../../geo/LatLng.js";
7
8
  import { pointToGeoJSON } from "../GeoJSONUtil.js";
@@ -26,7 +27,8 @@ import { MarkerDrag } from "./Marker.Drag.js";
26
27
  * @property {string} [title=''] Text for the browser tooltip that appear on marker hover
27
28
  * (no tooltip by default).
28
29
  * [Useful for accessibility](https://maplair.org/examples/accessibility/#markers-must-be-labelled).
29
- * @property {string} [alt='Marker'] Text for the `alt` attribute of the icon image.
30
+ * @property {string} [alt] Text for the `alt` attribute of the icon image, the
31
+ * translation of `'Marker'` by default.
30
32
  * [Useful for accessibility](https://maplair.org/examples/accessibility/#markers-must-be-labelled).
31
33
  * @property {number} [zIndexOffset=0] By default, marker images zIndex is set
32
34
  * automatically based on its latitude. Use this option if you want to put the marker on
@@ -38,9 +40,9 @@ import { MarkerDrag } from "./Marker.Drag.js";
38
40
  * marker, even at 0°, has no shadow, since the shadow of an upright pin looks wrong
39
41
  * under a tilted one. `null` means no rotation.
40
42
  * @property {boolean} [riseOnHover=false] If `true`, the marker will get on top of
41
- * others when you hover the pointer over it.
42
- * @property {number} [riseOffset=250] The z-index offset used for the `riseOnHover`
43
- * feature.
43
+ * others while the pointer is over it. It always does while it has focus.
44
+ * @property {number} [riseOffset=250] The z-index offset used when the marker gets on
45
+ * top of others on hover or focus.
44
46
  * @property {string} [pane='markerPane'] `Map pane` where the markers icon will be added.
45
47
  * @property {string} [shadowPane='shadowPane'] `Map pane` where the markers shadow will
46
48
  * be added.
@@ -93,7 +95,7 @@ var Marker = class Marker extends Layer {
93
95
  interactive: true,
94
96
  keyboard: true,
95
97
  title: "",
96
- alt: "Marker",
98
+ alt: void 0,
97
99
  zIndexOffset: 0,
98
100
  opacity: 1,
99
101
  rotation: null,
@@ -237,7 +239,7 @@ var Marker = class Marker extends Layer {
237
239
  if (this._icon) this._removeIcon();
238
240
  addIcon = true;
239
241
  if (options.title) icon.title = options.title;
240
- if (icon instanceof HTMLImageElement) icon.alt = options.alt ?? "";
242
+ if (icon instanceof HTMLImageElement) icon.alt = options.alt ?? I18n.translate("Marker");
241
243
  }
242
244
  icon.classList.add(classToAdd);
243
245
  if (options.keyboard) {
@@ -246,10 +248,9 @@ var Marker = class Marker extends Layer {
246
248
  on(icon, "keydown", this._onKeyDown, this);
247
249
  }
248
250
  this._icon = icon;
249
- if (options.riseOnHover) this.on({
250
- pointerover: this._bringToFront,
251
- pointerout: this._resetZIndex
252
- });
251
+ if (this._popup?._source === this) this._popup._updateSourceAria(this._popup.isOpen());
252
+ on(icon, "focusin focusout", this._updateRise, this);
253
+ if (options.riseOnHover) on(icon, "pointerover pointerout", this._updateRise, this);
253
254
  if (this.options.autoPanOnFocus) on(icon, "focus", this._panOnFocus, this);
254
255
  const newShadow = options.shadow ? options.icon.createShadow?.(this._shadow) ?? null : null;
255
256
  let addShadow = false;
@@ -263,15 +264,13 @@ var Marker = class Marker extends Layer {
263
264
  }
264
265
  this._shadow = newShadow;
265
266
  if (options.opacity < 1) this._updateOpacity();
266
- if (addIcon) this.getPane().appendChild(this._icon);
267
+ if (addIcon) this.getPane().append(this._icon);
267
268
  this._initInteraction();
268
- if (newShadow && addShadow) this.getPane(options.shadowPane).appendChild(this._shadow);
269
+ if (newShadow && addShadow) this.getPane(options.shadowPane).append(this._shadow);
269
270
  }
270
271
  _removeIcon() {
271
- if (this.options.riseOnHover) this.off({
272
- pointerover: this._bringToFront,
273
- pointerout: this._resetZIndex
274
- });
272
+ off(this._icon, "pointerover pointerout focusin focusout", this._updateRise, this);
273
+ this._hovered = this._focused = false;
275
274
  if (this.options.autoPanOnFocus) off(this._icon, "focus", this._panOnFocus, this);
276
275
  off(this._icon, "keydown", this._onKeyDown, this);
277
276
  this._icon.remove();
@@ -284,8 +283,8 @@ var Marker = class Marker extends Layer {
284
283
  if (visible === !this._culled) return;
285
284
  this._culled = !visible;
286
285
  if (visible) {
287
- this.getPane().appendChild(this._icon);
288
- if (this._shadow) this.getPane(this.options.shadowPane).appendChild(this._shadow);
286
+ this.getPane().append(this._icon);
287
+ if (this._shadow) this.getPane(this.options.shadowPane).append(this._shadow);
289
288
  this.update();
290
289
  } else {
291
290
  this._icon.remove();
@@ -299,7 +298,7 @@ var Marker = class Marker extends Layer {
299
298
  _setPos(pos) {
300
299
  this._positionElements(pos);
301
300
  this._zIndex = pos.y + this.options.zIndexOffset;
302
- this._resetZIndex();
301
+ this._updateRise();
303
302
  }
304
303
  _positionElements(pos) {
305
304
  const rotation = this.options.rotation;
@@ -341,33 +340,31 @@ var Marker = class Marker extends Layer {
341
340
  if (!this.options.interactive) return;
342
341
  this._icon.classList.add("maplair-interactive");
343
342
  this.addInteractiveTarget(this._icon);
344
- if (MarkerDrag) {
345
- if (this.dragging?._draggable?._element === this._icon) {
346
- this._icon.classList.toggle("maplair-marker-draggable", this.dragging.enabled());
347
- return;
348
- }
349
- let draggable = this.options.draggable;
350
- if (this.dragging) {
351
- draggable = this.dragging.enabled();
352
- this.dragging.disable();
353
- }
354
- /**
355
- * Marker dragging handler, see `Handler`. Only valid when the marker is on the
356
- * map (otherwise set [`marker.options.draggable`](#markeroptions-draggable)).
357
- *
358
- * Interaction handlers are properties of a marker instance that allow you to
359
- * control interaction behavior in runtime, enabling or disabling certain
360
- * features such as dragging (see `Handler` methods). Example:
361
- *
362
- * ```js
363
- * marker.dragging.disable();
364
- * ```
365
- * @group Interaction handlers
366
- * @type {MarkerDrag}
367
- */
368
- this.dragging = new MarkerDrag(this);
369
- if (draggable) this.dragging.enable();
343
+ if (this.dragging?._draggable?._element === this._icon) {
344
+ this._icon.classList.toggle("maplair-marker-draggable", this.dragging.enabled());
345
+ return;
370
346
  }
347
+ let draggable = this.options.draggable;
348
+ if (this.dragging) {
349
+ draggable = this.dragging.enabled();
350
+ this.dragging.disable();
351
+ }
352
+ /**
353
+ * Marker dragging handler, see `Handler`. Only valid when the marker is on the
354
+ * map (otherwise set [`marker.options.draggable`](#markeroptions-draggable)).
355
+ *
356
+ * Interaction handlers are properties of a marker instance that allow you to
357
+ * control interaction behavior in runtime, enabling or disabling certain
358
+ * features such as dragging (see `Handler` methods). Example:
359
+ *
360
+ * ```js
361
+ * marker.dragging.disable();
362
+ * ```
363
+ * @group Interaction handlers
364
+ * @type {MarkerDrag}
365
+ */
366
+ this.dragging = new MarkerDrag(this);
367
+ if (draggable) this.dragging.enable();
371
368
  }
372
369
  /**
373
370
  * Returns the current [rotation](#markeroptions-rotation) of the marker in degrees.
@@ -401,9 +398,13 @@ var Marker = class Marker extends Layer {
401
398
  return this;
402
399
  }
403
400
  _updateOpacity() {
404
- const opacity = this.options.opacity;
405
- if (this._icon) this._icon.style.opacity = `${opacity}`;
406
- if (this._shadow) this._shadow.style.opacity = `${opacity}`;
401
+ for (const el of [this._icon, this._shadow]) if (el) el.style.opacity = `${this.options.opacity}`;
402
+ }
403
+ _updateRise(e) {
404
+ if (e?.type.startsWith("pointer")) this._hovered = e.type === "pointerover";
405
+ else if (e) this._focused = e.type === "focusin";
406
+ if (this._hovered || this._focused) this._bringToFront();
407
+ else this._resetZIndex();
407
408
  }
408
409
  _bringToFront() {
409
410
  this._updateZIndex(this.options.riseOffset);