maplair 4.1.0 → 4.2.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 (211) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/esm/Maplair.js +5 -4
  3. package/dist/esm/Maplair.js.map +1 -1
  4. package/dist/esm/_virtual/_rolldown/runtime.js +1 -2
  5. package/dist/esm/control/AttributionControl.js +1 -2
  6. package/dist/esm/control/ButtonControl.js +1 -2
  7. package/dist/esm/control/ContextMenu.js +1 -2
  8. package/dist/esm/control/Control.js +1 -2
  9. package/dist/esm/control/FullscreenControl.js +1 -2
  10. package/dist/esm/control/LayersControl.js +27 -31
  11. package/dist/esm/control/LayersControl.js.map +1 -1
  12. package/dist/esm/control/LegendControl.js +1 -2
  13. package/dist/esm/control/MiniMapControl.js +1 -2
  14. package/dist/esm/control/RotateControl.js +1 -2
  15. package/dist/esm/control/ScaleControl.js +1 -2
  16. package/dist/esm/control/SearchControl.js +1 -2
  17. package/dist/esm/control/SideBySideControl.js +1 -2
  18. package/dist/esm/control/TextControl.js +1 -2
  19. package/dist/esm/control/TimeControl.js +1 -2
  20. package/dist/esm/control/ZoomControl.js +18 -29
  21. package/dist/esm/control/ZoomControl.js.map +1 -1
  22. package/dist/esm/core/Class.js +2 -9
  23. package/dist/esm/core/Class.js.map +1 -1
  24. package/dist/esm/core/Events.js +1 -2
  25. package/dist/esm/core/Handler.js +10 -3
  26. package/dist/esm/core/Handler.js.map +1 -1
  27. package/dist/esm/core/I18n.js +1 -2
  28. package/dist/esm/core/Util.js +2 -3
  29. package/dist/esm/core/Util.js.map +1 -1
  30. package/dist/esm/dom/DomEvent.DoubleTap.js +1 -2
  31. package/dist/esm/dom/DomEvent.PointerEvents.js +1 -2
  32. package/dist/esm/dom/DomEvent.js +10 -18
  33. package/dist/esm/dom/DomEvent.js.map +1 -1
  34. package/dist/esm/dom/DomUtil.js +1 -2
  35. package/dist/esm/dom/Draggable.js +4 -3
  36. package/dist/esm/dom/Draggable.js.map +1 -1
  37. package/dist/esm/dom/PosAnimation.js +1 -2
  38. package/dist/esm/geo/LatLng.js +1 -2
  39. package/dist/esm/geo/LatLngBounds.js +9 -15
  40. package/dist/esm/geo/LatLngBounds.js.map +1 -1
  41. package/dist/esm/geo/crs/CRS.js +1 -2
  42. package/dist/esm/geo/crs/EPSG3395.js +4 -5
  43. package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
  44. package/dist/esm/geo/crs/EPSG3857.js +4 -5
  45. package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
  46. package/dist/esm/geo/crs/EPSG4326.js +3 -4
  47. package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
  48. package/dist/esm/geo/crs/EarthCRS.js +1 -2
  49. package/dist/esm/geo/crs/SimpleCRS.js +3 -4
  50. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
  51. package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +4 -5
  52. package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
  53. package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +3 -4
  54. package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
  55. package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +4 -5
  56. package/dist/esm/geo/projection/SphericalMercatorProjection.js.map +1 -0
  57. package/dist/esm/geometry/Bounds.js +10 -14
  58. package/dist/esm/geometry/Bounds.js.map +1 -1
  59. package/dist/esm/geometry/LineUtil.js +2 -3
  60. package/dist/esm/geometry/LineUtil.js.map +1 -1
  61. package/dist/esm/geometry/Point.js +1 -2
  62. package/dist/esm/geometry/PolyUtil.js +17 -25
  63. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  64. package/dist/esm/geometry/Transformation.js +1 -2
  65. package/dist/esm/layer/BlanketOverlay.js +1 -2
  66. package/dist/esm/layer/Classification.js +1 -2
  67. package/dist/esm/layer/DivOverlay.js +2 -3
  68. package/dist/esm/layer/DivOverlay.js.map +1 -1
  69. package/dist/esm/layer/FeatureGroup.js +5 -4
  70. package/dist/esm/layer/FeatureGroup.js.map +1 -1
  71. package/dist/esm/layer/GeoJSON.Load.js +1 -2
  72. package/dist/esm/layer/GeoJSON.js +8 -10
  73. package/dist/esm/layer/GeoJSON.js.map +1 -1
  74. package/dist/esm/layer/GeoJSONUtil.js +1 -2
  75. package/dist/esm/layer/HeatLayer.js +2 -3
  76. package/dist/esm/layer/HeatLayer.js.map +1 -1
  77. package/dist/esm/layer/ImageOverlay.js +2 -3
  78. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  79. package/dist/esm/layer/Layer.js +1 -2
  80. package/dist/esm/layer/LayerGroup.js +2 -3
  81. package/dist/esm/layer/LayerGroup.js.map +1 -1
  82. package/dist/esm/layer/Popup.js +9 -16
  83. package/dist/esm/layer/Popup.js.map +1 -1
  84. package/dist/esm/layer/SVGOverlay.js +1 -2
  85. package/dist/esm/layer/Tooltip.js +16 -17
  86. package/dist/esm/layer/Tooltip.js.map +1 -1
  87. package/dist/esm/layer/VideoOverlay.js +1 -2
  88. package/dist/esm/layer/marker/DefaultIcon.js +29 -7
  89. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
  90. package/dist/esm/layer/marker/DivIcon.js +1 -2
  91. package/dist/esm/layer/marker/Icon.js +2 -2
  92. package/dist/esm/layer/marker/Icon.js.map +1 -1
  93. package/dist/esm/layer/marker/Marker.Drag.js +43 -4
  94. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  95. package/dist/esm/layer/marker/Marker.Move.js +4 -6
  96. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  97. package/dist/esm/layer/marker/Marker.js +54 -14
  98. package/dist/esm/layer/marker/Marker.js.map +1 -1
  99. package/dist/esm/layer/marker/MarkerClusterGroup.js +1 -2
  100. package/dist/esm/layer/marker/SvgIcon.js +1 -2
  101. package/dist/esm/layer/tile/GridLayer.js +4 -4
  102. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  103. package/dist/esm/layer/tile/TileLayer.js +8 -8
  104. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  105. package/dist/esm/layer/tile/WMSTileLayer.js +5 -4
  106. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
  107. package/dist/esm/layer/vector/Canvas.js +7 -14
  108. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  109. package/dist/esm/layer/vector/Circle.js +4 -3
  110. package/dist/esm/layer/vector/Circle.js.map +1 -1
  111. package/dist/esm/layer/vector/CircleMarker.js +2 -3
  112. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  113. package/dist/esm/layer/vector/Path.DashAnimation.js +1 -2
  114. package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
  115. package/dist/esm/layer/vector/Path.js +1 -2
  116. package/dist/esm/layer/vector/Polygon.js +2 -3
  117. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  118. package/dist/esm/layer/vector/Polyline.Decorations.js +1 -2
  119. package/dist/esm/layer/vector/Polyline.js +2 -3
  120. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  121. package/dist/esm/layer/vector/Rectangle.js +1 -2
  122. package/dist/esm/layer/vector/Renderer.getRenderer.js +4 -5
  123. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  124. package/dist/esm/layer/vector/Renderer.js +1 -2
  125. package/dist/esm/layer/vector/SVG.js +7 -4
  126. package/dist/esm/layer/vector/SVG.js.map +1 -1
  127. package/dist/esm/map/Hash.js +1 -2
  128. package/dist/esm/map/Map.Rotation.js +31 -16
  129. package/dist/esm/map/Map.Rotation.js.map +1 -1
  130. package/dist/esm/map/Map.js +10 -17
  131. package/dist/esm/map/Map.js.map +1 -1
  132. package/dist/esm/map/MapSync.js +1 -2
  133. package/dist/esm/map/handler/BoxZoomHandler.js +20 -40
  134. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  135. package/dist/esm/map/handler/DisplaceHandler.js +1 -2
  136. package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
  137. package/dist/esm/map/handler/DragHandler.js +1 -2
  138. package/dist/esm/map/handler/KeyboardHandler.js +23 -43
  139. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  140. package/dist/esm/map/handler/PinchZoomHandler.js +1 -2
  141. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +1 -2
  142. package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
  143. package/dist/esm/map/handler/TapHoldHandler.js +1 -2
  144. package/dist/esm/package.js +2 -3
  145. package/dist/maplair-global-src.js +487 -613
  146. package/dist/maplair-global-src.js.map +1 -1
  147. package/dist/maplair-global.js +2 -2
  148. package/dist/maplair-global.js.map +1 -1
  149. package/dist/maplair-src.js +483 -609
  150. package/dist/maplair-src.js.map +1 -1
  151. package/dist/maplair.css +1 -1263
  152. package/dist/maplair.js +2 -2
  153. package/dist/maplair.js.map +1 -1
  154. package/package.json +3 -8
  155. package/src/Maplair.all.js +0 -1
  156. package/src/control/LayersControl.js +39 -52
  157. package/src/control/ZoomControl.js +17 -31
  158. package/src/core/Class.js +5 -14
  159. package/src/core/Handler.js +11 -1
  160. package/src/core/Util.js +1 -1
  161. package/src/dom/DomEvent.js +9 -19
  162. package/src/dom/Draggable.js +5 -1
  163. package/src/geo/LatLngBounds.js +8 -15
  164. package/src/geo/crs/EPSG3395.js +3 -3
  165. package/src/geo/crs/EPSG3857.js +3 -3
  166. package/src/geo/crs/EPSG4326.js +2 -2
  167. package/src/geo/crs/SimpleCRS.js +2 -2
  168. package/src/geo/index.js +1 -2
  169. package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +1 -1
  170. package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +1 -1
  171. package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +1 -1
  172. package/src/geo/projection/index.js +5 -5
  173. package/src/geometry/Bounds.js +12 -17
  174. package/src/geometry/LineUtil.js +1 -1
  175. package/src/geometry/PolyUtil.js +23 -31
  176. package/src/layer/DivOverlay.js +1 -1
  177. package/src/layer/FeatureGroup.js +8 -2
  178. package/src/layer/GeoJSON.js +10 -13
  179. package/src/layer/HeatLayer.js +1 -1
  180. package/src/layer/ImageOverlay.js +2 -2
  181. package/src/layer/LayerGroup.js +1 -1
  182. package/src/layer/Popup.js +9 -19
  183. package/src/layer/Tooltip.js +19 -17
  184. package/src/layer/marker/DefaultIcon.js +33 -5
  185. package/src/layer/marker/Icon.js +2 -0
  186. package/src/layer/marker/Marker.Drag.js +53 -5
  187. package/src/layer/marker/Marker.Move.js +3 -4
  188. package/src/layer/marker/Marker.js +64 -13
  189. package/src/layer/tile/GridLayer.js +5 -2
  190. package/src/layer/tile/TileLayer.js +9 -6
  191. package/src/layer/tile/WMSTileLayer.js +5 -2
  192. package/src/layer/vector/Canvas.js +10 -14
  193. package/src/layer/vector/Circle.js +4 -1
  194. package/src/layer/vector/CircleMarker.js +2 -1
  195. package/src/layer/vector/Polygon.js +1 -1
  196. package/src/layer/vector/Polyline.js +1 -1
  197. package/src/layer/vector/Renderer.getRenderer.js +4 -3
  198. package/src/layer/vector/SVG.js +12 -2
  199. package/src/map/Map.Rotation.js +28 -4
  200. package/src/map/Map.js +17 -21
  201. package/src/map/handler/BoxZoomHandler.js +21 -42
  202. package/src/map/handler/KeyboardHandler.js +34 -53
  203. package/src/maplair.css +5 -0
  204. package/dist/esm/geo/projection/Projection.LonLat.js.map +0 -1
  205. package/dist/esm/geo/projection/Projection.Mercator.js.map +0 -1
  206. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +0 -1
  207. package/dist/esm/geo/projection/index.js +0 -14
  208. package/dist/esm/geo/projection/index.js.map +0 -1
  209. package/dist/esm/layer/marker/Marker.Rotation.js +0 -70
  210. package/dist/esm/layer/marker/Marker.Rotation.js.map +0 -1
  211. package/src/layer/marker/Marker.Rotation.js +0 -103
@@ -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\n\t\tif (this._tooltip && this.isTooltipOpen()) {\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, this._tooltip, 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\tif (!remove && this._tooltipHandlersAdded) { return; }\n\t\tconst onOff = remove ? 'off' : 'on',\n\t\tevents = {\n\t\t\tremove: this.closeTooltip,\n\t\t\tmove: this._moveTooltip\n\t\t};\n\t\tif (!this._tooltip.options.permanent) {\n\t\t\tevents.pointerover = this._openTooltip;\n\t\t\tevents.pointerout = this.closeTooltip;\n\t\t\tevents.click = this._openTooltip;\n\t\t\tif (this._map) {\n\t\t\t\tthis._addFocusListeners(remove);\n\t\t\t} else {\n\t\t\t\tevents.add = () => this._addFocusListeners(remove);\n\t\t\t}\n\t\t} else {\n\t\t\tevents.add = this._openTooltip;\n\t\t}\n\t\tif (this._tooltip.options.sticky) {\n\t\t\tevents.pointermove = this._moveTooltip;\n\t\t}\n\t\tthis[onOff](events);\n\t\tthis._tooltipHandlersAdded = !remove;\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_addFocusListeners(remove) {\n\t\tif (this.getElement) {\n\t\t\tthis._addFocusListenersOnLayer(this, remove);\n\t\t} else if (this.eachLayer) {\n\t\t\tthis.eachLayer(layer => this._addFocusListenersOnLayer(layer, remove), 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);\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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AAM,aAAa,WAAW;EAClD,OAAO;GAAC,KAAK,IAAI,IAAI,OAAO;GAAG,KAAK,IAAI,SAAS,OAAO;EAAC;CAC1D;CAEA,kBAAkB;EACjB,MAAM,MAAM,KAAK,KAAK,mBAAmB,KAAK,OAAO;EACrD,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\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,OAAO,MAAM,KAAK,KAAK;CACzC,OAAO,KAAK,IAAI,GAAG,MAAM,KAAK,IAAI,KAAK,IAAI,GAAG,QAAQ,OAAO,GAAG;AACjE;AAGA,SAAS,SAAS,UAAU,MAAM;CACjC,MAAM,MAAM,KAAK,IAAI,GAAG,OAAO,IAAI,EAAW;CAC9C,OAAO,KAAK,MAAM,KAAK,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,QAAQ,CAAC,CAAC;AAC1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,oBAAoB;;;;;;;;;;;;;;CAczB,YAAY,SAAS,QAAQ,SAAS;EAErC,KAAK,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K,QAAQ,kBAAkB,IAAI,CAAC,GAAG,CAAC,CAAC;CACrH;;;;;;CAOA,OAAO,SAAS,YAAY;EAC3B,WAAW,QAAQ,iBAAiB;EAEpC,MAAM,QAAQ,mBAAmB;CAClC;AACD"}
@@ -2,7 +2,7 @@ import { splitWords } from "../core/Util.js";
2
2
  import { on, stopPropagation } from "../dom/DomEvent.js";
3
3
  import { create } from "../dom/DomUtil.js";
4
4
  import { ImageOverlay } from "./ImageOverlay.js";
5
- //#region src/layer/VideoOverlay.js
5
+ // src/layer/VideoOverlay.js
6
6
  /** @import {ImageOverlayOptions} from './ImageOverlay.js' */
7
7
  /** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */
8
8
  /** @import {MaplairEvent} from '../core/Events.js' */
@@ -94,7 +94,6 @@ var VideoOverlay = class VideoOverlay extends ImageOverlay {
94
94
  }
95
95
  }
96
96
  };
97
- //#endregion
98
97
  export { VideoOverlay };
99
98
 
100
99
  //# sourceMappingURL=VideoOverlay.js.map
@@ -1,11 +1,23 @@
1
1
  import { Icon } from "./Icon.js";
2
- //#region src/layer/marker/DefaultIcon.js
2
+ // src/layer/marker/DefaultIcon.js
3
3
  /** @import {IconOptions} from './Icon.js' */
4
4
  /** @import {PointExpression} from '../../geometry/Point.js' */
5
5
  /**
6
+ * @param {string} fill
7
+ * @param {string} fillTop
8
+ * @param {number} fillTopOpacity
9
+ * @param {string} stroke
10
+ * @param {string} strokeTop
11
+ * @param {string} [outline]
12
+ * @returns {string}
13
+ */
14
+ const marker = (fill, fillTop, fillTopOpacity, stroke, strokeTop, outline = "") => `data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round" viewBox="0 0 500 820"><defs><linearGradient id="a" x1="0" x2="1" y1="0" y2="0" gradientTransform="rotate(-90 478.727 62.272)scale(37.566)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="${fill}"/><stop offset="1" stop-color="${fillTop}" stop-opacity="${fillTopOpacity}"/></linearGradient><linearGradient id="b" x1="0" x2="1" y1="0" y2="0" gradientTransform="rotate(-90 468.484 54.002)scale(19.053)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="${stroke}"/><stop offset="1" stop-color="${strokeTop}"/></linearGradient></defs><g fill="%23FFF"><path id="p" d="M416.500 542.096L420.919 533.569L422.024 531.437L424.460 529.996L424.233 527.174L426.670 525.732L426.382 522.881L428.720 521.213L428.075 518.393L429.979 516.125L428.342 513.639L429.080 510.777L426.581 509.207L426.168 506.292L423.266 505.773L421.781 503.221L418.898 503.859L416.511 502.112L414.131 503.870L411.248 503.241L409.766 505.793L406.865 506.302L406.439 509.216L403.933 510.775L404.661 513.641L403.023 516.136L404.935 518.393L404.271 521.204L406.590 522.896L406.299 525.752L408.738 527.189L408.516 530.011L410.956 531.448L412.065 533.578Z" transform="translate(-7889.1 -9807.44)scale(19.5417)"/></g><use href="%23p" fill="url(%23a)" stroke="url(%23b)" stroke-width="1.1" stroke-linejoin="miter" stroke-miterlimit="10"/>${outline}<path fill="%23FFF" d="m-90 2030 45-863a95 95 0 0 0-111-98l-859 151 116-320a65 65 0 0 0-20-73l-941-762 212-99a65 65 0 0 0 34-79l-186-572 542 115a65 65 0 0 0 73-38l105-247 423 454a65 65 0 0 0 111-57l-204-1052 327 189a65 65 0 0 0 91-27l332-652 332 652a65 65 0 0 0 91 27l327-189-204 1052a65 65 0 0 0 111 57l423-454 105 247a65 65 0 0 0 73 38l542-115-186 572a65 65 0 0 0 34 79l212 99-941 762a65 65 0 0 0-20 73l116 320-859-151a95 95 0 0 0-111 98l45 863z" transform="translate(250 258)scale(.068)"/></svg>`;
15
+ /**
6
16
  * Options of `DefaultIcon`.
7
17
  * @typedef {object} DefaultIconOptions
8
18
  * @property {string} [iconUrl] The maple leaf marker, inlined as an SVG data URI.
19
+ * @property {string|null} [color=null] Paints the pin in the given CSS color instead of
20
+ * the default red, overriding `iconUrl`, e.g. `new DefaultIcon({color: 'teal'})`.
9
21
  * @property {string} [shadowUrl] Its shadow, inlined as an SVG data URI.
10
22
  * @property {PointExpression|number} [iconSize=[25, 41]]
11
23
  * @property {PointExpression} [iconAnchor=[12, 41]]
@@ -15,9 +27,9 @@ import { Icon } from "./Icon.js";
15
27
  * @extends IconOptions
16
28
  */
17
29
  /**
18
- * A trivial subclass of `Icon`, represents the icon to use in `Marker`s when
19
- * no icon is specified. The maple leaf marker and its shadow are inlined as SVG data
20
- * URIs, so they work with any bundler and need no image files.
30
+ * A subclass of `Icon`, represents the icon to use in `Marker`s when no icon is
31
+ * specified, optionally in another `color`. The maple leaf marker and its shadow are
32
+ * inlined as SVG data URIs, so they work with any bundler and need no image files.
21
33
  *
22
34
  * In order to customize the default icon, just change the properties of
23
35
  * `DefaultIcon.defaultOptions` (which is a set of `Icon options`).
@@ -27,13 +39,14 @@ import { Icon } from "./Icon.js";
27
39
  */
28
40
  var DefaultIcon = class DefaultIcon extends Icon {
29
41
  static defaultOptions = {
30
- iconUrl: "data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" xml:space=\"preserve\" style=\"fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round\" viewBox=\"0 0 500 820\"><defs><linearGradient id=\"a\" x1=\"0\" x2=\"1\" y1=\"0\" y2=\"0\" gradientTransform=\"rotate(-90 478.727 62.272)scale(37.566)\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" stop-color=\"%23C2331B\"/><stop offset=\"1\" stop-color=\"%23E2603F\"/></linearGradient><linearGradient id=\"b\" x1=\"0\" x2=\"1\" y1=\"0\" y2=\"0\" gradientTransform=\"rotate(-90 468.484 54.002)scale(19.053)\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" stop-color=\"%238F2D20\"/><stop offset=\"1\" stop-color=\"%23B23A27\"/></linearGradient></defs><path fill=\"url(%23a)\" stroke=\"url(%23b)\" stroke-width=\"1.1\" stroke-linejoin=\"miter\" stroke-miterlimit=\"10\" d=\"M416.500 542.096L420.919 533.569L422.024 531.437L424.460 529.996L424.233 527.174L426.670 525.732L426.382 522.881L428.720 521.213L428.075 518.393L429.979 516.125L428.342 513.639L429.080 510.777L426.581 509.207L426.168 506.292L423.266 505.773L421.781 503.221L418.898 503.859L416.511 502.112L414.131 503.870L411.248 503.241L409.766 505.793L406.865 506.302L406.439 509.216L403.933 510.775L404.661 513.641L403.023 516.136L404.935 518.393L404.271 521.204L406.590 522.896L406.299 525.752L408.738 527.189L408.516 530.011L410.956 531.448L412.065 533.578Z\" transform=\"translate(-7889.1 -9807.44)scale(19.5417)\"/><path fill=\"%23FFF\" d=\"m-90 2030 45-863a95 95 0 0 0-111-98l-859 151 116-320a65 65 0 0 0-20-73l-941-762 212-99a65 65 0 0 0 34-79l-186-572 542 115a65 65 0 0 0 73-38l105-247 423 454a65 65 0 0 0 111-57l-204-1052 327 189a65 65 0 0 0 91-27l332-652 332 652a65 65 0 0 0 91 27l327-189-204 1052a65 65 0 0 0 111 57l423-454 105 247a65 65 0 0 0 73 38l542-115-186 572a65 65 0 0 0 34 79l212 99-941 762a65 65 0 0 0-20 73l116 320-859-151a95 95 0 0 0-111 98l45 863z\" transform=\"translate(250 258)scale(.068)\"/></svg>",
42
+ iconUrl: /* @__PURE__ */ marker("%23C2331B", "%23E2603F", 1, "%238F2D20", "%23B23A27"),
31
43
  shadowUrl: "data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" xml:space=\"preserve\" viewBox=\"0 0 817.2 820\"><radialGradient id=\"a\" cx=\"526.6\" cy=\"486.836\" r=\"478.154\" fx=\"275.876\" fy=\"893.983\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" style=\"stop-color:%235c5c5c;stop-opacity:.9477\"/><stop offset=\".112\" style=\"stop-color:%23474747;stop-opacity:.7805\"/><stop offset=\".34\" style=\"stop-color:%23202020;stop-opacity:.4413\"/><stop offset=\".523\" style=\"stop-color:%23090909;stop-opacity:.1692\"/><stop offset=\".637\" style=\"stop-color:%23000;stop-opacity:0\"/></radialGradient><path d=\"M254.7 820.0L430.1 664.9L473.9 626.1L541.3 599.9L561.5 548.6L629.0 522.4L648.1 470.5L715.4 440.2L726.3 388.9L789.2 347.6L774.9 302.4L817.1 250.3L775.4 221.8L792.3 168.8L732.1 159.3L721.8 112.9L651.7 124.5L614.0 92.7L545.0 124.7L486.2 113.3L430.2 159.7L360.8 169.0L325.1 222.0L255.1 250.3L245.6 302.4L186.6 347.8L209.1 388.9L169.0 440.0L205.6 470.8L173.5 522.7L215.1 548.9L184.8 600.2L226.4 626.3L232.1 665.1Z\" style=\"fill-rule:evenodd;clip-rule:evenodd;fill:url(%23a);fill-opacity:.7;filter:blur(15px)\"/></svg>",
32
44
  iconSize: [25, 41],
33
45
  iconAnchor: [12, 41],
34
46
  popupAnchor: [1, -34],
35
47
  tooltipAnchor: [16, -28],
36
- shadowSize: [41, 41]
48
+ shadowSize: [41, 41],
49
+ color: null
37
50
  };
38
51
  /**
39
52
  * Creates the default icon, optionally with changed options.
@@ -43,8 +56,17 @@ var DefaultIcon = class DefaultIcon extends Icon {
43
56
  super(...args);
44
57
  this.callInitHooks(DefaultIcon);
45
58
  }
59
+ /**
60
+ * @param {'icon'|'shadow'} name
61
+ * @returns {string|undefined}
62
+ */
63
+ _getIconUrl(name) {
64
+ const { color } = this.options;
65
+ if (!color || name !== "icon") return super._getIconUrl(name);
66
+ const c = encodeURIComponent(color);
67
+ return marker(c, c, .75, c, c, "<use href=\"%23p\" fill=\"none\" stroke=\"%23666\" stroke-opacity=\".4\"/>");
68
+ }
46
69
  };
47
- //#endregion
48
70
  export { DefaultIcon };
49
71
 
50
72
  //# sourceMappingURL=DefaultIcon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultIcon.js","names":[],"sources":["../../../../src/layer/marker/DefaultIcon.js"],"sourcesContent":["import {Icon} from './Icon.js';\n/** @import {IconOptions} from './Icon.js' */\n/** @import {PointExpression} from '../../geometry/Point.js' */\n\n/**\n * Options of `DefaultIcon`.\n * @typedef {object} DefaultIconOptions\n * @property {string} [iconUrl] The maple leaf marker, inlined as an SVG data URI.\n * @property {string} [shadowUrl] Its shadow, inlined as an SVG data URI.\n * @property {PointExpression|number} [iconSize=[25, 41]]\n * @property {PointExpression} [iconAnchor=[12, 41]]\n * @property {PointExpression} [popupAnchor=[1, -34]]\n * @property {PointExpression} [tooltipAnchor=[16, -28]]\n * @property {PointExpression|number} [shadowSize=[41, 41]]\n * @extends IconOptions\n */\n\n/**\n * A trivial subclass of `Icon`, represents the icon to use in `Marker`s when\n * no icon is specified. The maple leaf marker and its shadow are inlined as SVG data\n * URIs, so they work with any bundler and need no image files.\n *\n * In order to customize the default icon, just change the properties of\n * `DefaultIcon.defaultOptions` (which is a set of `Icon options`).\n *\n * If you want to _completely_ replace the default icon, override the\n * `Marker.defaultOptions.icon` with your own icon instead.\n */\nexport class DefaultIcon extends Icon {\n\n\tstatic defaultOptions = {\n\t\ticonUrl: 'data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" xml:space=\"preserve\" style=\"fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round\" viewBox=\"0 0 500 820\"><defs><linearGradient id=\"a\" x1=\"0\" x2=\"1\" y1=\"0\" y2=\"0\" gradientTransform=\"rotate(-90 478.727 62.272)scale(37.566)\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" stop-color=\"%23C2331B\"/><stop offset=\"1\" stop-color=\"%23E2603F\"/></linearGradient><linearGradient id=\"b\" x1=\"0\" x2=\"1\" y1=\"0\" y2=\"0\" gradientTransform=\"rotate(-90 468.484 54.002)scale(19.053)\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" stop-color=\"%238F2D20\"/><stop offset=\"1\" stop-color=\"%23B23A27\"/></linearGradient></defs><path fill=\"url(%23a)\" stroke=\"url(%23b)\" stroke-width=\"1.1\" stroke-linejoin=\"miter\" stroke-miterlimit=\"10\" d=\"M416.500 542.096L420.919 533.569L422.024 531.437L424.460 529.996L424.233 527.174L426.670 525.732L426.382 522.881L428.720 521.213L428.075 518.393L429.979 516.125L428.342 513.639L429.080 510.777L426.581 509.207L426.168 506.292L423.266 505.773L421.781 503.221L418.898 503.859L416.511 502.112L414.131 503.870L411.248 503.241L409.766 505.793L406.865 506.302L406.439 509.216L403.933 510.775L404.661 513.641L403.023 516.136L404.935 518.393L404.271 521.204L406.590 522.896L406.299 525.752L408.738 527.189L408.516 530.011L410.956 531.448L412.065 533.578Z\" transform=\"translate(-7889.1 -9807.44)scale(19.5417)\"/><path fill=\"%23FFF\" d=\"m-90 2030 45-863a95 95 0 0 0-111-98l-859 151 116-320a65 65 0 0 0-20-73l-941-762 212-99a65 65 0 0 0 34-79l-186-572 542 115a65 65 0 0 0 73-38l105-247 423 454a65 65 0 0 0 111-57l-204-1052 327 189a65 65 0 0 0 91-27l332-652 332 652a65 65 0 0 0 91 27l327-189-204 1052a65 65 0 0 0 111 57l423-454 105 247a65 65 0 0 0 73 38l542-115-186 572a65 65 0 0 0 34 79l212 99-941 762a65 65 0 0 0-20 73l116 320-859-151a95 95 0 0 0-111 98l45 863z\" transform=\"translate(250 258)scale(.068)\"/></svg>',\n\t\tshadowUrl: 'data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" xml:space=\"preserve\" viewBox=\"0 0 817.2 820\"><radialGradient id=\"a\" cx=\"526.6\" cy=\"486.836\" r=\"478.154\" fx=\"275.876\" fy=\"893.983\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" style=\"stop-color:%235c5c5c;stop-opacity:.9477\"/><stop offset=\".112\" style=\"stop-color:%23474747;stop-opacity:.7805\"/><stop offset=\".34\" style=\"stop-color:%23202020;stop-opacity:.4413\"/><stop offset=\".523\" style=\"stop-color:%23090909;stop-opacity:.1692\"/><stop offset=\".637\" style=\"stop-color:%23000;stop-opacity:0\"/></radialGradient><path d=\"M254.7 820.0L430.1 664.9L473.9 626.1L541.3 599.9L561.5 548.6L629.0 522.4L648.1 470.5L715.4 440.2L726.3 388.9L789.2 347.6L774.9 302.4L817.1 250.3L775.4 221.8L792.3 168.8L732.1 159.3L721.8 112.9L651.7 124.5L614.0 92.7L545.0 124.7L486.2 113.3L430.2 159.7L360.8 169.0L325.1 222.0L255.1 250.3L245.6 302.4L186.6 347.8L209.1 388.9L169.0 440.0L205.6 470.8L173.5 522.7L215.1 548.9L184.8 600.2L226.4 626.3L232.1 665.1Z\" style=\"fill-rule:evenodd;clip-rule:evenodd;fill:url(%23a);fill-opacity:.7;filter:blur(15px)\"/></svg>',\n\t\ticonSize: [25, 41],\n\t\ticonAnchor: [12, 41],\n\t\tpopupAnchor: [1, -34],\n\t\ttooltipAnchor: [16, -28],\n\t\tshadowSize: [41, 41]\n\t};\n\n\t/**\n\t * Creates the default icon, optionally with changed options.\n\t * @param {[options?: DefaultIconOptions]} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(DefaultIcon);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAa,cAAb,MAAa,oBAAoB,KAAK;CAErC,OAAO,iBAAiB;EACvB,SAAS;EACT,WAAW;EACX,UAAU,CAAC,IAAI,EAAE;EACjB,YAAY,CAAC,IAAI,EAAE;EACnB,aAAa,CAAC,GAAG,GAAG;EACpB,eAAe,CAAC,IAAI,GAAG;EACvB,YAAY,CAAC,IAAI,EAAE;CACpB;;;;;CAMA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,WAAW;CAC/B;AACD"}
1
+ {"version":3,"file":"DefaultIcon.js","names":[],"sources":["../../../../src/layer/marker/DefaultIcon.js"],"sourcesContent":["import {Icon} from './Icon.js';\n/** @import {IconOptions} from './Icon.js' */\n/** @import {PointExpression} from '../../geometry/Point.js' */\n\n// The maple leaf marker. The pin is drawn white under its fill, which fades to it at the top with a `fillTopOpacity`\n// below 1, so that a single color gets a highlight like the default one; the outline keeps light colors visible,\n// but would double the antialiased edges of the default pin.\n/**\n * @param {string} fill\n * @param {string} fillTop\n * @param {number} fillTopOpacity\n * @param {string} stroke\n * @param {string} strokeTop\n * @param {string} [outline]\n * @returns {string}\n */\nconst marker = (fill, fillTop, fillTopOpacity, stroke, strokeTop, outline = '') => `data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" xml:space=\"preserve\" style=\"fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round\" viewBox=\"0 0 500 820\"><defs><linearGradient id=\"a\" x1=\"0\" x2=\"1\" y1=\"0\" y2=\"0\" gradientTransform=\"rotate(-90 478.727 62.272)scale(37.566)\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" stop-color=\"${fill}\"/><stop offset=\"1\" stop-color=\"${fillTop}\" stop-opacity=\"${fillTopOpacity}\"/></linearGradient><linearGradient id=\"b\" x1=\"0\" x2=\"1\" y1=\"0\" y2=\"0\" gradientTransform=\"rotate(-90 468.484 54.002)scale(19.053)\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" stop-color=\"${stroke}\"/><stop offset=\"1\" stop-color=\"${strokeTop}\"/></linearGradient></defs><g fill=\"%23FFF\"><path id=\"p\" d=\"M416.500 542.096L420.919 533.569L422.024 531.437L424.460 529.996L424.233 527.174L426.670 525.732L426.382 522.881L428.720 521.213L428.075 518.393L429.979 516.125L428.342 513.639L429.080 510.777L426.581 509.207L426.168 506.292L423.266 505.773L421.781 503.221L418.898 503.859L416.511 502.112L414.131 503.870L411.248 503.241L409.766 505.793L406.865 506.302L406.439 509.216L403.933 510.775L404.661 513.641L403.023 516.136L404.935 518.393L404.271 521.204L406.590 522.896L406.299 525.752L408.738 527.189L408.516 530.011L410.956 531.448L412.065 533.578Z\" transform=\"translate(-7889.1 -9807.44)scale(19.5417)\"/></g><use href=\"%23p\" fill=\"url(%23a)\" stroke=\"url(%23b)\" stroke-width=\"1.1\" stroke-linejoin=\"miter\" stroke-miterlimit=\"10\"/>${outline}<path fill=\"%23FFF\" d=\"m-90 2030 45-863a95 95 0 0 0-111-98l-859 151 116-320a65 65 0 0 0-20-73l-941-762 212-99a65 65 0 0 0 34-79l-186-572 542 115a65 65 0 0 0 73-38l105-247 423 454a65 65 0 0 0 111-57l-204-1052 327 189a65 65 0 0 0 91-27l332-652 332 652a65 65 0 0 0 91 27l327-189-204 1052a65 65 0 0 0 111 57l423-454 105 247a65 65 0 0 0 73 38l542-115-186 572a65 65 0 0 0 34 79l212 99-941 762a65 65 0 0 0-20 73l116 320-859-151a95 95 0 0 0-111 98l45 863z\" transform=\"translate(250 258)scale(.068)\"/></svg>`;\n\n/**\n * Options of `DefaultIcon`.\n * @typedef {object} DefaultIconOptions\n * @property {string} [iconUrl] The maple leaf marker, inlined as an SVG data URI.\n * @property {string|null} [color=null] Paints the pin in the given CSS color instead of\n * the default red, overriding `iconUrl`, e.g. `new DefaultIcon({color: 'teal'})`.\n * @property {string} [shadowUrl] Its shadow, inlined as an SVG data URI.\n * @property {PointExpression|number} [iconSize=[25, 41]]\n * @property {PointExpression} [iconAnchor=[12, 41]]\n * @property {PointExpression} [popupAnchor=[1, -34]]\n * @property {PointExpression} [tooltipAnchor=[16, -28]]\n * @property {PointExpression|number} [shadowSize=[41, 41]]\n * @extends IconOptions\n */\n\n/**\n * A subclass of `Icon`, represents the icon to use in `Marker`s when no icon is\n * specified, optionally in another `color`. The maple leaf marker and its shadow are\n * inlined as SVG data URIs, so they work with any bundler and need no image files.\n *\n * In order to customize the default icon, just change the properties of\n * `DefaultIcon.defaultOptions` (which is a set of `Icon options`).\n *\n * If you want to _completely_ replace the default icon, override the\n * `Marker.defaultOptions.icon` with your own icon instead.\n */\nexport class DefaultIcon extends Icon {\n\n\tstatic defaultOptions = {\n\t\ticonUrl: /* @__PURE__ */ marker('%23C2331B', '%23E2603F', 1, '%238F2D20', '%23B23A27'),\n\t\tshadowUrl: 'data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" xml:space=\"preserve\" viewBox=\"0 0 817.2 820\"><radialGradient id=\"a\" cx=\"526.6\" cy=\"486.836\" r=\"478.154\" fx=\"275.876\" fy=\"893.983\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" style=\"stop-color:%235c5c5c;stop-opacity:.9477\"/><stop offset=\".112\" style=\"stop-color:%23474747;stop-opacity:.7805\"/><stop offset=\".34\" style=\"stop-color:%23202020;stop-opacity:.4413\"/><stop offset=\".523\" style=\"stop-color:%23090909;stop-opacity:.1692\"/><stop offset=\".637\" style=\"stop-color:%23000;stop-opacity:0\"/></radialGradient><path d=\"M254.7 820.0L430.1 664.9L473.9 626.1L541.3 599.9L561.5 548.6L629.0 522.4L648.1 470.5L715.4 440.2L726.3 388.9L789.2 347.6L774.9 302.4L817.1 250.3L775.4 221.8L792.3 168.8L732.1 159.3L721.8 112.9L651.7 124.5L614.0 92.7L545.0 124.7L486.2 113.3L430.2 159.7L360.8 169.0L325.1 222.0L255.1 250.3L245.6 302.4L186.6 347.8L209.1 388.9L169.0 440.0L205.6 470.8L173.5 522.7L215.1 548.9L184.8 600.2L226.4 626.3L232.1 665.1Z\" style=\"fill-rule:evenodd;clip-rule:evenodd;fill:url(%23a);fill-opacity:.7;filter:blur(15px)\"/></svg>',\n\t\ticonSize: [25, 41],\n\t\ticonAnchor: [12, 41],\n\t\tpopupAnchor: [1, -34],\n\t\ttooltipAnchor: [16, -28],\n\t\tshadowSize: [41, 41],\n\t\tcolor: null\n\t};\n\n\t/**\n\t * Creates the default icon, optionally with changed options.\n\t * @param {[options?: DefaultIconOptions]} args The options.\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(DefaultIcon);\n\t}\n\n\t/**\n\t * @param {'icon'|'shadow'} name\n\t * @returns {string|undefined}\n\t */\n\t_getIconUrl(name) {\n\t\tconst {color} = this.options;\n\t\tif (!color || name !== 'icon') { return super._getIconUrl(name); }\n\t\tconst c = encodeURIComponent(color);\n\t\treturn marker(c, c, 0.75, c, c, '<use href=\"%23p\" fill=\"none\" stroke=\"%23666\" stroke-opacity=\".4\"/>');\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,UAAU,MAAM,SAAS,gBAAgB,QAAQ,WAAW,UAAU,OAAO,2VAA2V,KAAK,kCAAkC,QAAQ,kBAAkB,eAAe,iMAAiM,OAAO,kCAAkC,UAAU,oxBAAoxB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B9gD,IAAa,cAAb,MAAa,oBAAoB,KAAK;CAErC,OAAO,iBAAiB;EACvB,SAAyB,uBAAO,aAAa,aAAa,GAAG,aAAa,WAAW;EACrF,WAAW;EACX,UAAU,CAAC,IAAI,EAAE;EACjB,YAAY,CAAC,IAAI,EAAE;EACnB,aAAa,CAAC,GAAG,GAAG;EACpB,eAAe,CAAC,IAAI,GAAG;EACvB,YAAY,CAAC,IAAI,EAAE;EACnB,OAAO;CACR;;;;;CAMA,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,WAAW;CAC/B;;;;;CAMA,YAAY,MAAM;EACjB,MAAM,EAAC,UAAS,KAAK;EACrB,IAAI,CAAC,SAAS,SAAS,QAAU,OAAO,MAAM,YAAY,IAAI;EAC9D,MAAM,IAAI,mBAAmB,KAAK;EAClC,OAAO,OAAO,GAAG,GAAG,KAAM,GAAG,GAAG,4EAAoE;CACrG;AACD"}
@@ -1,6 +1,6 @@
1
1
  import { Point } from "../../geometry/Point.js";
2
2
  import { Icon } from "./Icon.js";
3
- //#region src/layer/marker/DivIcon.js
3
+ // src/layer/marker/DivIcon.js
4
4
  /** @import {IconOptions} from './Icon.js' */
5
5
  /** @import {PointExpression} from '../../geometry/Point.js' */
6
6
  /**
@@ -73,7 +73,6 @@ var DivIcon = class DivIcon extends Icon {
73
73
  return null;
74
74
  }
75
75
  };
76
- //#endregion
77
76
  export { DivIcon };
78
77
 
79
78
  //# sourceMappingURL=DivIcon.js.map
@@ -1,7 +1,7 @@
1
1
  import { setOptions } from "../../core/Util.js";
2
2
  import { Class } from "../../core/Class.js";
3
3
  import { Point } from "../../geometry/Point.js";
4
- //#region src/layer/marker/Icon.js
4
+ // src/layer/marker/Icon.js
5
5
  /** @import {PointExpression} from '../../geometry/Point.js' */
6
6
  /**
7
7
  * Options of `Icon`.
@@ -113,6 +113,7 @@ var Icon = class Icon extends Class {
113
113
  img.style.marginLeft = `${-anchor.x}px`;
114
114
  img.style.marginTop = `${-anchor.y}px`;
115
115
  }
116
+ img.style.transformOrigin = anchor ? `${anchor.x}px ${anchor.y}px` : "0 0";
116
117
  if (size) {
117
118
  img.style.width = `${size.x}px`;
118
119
  img.style.height = `${size.y}px`;
@@ -127,7 +128,6 @@ var Icon = class Icon extends Class {
127
128
  return window.devicePixelRatio > 1 && this.options[`${name}RetinaUrl`] || this.options[`${name}Url`];
128
129
  }
129
130
  };
130
- //#endregion
131
131
  export { Icon };
132
132
 
133
133
  //# sourceMappingURL=Icon.js.map
@@ -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\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}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AAS,MAAM,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;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} 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_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,OAAO,KAAK,KAAK,QAAQ;EAGzE,OAAO;CACR;CAEA,eAAe,KAAK,MAAM;EACzB,MAAM,UAAU,KAAK;EACrB,IAAI,aAAa,QAAQ,GAAG,KAAK;EAEjC,IAAI,OAAO,eAAe,UACzB,aAAa,CAAC,YAAY,UAAU;EAGrC,MAAM,OAAO,MAAM,SAAS,UAAU,KAAK,MAAM,KAAK,UAAU;EAEhE,MAAM,iBAAiB,SAAS,YAAY,QAAQ,gBAAgB,QAAQ,cAAc,QAAQ,KAAK,SAAS,GAAG,IAAI;EACvH,MAAM,SAAS,MAAM,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,11 +1,19 @@
1
1
  import { Point } from "../../geometry/Point.js";
2
+ import { off, on } from "../../dom/DomEvent.js";
2
3
  import { getPosition, setPosition } from "../../dom/DomUtil.js";
3
4
  import { Bounds } from "../../geometry/Bounds.js";
4
5
  import { Handler } from "../../core/Handler.js";
5
6
  import { Draggable } from "../../dom/Draggable.js";
6
- //#region src/layer/marker/Marker.Drag.js
7
+ // src/layer/marker/Marker.Drag.js
7
8
  /** @import {Marker, MarkerMoveEvent} from './Marker.js' */
8
9
  /** @import {MaplairEvent, DragEndEvent} from '../../core/Events.js' */
10
+ /** @type {Record<string, [number, number]>} */
11
+ const arrows = {
12
+ ArrowLeft: [-1, 0],
13
+ ArrowRight: [1, 0],
14
+ ArrowUp: [0, -1],
15
+ ArrowDown: [0, 1]
16
+ };
9
17
  /**
10
18
  * The handler of `Marker` which makes the markers draggable, see the
11
19
  * [`dragging`](#marker-dragging) property of markers and its `draggable` option.
@@ -40,18 +48,21 @@ var MarkerDrag = class MarkerDrag extends Handler {
40
48
  drag: this._onDrag,
41
49
  dragend: this._onDragEnd
42
50
  }, this).enable();
51
+ on(icon, "keydown keyup blur", this._onKey, this);
43
52
  icon.classList.add("maplair-marker-draggable");
44
53
  }
45
54
  /**
46
55
  * Makes the icon of the marker undraggable, called by `disable()`.
47
56
  */
48
57
  removeHooks() {
58
+ this._keyOffset = null;
49
59
  this._draggable.off({
50
60
  dragstart: this._onDragStart,
51
61
  predrag: this._onPreDrag,
52
62
  drag: this._onDrag,
53
63
  dragend: this._onDragEnd
54
64
  }, this).disable();
65
+ off(this._draggable._element, "keydown keyup blur", this._onKey, this);
55
66
  this._marker._icon?.classList.remove("maplair-marker-draggable");
56
67
  }
57
68
  /**
@@ -86,8 +97,8 @@ var MarkerDrag = class MarkerDrag extends Handler {
86
97
  }
87
98
  }
88
99
  _onDrag(e) {
89
- const marker = this._marker, shadow = marker._shadow, iconPos = getPosition(marker._icon), latlng = marker._map.layerPointToLatLng(iconPos);
90
- if (shadow) setPosition(shadow, iconPos);
100
+ const marker = this._marker, iconPos = getPosition(marker._icon), latlng = marker._map.layerPointToLatLng(iconPos);
101
+ marker._positionElements(iconPos);
91
102
  marker._latlng = latlng;
92
103
  e.latlng = latlng;
93
104
  e.oldLatLng = this._oldLatLng;
@@ -98,8 +109,36 @@ var MarkerDrag = class MarkerDrag extends Handler {
98
109
  delete this._oldLatLng;
99
110
  this._marker.fire("moveend").fire("dragend", e);
100
111
  }
112
+ /** @param {KeyboardEvent|FocusEvent} e */
113
+ _onKey(e) {
114
+ const k = e, dir = arrows[k.key], draggable = this._draggable, { options, _map: map } = this._marker;
115
+ if (e.type !== "keydown") {
116
+ if (this._keyOffset) {
117
+ this._keyOffset = null;
118
+ draggable.finishDrag();
119
+ }
120
+ } else if (dir && k.target === draggable._element && !(k.altKey || k.ctrlKey || k.metaKey)) {
121
+ e.preventDefault();
122
+ if (!this._keyOffset) {
123
+ if (Draggable._dragging) return;
124
+ Draggable._dragging = draggable;
125
+ draggable._startPos = getPosition(draggable._element);
126
+ draggable._moved = draggable._moving = true;
127
+ this._keyOffset = new Point(0, 0);
128
+ draggable.fire("dragstart");
129
+ }
130
+ const offset = new Point(...dir).multiplyBy(k.shiftKey ? 30 : 10);
131
+ this._keyOffset = this._keyOffset.add(map._rotateToPane?.(offset) ?? offset);
132
+ draggable._newPos = draggable._startPos.add(this._keyOffset);
133
+ setPosition(draggable._element, draggable._newPos);
134
+ draggable.fire("drag", { originalEvent: k });
135
+ if (options.autoPan) map.panInside(this._marker._latlng, {
136
+ padding: options.autoPanPadding,
137
+ animate: false
138
+ });
139
+ }
140
+ }
101
141
  };
102
- //#endregion
103
142
  export { MarkerDrag };
104
143
 
105
144
  //# sourceMappingURL=Marker.Drag.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Marker.Drag.js","names":["DomUtil.getPosition"],"sources":["../../../../src/layer/marker/Marker.Drag.js"],"sourcesContent":["import {Handler} from '../../core/Handler.js';\nimport * as DomUtil from '../../dom/DomUtil.js';\nimport {Draggable} from '../../dom/Draggable.js';\nimport {Bounds} from '../../geometry/Bounds.js';\nimport {Point} from '../../geometry/Point.js';\n\n/** @import {Marker, MarkerMoveEvent} from './Marker.js' */\n/** @import {MaplairEvent, DragEndEvent} from '../../core/Events.js' */\n\n/**\n * The handler of `Marker` which makes the markers draggable, see the\n * [`dragging`](#marker-dragging) property of markers and its `draggable` option.\n *\n * @fires Marker#dragstart {MaplairEvent} Fired when the user starts dragging the marker.\n * @fires Marker#movestart {MaplairEvent} Fired when the marker starts moving (because of\n * dragging).\n * @fires Marker#drag {MarkerMoveEvent} Fired repeatedly while the user drags the marker.\n * @fires Marker#dragend {DragEndEvent} Fired when the user stops dragging the marker.\n * @fires Marker#moveend {MaplairEvent} Fired when the marker stops moving (because of\n * dragging).\n */\nexport class MarkerDrag extends Handler {\n\t/**\n\t * Creates the dragging handler of the given marker.\n\t * @param {Marker} marker\n\t */\n\tconstructor(marker) {\n\t\tsuper(marker._map);\n\t\tthis._marker = marker;\n\n\t\tthis.callInitHooks(MarkerDrag);\n\t}\n\n\t/**\n\t * Makes the icon of the marker draggable, called by `enable()`.\n\t */\n\taddHooks() {\n\t\tconst icon = this._marker._icon;\n\n\t\tif (!this._draggable) {\n\t\t\tthis._draggable = new Draggable(icon);\n\t\t}\n\n\t\tthis._draggable.on({\n\t\t\tdragstart: this._onDragStart,\n\t\t\tpredrag: this._onPreDrag,\n\t\t\tdrag: this._onDrag,\n\t\t\tdragend: this._onDragEnd\n\t\t}, this).enable();\n\n\t\ticon.classList.add('maplair-marker-draggable');\n\t}\n\n\t/**\n\t * Makes the icon of the marker undraggable, called by `disable()`.\n\t */\n\tremoveHooks() {\n\t\tthis._draggable.off({\n\t\t\tdragstart: this._onDragStart,\n\t\t\tpredrag: this._onPreDrag,\n\t\t\tdrag: this._onDrag,\n\t\t\tdragend: this._onDragEnd\n\t\t}, this).disable();\n\n\t\tthis._marker._icon?.classList.remove('maplair-marker-draggable');\n\t}\n\n\t/**\n\t * Returns `true` if the marker has been moved by the current or last drag.\n\t * @returns {boolean}\n\t */\n\tmoved() {\n\t\treturn this._draggable?._moved;\n\t}\n\n\t_adjustPan(e) {\n\t\tconst marker = this._marker,\n\t\tmap = marker._map,\n\t\tspeed = this._marker.options.autoPanSpeed,\n\t\tpadding = this._marker.options.autoPanPadding,\n\t\ticonPos = DomUtil.getPosition(marker._icon),\n\t\tbounds = map.getPixelBounds(),\n\t\torigin = map.getPixelOrigin();\n\n\t\tconst panBounds = new Bounds(\n\t\t\tbounds.min._subtract(origin).add(padding),\n\t\t\tbounds.max._subtract(origin).subtract(padding)\n\t\t);\n\n\t\tif (!panBounds.contains(iconPos)) {\n\t\t\t// Compute incremental movement\n\t\t\tconst movement = new Point(\n\t\t\t\t(Math.max(panBounds.max.x, iconPos.x) - panBounds.max.x) / (bounds.max.x - panBounds.max.x) -\n\t\t\t\t(Math.min(panBounds.min.x, iconPos.x) - panBounds.min.x) / (bounds.min.x - panBounds.min.x),\n\n\t\t\t\t(Math.max(panBounds.max.y, iconPos.y) - panBounds.max.y) / (bounds.max.y - panBounds.max.y) -\n\t\t\t\t(Math.min(panBounds.min.y, iconPos.y) - panBounds.min.y) / (bounds.min.y - panBounds.min.y)\n\t\t\t).multiplyBy(speed);\n\n\t\t\tmap.panBy(movement, {animate: false});\n\n\t\t\tthis._draggable._newPos._add(movement);\n\t\t\tthis._draggable._startPos._add(movement);\n\n\t\t\tDomUtil.setPosition(marker._icon, this._draggable._newPos);\n\t\t\tthis._onDrag(e);\n\n\t\t\tthis._panRequest = requestAnimationFrame(this._adjustPan.bind(this, e));\n\t\t}\n\t}\n\n\t_onDragStart() {\n\t\tthis._oldLatLng = this._marker.getLatLng();\n\n\t\t// When using ES6 imports it could not be set when `Popup` was not imported as well\n\t\tthis._marker.closePopup?.();\n\n\t\tthis._marker\n\t\t\t.fire('movestart')\n\t\t\t.fire('dragstart');\n\t}\n\n\t_onPreDrag(e) {\n\t\tif (this._marker.options.autoPan) {\n\t\t\tcancelAnimationFrame(this._panRequest);\n\t\t\tthis._panRequest = requestAnimationFrame(this._adjustPan.bind(this, e));\n\t\t}\n\t}\n\n\t_onDrag(e) {\n\t\tconst marker = this._marker,\n\t\tshadow = marker._shadow,\n\t\ticonPos = DomUtil.getPosition(marker._icon),\n\t\tlatlng = marker._map.layerPointToLatLng(iconPos);\n\n\t\t// update shadow position\n\t\tif (shadow) {\n\t\t\tDomUtil.setPosition(shadow, iconPos);\n\t\t}\n\n\t\tmarker._latlng = latlng;\n\t\te.latlng = latlng;\n\t\te.oldLatLng = this._oldLatLng;\n\n\t\tmarker\n\t\t\t.fire('move', e)\n\t\t\t.fire('drag', e);\n\t}\n\n\t_onDragEnd(e) {\n\t\tcancelAnimationFrame(this._panRequest);\n\n\t\tdelete this._oldLatLng;\n\t\tthis._marker\n\t\t\t.fire('moveend')\n\t\t\t.fire('dragend', e);\n\t}\n}\n"],"mappings":";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;EACZ,KAAK,QACH,KAAK,SAAS,CAAC,CACf,KAAK,WAAW,CAAC;CACpB;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 {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,O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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"}
@@ -1,7 +1,7 @@
1
1
  import { Point } from "../../geometry/Point.js";
2
2
  import { LatLng } from "../../geo/LatLng.js";
3
3
  import { Marker } from "./Marker.js";
4
- //#region src/layer/marker/Marker.Move.js
4
+ // src/layer/marker/Marker.Move.js
5
5
  /** @import {LatLngExpression} from '../../geo/LatLng.js' */
6
6
  /** @import {MaplairMap} from '../../map/Map.js' */
7
7
  /** @import {MaplairEvent} from '../../core/Events.js' */
@@ -11,9 +11,8 @@ import { Marker } from "./Marker.js";
11
11
  * @property {number} [duration=1000] The duration of the movement in milliseconds.
12
12
  * @property {number} [speed] The speed in meters (or units of the CRS) per second
13
13
  * instead of the `duration`.
14
- * @property {boolean} [rotate=false] Whether to set the `rotationAngle` of the icon to
15
- * the heading of the movement (for icons pointing up; needs the marker rotation, see
16
- * `rotationAngle`).
14
+ * @property {boolean} [rotate=false] Whether to set the `rotation` of the marker to
15
+ * the heading of the movement (for icons pointing up).
17
16
  */
18
17
  const { onRemove } = Marker.prototype;
19
18
  /** @typedef {typeof markerMoveMethods} MarkerMoveMethods */
@@ -52,7 +51,7 @@ Marker.include({
52
51
  i++;
53
52
  }
54
53
  const from = points[i], to = points[i + 1];
55
- if (options.rotate && !from.equals(to)) this.options.rotationAngle = this._heading(from, to);
54
+ if (options.rotate && !from.equals(to)) this.options.rotation = this._heading(from, to);
56
55
  this.setLatLng(this._interpolate(from, to, lengths[i] ? Math.min(1, distance / lengths[i]) : 1));
57
56
  if (moved < total) this._moveFrame = requestAnimationFrame(frame);
58
57
  else {
@@ -101,6 +100,5 @@ Marker.include({
101
100
  return onRemove.call(this, map);
102
101
  }
103
102
  });
104
- //#endregion
105
103
 
106
104
  //# sourceMappingURL=Marker.Move.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Marker.Move.js","names":[],"sources":["../../../../src/layer/marker/Marker.Move.js"],"sourcesContent":["import {Marker} from './Marker.js';\nimport {LatLng} from '../../geo/LatLng.js';\nimport {Point} from '../../geometry/Point.js';\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {MaplairEvent} from '../../core/Events.js' */\n\n/**\n * Options of the movement of markers, see `moveAlong()`.\n * @typedef {object} MarkerMovementOptions\n * @property {number} [duration=1000] The duration of the movement in milliseconds.\n * @property {number} [speed] The speed in meters (or units of the CRS) per second\n * instead of the `duration`.\n * @property {boolean} [rotate=false] Whether to set the `rotationAngle` of the icon to\n * the heading of the movement (for icons pointing up; needs the marker rotation, see\n * `rotationAngle`).\n */\n\n// The methods extended below\nconst {onRemove} = Marker.prototype;\n\n/**\n * Methods of `Marker` for the animated movement of markers, an optional feature: import\n * this module to add `moveTo()`, `moveAlong()`, `stopMoving()` and `isMoving()` to\n * `Marker`.\n *\n * ```js\n * import 'maplair/marker-movement';\n *\n * marker.moveAlong([[47.27, 11.40], [47.28, 11.42]], {duration: 5000});\n * ```\n *\n * Inspired by the [Leaflet.MovingMarker](https://github.com/ewoken/Leaflet.MovingMarker)\n * and [Leaflet.AnimatedMarker](https://github.com/openplans/Leaflet.AnimatedMarker) plugins.\n * @lends Marker.prototype\n * @fires Marker#moveend {MaplairEvent} Fired when the marker stops moving (after dragging\n * or `moveAlong()`).\n */\nconst markerMoveMethods = {\n\t/**\n\t * Moves the marker smoothly to `latlng`, see `moveAlong()`.\n\t * @group Marker movement\n\t * @param {LatLngExpression} latlng\n\t * @param {MarkerMovementOptions} [options]\n\t * @returns {this}\n\t */\n\tmoveTo(latlng, options) {\n\t\treturn this.moveAlong([latlng], options);\n\t},\n\n\t/**\n\t * Moves the marker smoothly along the given points, frame by frame at a constant\n\t * speed, e.g. to follow a vehicle or to replay a track. Fires `move` with each\n\t * frame and `moveend` at the end. A new movement or `stopMoving()` stops it; with\n\t * [reduced motion](https://developer.mozilla.org/docs/Web/CSS/@media/prefers-reduced-motion),\n\t * the marker jumps to the end.\n\t * Inspired by the [Leaflet.MovingMarker](https://github.com/ewoken/Leaflet.MovingMarker)\n\t * and [Leaflet.AnimatedMarker](https://github.com/openplans/Leaflet.AnimatedMarker) plugins.\n\t * @group Marker movement\n\t * @param {LatLngExpression[]} latlngs\n\t * @param {MarkerMovementOptions} [options]\n\t * @returns {this}\n\t */\n\tmoveAlong(latlngs, options = {}) {\n\t\tthis.stopMoving();\n\n\t\tconst points = [this._latlng, ...latlngs.map(latlng => LatLng.from(latlng))],\n\t\tlengths = points.slice(1).map((point, i) => this._map?.distance(points[i], point) ?? points[i].distanceTo(point)),\n\t\ttotal = lengths.reduce((sum, length) => sum + length, 0),\n\t\tduration = options.speed ? total / options.speed * 1000 : (options.duration ?? 1000),\n\t\tstart = performance.now();\n\n\t\tconst frame = () => {\n\t\t\t// the distance moved, at a constant speed\n\t\t\tlet distance = duration && !this._map?._prefersReducedMotion() ? Math.min(1, (performance.now() - start) / duration) * total : total,\n\t\t\ti = 0;\n\t\t\tconst moved = distance;\n\t\t\twhile (i < lengths.length - 1 && distance > lengths[i]) {\n\t\t\t\tdistance -= lengths[i];\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tconst from = points[i], to = points[i + 1];\n\t\t\tif (options.rotate && !from.equals(to)) {\n\t\t\t\tthis.options.rotationAngle = this._heading(from, to);\n\t\t\t}\n\t\t\tthis.setLatLng(this._interpolate(from, to, lengths[i] ? Math.min(1, distance / lengths[i]) : 1));\n\n\t\t\tif (moved < total) {\n\t\t\t\tthis._moveFrame = requestAnimationFrame(frame);\n\t\t\t} else {\n\t\t\t\tthis._moveFrame = null;\n\t\t\t\tthis.fire('moveend');\n\t\t\t}\n\t\t};\n\t\tthis._moveFrame = requestAnimationFrame(frame);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Stops the movement of `moveTo()` or `moveAlong()`.\n\t * @group Marker movement\n\t * @returns {this}\n\t */\n\tstopMoving() {\n\t\tcancelAnimationFrame(this._moveFrame);\n\t\tthis._moveFrame = null;\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` while the marker moves with `moveTo()` or `moveAlong()`.\n\t * @group Marker movement\n\t * @returns {boolean}\n\t */\n\tisMoving() {\n\t\treturn !!this._moveFrame;\n\t},\n\n\t// A straight line in the projection of the map (if any)\n\t_interpolate(from, to, t) {\n\t\tconst crs = this._map?.options.crs;\n\t\tif (!crs) {\n\t\t\treturn new LatLng(from.lat + (to.lat - from.lat) * t, from.lng + (to.lng - from.lng) * t);\n\t\t}\n\t\tconst a = crs.projection.project(from),\n\t\tb = crs.projection.project(to);\n\t\treturn crs.projection.unproject(a.add(b.subtract(a).multiplyBy(t)));\n\t},\n\n\t// The heading from `from` to `to` in degrees clockwise from north, relative to\n\t// the screen unless the icon rotates with the view\n\t_heading(from, to) {\n\t\tconst crs = this._map?.options.crs,\n\t\ta = crs ? crs.latLngToPoint(from, 0) : new Point(from.lng, -from.lat),\n\t\tb = crs ? crs.latLngToPoint(to, 0) : new Point(to.lng, -to.lat),\n\t\theading = Math.atan2(b.x - a.x, a.y - b.y) * 180 / Math.PI;\n\t\treturn heading - (this.options.rotateWithView ? 0 : (this._map?.getBearing?.() ?? 0));\n\t},\n\n\t/**\n\t * Stops the movement when the marker is removed from the map.\n\t * @internal\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map) {\n\t\tthis.stopMoving();\n\t\treturn onRemove.call(this, map);\n\t}\n};\n/** @typedef {typeof markerMoveMethods} MarkerMoveMethods */\n\nMarker.include(markerMoveMethods);\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,MAAM,EAAC,aAAY,OAAO;;AAoI1B,OAAO,QAAQ;;;;;;;;CAzGd,OAAO,QAAQ,SAAS;EACvB,OAAO,KAAK,UAAU,CAAC,MAAM,GAAG,OAAO;CACxC;;;;;;;;;;;;;;CAeA,UAAU,SAAS,UAAU,CAAC,GAAG;EAChC,KAAK,WAAW;EAEhB,MAAM,SAAS,CAAC,KAAK,SAAS,GAAG,QAAQ,KAAI,WAAU,OAAO,KAAK,MAAM,CAAC,CAAC,GAC3E,UAAU,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,KAAK,MAAM,SAAS,OAAO,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC,WAAW,KAAK,CAAC,GAChH,QAAQ,QAAQ,QAAQ,KAAK,WAAW,MAAM,QAAQ,CAAC,GACvD,WAAW,QAAQ,QAAQ,QAAQ,QAAQ,QAAQ,MAAQ,QAAQ,YAAY,KAC/E,QAAQ,YAAY,IAAI;EAExB,MAAM,cAAc;GAEnB,IAAI,WAAW,YAAY,CAAC,KAAK,MAAM,sBAAsB,IAAI,KA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AAK,KAAK,CAAC,KAAK,GAAG,GACpE,IAAI,MAAM,IAAI,cAAc,IAAI,CAAC,IAAI,IAAI,MAAM,GAAG,KAAK,CAAC,GAAG,GAAG;EAE9D,OADU,KAAK,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,IAAI,MAAM,KAAK,MACtC,KAAK,QAAQ,iBAAiB,IAAK,KAAK,MAAM,aAAa,KAAK;CACnF;;;;;;CAOA,SAAS,KAAK;EACb,KAAK,WAAW;EAChB,OAAO,SAAS,KAAK,MAAM,GAAG;CAC/B;AAI8B,CAAC"}
1
+ {"version":3,"file":"Marker.Move.js","names":[],"sources":["../../../../src/layer/marker/Marker.Move.js"],"sourcesContent":["import {Marker} from './Marker.js';\nimport {LatLng} from '../../geo/LatLng.js';\nimport {Point} from '../../geometry/Point.js';\n/** @import {LatLngExpression} from '../../geo/LatLng.js' */\n/** @import {MaplairMap} from '../../map/Map.js' */\n/** @import {MaplairEvent} from '../../core/Events.js' */\n\n/**\n * Options of the movement of markers, see `moveAlong()`.\n * @typedef {object} MarkerMovementOptions\n * @property {number} [duration=1000] The duration of the movement in milliseconds.\n * @property {number} [speed] The speed in meters (or units of the CRS) per second\n * instead of the `duration`.\n * @property {boolean} [rotate=false] Whether to set the `rotation` of the marker to\n * the heading of the movement (for icons pointing up).\n */\n\n// The methods extended below\nconst {onRemove} = Marker.prototype;\n\n/**\n * Methods of `Marker` for the animated movement of markers, an optional feature: import\n * this module to add `moveTo()`, `moveAlong()`, `stopMoving()` and `isMoving()` to\n * `Marker`.\n *\n * ```js\n * import 'maplair/marker-movement';\n *\n * marker.moveAlong([[47.27, 11.40], [47.28, 11.42]], {duration: 5000});\n * ```\n *\n * Inspired by the [Leaflet.MovingMarker](https://github.com/ewoken/Leaflet.MovingMarker)\n * and [Leaflet.AnimatedMarker](https://github.com/openplans/Leaflet.AnimatedMarker) plugins.\n * @lends Marker.prototype\n * @fires Marker#moveend {MaplairEvent} Fired when the marker stops moving (after dragging\n * or `moveAlong()`).\n */\nconst markerMoveMethods = {\n\t/**\n\t * Moves the marker smoothly to `latlng`, see `moveAlong()`.\n\t * @group Marker movement\n\t * @param {LatLngExpression} latlng\n\t * @param {MarkerMovementOptions} [options]\n\t * @returns {this}\n\t */\n\tmoveTo(latlng, options) {\n\t\treturn this.moveAlong([latlng], options);\n\t},\n\n\t/**\n\t * Moves the marker smoothly along the given points, frame by frame at a constant\n\t * speed, e.g. to follow a vehicle or to replay a track. Fires `move` with each\n\t * frame and `moveend` at the end. A new movement or `stopMoving()` stops it; with\n\t * [reduced motion](https://developer.mozilla.org/docs/Web/CSS/@media/prefers-reduced-motion),\n\t * the marker jumps to the end.\n\t * Inspired by the [Leaflet.MovingMarker](https://github.com/ewoken/Leaflet.MovingMarker)\n\t * and [Leaflet.AnimatedMarker](https://github.com/openplans/Leaflet.AnimatedMarker) plugins.\n\t * @group Marker movement\n\t * @param {LatLngExpression[]} latlngs\n\t * @param {MarkerMovementOptions} [options]\n\t * @returns {this}\n\t */\n\tmoveAlong(latlngs, options = {}) {\n\t\tthis.stopMoving();\n\n\t\tconst points = [this._latlng, ...latlngs.map(latlng => LatLng.from(latlng))],\n\t\tlengths = points.slice(1).map((point, i) => this._map?.distance(points[i], point) ?? points[i].distanceTo(point)),\n\t\ttotal = lengths.reduce((sum, length) => sum + length, 0),\n\t\tduration = options.speed ? total / options.speed * 1000 : (options.duration ?? 1000),\n\t\tstart = performance.now();\n\n\t\tconst frame = () => {\n\t\t\t// the distance moved, at a constant speed\n\t\t\tlet distance = duration && !this._map?._prefersReducedMotion() ? Math.min(1, (performance.now() - start) / duration) * total : total,\n\t\t\ti = 0;\n\t\t\tconst moved = distance;\n\t\t\twhile (i < lengths.length - 1 && distance > lengths[i]) {\n\t\t\t\tdistance -= lengths[i];\n\t\t\t\ti++;\n\t\t\t}\n\t\t\tconst from = points[i], to = points[i + 1];\n\t\t\tif (options.rotate && !from.equals(to)) {\n\t\t\t\tthis.options.rotation = this._heading(from, to);\n\t\t\t}\n\t\t\tthis.setLatLng(this._interpolate(from, to, lengths[i] ? Math.min(1, distance / lengths[i]) : 1));\n\n\t\t\tif (moved < total) {\n\t\t\t\tthis._moveFrame = requestAnimationFrame(frame);\n\t\t\t} else {\n\t\t\t\tthis._moveFrame = null;\n\t\t\t\tthis.fire('moveend');\n\t\t\t}\n\t\t};\n\t\tthis._moveFrame = requestAnimationFrame(frame);\n\t\treturn this;\n\t},\n\n\t/**\n\t * Stops the movement of `moveTo()` or `moveAlong()`.\n\t * @group Marker movement\n\t * @returns {this}\n\t */\n\tstopMoving() {\n\t\tcancelAnimationFrame(this._moveFrame);\n\t\tthis._moveFrame = null;\n\t\treturn this;\n\t},\n\n\t/**\n\t * Returns `true` while the marker moves with `moveTo()` or `moveAlong()`.\n\t * @group Marker movement\n\t * @returns {boolean}\n\t */\n\tisMoving() {\n\t\treturn !!this._moveFrame;\n\t},\n\n\t// A straight line in the projection of the map (if any)\n\t_interpolate(from, to, t) {\n\t\tconst crs = this._map?.options.crs;\n\t\tif (!crs) {\n\t\t\treturn new LatLng(from.lat + (to.lat - from.lat) * t, from.lng + (to.lng - from.lng) * t);\n\t\t}\n\t\tconst a = crs.projection.project(from),\n\t\tb = crs.projection.project(to);\n\t\treturn crs.projection.unproject(a.add(b.subtract(a).multiplyBy(t)));\n\t},\n\n\t// The heading from `from` to `to` in degrees clockwise from north, relative to\n\t// the screen unless the icon rotates with the view\n\t_heading(from, to) {\n\t\tconst crs = this._map?.options.crs,\n\t\ta = crs ? crs.latLngToPoint(from, 0) : new Point(from.lng, -from.lat),\n\t\tb = crs ? crs.latLngToPoint(to, 0) : new Point(to.lng, -to.lat),\n\t\theading = Math.atan2(b.x - a.x, a.y - b.y) * 180 / Math.PI;\n\t\treturn heading - (this.options.rotateWithView ? 0 : (this._map?.getBearing?.() ?? 0));\n\t},\n\n\t/**\n\t * Stops the movement when the marker is removed from the map.\n\t * @internal\n\t * @param {MaplairMap} map\n\t */\n\tonRemove(map)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