maplair 4.0.0-alpha.2 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/CHANGELOG.md +140 -38
  2. package/LICENSE +1 -1
  3. package/README.md +10 -9
  4. package/dist/esm/Maplair.js +14 -14
  5. package/dist/esm/control/AttributionControl.js +24 -14
  6. package/dist/esm/control/AttributionControl.js.map +1 -1
  7. package/dist/esm/control/ButtonControl.js +9 -11
  8. package/dist/esm/control/ButtonControl.js.map +1 -1
  9. package/dist/esm/control/ContextMenu.js +1 -3
  10. package/dist/esm/control/ContextMenu.js.map +1 -1
  11. package/dist/esm/control/Control.js +9 -16
  12. package/dist/esm/control/Control.js.map +1 -1
  13. package/dist/esm/control/FullscreenControl.js +5 -7
  14. package/dist/esm/control/FullscreenControl.js.map +1 -1
  15. package/dist/esm/control/LayersControl.js +144 -35
  16. package/dist/esm/control/LayersControl.js.map +1 -1
  17. package/dist/esm/control/LegendControl.js +7 -9
  18. package/dist/esm/control/LegendControl.js.map +1 -1
  19. package/dist/esm/control/MiniMapControl.js +14 -16
  20. package/dist/esm/control/MiniMapControl.js.map +1 -1
  21. package/dist/esm/control/RotateControl.js +1 -3
  22. package/dist/esm/control/RotateControl.js.map +1 -1
  23. package/dist/esm/control/ScaleControl.js +7 -9
  24. package/dist/esm/control/ScaleControl.js.map +1 -1
  25. package/dist/esm/control/SearchControl.js +100 -18
  26. package/dist/esm/control/SearchControl.js.map +1 -1
  27. package/dist/esm/control/SideBySideControl.js +1 -3
  28. package/dist/esm/control/SideBySideControl.js.map +1 -1
  29. package/dist/esm/control/TextControl.js +5 -7
  30. package/dist/esm/control/TextControl.js.map +1 -1
  31. package/dist/esm/control/TimeControl.js +408 -0
  32. package/dist/esm/control/TimeControl.js.map +1 -0
  33. package/dist/esm/control/ZoomControl.js +5 -7
  34. package/dist/esm/control/ZoomControl.js.map +1 -1
  35. package/dist/esm/core/Class.js +28 -37
  36. package/dist/esm/core/Class.js.map +1 -1
  37. package/dist/esm/core/Events.js +21 -8
  38. package/dist/esm/core/Events.js.map +1 -1
  39. package/dist/esm/core/Handler.js +13 -11
  40. package/dist/esm/core/Handler.js.map +1 -1
  41. package/dist/esm/core/Util.js +13 -1
  42. package/dist/esm/core/Util.js.map +1 -1
  43. package/dist/esm/dom/DomEvent.DoubleTap.js +25 -22
  44. package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -1
  45. package/dist/esm/dom/DomEvent.PointerEvents.js +2 -16
  46. package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
  47. package/dist/esm/dom/DomEvent.js +8 -42
  48. package/dist/esm/dom/DomEvent.js.map +1 -1
  49. package/dist/esm/dom/DomUtil.js +14 -68
  50. package/dist/esm/dom/DomUtil.js.map +1 -1
  51. package/dist/esm/dom/Draggable.js +17 -18
  52. package/dist/esm/dom/Draggable.js.map +1 -1
  53. package/dist/esm/dom/PosAnimation.js +3 -25
  54. package/dist/esm/dom/PosAnimation.js.map +1 -1
  55. package/dist/esm/geo/LatLng.js +34 -6
  56. package/dist/esm/geo/LatLng.js.map +1 -1
  57. package/dist/esm/geo/LatLngBounds.js +19 -7
  58. package/dist/esm/geo/LatLngBounds.js.map +1 -1
  59. package/dist/esm/geo/crs/CRS.js +4 -3
  60. package/dist/esm/geo/crs/CRS.js.map +1 -1
  61. package/dist/esm/geo/crs/EPSG3395.js +1 -1
  62. package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
  63. package/dist/esm/geo/crs/EPSG3857.js +1 -1
  64. package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
  65. package/dist/esm/geo/crs/EPSG4326.js +1 -1
  66. package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
  67. package/dist/esm/geo/crs/EarthCRS.js +2 -2
  68. package/dist/esm/geo/crs/EarthCRS.js.map +1 -1
  69. package/dist/esm/geo/crs/SimpleCRS.js +1 -1
  70. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
  71. package/dist/esm/geo/projection/Projection.LonLat.js +3 -3
  72. package/dist/esm/geo/projection/Projection.LonLat.js.map +1 -1
  73. package/dist/esm/geo/projection/Projection.Mercator.js +3 -3
  74. package/dist/esm/geo/projection/Projection.Mercator.js.map +1 -1
  75. package/dist/esm/geo/projection/Projection.SphericalMercator.js +3 -3
  76. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +1 -1
  77. package/dist/esm/geometry/Bounds.js +19 -7
  78. package/dist/esm/geometry/Bounds.js.map +1 -1
  79. package/dist/esm/geometry/LineUtil.js +36 -30
  80. package/dist/esm/geometry/LineUtil.js.map +1 -1
  81. package/dist/esm/geometry/Point.js +23 -5
  82. package/dist/esm/geometry/Point.js.map +1 -1
  83. package/dist/esm/geometry/PolyUtil.js +9 -28
  84. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  85. package/dist/esm/layer/BlanketOverlay.js +6 -8
  86. package/dist/esm/layer/BlanketOverlay.js.map +1 -1
  87. package/dist/esm/layer/DivOverlay.js +15 -20
  88. package/dist/esm/layer/DivOverlay.js.map +1 -1
  89. package/dist/esm/layer/GeoJSON.js +9 -145
  90. package/dist/esm/layer/GeoJSON.js.map +1 -1
  91. package/dist/esm/layer/GeoJSONUtil.js +75 -0
  92. package/dist/esm/layer/GeoJSONUtil.js.map +1 -0
  93. package/dist/esm/layer/HeatLayer.js +15 -17
  94. package/dist/esm/layer/HeatLayer.js.map +1 -1
  95. package/dist/esm/layer/ImageOverlay.js +20 -26
  96. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  97. package/dist/esm/layer/Layer.js +8 -10
  98. package/dist/esm/layer/Layer.js.map +1 -1
  99. package/dist/esm/layer/LayerGroup.js +51 -0
  100. package/dist/esm/layer/LayerGroup.js.map +1 -1
  101. package/dist/esm/layer/Popup.js +27 -43
  102. package/dist/esm/layer/Popup.js.map +1 -1
  103. package/dist/esm/layer/SVGOverlay.js +2 -5
  104. package/dist/esm/layer/SVGOverlay.js.map +1 -1
  105. package/dist/esm/layer/Tooltip.js +15 -17
  106. package/dist/esm/layer/Tooltip.js.map +1 -1
  107. package/dist/esm/layer/VideoOverlay.js +12 -15
  108. package/dist/esm/layer/VideoOverlay.js.map +1 -1
  109. package/dist/esm/layer/marker/DefaultIcon.js +15 -48
  110. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
  111. package/dist/esm/layer/marker/DivIcon.js +8 -10
  112. package/dist/esm/layer/marker/DivIcon.js.map +1 -1
  113. package/dist/esm/layer/marker/Icon.js +9 -12
  114. package/dist/esm/layer/marker/Icon.js.map +1 -1
  115. package/dist/esm/layer/marker/Marker.Drag.js +1 -1
  116. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  117. package/dist/esm/layer/marker/Marker.Move.js +2 -3
  118. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  119. package/dist/esm/layer/marker/Marker.js +63 -35
  120. package/dist/esm/layer/marker/Marker.js.map +1 -1
  121. package/dist/esm/layer/marker/MarkerClusterGroup.js +302 -0
  122. package/dist/esm/layer/marker/MarkerClusterGroup.js.map +1 -0
  123. package/dist/esm/layer/marker/SvgIcon.js +6 -8
  124. package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
  125. package/dist/esm/layer/tile/GridLayer.js +86 -98
  126. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  127. package/dist/esm/layer/tile/TileLayer.js +28 -36
  128. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  129. package/dist/esm/layer/tile/WMSTileLayer.js +28 -23
  130. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
  131. package/dist/esm/layer/vector/Canvas.js +1 -3
  132. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  133. package/dist/esm/layer/vector/Circle.js +2 -2
  134. package/dist/esm/layer/vector/Circle.js.map +1 -1
  135. package/dist/esm/layer/vector/CircleMarker.js +17 -7
  136. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  137. package/dist/esm/layer/vector/Path.DashAnimation.js +2 -3
  138. package/dist/esm/layer/vector/Path.DashAnimation.js.map +1 -1
  139. package/dist/esm/layer/vector/Path.js +27 -20
  140. package/dist/esm/layer/vector/Path.js.map +1 -1
  141. package/dist/esm/layer/vector/Polygon.js +20 -4
  142. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  143. package/dist/esm/layer/vector/Polyline.Decorations.js +2 -2
  144. package/dist/esm/layer/vector/Polyline.js +24 -8
  145. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  146. package/dist/esm/layer/vector/Renderer.getRenderer.js +14 -13
  147. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  148. package/dist/esm/layer/vector/SVG.js +5 -5
  149. package/dist/esm/layer/vector/SVG.js.map +1 -1
  150. package/dist/esm/map/Map.Rotation.js +15 -11
  151. package/dist/esm/map/Map.Rotation.js.map +1 -1
  152. package/dist/esm/map/Map.js +135 -129
  153. package/dist/esm/map/Map.js.map +1 -1
  154. package/dist/esm/map/handler/BoxZoomHandler.js +5 -7
  155. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  156. package/dist/esm/map/handler/DisplaceHandler.js +6 -8
  157. package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
  158. package/dist/esm/map/handler/DragHandler.js +20 -20
  159. package/dist/esm/map/handler/DragHandler.js.map +1 -1
  160. package/dist/esm/map/handler/KeyboardHandler.js +37 -37
  161. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  162. package/dist/esm/map/handler/PinchZoomHandler.js +12 -3
  163. package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
  164. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +3 -4
  165. package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
  166. package/dist/esm/map/handler/TapHoldHandler.js +12 -5
  167. package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
  168. package/dist/esm/package.js +1 -1
  169. package/dist/maplair-global-src.js +6326 -5625
  170. package/dist/maplair-global-src.js.map +1 -1
  171. package/dist/maplair-global.js +3 -3
  172. package/dist/maplair-global.js.map +1 -1
  173. package/dist/maplair-src.js +9010 -8290
  174. package/dist/maplair-src.js.map +1 -1
  175. package/dist/maplair.css +148 -98
  176. package/dist/maplair.js +3 -3
  177. package/dist/maplair.js.map +1 -1
  178. package/i18n/cs.json +6 -0
  179. package/i18n/de.json +6 -0
  180. package/i18n/en.json +6 -0
  181. package/i18n/es.json +6 -0
  182. package/i18n/fr.json +6 -0
  183. package/i18n/hu.json +6 -0
  184. package/i18n/it.json +6 -0
  185. package/i18n/rm.json +6 -0
  186. package/i18n/sk.json +6 -0
  187. package/i18n/sl.json +6 -0
  188. package/package.json +12 -14
  189. package/src/control/AttributionControl.js +25 -18
  190. package/src/control/ButtonControl.js +9 -11
  191. package/src/control/ContextMenu.js +3 -5
  192. package/src/control/Control.js +9 -19
  193. package/src/control/FullscreenControl.js +5 -7
  194. package/src/control/LayersControl.js +159 -36
  195. package/src/control/LegendControl.js +7 -9
  196. package/src/control/MiniMapControl.js +9 -11
  197. package/src/control/RotateControl.js +3 -5
  198. package/src/control/ScaleControl.js +7 -9
  199. package/src/control/SearchControl.js +104 -21
  200. package/src/control/SideBySideControl.js +3 -5
  201. package/src/control/TextControl.js +5 -7
  202. package/src/control/TimeControl.js +471 -0
  203. package/src/control/ZoomControl.js +5 -7
  204. package/src/control/index.js +1 -0
  205. package/src/core/Class.js +35 -34
  206. package/src/core/Events.js +22 -3
  207. package/src/core/Handler.js +14 -12
  208. package/src/core/Util.js +19 -1
  209. package/src/core/index.js +0 -1
  210. package/src/dom/DomEvent.DoubleTap.js +18 -10
  211. package/src/dom/DomEvent.PointerEvents.js +3 -26
  212. package/src/dom/DomEvent.js +8 -66
  213. package/src/dom/DomUtil.js +22 -78
  214. package/src/dom/Draggable.js +27 -22
  215. package/src/dom/PosAnimation.js +3 -25
  216. package/src/dom/index.js +0 -1
  217. package/src/geo/LatLng.js +40 -4
  218. package/src/geo/LatLngBounds.js +20 -7
  219. package/src/geo/crs/CRS.js +4 -3
  220. package/src/geo/crs/EPSG3395.js +1 -1
  221. package/src/geo/crs/EPSG3857.js +1 -1
  222. package/src/geo/crs/EPSG4326.js +1 -1
  223. package/src/geo/crs/EarthCRS.js +2 -8
  224. package/src/geo/crs/SimpleCRS.js +1 -1
  225. package/src/geo/projection/Projection.LonLat.js +3 -3
  226. package/src/geo/projection/Projection.Mercator.js +3 -3
  227. package/src/geo/projection/Projection.SphericalMercator.js +3 -3
  228. package/src/geometry/Bounds.js +20 -7
  229. package/src/geometry/LineUtil.js +47 -48
  230. package/src/geometry/Point.js +24 -5
  231. package/src/geometry/PolyUtil.js +15 -44
  232. package/src/layer/BlanketOverlay.js +6 -10
  233. package/src/layer/DivOverlay.js +15 -26
  234. package/src/layer/GeoJSON.js +7 -205
  235. package/src/layer/GeoJSONUtil.js +85 -0
  236. package/src/layer/HeatLayer.js +9 -11
  237. package/src/layer/ImageOverlay.js +19 -30
  238. package/src/layer/Layer.js +8 -10
  239. package/src/layer/LayerGroup.js +71 -0
  240. package/src/layer/Popup.js +31 -46
  241. package/src/layer/SVGOverlay.js +1 -5
  242. package/src/layer/Tooltip.js +15 -19
  243. package/src/layer/VideoOverlay.js +12 -15
  244. package/src/layer/marker/DefaultIcon.js +15 -61
  245. package/src/layer/marker/DivIcon.js +10 -12
  246. package/src/layer/marker/Icon.js +9 -12
  247. package/src/layer/marker/Marker.Drag.js +1 -1
  248. package/src/layer/marker/Marker.Move.js +2 -3
  249. package/src/layer/marker/Marker.js +83 -41
  250. package/src/layer/marker/MarkerClusterGroup.js +370 -0
  251. package/src/layer/marker/SvgIcon.js +7 -9
  252. package/src/layer/marker/index.js +1 -0
  253. package/src/layer/tile/GridLayer.js +104 -134
  254. package/src/layer/tile/TileLayer.js +35 -43
  255. package/src/layer/tile/WMSTileLayer.js +26 -24
  256. package/src/layer/vector/Canvas.js +3 -5
  257. package/src/layer/vector/Circle.js +5 -2
  258. package/src/layer/vector/CircleMarker.js +17 -6
  259. package/src/layer/vector/Path.DashAnimation.js +1 -2
  260. package/src/layer/vector/Path.js +30 -21
  261. package/src/layer/vector/Polygon.js +28 -5
  262. package/src/layer/vector/Polyline.js +26 -7
  263. package/src/layer/vector/Renderer.getRenderer.js +17 -17
  264. package/src/layer/vector/SVG.js +5 -5
  265. package/src/map/Map.Rotation.js +19 -11
  266. package/src/map/Map.js +163 -154
  267. package/src/map/handler/BoxZoomHandler.js +9 -8
  268. package/src/map/handler/DisplaceHandler.js +6 -8
  269. package/src/map/handler/DragHandler.js +26 -29
  270. package/src/map/handler/KeyboardHandler.js +44 -50
  271. package/src/map/handler/PinchZoomHandler.js +16 -5
  272. package/src/map/handler/ScrollWheelZoomHandler.js +6 -4
  273. package/src/map/handler/TapHoldHandler.js +15 -4
  274. package/src/map/index.js +1 -1
  275. package/src/maplair.css +148 -98
  276. package/dist/esm/core/Browser.js +0 -100
  277. package/dist/esm/core/Browser.js.map +0 -1
  278. package/dist/images/layers.svg +0 -1
  279. package/dist/images/marker-icon.svg +0 -1
  280. package/dist/images/marker-shadow.svg +0 -1
  281. package/src/core/Browser.js +0 -110
  282. package/src/images/layers.svg +0 -1
  283. package/src/images/marker-icon.svg +0 -1
  284. package/src/images/marker-shadow.svg +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DomEvent.js","names":["Util.splitWords","Util.stamp","Browser"],"sources":["../../../src/dom/DomEvent.js"],"sourcesContent":["import {Point} from '../geometry/Point.js';\nimport * as Util from '../core/Util.js';\nimport Browser from '../core/Browser.js';\nimport {addDoubleTapListener, removeDoubleTapListener} from './DomEvent.DoubleTap.js';\nimport {getScale} from './DomUtil.js';\n\nimport * as PointerEvents from './DomEvent.PointerEvents.js';\nexport {PointerEvents};\n\n// DomEvent: utility functions to work with the\n// [DOM events](https://developer.mozilla.org/docs/Web/API/Event), used by Maplair\n// internally. The functions return the `DomEvent` namespace for chaining.\n\n// Inspired by John Resig, Dean Edwards and YUI addEvent implementations.\n\n/**\n * Adds a listener function (`fn`) to a particular DOM event type of the\n * element `obj`. You can optionally specify the context of the listener\n * (object the `this` keyword will point to). You can also pass several\n * space-separated types (e.g. `'click dblclick'`). Alternatively, adds a set of\n * type/listener pairs, e.g. `{click: onClick, pointermove: onPointerMove}`, with the\n * context as third argument.\n * @param {EventTarget} obj\n * @param {string|Record<string, (ev: any) => void>} types\n * @param {((ev: any) => void)|object} [fn]\n * @param {object} [context]\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function on(obj, types, fn, context) {\n\n\tif (types && typeof types === 'object') {\n\t\tfor (const [type, listener] of Object.entries(types)) {\n\t\t\taddOne(obj, type, listener, fn);\n\t\t}\n\t} else {\n\t\tfor (const type of Util.splitWords(types)) {\n\t\t\taddOne(obj, type, fn, context);\n\t\t}\n\t}\n\n\treturn this;\n}\n\nconst eventsKey = '_maplair_events';\n\n/**\n * Removes a previously added listener function.\n * Note that if you passed a custom context to on, you must pass the same\n * context to `off` in order to remove the listener. Alternatively, removes a set of\n * type/listener pairs, e.g. `{click: onClick, pointermove: onPointerMove}`; with\n * `types` only, removes all previously added listeners of given types; with the\n * element only, removes all previously added listeners from the given element.\n * @param {EventTarget} obj\n * @param {string|Record<string, (ev: any) => void>} [types]\n * @param {((ev: any) => void)|object} [fn]\n * @param {object} [context]\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function off(obj, types, fn, context) {\n\n\tif (arguments.length === 1) {\n\t\tbatchRemove(obj);\n\t\tdelete obj[eventsKey];\n\n\t} else if (types && typeof types === 'object') {\n\t\tfor (const [type, listener] of Object.entries(types)) {\n\t\t\tremoveOne(obj, type, listener, fn);\n\t\t}\n\n\t} else {\n\t\ttypes = Util.splitWords(types);\n\n\t\tif (arguments.length === 2) {\n\t\t\tbatchRemove(obj, type => types.includes(type));\n\t\t} else {\n\t\t\tfor (const type of types) {\n\t\t\t\tremoveOne(obj, type, fn, context);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn this;\n}\n\nconst DIGIT_RE = /\\d/;\n\nfunction batchRemove(obj, filterFn) {\n\tfor (const id of Object.keys(obj[eventsKey] ?? {})) {\n\t\tconst type = id.split(DIGIT_RE)[0];\n\t\tif (!filterFn || filterFn(type)) {\n\t\t\tremoveOne(obj, type, null, null, id);\n\t\t}\n\t}\n}\n\nconst pointerSubst = {\n\tpointerenter: 'pointerover',\n\tpointerleave: 'pointerout',\n\twheel: typeof window === 'undefined' ? false : !('onwheel' in window) && 'mousewheel'\n};\n\nfunction addOne(obj, type, fn, context) {\n\tconst id = type + Util.stamp(fn) + (context ? `_${Util.stamp(context)}` : '');\n\n\tif (obj[eventsKey] && obj[eventsKey][id]) { return this; }\n\n\tlet handler = function (e) {\n\t\treturn fn.call(context || obj, e);\n\t};\n\n\tconst originalHandler = handler;\n\n\tif (Browser.touch && (type === 'dblclick')) {\n\t\thandler = addDoubleTapListener(obj, handler);\n\n\t} else if ('addEventListener' in obj) {\n\n\t\tif (type === 'wheel' || type === 'mousewheel') {\n\t\t\tobj.addEventListener(pointerSubst[type] || type, handler, {passive: false});\n\t\t} else if (type === 'pointerenter' || type === 'pointerleave') {\n\t\t\thandler = function (e) {\n\t\t\t\tif (isExternalTarget(obj, e)) {\n\t\t\t\t\toriginalHandler(e);\n\t\t\t\t}\n\t\t\t};\n\t\t\tobj.addEventListener(pointerSubst[type], handler, false);\n\n\t\t} else {\n\t\t\tobj.addEventListener(type, originalHandler, false);\n\t\t}\n\n\t} else {\n\t\tobj.attachEvent(`on${type}`, handler);\n\t}\n\n\tobj[eventsKey] ??= {};\n\tobj[eventsKey][id] = handler;\n}\n\nfunction removeOne(obj, type, fn, context, id) {\n\tid ??= type + Util.stamp(fn) + (context ? `_${Util.stamp(context)}` : '');\n\tconst handler = obj[eventsKey] && obj[eventsKey][id];\n\n\tif (!handler) { return this; }\n\n\tif (Browser.touch && (type === 'dblclick')) {\n\t\tremoveDoubleTapListener(obj, handler);\n\n\t} else if ('removeEventListener' in obj) {\n\n\t\tobj.removeEventListener(pointerSubst[type] || type, handler, false);\n\n\t} else {\n\t\tobj.detachEvent(`on${type}`, handler);\n\t}\n\n\tobj[eventsKey][id] = null;\n}\n\n/**\n * Stop the given event from propagation to parent elements. Used inside the listener\n * functions:\n * ```js\n * DomEvent.on(div, 'click', DomEvent.stopPropagation);\n * ```\n * Also accepts a Maplair event with an `originalEvent`.\n * @param {Event|{originalEvent: Event}} e\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function stopPropagation(e) {\n\n\t// feature detection rather than `instanceof Event`, which fails for events from other windows (e.g. iframes)\n\tif (e.stopPropagation) {\n\t\te.stopPropagation();\n\t} else if (e.originalEvent) { // In case of Maplair event.\n\t\te.originalEvent._stopped = true;\n\t} else {\n\t\t// custom Maplair event\n\t\tconsole.debug('Unsupported event', e);\n\t}\n\n\treturn this;\n}\n\n/**\n * Adds `stopPropagation` to the element's `'wheel'` events (plus browser variants).\n * @param {HTMLElement} el\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function disableScrollPropagation(el) {\n\taddOne(el, 'wheel', stopPropagation);\n\treturn this;\n}\n\n/**\n * Adds `stopPropagation` to the element's `'dblclick'`, `'contextmenu'`\n * and `'pointerdown'` events (plus browser variants).\n * For `'click'` events, prevents the map from handling the click\n * while still allowing the native DOM click event to propagate normally.\n * @param {HTMLElement} el\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function disableClickPropagation(el) {\n\ton(el, 'pointerdown dblclick contextmenu', stopPropagation);\n\tel['_maplair_disable_click'] = true;\n\treturn this;\n}\n\n/**\n * Prevents the default action of the DOM Event `e` from happening (such as\n * following a link in the href of the a element, or doing a POST request\n * with page reload when a `<form>` is submitted).\n * Use it inside listener functions.\n * @param {Event} e\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function preventDefault(e) {\n\te.preventDefault?.();\n\treturn this;\n}\n\n/**\n * Does `stopPropagation` and `preventDefault` at the same time.\n * @param {Event} e\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function stop(e) {\n\tpreventDefault(e);\n\tstopPropagation(e);\n\treturn this;\n}\n\n/**\n * Returns an array containing the `HTMLElement`s that the given DOM event\n * should propagate to (if not stopped).\n * @param {Event} ev\n * @returns {EventTarget[]}\n */\nexport function getPropagationPath(ev) {\n\treturn ev.composedPath();\n}\n\n\n/**\n * Gets normalized pointer position from a DOM event relative to the\n * `container` (border excluded) or to the whole page if not specified.\n * @param {MouseEvent|Touch} e\n * @param {HTMLElement} [container]\n * @returns {Point}\n */\nexport function getPointerPosition(e, container) {\n\tif (!container) {\n\t\treturn new Point(e.clientX, e.clientY);\n\t}\n\n\tconst scale = getScale(container),\n\toffset = scale.boundingClientRect; // left and top values are in page scale (like the event clientX/Y)\n\n\treturn new Point(\n\t\t// offset.left/top values are in page scale (like clientX/Y),\n\t\t// whereas clientLeft/Top (border width) values are the original values (before CSS scale applies).\n\t\t(e.clientX - offset.left) / scale.x - container.clientLeft,\n\t\t(e.clientY - offset.top) / scale.y - container.clientTop\n\t);\n}\n\n/**\n * Gets the wheel pixel factor based on the devicePixelRatio.\n * @returns {number}\n */\nexport function getWheelPxFactor() {\n\t// We need double the scroll pixels (see #7403 and #4538) for all Browsers\n\t// except OSX (Mac) -> 3x, Chrome running on Linux 1x\n\tconst ratio = window.devicePixelRatio;\n\treturn Browser.linux && Browser.chrome ? ratio :\n\t\tBrowser.mac ? ratio * 3 :\n\t\tratio > 0 ? 2 * ratio : 1;\n}\n\n/**\n * Gets normalized wheel delta from a wheel DOM event, in vertical\n * pixels scrolled (negative if scrolling down).\n * Events from pointing devices without precise scrolling are mapped to\n * a best guess of 60 pixels.\n * @param {WheelEvent} e\n * @returns {number}\n */\nexport function getWheelDelta(e) {\n\treturn (e.deltaY && e.deltaMode === 0) ? -e.deltaY / getWheelPxFactor() : // Pixels\n\t\t(e.deltaY && e.deltaMode === 1) ? -e.deltaY * 20 : // Lines\n\t\t(e.deltaY && e.deltaMode === 2) ? -e.deltaY * 60 : // Pages\n\t\t(e.deltaX || e.deltaZ) ? 0 :\t// Skip horizontal/depth wheel events\n\t\t0;\n}\n\n/**\n * Checks if the pointer really left/entered the element `el` (for\n * `pointerenter`/`pointerleave`).\n * @internal\n * @param {Node} el\n * @param {MouseEvent} e\n * @returns {boolean}\n */\nexport function isExternalTarget(el, e) {\n\n\tlet related = e.relatedTarget;\n\n\tif (!related) { return true; }\n\n\ttry {\n\t\twhile (related && (related !== el)) {\n\t\t\trelated = related.parentNode;\n\t\t}\n\t} catch (err) {\n\t\treturn false;\n\t}\n\treturn (related !== el);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,GAAG,KAAK,OAAO,IAAI,SAAS;CAE3C,IAAI,SAAS,OAAO,UAAU,UAC7B,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,KAAK,GAClD,OAAO,KAAK,MAAM,UAAU,EAAE;MAG/B,KAAK,MAAM,QAAQA,WAAgB,KAAK,GACvC,OAAO,KAAK,MAAM,IAAI,OAAO;CAI/B,OAAO;AACR;AAEA,MAAM,YAAY;;;;;;;;;;;;;;AAelB,SAAgB,IAAI,KAAK,OAAO,IAAI,SAAS;CAE5C,IAAI,UAAU,WAAW,GAAG;EAC3B,YAAY,GAAG;EACf,OAAO,IAAI;CAEZ,OAAO,IAAI,SAAS,OAAO,UAAU,UACpC,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,KAAK,GAClD,UAAU,KAAK,MAAM,UAAU,EAAE;MAG5B;EACN,QAAQA,WAAgB,KAAK;EAE7B,IAAI,UAAU,WAAW,GACxB,YAAY,MAAK,SAAQ,MAAM,SAAS,IAAI,CAAC;OAE7C,KAAK,MAAM,QAAQ,OAClB,UAAU,KAAK,MAAM,IAAI,OAAO;CAGnC;CAEA,OAAO;AACR;AAEA,MAAM,WAAW;AAEjB,SAAS,YAAY,KAAK,UAAU;CACnC,KAAK,MAAM,MAAM,OAAO,KAAK,IAAI,cAAc,CAAC,CAAC,GAAG;EACnD,MAAM,OAAO,GAAG,MAAM,QAAQ,C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AAc,GAAG;CAChC,OAAQ,EAAE,UAAU,EAAE,cAAc,IAAK,CAAC,EAAE,SAAS,iBAAiB,IACpE,EAAE,UAAU,EAAE,cAAc,IAAK,CAAC,EAAE,SAAS,KAC7C,EAAE,UAAU,EAAE,cAAc,IAAK,CAAC,EAAE,SAAS,KAC7C,EAAE,UAAU,EAAE,SAAU,IACzB;AACF;;;;;;;;;AAUA,SAAgB,iBAAiB,IAAI,GAAG;CAEvC,IAAI,UAAU,EAAE;CAEhB,IAAI,CAAC,SAAW,OAAO;CAEvB,IAAI;EACH,OAAO,WAAY,YAAY,IAC9B,UAAU,QAAQ;CAEpB,SAAS,KAAK;EACb,OAAO;CACR;CACA,OAAQ,YAAY;AACrB"}
1
+ {"version":3,"file":"DomEvent.js","names":["Util.splitWords","Util.stamp"],"sources":["../../../src/dom/DomEvent.js"],"sourcesContent":["import {Point} from '../geometry/Point.js';\nimport * as Util from '../core/Util.js';\nimport {addDoubleTapListener, removeDoubleTapListener} from './DomEvent.DoubleTap.js';\nimport {getScale} from './DomUtil.js';\n\nimport * as PointerEvents from './DomEvent.PointerEvents.js';\nexport {PointerEvents};\n\n// DomEvent: utility functions to work with the\n// [DOM events](https://developer.mozilla.org/docs/Web/API/Event), used by Maplair\n// internally. The functions return the `DomEvent` namespace for chaining.\n\n// Inspired by John Resig, Dean Edwards and YUI addEvent implementations.\n\n/**\n * Adds a listener function (`fn`) to a particular DOM event type of the\n * element `obj`. You can optionally specify the context of the listener\n * (object the `this` keyword will point to). You can also pass several\n * space-separated types (e.g. `'click dblclick'`). Alternatively, adds a set of\n * type/listener pairs, e.g. `{click: onClick, pointermove: onPointerMove}`, with the\n * context as third argument.\n * @param {EventTarget} obj\n * @param {string|Record<string, (ev: any) => void>} types\n * @param {((ev: any) => void)|object} [fn]\n * @param {object} [context]\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function on(obj, types, fn, context) {\n\n\tif (types && typeof types === 'object') {\n\t\tfor (const [type, listener] of Object.entries(types)) {\n\t\t\taddOne(obj, type, listener, fn);\n\t\t}\n\t} else {\n\t\tfor (const type of Util.splitWords(types)) {\n\t\t\taddOne(obj, type, fn, context);\n\t\t}\n\t}\n\n\treturn this;\n}\n\nconst eventsKey = '_maplair_events';\n\n/**\n * Removes a previously added listener function.\n * Note that if you passed a custom context to on, you must pass the same\n * context to `off` in order to remove the listener. Alternatively, removes a set of\n * type/listener pairs, e.g. `{click: onClick, pointermove: onPointerMove}`; with\n * `types` only, removes all previously added listeners of given types; with the\n * element only, removes all previously added listeners from the given element.\n * @param {EventTarget} obj\n * @param {string|Record<string, (ev: any) => void>} [types]\n * @param {((ev: any) => void)|object} [fn]\n * @param {object} [context]\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function off(obj, types, fn, context) {\n\n\tif (arguments.length === 1) {\n\t\tbatchRemove(obj);\n\t\tdelete obj[eventsKey];\n\n\t} else if (types && typeof types === 'object') {\n\t\tfor (const [type, listener] of Object.entries(types)) {\n\t\t\tremoveOne(obj, type, listener, fn);\n\t\t}\n\n\t} else {\n\t\ttypes = Util.splitWords(types);\n\n\t\tif (arguments.length === 2) {\n\t\t\tbatchRemove(obj, type => types.includes(type));\n\t\t} else {\n\t\t\tfor (const type of types) {\n\t\t\t\tremoveOne(obj, type, fn, context);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn this;\n}\n\nconst DIGIT_RE = /\\d/;\n\nfunction batchRemove(obj, filterFn) {\n\tfor (const id of Object.keys(obj[eventsKey] ?? {})) {\n\t\tconst type = id.split(DIGIT_RE)[0];\n\t\tif (!filterFn || filterFn(type)) {\n\t\t\tremoveOne(obj, type, null, null, id);\n\t\t}\n\t}\n}\n\nfunction addOne(obj, type, fn, context) {\n\tconst id = type + Util.stamp(fn) + (context ? `_${Util.stamp(context)}` : '');\n\n\tif (obj[eventsKey] && obj[eventsKey][id]) { return this; }\n\n\tlet handler = function (e) {\n\t\treturn fn.call(context || obj, e);\n\t};\n\n\tif (type === 'dblclick') {\n\t\thandler = addDoubleTapListener(obj, handler);\n\t} else {\n\t\tobj.addEventListener(type, handler, type === 'wheel' ? {passive: false} : false);\n\t}\n\n\tobj[eventsKey] ??= {};\n\tobj[eventsKey][id] = handler;\n}\n\nfunction removeOne(obj, type, fn, context, id) {\n\tid ??= type + Util.stamp(fn) + (context ? `_${Util.stamp(context)}` : '');\n\tconst handler = obj[eventsKey] && obj[eventsKey][id];\n\n\tif (!handler) { return this; }\n\n\tif (type === 'dblclick') {\n\t\tremoveDoubleTapListener(obj, handler);\n\t} else {\n\t\tobj.removeEventListener(type, handler, false);\n\t}\n\n\tobj[eventsKey][id] = null;\n}\n\n/**\n * Stop the given event from propagation to parent elements. Used inside the listener\n * functions:\n * ```js\n * DomEvent.on(div, 'click', DomEvent.stopPropagation);\n * ```\n * Also accepts a Maplair event with an `originalEvent`.\n * @param {Event|{originalEvent: Event}} e\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function stopPropagation(e) {\n\n\t// feature detection rather than `instanceof Event`, which fails for events from other windows (e.g. iframes)\n\tif (e.stopPropagation) {\n\t\te.stopPropagation();\n\t} else if (e.originalEvent) { // In case of Maplair event.\n\t\te.originalEvent._stopped = true;\n\t} else {\n\t\t// custom Maplair event\n\t\tconsole.debug('Unsupported event', e);\n\t}\n\n\treturn this;\n}\n\n/**\n * Adds `stopPropagation` to the element's `'wheel'` events (plus browser variants).\n * @param {HTMLElement} el\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function disableScrollPropagation(el) {\n\taddOne(el, 'wheel', stopPropagation);\n\treturn this;\n}\n\n/**\n * Adds `stopPropagation` to the element's `'dblclick'`, `'contextmenu'`\n * and `'pointerdown'` events (plus browser variants).\n * For `'click'` events, prevents the map from handling the click\n * while still allowing the native DOM click event to propagate normally.\n * @param {HTMLElement} el\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function disableClickPropagation(el) {\n\ton(el, 'pointerdown dblclick contextmenu', stopPropagation);\n\tel['_maplair_disable_click'] = true;\n\treturn this;\n}\n\n/**\n * Prevents the default action of the DOM Event `e` from happening (such as\n * following a link in the href of the a element, or doing a POST request\n * with page reload when a `<form>` is submitted).\n * Use it inside listener functions.\n * @param {Event} e\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function preventDefault(e) {\n\te.preventDefault?.();\n\treturn this;\n}\n\n/**\n * Does `stopPropagation` and `preventDefault` at the same time.\n * @param {Event} e\n * @returns {typeof import('./DomEvent.js')}\n */\nexport function stop(e) {\n\tpreventDefault(e);\n\tstopPropagation(e);\n\treturn this;\n}\n\n/**\n * Gets normalized pointer position from a DOM event relative to the\n * `container` (border excluded) or to the whole page if not specified.\n * @param {MouseEvent|Touch} e\n * @param {HTMLElement} [container]\n * @returns {Point}\n */\nexport function getPointerPosition(e, container) {\n\tif (!container) {\n\t\treturn new Point(e.clientX, e.clientY);\n\t}\n\n\tconst scale = getScale(container),\n\toffset = scale.boundingClientRect; // left and top values are in page scale (like the event clientX/Y)\n\n\treturn new Point(\n\t\t// offset.left/top values are in page scale (like clientX/Y),\n\t\t// whereas clientLeft/Top (border width) values are the original values (before CSS scale applies).\n\t\t(e.clientX - offset.left) / scale.x - container.clientLeft,\n\t\t(e.clientY - offset.top) / scale.y - container.clientTop\n\t);\n}\n\n/**\n * Gets the wheel pixel factor based on the devicePixelRatio.\n * @returns {number}\n */\nexport function getWheelPxFactor() {\n\t// We need double the scroll pixels (see #7403 and #4538)\n\treturn window.devicePixelRatio * 2;\n}\n\n/**\n * Gets normalized wheel delta from a wheel DOM event, in vertical\n * pixels scrolled (negative if scrolling down).\n * Events from pointing devices without precise scrolling are mapped to\n * a best guess of 60 pixels.\n * @param {WheelEvent} e\n * @returns {number}\n */\nexport function getWheelDelta(e) {\n\treturn (e.deltaY && e.deltaMode === 0) ? -e.deltaY / getWheelPxFactor() : // Pixels\n\t\t(e.deltaY && e.deltaMode === 1) ? -e.deltaY * 20 : // Lines\n\t\t(e.deltaY && e.deltaMode === 2) ? -e.deltaY * 60 : // Pages\n\t\t(e.deltaX || e.deltaZ) ? 0 :\t// Skip horizontal/depth wheel events\n\t\t0;\n}\n\n/**\n * Checks if the pointer really left/entered the element `el` (for\n * `pointerover`/`pointerout`).\n * @internal\n * @param {Node} el\n * @param {MouseEvent} e\n * @returns {boolean}\n */\nexport function isExternalTarget(el, e) {\n\treturn !el.contains(e.relatedTarget);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,GAAG,KAAK,OAAO,IAAI,SAAS;CAE3C,IAAI,SAAS,OAAO,UAAU,UAC7B,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,KAAK,GAClD,OAAO,KAAK,MAAM,UAAU,EAAE;MAG/B,KAAK,MAAM,QAAQA,WAAgB,KAAK,GACvC,OAAO,KAAK,MAAM,IAAI,OAAO;CAI/B,OAAO;AACR;AAEA,MAAM,YAAY;;;;;;;;;;;;;;AAelB,SAAgB,IAAI,KAAK,OAAO,IAAI,SAAS;CAE5C,IAAI,UAAU,WAAW,GAAG;EAC3B,YAAY,GAAG;EACf,OAAO,IAAI;CAEZ,OAAO,IAAI,SAAS,OAAO,UAAU,UACpC,KAAK,MAAM,CAAC,MAAM,aAAa,OAAO,QAAQ,KAAK,GAClD,UAAU,KAAK,MAAM,UAAU,EAAE;MAG5B;EACN,QAAQA,WAAgB,KAAK;EAE7B,IAAI,UAAU,WAAW,GACxB,YAAY,MAAK,SAAQ,MAAM,SAAS,IAAI,CAAC;OAE7C,KAAK,MAAM,QAAQ,OAClB,UAAU,KAAK,MAAM,IAAI,OAAO;CAGnC;CAEA,OAAO;AACR;AAEA,MAAM,WAAW;AAEjB,SAAS,YAAY,KAAK,UAAU;CACnC,KAAK,MAAM,MAAM,OAAO,KAAK,IAAI,cAAc,CAAC,CAAC,GAAG;EACnD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,CAAC;EAChC,IAAI,CAAC,YAAY,SAAS,IAAI,GAC7B,UAAU,KAAK,MAAM,MAAM,MAAM,EAAE;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AK,GAAG;CACvB,eAAe,CAAC;CAChB,gBAAgB,CAAC;CACjB,OAAO;AACR;;;;;;;;AASA,SAAgB,mBAAmB,GAAG,WAAW;CAChD,IAAI,CAAC,WACJ,OAAO,IAAI,MAAM,EAAE,SAAS,EAAE,OAAO;CAGtC,MAAM,QAAQ,SAAS,SAAS,GAChC,SAAS,MAAM;CAEf,OAAO,IAAI,OAGT,EAAE,UAAU,OAAO,QAAQ,MAAM,IAAI,UAAU,aAC/C,EAAE,UAAU,OAAO,OAAO,MAAM,IAAI,UAAU,SAChD;AACD;;;;;AAMA,SAAgB,mBAAmB;CAElC,OAAO,OAAO,mBAAmB;AAClC;;;;;;;;;AAUA,SAAgB,cAAc,GAAG;CAChC,OAAQ,EAAE,UAAU,EAAE,cAAc,IAAK,CAAC,EAAE,SAAS,iBAAiB,IACpE,EAAE,UAAU,EAAE,cAAc,IAAK,CAAC,EAAE,SAAS,KAC7C,EAAE,UAAU,EAAE,cAAc,IAAK,CAAC,EAAE,SAAS,KAC7C,EAAE,UAAU,EAAE,SAAU,IACzB;AACF;;;;;;;;;AAUA,SAAgB,iBAAiB,IAAI,GAAG;CACvC,OAAO,CAAC,GAAG,SAAS,EAAE,aAAa;AACpC"}
@@ -5,15 +5,11 @@ import { off, on, preventDefault } from "./DomEvent.js";
5
5
  var DomUtil_exports = /* @__PURE__ */ __exportAll({
6
6
  create: () => create,
7
7
  disableImageDrag: () => disableImageDrag,
8
- disableTextSelection: () => disableTextSelection,
9
8
  enableImageDrag: () => enableImageDrag,
10
- enableTextSelection: () => enableTextSelection,
11
9
  get: () => get,
12
10
  getPosition: () => getPosition,
13
11
  getScale: () => getScale,
14
12
  getSizedParentNode: () => getSizedParentNode,
15
- preventOutline: () => preventOutline,
16
- restoreOutline: () => restoreOutline,
17
13
  setPosition: () => setPosition,
18
14
  setTransform: () => setTransform,
19
15
  toBack: () => toBack,
@@ -50,7 +46,9 @@ function create(tagName, className, container) {
50
46
  */
51
47
  function toFront(el) {
52
48
  const parent = el.parentNode;
53
- if (parent && parent.lastChild !== el) parent.appendChild(el);
49
+ if (!parent || parent.lastChild === el) return;
50
+ if (el.matches(":hover")) while (el.nextSibling) parent.insertBefore(el.nextSibling, el);
51
+ else parent.appendChild(el);
54
52
  }
55
53
  /**
56
54
  * Makes `el` the first child of its parent, so it renders behind the other children.
@@ -59,7 +57,9 @@ function toFront(el) {
59
57
  */
60
58
  function toBack(el) {
61
59
  const parent = el.parentNode;
62
- if (parent && parent.firstChild !== el) parent.insertBefore(el, parent.firstChild);
60
+ if (!parent || parent.firstChild === el) return;
61
+ if (el.matches(":hover")) while (el.previousSibling) parent.insertBefore(el.previousSibling, el.nextSibling);
62
+ else parent.insertBefore(el, parent.firstChild);
63
63
  }
64
64
  /**
65
65
  * Resets the 3D CSS transform of `el` so it is translated by `offset` pixels
@@ -77,16 +77,18 @@ function setTransform(el, offset, scale) {
77
77
  }
78
78
  const positions = /* @__PURE__ */ new WeakMap();
79
79
  /**
80
- * Sets the position of `el` to coordinates specified by `point`,
81
- * using CSS translate or top/left positioning depending on the browser
82
- * (used by Maplair internally to position its layers).
80
+ * Sets the position of `el` to coordinates specified by `point` using a CSS translate
81
+ * (used by Maplair internally to position its layers). With `flat`, the translate is 2D,
82
+ * so `el` is painted into its parent's compositor layer instead of getting a layer of its own.
83
83
  * @param {HTMLElement|SVGElement} el
84
84
  * @param {Point} point
85
+ * @param {boolean} [flat]
85
86
  * @returns {void}
86
87
  */
87
- function setPosition(el, point) {
88
+ function setPosition(el, point, flat) {
88
89
  positions.set(el, point);
89
- setTransform(el, point);
90
+ if (flat) el.style.transform = `translate(${point.x}px, ${point.y}px)`;
91
+ else setTransform(el, point);
90
92
  }
91
93
  /**
92
94
  * Returns the coordinates of an element previously positioned with setPosition.
@@ -96,31 +98,6 @@ function setPosition(el, point) {
96
98
  function getPosition(el) {
97
99
  return positions.get(el) ?? new Point(0, 0);
98
100
  }
99
- const documentStyle = typeof document === "undefined" ? {} : document.documentElement.style;
100
- const userSelectProp = ["userSelect", "WebkitUserSelect"].find((prop) => prop in documentStyle);
101
- let prevUserSelect;
102
- /**
103
- * Prevents the user from selecting text in the document. Used internally
104
- * by Maplair to override the behaviour of any click-and-drag interaction on
105
- * the map. Affects drag interactions on the whole document.
106
- * @returns {void}
107
- */
108
- function disableTextSelection() {
109
- const value = documentStyle[userSelectProp];
110
- if (value === "none") return;
111
- prevUserSelect = value;
112
- documentStyle[userSelectProp] = "none";
113
- }
114
- /**
115
- * Cancels the effects of a previous
116
- * [`DomUtil.disableTextSelection`](#domutil-disabletextselection).
117
- * @returns {void}
118
- */
119
- function enableTextSelection() {
120
- if (typeof prevUserSelect === "undefined") return;
121
- documentStyle[userSelectProp] = prevUserSelect;
122
- prevUserSelect = void 0;
123
- }
124
101
  /**
125
102
  * Prevents the user from generating `dragstart` DOM events, usually generated when
126
103
  * the user drags an image.
@@ -137,37 +114,6 @@ function disableImageDrag() {
137
114
  function enableImageDrag() {
138
115
  off(window, "dragstart", preventDefault);
139
116
  }
140
- let _outlineElement;
141
- let _outlineStyle;
142
- /**
143
- * Makes the [outline](https://developer.mozilla.org/docs/Web/CSS/outline)
144
- * of the element `element` invisible. Used internally by Maplair to prevent
145
- * focusable elements from displaying an outline when the user performs a
146
- * drag interaction on them.
147
- * @param {HTMLElement} element
148
- * @returns {void}
149
- */
150
- function preventOutline(element) {
151
- while (element.tabIndex === -1) element = element.parentNode;
152
- if (!element.style) return;
153
- restoreOutline();
154
- _outlineElement = element;
155
- _outlineStyle = element.style.outlineStyle;
156
- element.style.outlineStyle = "none";
157
- on(window, "keydown", restoreOutline);
158
- }
159
- /**
160
- * Cancels the effects of a previous
161
- * [`DomUtil.preventOutline`](#domutil-preventoutline).
162
- * @returns {void}
163
- */
164
- function restoreOutline() {
165
- if (!_outlineElement) return;
166
- _outlineElement.style.outlineStyle = _outlineStyle;
167
- _outlineElement = void 0;
168
- _outlineStyle = void 0;
169
- off(window, "keydown", restoreOutline);
170
- }
171
117
  /**
172
118
  * Finds the closest parent node which size (width and height) is not null.
173
119
  * @param {HTMLElement} element
@@ -196,6 +142,6 @@ function getScale(element) {
196
142
  };
197
143
  }
198
144
  //#endregion
199
- export { DomUtil_exports, create, disableImageDrag, disableTextSelection, enableImageDrag, enableTextSelection, get, getPosition, getScale, getSizedParentNode, preventOutline, restoreOutline, setPosition, setTransform, toBack, toFront };
145
+ export { DomUtil_exports, create, disableImageDrag, enableImageDrag, get, getPosition, getScale, getSizedParentNode, setPosition, setTransform, toBack, toFront };
200
146
 
201
147
  //# sourceMappingURL=DomUtil.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DomUtil.js","names":["DomEvent.preventDefault"],"sources":["../../../src/dom/DomUtil.js"],"sourcesContent":["import * as DomEvent from './DomEvent.js';\nimport {Point} from '../geometry/Point.js';\n\n// DomUtil: utility functions to work with the\n// [DOM](https://developer.mozilla.org/docs/Web/API/Document_Object_Model)\n// tree, used by Maplair internally.\n//\n// Most functions expecting or returning a `HTMLElement` also work for\n// SVG elements. The only difference is that classes refer to CSS classes\n// in HTML and SVG classes in SVG.\n\n/**\n * Returns an element given its DOM id, or returns the element itself\n * if it was passed directly.\n * @param {string|HTMLElement} id\n * @returns {HTMLElement|null}\n */\nexport function get(id) {\n\treturn typeof id === 'string' ? document.getElementById(id) : id;\n}\n\n/**\n * Creates an HTML element with `tagName`, sets its class to `className`, and\n * optionally appends it to `container` element.\n * @param {string} tagName\n * @param {string} [className]\n * @param {HTMLElement} [container]\n * @returns {HTMLElement}\n */\nexport function create(tagName, className, container) {\n\tconst el = document.createElement(tagName);\n\tel.className = className ?? '';\n\n\tcontainer?.appendChild(el);\n\treturn el;\n}\n\n/**\n * Makes `el` the last child of its parent, so it renders in front of the other\n * children.\n * @param {Element} el\n * @returns {void}\n */\nexport function toFront(el) {\n\tconst parent = el.parentNode;\n\tif (parent && parent.lastChild !== el) {\n\t\tparent.appendChild(el);\n\t}\n}\n\n/**\n * Makes `el` the first child of its parent, so it renders behind the other children.\n * @param {Element} el\n * @returns {void}\n */\nexport function toBack(el) {\n\tconst parent = el.parentNode;\n\tif (parent && parent.firstChild !== el) {\n\t\tparent.insertBefore(el, parent.firstChild);\n\t}\n}\n\n/**\n * Resets the 3D CSS transform of `el` so it is translated by `offset` pixels\n * and optionally scaled by `scale`. Does not have an effect if the\n * browser doesn't support 3D CSS transforms.\n * @param {HTMLElement|SVGElement} el\n * @param {Point} [offset]\n * @param {number} [scale]\n * @returns {void}\n */\nexport function setTransform(el, offset, scale) {\n\tconst pos = offset ?? new Point(0, 0);\n\n\t// same format as browsers serialize it, so that unchanged positions can be skipped\n\tconst transform = `translate3d(${pos.x}px, ${pos.y}px, 0px)${scale ? ` scale(${scale})` : ''}`;\n\tif (el.style.transform !== transform) {\n\t\tel.style.transform = transform;\n\t}\n}\n\nconst positions = new WeakMap();\n\n/**\n * Sets the position of `el` to coordinates specified by `point`,\n * using CSS translate or top/left positioning depending on the browser\n * (used by Maplair internally to position its layers).\n * @param {HTMLElement|SVGElement} el\n * @param {Point} point\n * @returns {void}\n */\nexport function setPosition(el, point) {\n\tpositions.set(el, point);\n\tsetTransform(el, point);\n}\n\n/**\n * Returns the coordinates of an element previously positioned with setPosition.\n * @param {HTMLElement|SVGElement} el\n * @returns {Point}\n */\nexport function getPosition(el) {\n\t// this method is only used for elements previously positioned using setPosition,\n\t// so it's safe to cache the position for performance\n\treturn positions.get(el) ?? new Point(0, 0);\n}\n\nconst documentStyle = typeof document === 'undefined' ? {} : document.documentElement.style;\n// Safari still needs a vendor prefix, we need to detect with property name is supported.\nconst userSelectProp = ['userSelect', 'WebkitUserSelect'].find(prop => prop in documentStyle);\nlet prevUserSelect;\n\n/**\n * Prevents the user from selecting text in the document. Used internally\n * by Maplair to override the behaviour of any click-and-drag interaction on\n * the map. Affects drag interactions on the whole document.\n * @returns {void}\n */\nexport function disableTextSelection() {\n\tconst value = documentStyle[userSelectProp];\n\n\tif (value === 'none') {\n\t\treturn;\n\t}\n\n\tprevUserSelect = value;\n\tdocumentStyle[userSelectProp] = 'none';\n}\n\n/**\n * Cancels the effects of a previous\n * [`DomUtil.disableTextSelection`](#domutil-disabletextselection).\n * @returns {void}\n */\nexport function enableTextSelection() {\n\tif (typeof prevUserSelect === 'undefined') {\n\t\treturn;\n\t}\n\n\tdocumentStyle[userSelectProp] = prevUserSelect;\n\tprevUserSelect = undefined;\n}\n\n/**\n * Prevents the user from generating `dragstart` DOM events, usually generated when\n * the user drags an image.\n * @returns {void}\n */\nexport function disableImageDrag() {\n\tDomEvent.on(window, 'dragstart', DomEvent.preventDefault);\n}\n\n/**\n * Cancels the effects of a previous\n * [`DomUtil.disableImageDrag`](#domutil-disableimagedrag).\n * @returns {void}\n */\nexport function enableImageDrag() {\n\tDomEvent.off(window, 'dragstart', DomEvent.preventDefault);\n}\n\nlet _outlineElement, _outlineStyle;\n\n/**\n * Makes the [outline](https://developer.mozilla.org/docs/Web/CSS/outline)\n * of the element `element` invisible. Used internally by Maplair to prevent\n * focusable elements from displaying an outline when the user performs a\n * drag interaction on them.\n * @param {HTMLElement} element\n * @returns {void}\n */\nexport function preventOutline(element) {\n\twhile (element.tabIndex === -1) {\n\t\telement = element.parentNode;\n\t}\n\tif (!element.style) { return; }\n\trestoreOutline();\n\t_outlineElement = element;\n\t_outlineStyle = element.style.outlineStyle;\n\telement.style.outlineStyle = 'none';\n\tDomEvent.on(window, 'keydown', restoreOutline);\n}\n\n/**\n * Cancels the effects of a previous\n * [`DomUtil.preventOutline`](#domutil-preventoutline).\n * @returns {void}\n */\nexport function restoreOutline() {\n\tif (!_outlineElement) { return; }\n\t_outlineElement.style.outlineStyle = _outlineStyle;\n\t_outlineElement = undefined;\n\t_outlineStyle = undefined;\n\tDomEvent.off(window, 'keydown', restoreOutline);\n}\n\n/**\n * Finds the closest parent node which size (width and height) is not null.\n * @param {HTMLElement} element\n * @returns {HTMLElement}\n */\nexport function getSizedParentNode(element) {\n\tdo {\n\t\telement = element.parentNode;\n\t} while ((!element.offsetWidth || !element.offsetHeight) && element !== document.body);\n\treturn element;\n}\n\n/**\n * Computes the CSS scale currently applied on the element.\n * Returns an object with `x` and `y` members as horizontal and vertical scales\n * respectively, and `boundingClientRect` as the result of\n * [`getBoundingClientRect()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect).\n * @param {HTMLElement} element\n * @returns {{x: number, y: number, boundingClientRect: DOMRect}}\n */\nexport function getScale(element) {\n\tconst rect = element.getBoundingClientRect();\n\n\treturn {\n\t\tx: rect.width / element.offsetWidth || 1,\n\t\ty: rect.height / element.offsetHeight || 1,\n\t\tboundingClientRect: rect\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,SAAgB,IAAI,IAAI;CACvB,OAAO,OAAO,OAAO,WAAW,SAAS,eAAe,EAAE,IAAI;AAC/D;;;;;;;;;AAUA,SAAgB,OAAO,SAAS,WAAW,WAAW;CACrD,MAAM,KAAK,SAAS,cAAc,OAAO;CACzC,GAAG,YAAY,aAAa;CAE5B,WAAW,YAAY,EAAE;CACzB,OAAO;AACR;;;;;;;AAQA,SAAgB,QAAQ,IAAI;CAC3B,MAAM,SAAS,GAAG;CAClB,IAAI,UAAU,OAAO,cAAc,IAClC,OAAO,YAAY,EAAE;AAEvB;;;;;;AAOA,SAAgB,OAAO,IAAI;CAC1B,MAAM,SAAS,GAAG;CAClB,IAAI,UAAU,OAAO,eAAe,IACnC,OAAO,aAAa,IAAI,OAAO,UAAU;AAE3C;;;;;;;;;;AAWA,SAAgB,aAAa,IAAI,QAAQ,OAAO;CAC/C,MAAM,MAAM,UAAU,IAAI,MAAM,GAAG,CAAC;CAGpC,MAAM,YAAY,eAAe,IAAI,EAAE,MAAM,IAAI,EAAE,UAAU,QAAQ,UAAU,MAAM,KAAK;CAC1F,IAAI,GAAG,MAAM,cAAc,WAC1B,GAAG,MAAM,YAAY;AAEvB;AAEA,MAAM,4BAAY,IAAI,QAAQ;;;;;;;;;AAU9B,SAAgB,YAAY,IAAI,OA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O;AACR;;;;;;;;;AAUA,SAAgB,SAAS,SAAS;CACjC,MAAM,OAAO,QAAQ,sBAAsB;CAE3C,OAAO;EACN,GAAG,KAAK,QAAQ,QAAQ,eAAe;EACvC,GAAG,KAAK,SAAS,QAAQ,gBAAgB;EACzC,oBAAoB;CACrB;AACD"}
1
+ {"version":3,"file":"DomUtil.js","names":["DomEvent.preventDefault"],"sources":["../../../src/dom/DomUtil.js"],"sourcesContent":["import * as DomEvent from './DomEvent.js';\nimport {Point} from '../geometry/Point.js';\n\n// DomUtil: utility functions to work with the\n// [DOM](https://developer.mozilla.org/docs/Web/API/Document_Object_Model)\n// tree, used by Maplair internally.\n//\n// Most functions expecting or returning a `HTMLElement` also work for\n// SVG elements. The only difference is that classes refer to CSS classes\n// in HTML and SVG classes in SVG.\n\n/**\n * Returns an element given its DOM id, or returns the element itself\n * if it was passed directly.\n * @param {string|HTMLElement} id\n * @returns {HTMLElement|null}\n */\nexport function get(id) {\n\treturn typeof id === 'string' ? document.getElementById(id) : id;\n}\n\n/**\n * Creates an HTML element with `tagName`, sets its class to `className`, and\n * optionally appends it to `container` element.\n * @param {string} tagName\n * @param {string} [className]\n * @param {HTMLElement} [container]\n * @returns {HTMLElement}\n */\nexport function create(tagName, className, container) {\n\tconst el = document.createElement(tagName);\n\tel.className = className ?? '';\n\n\tcontainer?.appendChild(el);\n\treturn el;\n}\n\n/**\n * Makes `el` the last child of its parent, so it renders in front of the other\n * children.\n * @param {Element} el\n * @returns {void}\n */\nexport function toFront(el) {\n\tconst parent = el.parentNode;\n\tif (!parent || parent.lastChild === el) { return; }\n\n\t// re-inserting a hovered node (e.g. bringToFront in a pointerover handler) makes Chromium 144+ fire a repeated\n\t// pointerover and lose the next pointerout (#10129), so move the nodes after it instead\n\tif (el.matches(':hover')) {\n\t\twhile (el.nextSibling) { parent.insertBefore(el.nextSibling, el); }\n\t} else {\n\t\tparent.appendChild(el);\n\t}\n}\n\n/**\n * Makes `el` the first child of its parent, so it renders behind the other children.\n * @param {Element} el\n * @returns {void}\n */\nexport function toBack(el) {\n\tconst parent = el.parentNode;\n\tif (!parent || parent.firstChild === el) { return; }\n\n\tif (el.matches(':hover')) { // see toFront\n\t\twhile (el.previousSibling) { parent.insertBefore(el.previousSibling, el.nextSibling); }\n\t} else {\n\t\tparent.insertBefore(el, parent.firstChild);\n\t}\n}\n\n/**\n * Resets the 3D CSS transform of `el` so it is translated by `offset` pixels\n * and optionally scaled by `scale`. Does not have an effect if the\n * browser doesn't support 3D CSS transforms.\n * @param {HTMLElement|SVGElement} el\n * @param {Point} [offset]\n * @param {number} [scale]\n * @returns {void}\n */\nexport function setTransform(el, offset, scale) {\n\tconst pos = offset ?? new Point(0, 0);\n\n\t// same format as browsers serialize it, so that unchanged positions can be skipped\n\tconst transform = `translate3d(${pos.x}px, ${pos.y}px, 0px)${scale ? ` scale(${scale})` : ''}`;\n\tif (el.style.transform !== transform) {\n\t\tel.style.transform = transform;\n\t}\n}\n\nconst positions = new WeakMap();\n\n/**\n * Sets the position of `el` to coordinates specified by `point` using a CSS translate\n * (used by Maplair internally to position its layers). With `flat`, the translate is 2D,\n * so `el` is painted into its parent's compositor layer instead of getting a layer of its own.\n * @param {HTMLElement|SVGElement} el\n * @param {Point} point\n * @param {boolean} [flat]\n * @returns {void}\n */\nexport function setPosition(el, point, flat) {\n\tpositions.set(el, point);\n\tif (flat) {\n\t\tel.style.transform = `translate(${point.x}px, ${point.y}px)`;\n\t} else {\n\t\tsetTransform(el, point);\n\t}\n}\n\n/**\n * Returns the coordinates of an element previously positioned with setPosition.\n * @param {HTMLElement|SVGElement} el\n * @returns {Point}\n */\nexport function getPosition(el) {\n\t// this method is only used for elements previously positioned using setPosition,\n\t// so it's safe to cache the position for performance\n\treturn positions.get(el) ?? new Point(0, 0);\n}\n\n/**\n * Prevents the user from generating `dragstart` DOM events, usually generated when\n * the user drags an image.\n * @returns {void}\n */\nexport function disableImageDrag() {\n\tDomEvent.on(window, 'dragstart', DomEvent.preventDefault);\n}\n\n/**\n * Cancels the effects of a previous\n * [`DomUtil.disableImageDrag`](#domutil-disableimagedrag).\n * @returns {void}\n */\nexport function enableImageDrag() {\n\tDomEvent.off(window, 'dragstart', DomEvent.preventDefault);\n}\n\n/**\n * Finds the closest parent node which size (width and height) is not null.\n * @param {HTMLElement} element\n * @returns {HTMLElement}\n */\nexport function getSizedParentNode(element) {\n\tdo {\n\t\telement = element.parentNode;\n\t} while ((!element.offsetWidth || !element.offsetHeight) && element !== document.body);\n\treturn element;\n}\n\n/**\n * Computes the CSS scale currently applied on the element.\n * Returns an object with `x` and `y` members as horizontal and vertical scales\n * respectively, and `boundingClientRect` as the result of\n * [`getBoundingClientRect()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect).\n * @param {HTMLElement} element\n * @returns {{x: number, y: number, boundingClientRect: DOMRect}}\n */\nexport function getScale(element) {\n\tconst rect = element.getBoundingClientRect();\n\n\treturn {\n\t\tx: rect.width / element.offsetWidth || 1,\n\t\ty: rect.height / element.offsetHeight || 1,\n\t\tboundingClientRect: rect\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAiBA,SAAgB,IAAI,IAAI;CACvB,OAAO,OAAO,OAAO,WAAW,SAAS,eAAe,EAAE,IAAI;AAC/D;;;;;;;;;AAUA,SAAgB,OAAO,SAAS,WAAW,WAAW;CACrD,MAAM,KAAK,SAAS,cAAc,OAAO;CACzC,GAAG,YAAY,aAAa;CAE5B,WAAW,YAAY,EAAE;CACzB,OAAO;AACR;;;;;;;AAQA,SAAgB,QAAQ,IAAI;CAC3B,MAAM,SAAS,GAAG;CAClB,IAAI,CAAC,UAAU,OAAO,cAAc,IAAM;CAI1C,IAAI,GAAG,QAAQ,QAAQ,GACtB,OAAO,GAAG,aAAe,OAAO,aAAa,GAAG,aAAa,EAAE;MAE/D,OAAO,YAAY,EAAE;AAEvB;;;;;;AAOA,SAAgB,OAAO,IAAI;CAC1B,MAAM,SAAS,GAAG;CAClB,IAAI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";
2
2
  import { Point } from "../geometry/Point.js";
3
3
  import { getPointers } from "./DomEvent.PointerEvents.js";
4
4
  import { off, on } from "./DomEvent.js";
5
- import { disableImageDrag, disableTextSelection, enableImageDrag, enableTextSelection, getPosition, getScale, getSizedParentNode, preventOutline, setPosition } from "./DomUtil.js";
5
+ import { disableImageDrag, enableImageDrag, getPosition, getScale, getSizedParentNode, setPosition } from "./DomUtil.js";
6
6
  import { Evented } from "../core/Events.js";
7
7
  //#region src/dom/Draggable.js
8
8
  /** @import {MaplairEvent, DragEndEvent} from '../core/Events.js' */
@@ -38,23 +38,20 @@ import { Evented } from "../core/Events.js";
38
38
  * the drag was finished without inertia, e.g. by disabling the draggable).
39
39
  */
40
40
  var Draggable = class Draggable extends Evented {
41
- static {
42
- this.setDefaultOptions({ clickTolerance: 3 });
43
- }
41
+ static defaultOptions = { clickTolerance: 3 };
44
42
  /**
45
43
  * Creates a `Draggable` object for moving `element` when you start dragging the
46
44
  * `dragStartTarget` element (equals `element` itself by default).
47
45
  * @param {HTMLElement} element
48
46
  * @param {HTMLElement} [dragStartTarget]
49
- * @param {boolean} [preventOutline]
50
47
  * @param {DraggableOptions} [options]
51
48
  */
52
- constructor(element, dragStartTarget, preventOutline, options) {
49
+ constructor(element, dragStartTarget, options) {
50
+ if (typeof options === "boolean") throw new Error("Draggable: the preventOutline argument is removed in Maplair. Pass options as the third argument.");
53
51
  super();
54
52
  setOptions(this, options);
55
53
  this._element = element;
56
54
  this._dragStartTarget = dragStartTarget ?? element;
57
- this._preventOutline = preventOutline;
58
55
  this.callInitHooks(Draggable);
59
56
  }
60
57
  /**
@@ -86,9 +83,7 @@ var Draggable = class Draggable extends Evented {
86
83
  }
87
84
  if (Draggable._dragging || e.shiftKey || e.button !== 0 && e.pointerType !== "touch") return;
88
85
  Draggable._dragging = this;
89
- if (this._preventOutline) preventOutline(this._element);
90
86
  disableImageDrag();
91
- disableTextSelection();
92
87
  if (this._moving) return;
93
88
  this.fire("down");
94
89
  const sizedParent = getSizedParentNode(this._element);
@@ -96,7 +91,7 @@ var Draggable = class Draggable extends Evented {
96
91
  this._startPos = getPosition(this._element);
97
92
  this._parentScale = getScale(sizedParent);
98
93
  on(this._dragStartTarget, "pointermove", this._onMove, this);
99
- on(this._dragStartTarget, "pointerup pointercancel", this._onUp, this);
94
+ on(this._dragStartTarget, "pointerup pointercancel lostpointercapture", this._onUp, this);
100
95
  }
101
96
  _onMove(e) {
102
97
  if (getPointers().length > 1) {
@@ -104,16 +99,17 @@ var Draggable = class Draggable extends Evented {
104
99
  return;
105
100
  }
106
101
  const offset = new Point(e.clientX, e.clientY)._subtract(this._startPoint);
107
- if (!offset.x && !offset.y) return;
108
- if (Math.abs(offset.x) + Math.abs(offset.y) < this.options.clickTolerance) return;
102
+ const dist = Math.abs(offset.x) + Math.abs(offset.y);
103
+ if (!this._moved && (!dist || dist < this.options.clickTolerance)) return;
109
104
  offset.x /= this._parentScale.x;
110
105
  offset.y /= this._parentScale.y;
111
106
  if (e.cancelable) e.preventDefault();
112
107
  if (!this._moved) {
113
108
  this.fire("dragstart", { originalEvent: e });
114
109
  this._moved = true;
115
- this._element.ownerDocument.body.classList.add("maplair-dragging");
116
- this._lastTarget = e.target ?? e.srcElement;
110
+ this._draggingContainer = this._element.closest(".maplair-container") ?? this._element;
111
+ this._draggingContainer.classList.add("maplair-dragging");
112
+ this._lastTarget = e.target;
117
113
  this._lastTarget.classList.add("maplair-drag-target");
118
114
  }
119
115
  this._newPos = this._startPos.add(offset);
@@ -124,10 +120,13 @@ var Draggable = class Draggable extends Evented {
124
120
  _updatePosition() {
125
121
  const e = { originalEvent: this._lastEvent };
126
122
  this.fire("predrag", e);
123
+ const dpr = window.devicePixelRatio;
124
+ this._newPos = this._newPos.multiplyBy(dpr)._round()._divideBy(dpr);
127
125
  setPosition(this._element, this._newPos);
128
126
  this.fire("drag", e);
129
127
  }
130
- _onUp() {
128
+ _onUp(e) {
129
+ if (e.type === "lostpointercapture" && e.buttons) return;
131
130
  this.finishDrag();
132
131
  }
133
132
  /**
@@ -137,15 +136,15 @@ var Draggable = class Draggable extends Evented {
137
136
  * @returns {void}
138
137
  */
139
138
  finishDrag(noInertia) {
140
- this._element.ownerDocument.body.classList.remove("maplair-dragging");
139
+ this._draggingContainer?.classList.remove("maplair-dragging");
140
+ this._draggingContainer = null;
141
141
  if (this._lastTarget) {
142
142
  this._lastTarget.classList.remove("maplair-drag-target");
143
143
  this._lastTarget = null;
144
144
  }
145
145
  off(this._dragStartTarget, "pointermove", this._onMove, this);
146
- off(this._dragStartTarget, "pointerup pointercancel", this._onUp, this);
146
+ off(this._dragStartTarget, "pointerup pointercancel lostpointercapture", this._onUp, this);
147
147
  enableImageDrag();
148
- enableTextSelection();
149
148
  const fireDragend = this._moved && this._moving;
150
149
  this._moving = false;
151
150
  Draggable._dragging = false;
@@ -1 +1 @@
1
- {"version":3,"file":"Draggable.js","names":["PointerEvents.getPointers","DomUtil.getSizedParentNode","DomUtil.getPosition","DomUtil.getScale"],"sources":["../../../src/dom/Draggable.js"],"sourcesContent":["import {Evented} from '../core/Events.js';\nimport * as DomEvent from './DomEvent.js';\nimport * as DomUtil from './DomUtil.js';\nimport * as Util from '../core/Util.js';\nimport {Point} from '../geometry/Point.js';\nimport * as PointerEvents from './DomEvent.PointerEvents.js';\n/** @import {MaplairEvent, DragEndEvent} from '../core/Events.js' */\n\n/**\n * Options of `Draggable`.\n * @typedef {object} DraggableOptions\n * @property {number} [clickTolerance=3] The max number of pixels a user can shift the\n * pointer during a click for it to be considered a valid click (as opposed to a\n * pointer drag).\n */\n\n/**\n * The event object of `dragstart`, `predrag` and `drag` of `Draggable`.\n * @typedef {object} DraggableEvent\n * @property {PointerEvent} originalEvent The DOM event of the pointer which drags.\n * @extends MaplairEvent\n */\n\n/**\n * A class for making DOM elements draggable.\n * Used internally for map and marker dragging. Works on any DOM element.\n *\n * @example\n * ```js\n * const draggable = new Draggable(elementToDrag);\n * draggable.enable();\n * ```\n *\n * @fires down {MaplairEvent} Fired when a drag is about to start.\n * @fires dragstart {DraggableEvent} Fired when a drag starts.\n * @fires predrag {DraggableEvent} Fired continuously during dragging *before* each\n * corresponding update of the element's position.\n * @fires drag {DraggableEvent} Fired continuously during dragging.\n * @fires dragend {DragEndEvent} Fired when the drag ends (with `noInertia: true` if\n * the drag was finished without inertia, e.g. by disabling the draggable).\n */\nexport class Draggable extends Evented {\n\n\tstatic {\n\t\tthis.setDefaultOptions({\n\t\t\tclickTolerance: 3\n\t\t});\n\t}\n\n\t/**\n\t * Creates a `Draggable` object for moving `element` when you start dragging the\n\t * `dragStartTarget` element (equals `element` itself by default).\n\t * @param {HTMLElement} element\n\t * @param {HTMLElement} [dragStartTarget]\n\t * @param {boolean} [preventOutline]\n\t * @param {DraggableOptions} [options]\n\t */\n\tconstructor(element, dragStartTarget, preventOutline, options) {\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\n\t\tthis._element = element;\n\t\tthis._dragStartTarget = dragStartTarget ?? element;\n\t\tthis._preventOutline = preventOutline;\n\n\t\tthis.callInitHooks(Draggable);\n\t}\n\n\t/**\n\t * Enables the dragging ability.\n\t * @returns {void}\n\t */\n\tenable() {\n\t\tif (this._enabled) { return; }\n\n\t\tDomEvent.on(this._dragStartTarget, 'pointerdown', this._onDown, this);\n\n\t\tthis._enabled = true;\n\t}\n\n\t/**\n\t * Disables the dragging ability.\n\t * @returns {void}\n\t */\n\tdisable() {\n\t\tif (!this._enabled) { return; }\n\n\t\t// If we're currently dragging this draggable,\n\t\t// disabling it counts as first ending the drag.\n\t\tif (Draggable._dragging === this) {\n\t\t\tthis.finishDrag(true);\n\t\t}\n\n\t\tDomEvent.off(this._dragStartTarget, 'pointerdown', this._onDown, this);\n\n\t\tthis._enabled = false;\n\t\tthis._moved = false;\n\t}\n\n\t_onDown(e) {\n\t\tthis._moved = false;\n\n\t\tif (this._element.classList.contains('maplair-zoom-anim')) { return; }\n\n\t\tif (PointerEvents.getPointers().length !== 1) {\n\t\t\t// Finish dragging to avoid conflict with touchZoom\n\t\t\tif (Draggable._dragging === this) {\n\t\t\t\tthis.finishDrag();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (Draggable._dragging || e.shiftKey || (e.button !== 0 && e.pointerType !== 'touch')) { return; }\n\t\tDraggable._dragging = this; // Prevent dragging multiple objects at once.\n\n\t\tif (this._preventOutline) {\n\t\t\tDomUtil.preventOutline(this._element);\n\t\t}\n\n\t\tDomUtil.disableImageDrag();\n\t\tDomUtil.disableTextSelection();\n\n\t\tif (this._moving) { return; }\n\n\t\tthis.fire('down');\n\n\t\tconst sizedParent = DomUtil.getSizedParentNode(this._element);\n\n\t\tthis._startPoint = new Point(e.clientX, e.clientY);\n\t\tthis._startPos = DomUtil.getPosition(this._element);\n\n\t\t// Cache the scale, so that we can continuously compensate for it during drag (_onMove).\n\t\tthis._parentScale = DomUtil.getScale(sizedParent);\n\n\t\tDomEvent.on(this._dragStartTarget, 'pointermove', this._onMove, this);\n\t\tDomEvent.on(this._dragStartTarget, 'pointerup pointercancel', this._onUp, this);\n\t}\n\n\t_onMove(e) {\n\t\tif (PointerEvents.getPointers().length > 1) {\n\t\t\tthis._moved = true;\n\t\t\treturn;\n\t\t}\n\n\t\tconst offset = new Point(e.clientX, e.clientY)._subtract(this._startPoint);\n\n\t\tif (!offset.x && !offset.y) { return; }\n\t\tif (Math.abs(offset.x) + Math.abs(offset.y) < this.options.clickTolerance) { return; }\n\n\t\t// We assume that the parent container's position, border and scale do not change for the duration of the drag.\n\t\t// Therefore there is no need to account for the position and border (they are eliminated by the subtraction)\n\t\t// and we can use the cached value for the scale.\n\t\toffset.x /= this._parentScale.x;\n\t\toffset.y /= this._parentScale.y;\n\n\t\tif (e.cancelable) {\n\t\t\te.preventDefault();\n\t\t}\n\n\t\tif (!this._moved) {\n\t\t\tthis.fire('dragstart', {originalEvent: e});\n\n\t\t\tthis._moved = true;\n\n\t\t\tthis._element.ownerDocument.body.classList.add('maplair-dragging');\n\n\t\t\tthis._lastTarget = e.target ?? e.srcElement;\n\t\t\tthis._lastTarget.classList.add('maplair-drag-target');\n\t\t}\n\n\t\tthis._newPos = this._startPos.add(offset);\n\t\tthis._moving = true;\n\n\t\tthis._lastEvent = e;\n\t\tthis._updatePosition();\n\t}\n\n\t_updatePosition() {\n\t\tconst e = {originalEvent: this._lastEvent};\n\n\t\tthis.fire('predrag', e);\n\t\tDomUtil.setPosition(this._element, this._newPos);\n\n\t\tthis.fire('drag', e);\n\t}\n\n\t_onUp() {\n\t\tthis.finishDrag();\n\t}\n\n\t/**\n\t * Ends the current drag.\n\t * @internal\n\t * @param {boolean} [noInertia]\n\t * @returns {void}\n\t */\n\tfinishDrag(noInertia) {\n\t\tthis._element.ownerDocument.body.classList.remove('maplair-dragging');\n\n\t\tif (this._lastTarget) {\n\t\t\tthis._lastTarget.classList.remove('maplair-drag-target');\n\t\t\tthis._lastTarget = null;\n\t\t}\n\n\t\tDomEvent.off(this._dragStartTarget, 'pointermove', this._onMove, this);\n\t\tDomEvent.off(this._dragStartTarget, 'pointerup pointercancel', this._onUp, this);\n\n\t\tDomUtil.enableImageDrag();\n\t\tDomUtil.enableTextSelection();\n\n\t\tconst fireDragend = this._moved && this._moving;\n\n\t\tthis._moving = false;\n\t\tDraggable._dragging = false;\n\n\t\tif (fireDragend) {\n\t\t\tthis.fire('dragend', {\n\t\t\t\tnoInertia,\n\t\t\t\tdistance: this._newPos.distanceTo(this._startPos)\n\t\t\t});\n\t\t}\n\t}\n\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,YAAb,MAAa,kBAAkB,QAAQ;CAEtC;EACC,KAAK,kBAAkB,EACtB,gBAAgB,EACjB,CAAC;CACF;;;;;;;;;CAUA,YAAY,SAAS,iBAAiB,gBAAgB,SAAS;EAC9D,MAAM;EACN,WAAgB,MAAM,OAAO;EAE7B,KAAK,WAAW;EAChB,KAAK,mBAAmB,mBAAmB;EAC3C,KAAK,kBAAkB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
+ {"version":3,"file":"Draggable.js","names":["PointerEvents.getPointers","DomUtil.getSizedParentNode","DomUtil.getPosition","DomUtil.getScale"],"sources":["../../../src/dom/Draggable.js"],"sourcesContent":["import {Evented} from '../core/Events.js';\nimport * as DomEvent from './DomEvent.js';\nimport * as DomUtil from './DomUtil.js';\nimport * as Util from '../core/Util.js';\nimport {Point} from '../geometry/Point.js';\nimport * as PointerEvents from './DomEvent.PointerEvents.js';\n/** @import {MaplairEvent, DragEndEvent} from '../core/Events.js' */\n\n/**\n * Options of `Draggable`.\n * @typedef {object} DraggableOptions\n * @property {number} [clickTolerance=3] The max number of pixels a user can shift the\n * pointer during a click for it to be considered a valid click (as opposed to a\n * pointer drag).\n */\n\n/**\n * The event object of `dragstart`, `predrag` and `drag` of `Draggable`.\n * @typedef {object} DraggableEvent\n * @property {PointerEvent} originalEvent The DOM event of the pointer which drags.\n * @extends MaplairEvent\n */\n\n/**\n * A class for making DOM elements draggable.\n * Used internally for map and marker dragging. Works on any DOM element.\n *\n * @example\n * ```js\n * const draggable = new Draggable(elementToDrag);\n * draggable.enable();\n * ```\n *\n * @fires down {MaplairEvent} Fired when a drag is about to start.\n * @fires dragstart {DraggableEvent} Fired when a drag starts.\n * @fires predrag {DraggableEvent} Fired continuously during dragging *before* each\n * corresponding update of the element's position.\n * @fires drag {DraggableEvent} Fired continuously during dragging.\n * @fires dragend {DragEndEvent} Fired when the drag ends (with `noInertia: true` if\n * the drag was finished without inertia, e.g. by disabling the draggable).\n */\nexport class Draggable extends Evented {\n\n\tstatic defaultOptions = {\n\t\tclickTolerance: 3\n\t};\n\n\t/**\n\t * Creates a `Draggable` object for moving `element` when you start dragging the\n\t * `dragStartTarget` element (equals `element` itself by default).\n\t * @param {HTMLElement} element\n\t * @param {HTMLElement} [dragStartTarget]\n\t * @param {DraggableOptions} [options]\n\t */\n\tconstructor(element, dragStartTarget, options) {\n\t\tif (typeof options === 'boolean') {\n\t\t\tthrow new Error('Draggable: the preventOutline argument is removed in Maplair. Pass options as the third argument.');\n\t\t}\n\t\tsuper();\n\t\tUtil.setOptions(this, options);\n\n\t\tthis._element = element;\n\t\tthis._dragStartTarget = dragStartTarget ?? element;\n\n\t\tthis.callInitHooks(Draggable);\n\t}\n\n\t/**\n\t * Enables the dragging ability.\n\t * @returns {void}\n\t */\n\tenable() {\n\t\tif (this._enabled) { return; }\n\n\t\tDomEvent.on(this._dragStartTarget, 'pointerdown', this._onDown, this);\n\n\t\tthis._enabled = true;\n\t}\n\n\t/**\n\t * Disables the dragging ability.\n\t * @returns {void}\n\t */\n\tdisable() {\n\t\tif (!this._enabled) { return; }\n\n\t\t// If we're currently dragging this draggable,\n\t\t// disabling it counts as first ending the drag.\n\t\tif (Draggable._dragging === this) {\n\t\t\tthis.finishDrag(true);\n\t\t}\n\n\t\tDomEvent.off(this._dragStartTarget, 'pointerdown', this._onDown, this);\n\n\t\tthis._enabled = false;\n\t\tthis._moved = false;\n\t}\n\n\t_onDown(e) {\n\t\tthis._moved = false;\n\n\t\tif (this._element.classList.contains('maplair-zoom-anim')) { return; }\n\n\t\tif (PointerEvents.getPointers().length !== 1) {\n\t\t\t// Finish dragging to avoid conflict with touchZoom\n\t\t\tif (Draggable._dragging === this) {\n\t\t\t\tthis.finishDrag();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (Draggable._dragging || e.shiftKey || (e.button !== 0 && e.pointerType !== 'touch')) { return; }\n\t\tDraggable._dragging = this; // Prevent dragging multiple objects at once.\n\n\t\tDomUtil.disableImageDrag();\n\n\t\tif (this._moving) { return; }\n\n\t\tthis.fire('down');\n\n\t\tconst sizedParent = DomUtil.getSizedParentNode(this._element);\n\n\t\tthis._startPoint = new Point(e.clientX, e.clientY);\n\t\tthis._startPos = DomUtil.getPosition(this._element);\n\n\t\t// Cache the scale, so that we can continuously compensate for it during drag (_onMove).\n\t\tthis._parentScale = DomUtil.getScale(sizedParent);\n\n\t\tDomEvent.on(this._dragStartTarget, 'pointermove', this._onMove, this);\n\t\tDomEvent.on(this._dragStartTarget, 'pointerup pointercancel lostpointercapture', this._onUp, this);\n\t}\n\n\t_onMove(e) {\n\t\tif (PointerEvents.getPointers().length > 1) {\n\t\t\tthis._moved = true;\n\t\t\treturn;\n\t\t}\n\n\t\tconst offset = new Point(e.clientX, e.clientY)._subtract(this._startPoint);\n\n\t\t// once the drag has started, the pointer must be followed even when it comes back near the start point\n\t\tconst dist = Math.abs(offset.x) + Math.abs(offset.y);\n\t\tif (!this._moved && (!dist || dist < this.options.clickTolerance)) { return; }\n\n\t\t// We assume that the parent container's position, border and scale do not change for the duration of the drag.\n\t\t// Therefore there is no need to account for the position and border (they are eliminated by the subtraction)\n\t\t// and we can use the cached value for the scale.\n\t\toffset.x /= this._parentScale.x;\n\t\toffset.y /= this._parentScale.y;\n\n\t\tif (e.cancelable) {\n\t\t\te.preventDefault();\n\t\t}\n\n\t\tif (!this._moved) {\n\t\t\tthis.fire('dragstart', {originalEvent: e});\n\n\t\t\tthis._moved = true;\n\n\t\t\t// on the map container rather than the body, so that toggling it doesn't restyle the whole page\n\t\t\tthis._draggingContainer = this._element.closest('.maplair-container') ?? this._element;\n\t\t\tthis._draggingContainer.classList.add('maplair-dragging');\n\n\t\t\tthis._lastTarget = e.target;\n\t\t\tthis._lastTarget.classList.add('maplair-drag-target');\n\t\t}\n\n\t\tthis._newPos = this._startPos.add(offset);\n\t\tthis._moving = true;\n\n\t\tthis._lastEvent = e;\n\t\tthis._updatePosition();\n\t}\n\n\t_updatePosition() {\n\t\tconst e = {originalEvent: this._lastEvent};\n\n\t\tthis.fire('predrag', e);\n\n\t\t// pointer events can have fractional coordinates; snap them to device pixels, since an edge in the middle of\n\t\t// one is drawn partly transparent on both sides and shows a seam between tiles\n\t\tconst dpr = window.devicePixelRatio;\n\t\tthis._newPos = this._newPos.multiplyBy(dpr)._round()._divideBy(dpr);\n\t\tDomUtil.setPosition(this._element, this._newPos);\n\n\t\tthis.fire('drag', e);\n\t}\n\n\t_onUp(e) {\n\t\t// releasing the button outside the window may fire no pointerup, only a lostpointercapture with no buttons;\n\t\t// capture lost while the button is still held (e.g. the pressed element was removed) shouldn't end the drag\n\t\tif (e.type === 'lostpointercapture' && e.buttons) { return; }\n\t\tthis.finishDrag();\n\t}\n\n\t/**\n\t * Ends the current drag.\n\t * @internal\n\t * @param {boolean} [noInertia]\n\t * @returns {void}\n\t */\n\tfinishDrag(noInertia) {\n\t\tthis._draggingContainer?.classList.remove('maplair-dragging');\n\t\tthis._draggingContainer = null;\n\n\t\tif (this._lastTarget) {\n\t\t\tthis._lastTarget.classList.remove('maplair-drag-target');\n\t\t\tthis._lastTarget = null;\n\t\t}\n\n\t\tDomEvent.off(this._dragStartTarget, 'pointermove', this._onMove, this);\n\t\tDomEvent.off(this._dragStartTarget, 'pointerup pointercancel lostpointercapture', this._onUp, this);\n\n\t\tDomUtil.enableImageDrag();\n\n\t\tconst fireDragend = this._moved && this._moving;\n\n\t\tthis._moving = false;\n\t\tDraggable._dragging = false;\n\n\t\tif (fireDragend) {\n\t\t\tthis.fire('dragend', {\n\t\t\t\tnoInertia,\n\t\t\t\tdistance: this._newPos.distanceTo(this._startPos)\n\t\t\t});\n\t\t}\n\t}\n\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,YAAb,MAAa,kBAAkB,QAAQ;CAEtC,OAAO,iBAAiB,EACvB,gBAAgB,EACjB;;;;;;;;CASA,YAAY,SAAS,iBAAiB,SAAS;EAC9C,IAAI,OAAO,YAAY,WACtB,MAAM,IAAI,MAAM,mGAAmG;EAEpH,MAAM;EACN,WAAgB,MAAM,OAAO;EAE7B,KAAK,WAAW;EAChB,KAAK,mBAAmB,mBAAmB;EAE3C,KAAK,cAAc,SAAS;CAC7B;;;;;CAMA,SAAS;EACR,IAAI,KAAK,UAAY;EAErB,GAAY,KAAK,kBAAkB,eAAe,KAAK,SAAS,IAAI;EAEpE,KAAK,WAAW;CACjB;;;;;CAMA,UAAU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events.js";
4
4
  /** @import {Point} from '../geometry/Point.js' */
5
5
  /** @import {MaplairEvent} from '../core/Events.js' */
6
6
  /**
7
- * Used internally for panning animations and utilizing CSS Transitions for modern
8
- * browsers.
9
- *
10
- * @example
11
- * ```js
12
- * const myPositionMarker = new Marker([48.864716, 2.294694]).addTo(map);
13
- *
14
- * myPositionMarker.on("click", function() {
15
- * const pos = map.latLngToLayerPoint(myPositionMarker.getLatLng());
16
- * pos.y -= 25;
17
- * const fx = new PosAnimation();
18
- *
19
- * fx.once('end',function() {
20
- * pos.y += 25;
21
- * fx.run(myPositionMarker._icon, pos, 0.8);
22
- * });
23
- *
24
- * fx.run(myPositionMarker._icon, pos, 0.3);
25
- * });
26
- *
27
- * ```
28
- *
29
- * @fires start {MaplairEvent} Fired when the animation starts.
30
- * @fires step {MaplairEvent} Fired continuously during the animation.
31
- * @fires end {MaplairEvent} Fired when the animation ends.
7
+ * Runs the map's pan animations: moves an element to a new position on an ease-out
8
+ * curve, firing `start`, `step` and `end`.
9
+ * @internal
32
10
  */
33
11
  var PosAnimation = class PosAnimation extends Evented {
34
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"PosAnimation.js","names":["DomUtil.getPosition"],"sources":["../../../src/dom/PosAnimation.js"],"sourcesContent":["import {Evented} from '../core/Events.js';\nimport * as DomUtil from '../dom/DomUtil.js';\n/** @import {Point} from '../geometry/Point.js' */\n/** @import {MaplairEvent} from '../core/Events.js' */\n\n/**\n * Used internally for panning animations and utilizing CSS Transitions for modern\n * browsers.\n *\n * @example\n * ```js\n * const myPositionMarker = new Marker([48.864716, 2.294694]).addTo(map);\n *\n * myPositionMarker.on(\"click\", function() {\n * \tconst pos = map.latLngToLayerPoint(myPositionMarker.getLatLng());\n * \tpos.y -= 25;\n * \tconst fx = new PosAnimation();\n *\n * \tfx.once('end',function() {\n * \t\tpos.y += 25;\n * \t\tfx.run(myPositionMarker._icon, pos, 0.8);\n * \t});\n *\n * \tfx.run(myPositionMarker._icon, pos, 0.3);\n * });\n *\n * ```\n *\n * @fires start {MaplairEvent} Fired when the animation starts.\n * @fires step {MaplairEvent} Fired continuously during the animation.\n * @fires end {MaplairEvent} Fired when the animation ends.\n */\nexport class PosAnimation extends Evented {\n\t/**\n\t * Creates a `PosAnimation` object.\n\t * @param {...any} args\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(PosAnimation);\n\t}\n\n\t/**\n\t * Run an animation of a given element to a new position, optionally setting\n\t * duration in seconds (`0.25` by default) and easing linearity factor (3rd\n\t * argument of the [cubic bezier curve](https://cubic-bezier.com/#0,0,.5,1),\n\t * `0.5` by default).\n\t * @param {HTMLElement} el\n\t * @param {Point} newPos\n\t * @param {number} [duration=0.25]\n\t * @param {number} [easeLinearity=0.5]\n\t * @returns {void}\n\t */\n\trun(el, newPos, duration, easeLinearity) {\n\t\tthis.stop();\n\n\t\tthis._el = el;\n\t\tthis._inProgress = true;\n\t\tthis._duration = duration ?? 0.25;\n\t\tthis._easeOutPower = 1 / Math.max(easeLinearity ?? 0.5, 0.2);\n\n\t\tthis._startPos = DomUtil.getPosition(el);\n\t\tthis._offset = newPos.subtract(this._startPos);\n\t\tthis._startTime = Date.now();\n\n\t\tthis.fire('start');\n\n\t\tthis._animate();\n\t}\n\n\t/**\n\t * Stops the animation (if currently running).\n\t * @returns {void}\n\t */\n\tstop() {\n\t\tif (!this._inProgress) { return; }\n\n\t\tthis._step(true);\n\t\tthis._complete();\n\t}\n\n\t_animate() {\n\t\t// animation loop\n\t\tthis._animId = requestAnimationFrame(this._animate.bind(this));\n\t\tthis._step();\n\t}\n\n\t_step(round) {\n\t\tconst elapsed = (Date.now()) - this._startTime,\n\t\tduration = this._duration * 1000;\n\n\t\tif (elapsed < duration) {\n\t\t\tthis._runFrame(this._easeOut(elapsed / duration), round);\n\t\t} else {\n\t\t\tthis._runFrame(1);\n\t\t\tthis._complete();\n\t\t}\n\t}\n\n\t_runFrame(progress, round) {\n\t\tconst pos = this._startPos.add(this._offset.multiplyBy(progress));\n\t\tif (round) {\n\t\t\tpos._round();\n\t\t}\n\t\tDomUtil.setPosition(this._el, pos);\n\n\t\tthis.fire('step');\n\t}\n\n\t_complete() {\n\t\tcancelAnimationFrame(this._animId);\n\n\t\tthis._inProgress = false;\n\t\tthis.fire('end');\n\t}\n\n\t_easeOut(t) {\n\t\treturn 1 - (1 - t) ** this._easeOutPower;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAa,eAAb,MAAa,qBAAqB,QAAQ;;;;;CAKzC,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,YAAY;CAChC;;;;;;;;;;;;CAaA,IAAI,IAAI,QAAQ,UAAU,eAAe;EACxC,KAAK,KAAK;EAEV,KAAK,MAAM;EACX,KAAK,cAAc;EACnB,KAAK,YAAY,YAAY;EAC7B,KAAK,gBAAgB,IAAI,KAAK,IAAI,iBAAiB,IAAK,EAAG;EAE3D,KAAK,YAAYA,YAAoB,EAAE;EACvC,KAAK,UAAU,OAAO,SAAS,KAAK,SAAS;EAC7C,KAAK,aAAa,KAAK,IAAI;EAE3B,KAAK,KAAK,OAAO;EAEjB,KAAK,SAAS;CACf;;;;;CAMA,OAAO;EACN,IAAI,CAAC,KAAK,aAAe;EAEzB,KAAK,MAAM,IAAI;EACf,KAAK,UAAU;CAChB;CAEA,WAAW;EAEV,KAAK,UAAU,sBAAsB,KAAK,SAAS,KAAK,IAAI,CAAC;EAC7D,KAAK,MAAM;CACZ;CAEA,MAAM,OAAO;EACZ,MAAM,UAAW,KAAK,IAAI,IAAK,KAAK,YACpC,WAAW,KAAK,YAAY;EAE5B,IAAI,UAAU,UACb,KAAK,UAAU,KAAK,SAAS,UAAU,QAAQ,GAAG,KAAK;OACjD;GACN,KAAK,UAAU,CAAC;GAChB,KAAK,UAAU;EAChB;CACD;CAEA,UAAU,UAAU,OAAO;EAC1B,MAAM,MAAM,KAAK,UAAU,IAAI,KAAK,QAAQ,WAAW,QAAQ,CAAC;EAChE,IAAI,OACH,IAAI,OAAO;EAEZ,YAAoB,KAAK,KAAK,GAAG;EAEjC,KAAK,KAAK,MAAM;CACjB;CAEA,YAAY;EACX,qBAAqB,KAAK,OAAO;EAEjC,KAAK,cAAc;EACnB,KAAK,KAAK,KAAK;CAChB;CAEA,SAAS,GAAG;EACX,OAAO,KAAK,IAAI,MAAM,KAAK;CAC5B;AACD"}
1
+ {"version":3,"file":"PosAnimation.js","names":["DomUtil.getPosition"],"sources":["../../../src/dom/PosAnimation.js"],"sourcesContent":["import {Evented} from '../core/Events.js';\nimport * as DomUtil from '../dom/DomUtil.js';\n/** @import {Point} from '../geometry/Point.js' */\n/** @import {MaplairEvent} from '../core/Events.js' */\n\n/**\n * Runs the map's pan animations: moves an element to a new position on an ease-out\n * curve, firing `start`, `step` and `end`.\n * @internal\n */\nexport class PosAnimation extends Evented {\n\t/**\n\t * Creates a `PosAnimation` object.\n\t * @param {...any} args\n\t */\n\tconstructor(...args) {\n\t\tsuper(...args);\n\t\tthis.callInitHooks(PosAnimation);\n\t}\n\n\t/**\n\t * Run an animation of a given element to a new position, optionally setting\n\t * duration in seconds (`0.25` by default) and easing linearity factor (3rd\n\t * argument of the [cubic bezier curve](https://cubic-bezier.com/#0,0,.5,1),\n\t * `0.5` by default).\n\t * @param {HTMLElement} el\n\t * @param {Point} newPos\n\t * @param {number} [duration=0.25]\n\t * @param {number} [easeLinearity=0.5]\n\t * @returns {void}\n\t */\n\trun(el, newPos, duration, easeLinearity) {\n\t\tthis.stop();\n\n\t\tthis._el = el;\n\t\tthis._inProgress = true;\n\t\tthis._duration = duration ?? 0.25;\n\t\tthis._easeOutPower = 1 / Math.max(easeLinearity ?? 0.5, 0.2);\n\n\t\tthis._startPos = DomUtil.getPosition(el);\n\t\tthis._offset = newPos.subtract(this._startPos);\n\t\tthis._startTime = Date.now();\n\n\t\tthis.fire('start');\n\n\t\tthis._animate();\n\t}\n\n\t/**\n\t * Stops the animation (if currently running).\n\t * @returns {void}\n\t */\n\tstop() {\n\t\tif (!this._inProgress) { return; }\n\n\t\tthis._step(true);\n\t\tthis._complete();\n\t}\n\n\t_animate() {\n\t\t// animation loop\n\t\tthis._animId = requestAnimationFrame(this._animate.bind(this));\n\t\tthis._step();\n\t}\n\n\t_step(round) {\n\t\tconst elapsed = (Date.now()) - this._startTime,\n\t\tduration = this._duration * 1000;\n\n\t\tif (elapsed < duration) {\n\t\t\tthis._runFrame(this._easeOut(elapsed / duration), round);\n\t\t} else {\n\t\t\tthis._runFrame(1);\n\t\t\tthis._complete();\n\t\t}\n\t}\n\n\t_runFrame(progress, round) {\n\t\tconst pos = this._startPos.add(this._offset.multiplyBy(progress));\n\t\tif (round) {\n\t\t\tpos._round();\n\t\t}\n\t\tDomUtil.setPosition(this._el, pos);\n\n\t\tthis.fire('step');\n\t}\n\n\t_complete() {\n\t\tcancelAnimationFrame(this._animId);\n\n\t\tthis._inProgress = false;\n\t\tthis.fire('end');\n\t}\n\n\t_easeOut(t) {\n\t\treturn 1 - (1 - t) ** this._easeOutPower;\n\t}\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAa,eAAb,MAAa,qBAAqB,QAAQ;;;;;CAKzC,YAAY,GAAG,MAAM;EACpB,MAAM,GAAG,IAAI;EACb,KAAK,cAAc,YAAY;CAChC;;;;;;;;;;;;CAaA,IAAI,IAAI,QAAQ,UAAU,eAAe;EACxC,KAAK,KAAK;EAEV,KAAK,MAAM;EACX,KAAK,cAAc;EACnB,KAAK,YAAY,YAAY;EAC7B,KAAK,gBAAgB,IAAI,KAAK,IAAI,iBAAiB,IAAK,EAAG;EAE3D,KAAK,YAAYA,YAAoB,EAAE;EACvC,KAAK,UAAU,OAAO,SAAS,KAAK,SAAS;EAC7C,KAAK,aAAa,KAAK,IAAI;EAE3B,KAAK,KAAK,OAAO;EAEjB,KAAK,SAAS;CACf;;;;;CAMA,OAAO;EACN,IAAI,CAAC,KAAK,aAAe;EAEzB,KAAK,MAAM,IAAI;EACf,KAAK,UAAU;CAChB;CAEA,WAAW;EAEV,KAAK,UAAU,sBAAsB,KAAK,SAAS,KAAK,IAAI,CAAC;EAC7D,KAAK,MAAM;CACZ;CAEA,MAAM,OAAO;EACZ,MAAM,UAAW,KAAK,IAAI,IAAK,KAAK,YACpC,WAAW,KAAK,YAAY;EAE5B,IAAI,UAAU,UACb,KAAK,UAAU,KAAK,SAAS,UAAU,QAAQ,GAAG,KAAK;OACjD;GACN,KAAK,UAAU,CAAC;GAChB,KAAK,UAAU;EAChB;CACD;CAEA,UAAU,UAAU,OAAO;EAC1B,MAAM,MAAM,KAAK,UAAU,IAAI,KAAK,QAAQ,WAAW,QAAQ,CAAC;EAChE,IAAI,OACH,IAAI,OAAO;EAEZ,YAAoB,KAAK,KAAK,GAAG;EAEjC,KAAK,KAAK,MAAM;CACjB;CAEA,YAAY;EACX,qBAAqB,KAAK,OAAO;EAEjC,KAAK,cAAc;EACnB,KAAK,KAAK,KAAK;CAChB;CAEA,SAAS,GAAG;EACX,OAAO,KAAK,IAAI,MAAM,KAAK;CAC5B;AACD"}
@@ -1,6 +1,5 @@
1
- import { formatNum } from "../core/Util.js";
1
+ import { formatNum, wrapNum } from "../core/Util.js";
2
2
  import { LatLngBounds } from "./LatLngBounds.js";
3
- import { EarthCRS } from "./crs/EarthCRS.js";
4
3
  //#region src/geo/LatLng.js
5
4
  const coordinate = String.raw`([+-]?\d+(?:\.\d+)?)\s*°?`;
6
5
  const separator = String.raw`(?:\s*[,;]\s*|\s+)`;
@@ -92,6 +91,24 @@ var LatLng = class LatLng {
92
91
  this.alt = +_alt;
93
92
  }
94
93
  /**
94
+ * Returns the given `LatLng` object as it is, or else a new `LatLng` object created
95
+ * from the given arguments (the same as of the constructor) — unlike the
96
+ * constructor, which always creates a new object.
97
+ *
98
+ * @example
99
+ * ```js
100
+ * LatLng.from(latlng) === latlng; // true
101
+ * LatLng.from([50.5, 30.5]); // LatLng(50.5, 30.5)
102
+ * ```
103
+ * @param {number|LatLngExpression} lat Latitude in degrees, or the coordinates.
104
+ * @param {number} [lng] Longitude in degrees.
105
+ * @param {number} [alt] Altitude in meters.
106
+ * @returns {LatLng}
107
+ */
108
+ static from(lat, lng, alt) {
109
+ return lat instanceof LatLng ? lat : new LatLng(lat, lng, alt);
110
+ }
111
+ /**
95
112
  * Returns `true` if the LatLng object can be properly initialized with the given
96
113
  * arguments (the same as of the constructor).
97
114
  * @param {any} lat
@@ -153,7 +170,7 @@ var LatLng = class LatLng {
153
170
  */
154
171
  equals(obj, maxMargin) {
155
172
  if (!obj) return false;
156
- obj = new LatLng(obj);
173
+ obj = LatLng.from(obj);
157
174
  return Math.max(Math.abs(this.lat - obj.lat), Math.abs(this.lng - obj.lng)) <= (maxMargin ?? 1e-9);
158
175
  }
159
176
  /**
@@ -171,7 +188,7 @@ var LatLng = class LatLng {
171
188
  * @returns {number}
172
189
  */
173
190
  distanceTo(other) {
174
- return EarthCRS.distance(this, new LatLng(other));
191
+ return haversineDistance(this, LatLng.from(other), 6371e3);
175
192
  }
176
193
  /**
177
194
  * Returns a new `LatLng` object with the longitude wrapped so it's always between
@@ -179,7 +196,7 @@ var LatLng = class LatLng {
179
196
  * @returns {LatLng}
180
197
  */
181
198
  wrap() {
182
- return EarthCRS.wrapLatLng(this);
199
+ return new LatLng(this.lat, wrapNum(this.lng, [-180, 180], true), this.alt);
183
200
  }
184
201
  /**
185
202
  * Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2`
@@ -192,7 +209,18 @@ var LatLng = class LatLng {
192
209
  return new LatLngBounds([this.lat - latAccuracy, this.lng - lngAccuracy], [this.lat + latAccuracy, this.lng + lngAccuracy]);
193
210
  }
194
211
  };
212
+ /**
213
+ * The great-circle distance on a sphere of radius `R`, shared with `EarthCRS.distance()`.
214
+ * @param {LatLng} latlng1
215
+ * @param {LatLng} latlng2
216
+ * @param {number} R
217
+ * @returns {number}
218
+ */
219
+ function haversineDistance(latlng1, latlng2, R) {
220
+ const rad = Math.PI / 180, lat1 = latlng1.lat * rad, lat2 = latlng2.lat * rad, sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2), sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2), a = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon;
221
+ return R * (2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)));
222
+ }
195
223
  //#endregion
196
- export { LatLng };
224
+ export { LatLng, haversineDistance };
197
225
 
198
226
  //# sourceMappingURL=LatLng.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LatLng.js","names":["Util.formatNum"],"sources":["../../../src/geo/LatLng.js"],"sourcesContent":["import * as Util from '../core/Util.js';\nimport {EarthCRS} from './crs/EarthCRS.js';\nimport {LatLngBounds} from './LatLngBounds.js';\n\n// a coordinate in decimal degrees, with an optional degree sign\nconst coordinate = String.raw`([+-]?\\d+(?:\\.\\d+)?)\\s*°?`,\nseparator = String.raw`(?:\\s*[,;]\\s*|\\s+)`,\n// `47.27 11.4`, `47.27, 11.4`, `+47.27;+11.4`\nplainRe = new RegExp(`^${coordinate}${separator}${coordinate}$`),\n// `N47.27 E11.4`, `N 47.27°, E 11.4°`\nprefixRe = new RegExp(`^([NSEW])\\\\s*${coordinate}${separator}([NSEW])\\\\s*${coordinate}$`, 'i'),\n// `47.27N 11.4E`, `47.27° N, 11.4° E`\nsuffixRe = new RegExp(`^${coordinate}\\\\s*([NSEW])${separator}${coordinate}\\\\s*([NSEW])$`, 'i'),\nhemisphereRe = /^[NSEW]$/i,\n// `geo:47.27,11.4`, `geo:47.27,11.4,500;u=35`, `geo:47.27,11.4?z=13` (RFC 5870)\ngeoUriRe = /^geo:([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?)(?:,([+-]?\\d+(?:\\.\\d+)?))?(?:[;?].*)?$/i;\n\n/**\n * A geographical point: a `LatLng`, an array of the form `[lat, lng]` or\n * `[lat, lng, alt]`, or a plain object of the form `{lat, lng}` or `{lat, lng, alt}`\n * (`lon` can be used in place of `lng`). Accepted by all Maplair methods which accept\n * `LatLng` objects (unless noted otherwise). Plain arrays (`number[]`) are accepted\n * for JavaScript, where array literals in variables are no tuples.\n * @typedef {LatLng|[number, number]|[number, number, number]|number[]|{lat: number, lng: number, alt?: number}|{lat: number, lon: number, alt?: number}} LatLngExpression\n */\n\n/**\n * Represents a geographical point with a certain latitude and longitude.\n *\n * @example\n * ```js\n * const latlng = new LatLng(50.5, 30.5);\n * ```\n *\n * All Maplair methods that accept LatLng objects also accept them in a simple Array\n * form and simple object form (unless noted otherwise), so these lines are equivalent:\n *\n * ```js\n * map.panTo([50, 30]);\n * map.panTo({lat: 50, lng: 30});\n * map.panTo({lat: 50, lon: 30});\n * map.panTo(new LatLng(50, 30));\n * ```\n *\n * Note that `LatLng` does not inherit from Maplair's `Class` object,\n * which means new classes can't inherit from it, and new methods\n * can't be added to it with the `include` function.\n */\nexport class LatLng {\n\t/**\n\t * Creates an object representing a geographical point with the given latitude and\n\t * longitude (and optionally altitude). Alternatively, expects a `LatLng` object, an\n\t * array of the form `[lat, lng]` or `[lat, lng, alt]`, or a plain object of the form\n\t * `{lat, lng}` or `{lat, lng, alt}` (`lon` can be used in place of `lng`) instead.\n\t * @param {number|LatLngExpression} lat Latitude in degrees, or the coordinates.\n\t * @param {number} [lng] Longitude in degrees.\n\t * @param {number} [alt] Altitude in meters.\n\t */\n\tconstructor(lat, lng, alt) {\n\t\tconst valid = LatLng.validate(lat, lng, alt);\n\t\tif (!valid) {\n\t\t\tthrow new Error(`Invalid LatLng object: (${lat}, ${lng})`);\n\t\t}\n\n\t\tlet _lat, _lng, _alt;\n\t\tif (lat instanceof LatLng) {\n\t\t\t_lat = lat.lat;\n\t\t\t_lng = lat.lng;\n\t\t\t_alt = lat.alt;\n\t\t} else if (Array.isArray(lat) && typeof lat[0] !== 'object') {\n\t\t\tif (lat.length === 3) {\n\t\t\t\t_lat = lat[0];\n\t\t\t\t_lng = lat[1];\n\t\t\t\t_alt = lat[2];\n\t\t\t} else if (lat.length === 2) {\n\t\t\t\t_lat = lat[0];\n\t\t\t\t_lng = lat[1];\n\t\t\t}\n\t\t} else if (typeof lat === 'object' && 'lat' in lat) {\n\t\t\t_lat = lat.lat;\n\t\t\t_lng = 'lng' in lat ? lat.lng : lat.lon;\n\t\t\t_alt = lat.alt;\n\t\t} else {\n\t\t\t_lat = lat;\n\t\t\t_lng = lng;\n\t\t\t_alt = alt;\n\t\t}\n\n\t\t/**\n\t\t * Latitude in degrees.\n\t\t * @type {number}\n\t\t */\n\t\tthis.lat = +_lat;\n\n\t\t/**\n\t\t * Longitude in degrees.\n\t\t * @type {number}\n\t\t */\n\t\tthis.lng = +_lng;\n\n\t\tif (_alt !== undefined) {\n\t\t\t/**\n\t\t\t * Altitude in meters (optional).\n\t\t\t * @type {number|undefined}\n\t\t\t */\n\t\t\tthis.alt = +_alt;\n\t\t}\n\t}\n\n\t/**\n\t * Returns `true` if the LatLng object can be properly initialized with the given\n\t * arguments (the same as of the constructor).\n\t * @param {any} lat\n\t * @param {any} [lng]\n\t * @param {any} [alt]\n\t * @returns {boolean}\n\t */\n\t// eslint-disable-next-line no-unused-vars\n\tstatic validate(lat, lng, alt) {\n\t\tif (lat instanceof LatLng || (typeof lat === 'object' && lat !== null && 'lat' in lat)) {\n\t\t\treturn true;\n\t\t} else if (lat && Array.isArray(lat) && typeof lat[0] !== 'object') {\n\t\t\tif (lat.length === 3 || lat.length === 2) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t} else if ((lat || lat === 0) && (lng || lng === 0)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Parses coordinates in decimal degrees: a pair of numbers (latitude first), e.g.\n\t * `'47.27, 11.4'` or `'47.27 11.4'`, with the hemispheres before or after the numbers,\n\t * e.g. `'N 47.27, E 11.4'`, `'47.27° S 11.4° W'` (also longitude first), or a\n\t * [geo URI](https://www.rfc-editor.org/rfc/rfc5870) like `'geo:47.27,11.4'` (with an\n\t * optional altitude). Returns `null` for other text and out-of-range coordinates.\n\t *\n\t * @example\n\t * ```js\n\t * LatLng.parse('47.2692 N, 11.4041 E'); // LatLng(47.2692, 11.4041)\n\t * LatLng.parse('geo:47.2692,11.4041?z=13'); // LatLng(47.2692, 11.4041)\n\t * ```\n\t * @param {string} text\n\t * @returns {LatLng|null}\n\t */\n\tstatic parse(text) {\n\t\ttext = text.trim();\n\t\tlet lat, lng, alt, match;\n\t\tif ((match = geoUriRe.exec(text))) {\n\t\t\t[lat, lng, alt] = match.slice(1).map(n => (n === undefined ? undefined : Number(n)));\n\t\t} else if ((match = plainRe.exec(text))) {\n\t\t\t[lat, lng] = match.slice(1).map(Number);\n\t\t} else if ((match = prefixRe.exec(text) ?? suffixRe.exec(text))) {\n\t\t\t// the hemisphere and the number of both coordinates\n\t\t\tconst prefixed = hemisphereRe.test(match[1]),\n\t\t\tcoords = prefixed ?\n\t\t\t\t[[match[1], match[2]], [match[3], match[4]]] :\n\t\t\t\t[[match[2], match[1]], [match[4], match[3]]];\n\t\t\tfor (const [hemisphere, number] of coords) {\n\t\t\t\tconst h = hemisphere.toUpperCase(),\n\t\t\t\tvalue = Math.abs(Number(number)) * (h === 'S' || h === 'W' ? -1 : 1);\n\t\t\t\tif (h === 'N' || h === 'S') {\n\t\t\t\t\tif (lat !== undefined) { return null; }\n\t\t\t\t\tlat = value;\n\t\t\t\t} else {\n\t\t\t\t\tif (lng !== undefined) { return null; }\n\t\t\t\t\tlng = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (lat === undefined || Math.abs(lat) > 90 || Math.abs(lng) > 180) { return null; }\n\t\treturn new LatLng(lat, lng, alt);\n\t}\n\n\t/**\n\t * Returns `true` if the given `LatLng` point is at the same position (within a small\n\t * margin of error). The margin of error can be overridden by setting `maxMargin` to\n\t * a small number.\n\t * @param {LatLngExpression} obj\n\t * @param {number} [maxMargin]\n\t * @returns {boolean}\n\t */\n\tequals(obj, maxMargin) {\n\t\tif (!obj) { return false; }\n\n\t\tobj = new LatLng(obj);\n\n\t\tconst margin = Math.max(\n\t\t\tMath.abs(this.lat - obj.lat),\n\t\t\tMath.abs(this.lng - obj.lng));\n\n\t\treturn margin <= (maxMargin ?? 1.0E-9);\n\t}\n\n\t/**\n\t * Returns a string representation of the point (for debugging purposes).\n\t * @param {number|false} [precision]\n\t * @returns {string}\n\t */\n\ttoString(precision) {\n\t\treturn `LatLng(${Util.formatNum(this.lat, precision)}, ${Util.formatNum(this.lng, precision)})`;\n\t}\n\n\t/**\n\t * Returns the distance (in meters) to the given `LatLng` calculated using the\n\t * [Haversine formula](https://en.wikipedia.org/wiki/Haversine_formula).\n\t * @param {LatLngExpression} other\n\t * @returns {number}\n\t */\n\tdistanceTo(other) {\n\t\treturn EarthCRS.distance(this, new LatLng(other));\n\t}\n\n\t/**\n\t * Returns a new `LatLng` object with the longitude wrapped so it's always between\n\t * -180 and +180 degrees.\n\t * @returns {LatLng}\n\t */\n\twrap() {\n\t\treturn EarthCRS.wrapLatLng(this);\n\t}\n\n\t/**\n\t * Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2`\n\t * meters apart from the `LatLng`.\n\t * @param {number} sizeInMeters\n\t * @returns {LatLngBounds}\n\t */\n\ttoBounds(sizeInMeters) {\n\t\tconst latAccuracy = 180 * sizeInMeters / 40075017,\n\t\tlngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);\n\n\t\treturn new LatLngBounds(\n\t\t\t[this.lat - latAccuracy, this.lng - lngAccuracy],\n\t\t\t[this.lat + latAccuracy, this.lng + lngAccuracy]);\n\t}\n\n};\n"],"mappings":";;;;AAKA,MAAM,aAAa,OAAO,GAAG;AAC7B,MAAA,YAAY,OAAO,GAAG;AAEtB,MAAA,UAAU,IAAI,OAAO,IAAI,aAAa,YAAY,WAAW,EAAE;AAE/D,MAAA,WAAW,IAAI,OAAO,gBAAgB,aA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,CAAC,KAAO,OAAO;EAEnB,MAAM,IAAI,OAAO,GAAG;EAMpB,OAJe,KAAK,IACnB,KAAK,IAAI,KAAK,MAAM,IAAI,GAAG,GAC3B,KAAK,IAAI,KAAK,MAAM,IAAI,GAAG,CAEhB,MAAM,aAAa;CAChC;;;;;;CAOA,SAAS,WAAW;EACnB,OAAO,UAAUA,UAAe,KAAK,KAAK,SAAS,EAAE,IAAIA,UAAe,KAAK,KAAK,SAAS,EAAE;CAC9F;;;;;;;CAQA,WAAW,OAAO;EACjB,OAAO,SAAS,SAAS,MAAM,IAAI,OAAO,KAAK,CAAC;CACjD;;;;;;CAOA,OAAO;EACN,OAAO,SAAS,WAAW,IAAI;CAChC;;;;;;;CAQA,SAAS,cAAc;EACtB,MAAM,cAAc,MAAM,eAAe,UACzC,cAAc,cAAc,KAAK,IAAK,KAAK,KAAK,MAAO,KAAK,GAAG;EAE/D,OAAO,IAAI,aACV,CAAC,KAAK,MAAM,aAAa,KAAK,MAAM,WAAW,GAC/C,CAAC,KAAK,MAAM,aAAa,KAAK,MAAM,WAAW,CAAC;CAClD;AAED"}
1
+ {"version":3,"file":"LatLng.js","names":["Util.formatNum","Util.wrapNum"],"sources":["../../../src/geo/LatLng.js"],"sourcesContent":["import * as Util from '../core/Util.js';\nimport {LatLngBounds} from './LatLngBounds.js';\n\n// a coordinate in decimal degrees, with an optional degree sign\nconst coordinate = String.raw`([+-]?\\d+(?:\\.\\d+)?)\\s*°?`,\nseparator = String.raw`(?:\\s*[,;]\\s*|\\s+)`,\n// `47.27 11.4`, `47.27, 11.4`, `+47.27;+11.4`\nplainRe = new RegExp(`^${coordinate}${separator}${coordinate}$`),\n// `N47.27 E11.4`, `N 47.27°, E 11.4°`\nprefixRe = new RegExp(`^([NSEW])\\\\s*${coordinate}${separator}([NSEW])\\\\s*${coordinate}$`, 'i'),\n// `47.27N 11.4E`, `47.27° N, 11.4° E`\nsuffixRe = new RegExp(`^${coordinate}\\\\s*([NSEW])${separator}${coordinate}\\\\s*([NSEW])$`, 'i'),\nhemisphereRe = /^[NSEW]$/i,\n// `geo:47.27,11.4`, `geo:47.27,11.4,500;u=35`, `geo:47.27,11.4?z=13` (RFC 5870)\ngeoUriRe = /^geo:([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?)(?:,([+-]?\\d+(?:\\.\\d+)?))?(?:[;?].*)?$/i;\n\n/**\n * A geographical point: a `LatLng`, an array of the form `[lat, lng]` or\n * `[lat, lng, alt]`, or a plain object of the form `{lat, lng}` or `{lat, lng, alt}`\n * (`lon` can be used in place of `lng`). Accepted by all Maplair methods which accept\n * `LatLng` objects (unless noted otherwise). Plain arrays (`number[]`) are accepted\n * for JavaScript, where array literals in variables are no tuples.\n * @typedef {LatLng|[number, number]|[number, number, number]|number[]|{lat: number, lng: number, alt?: number}|{lat: number, lon: number, alt?: number}} LatLngExpression\n */\n\n/**\n * Represents a geographical point with a certain latitude and longitude.\n *\n * @example\n * ```js\n * const latlng = new LatLng(50.5, 30.5);\n * ```\n *\n * All Maplair methods that accept LatLng objects also accept them in a simple Array\n * form and simple object form (unless noted otherwise), so these lines are equivalent:\n *\n * ```js\n * map.panTo([50, 30]);\n * map.panTo({lat: 50, lng: 30});\n * map.panTo({lat: 50, lon: 30});\n * map.panTo(new LatLng(50, 30));\n * ```\n *\n * Note that `LatLng` does not inherit from Maplair's `Class` object,\n * which means new classes can't inherit from it, and new methods\n * can't be added to it with the `include` function.\n */\nexport class LatLng {\n\t/**\n\t * Creates an object representing a geographical point with the given latitude and\n\t * longitude (and optionally altitude). Alternatively, expects a `LatLng` object, an\n\t * array of the form `[lat, lng]` or `[lat, lng, alt]`, or a plain object of the form\n\t * `{lat, lng}` or `{lat, lng, alt}` (`lon` can be used in place of `lng`) instead.\n\t * @param {number|LatLngExpression} lat Latitude in degrees, or the coordinates.\n\t * @param {number} [lng] Longitude in degrees.\n\t * @param {number} [alt] Altitude in meters.\n\t */\n\tconstructor(lat, lng, alt) {\n\t\tconst valid = LatLng.validate(lat, lng, alt);\n\t\tif (!valid) {\n\t\t\tthrow new Error(`Invalid LatLng object: (${lat}, ${lng})`);\n\t\t}\n\n\t\tlet _lat, _lng, _alt;\n\t\tif (lat instanceof LatLng) {\n\t\t\t_lat = lat.lat;\n\t\t\t_lng = lat.lng;\n\t\t\t_alt = lat.alt;\n\t\t} else if (Array.isArray(lat) && typeof lat[0] !== 'object') {\n\t\t\tif (lat.length === 3) {\n\t\t\t\t_lat = lat[0];\n\t\t\t\t_lng = lat[1];\n\t\t\t\t_alt = lat[2];\n\t\t\t} else if (lat.length === 2) {\n\t\t\t\t_lat = lat[0];\n\t\t\t\t_lng = lat[1];\n\t\t\t}\n\t\t} else if (typeof lat === 'object' && 'lat' in lat) {\n\t\t\t_lat = lat.lat;\n\t\t\t_lng = 'lng' in lat ? lat.lng : lat.lon;\n\t\t\t_alt = lat.alt;\n\t\t} else {\n\t\t\t_lat = lat;\n\t\t\t_lng = lng;\n\t\t\t_alt = alt;\n\t\t}\n\n\t\t/**\n\t\t * Latitude in degrees.\n\t\t * @type {number}\n\t\t */\n\t\tthis.lat = +_lat;\n\n\t\t/**\n\t\t * Longitude in degrees.\n\t\t * @type {number}\n\t\t */\n\t\tthis.lng = +_lng;\n\n\t\tif (_alt !== undefined) {\n\t\t\t/**\n\t\t\t * Altitude in meters (optional).\n\t\t\t * @type {number|undefined}\n\t\t\t */\n\t\t\tthis.alt = +_alt;\n\t\t}\n\t}\n\n\t/**\n\t * Returns the given `LatLng` object as it is, or else a new `LatLng` object created\n\t * from the given arguments (the same as of the constructor) — unlike the\n\t * constructor, which always creates a new object.\n\t *\n\t * @example\n\t * ```js\n\t * LatLng.from(latlng) === latlng; // true\n\t * LatLng.from([50.5, 30.5]); // LatLng(50.5, 30.5)\n\t * ```\n\t * @param {number|LatLngExpression} lat Latitude in degrees, or the coordinates.\n\t * @param {number} [lng] Longitude in degrees.\n\t * @param {number} [alt] Altitude in meters.\n\t * @returns {LatLng}\n\t */\n\tstatic from(lat, lng, alt) {\n\t\treturn lat instanceof LatLng ? lat : new LatLng(lat, lng, alt);\n\t}\n\n\t/**\n\t * Returns `true` if the LatLng object can be properly initialized with the given\n\t * arguments (the same as of the constructor).\n\t * @param {any} lat\n\t * @param {any} [lng]\n\t * @param {any} [alt]\n\t * @returns {boolean}\n\t */\n\t// eslint-disable-next-line no-unused-vars\n\tstatic validate(lat, lng, alt) {\n\t\tif (lat instanceof LatLng || (typeof lat === 'object' && lat !== null && 'lat' in lat)) {\n\t\t\treturn true;\n\t\t} else if (lat && Array.isArray(lat) && typeof lat[0] !== 'object') {\n\t\t\tif (lat.length === 3 || lat.length === 2) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn false;\n\t\t} else if ((lat || lat === 0) && (lng || lng === 0)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Parses coordinates in decimal degrees: a pair of numbers (latitude first), e.g.\n\t * `'47.27, 11.4'` or `'47.27 11.4'`, with the hemispheres before or after the numbers,\n\t * e.g. `'N 47.27, E 11.4'`, `'47.27° S 11.4° W'` (also longitude first), or a\n\t * [geo URI](https://www.rfc-editor.org/rfc/rfc5870) like `'geo:47.27,11.4'` (with an\n\t * optional altitude). Returns `null` for other text and out-of-range coordinates.\n\t *\n\t * @example\n\t * ```js\n\t * LatLng.parse('47.2692 N, 11.4041 E'); // LatLng(47.2692, 11.4041)\n\t * LatLng.parse('geo:47.2692,11.4041?z=13'); // LatLng(47.2692, 11.4041)\n\t * ```\n\t * @param {string} text\n\t * @returns {LatLng|null}\n\t */\n\tstatic parse(text) {\n\t\ttext = text.trim();\n\t\tlet lat, lng, alt, match;\n\t\tif ((match = geoUriRe.exec(text))) {\n\t\t\t[lat, lng, alt] = match.slice(1).map(n => (n === undefined ? undefined : Number(n)));\n\t\t} else if ((match = plainRe.exec(text))) {\n\t\t\t[lat, lng] = match.slice(1).map(Number);\n\t\t} else if ((match = prefixRe.exec(text) ?? suffixRe.exec(text))) {\n\t\t\t// the hemisphere and the number of both coordinates\n\t\t\tconst prefixed = hemisphereRe.test(match[1]),\n\t\t\tcoords = prefixed ?\n\t\t\t\t[[match[1], match[2]], [match[3], match[4]]] :\n\t\t\t\t[[match[2], match[1]], [match[4], match[3]]];\n\t\t\tfor (const [hemisphere, number] of coords) {\n\t\t\t\tconst h = hemisphere.toUpperCase(),\n\t\t\t\tvalue = Math.abs(Number(number)) * (h === 'S' || h === 'W' ? -1 : 1);\n\t\t\t\tif (h === 'N' || h === 'S') {\n\t\t\t\t\tif (lat !== undefined) { return null; }\n\t\t\t\t\tlat = value;\n\t\t\t\t} else {\n\t\t\t\t\tif (lng !== undefined) { return null; }\n\t\t\t\t\tlng = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (lat === undefined || Math.abs(lat) > 90 || Math.abs(lng) > 180) { return null; }\n\t\treturn new LatLng(lat, lng, alt);\n\t}\n\n\t/**\n\t * Returns `true` if the given `LatLng` point is at the same position (within a small\n\t * margin of error). The margin of error can be overridden by setting `maxMargin` to\n\t * a small number.\n\t * @param {LatLngExpression} obj\n\t * @param {number} [maxMargin]\n\t * @returns {boolean}\n\t */\n\tequals(obj, maxMargin) {\n\t\tif (!obj) { return false; }\n\n\t\tobj = LatLng.from(obj);\n\n\t\tconst margin = Math.max(\n\t\t\tMath.abs(this.lat - obj.lat),\n\t\t\tMath.abs(this.lng - obj.lng));\n\n\t\treturn margin <= (maxMargin ?? 1.0E-9);\n\t}\n\n\t/**\n\t * Returns a string representation of the point (for debugging purposes).\n\t * @param {number|false} [precision]\n\t * @returns {string}\n\t */\n\ttoString(precision) {\n\t\treturn `LatLng(${Util.formatNum(this.lat, precision)}, ${Util.formatNum(this.lng, precision)})`;\n\t}\n\n\t/**\n\t * Returns the distance (in meters) to the given `LatLng` calculated using the\n\t * [Haversine formula](https://en.wikipedia.org/wiki/Haversine_formula).\n\t * @param {LatLngExpression} other\n\t * @returns {number}\n\t */\n\tdistanceTo(other) {\n\t\treturn haversineDistance(this, LatLng.from(other), 6371000);\n\t}\n\n\t/**\n\t * Returns a new `LatLng` object with the longitude wrapped so it's always between\n\t * -180 and +180 degrees.\n\t * @returns {LatLng}\n\t */\n\twrap() {\n\t\treturn new LatLng(this.lat, Util.wrapNum(this.lng, [-180, 180], true), this.alt);\n\t}\n\n\t/**\n\t * Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2`\n\t * meters apart from the `LatLng`.\n\t * @param {number} sizeInMeters\n\t * @returns {LatLngBounds}\n\t */\n\ttoBounds(sizeInMeters) {\n\t\tconst latAccuracy = 180 * sizeInMeters / 40075017,\n\t\tlngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);\n\n\t\treturn new LatLngBounds(\n\t\t\t[this.lat - latAccuracy, this.lng - lngAccuracy],\n\t\t\t[this.lat + latAccuracy, this.lng + lngAccuracy]);\n\t}\n\n};\n\n/**\n * The great-circle distance on a sphere of radius `R`, shared with `EarthCRS.distance()`.\n * @param {LatLng} latlng1\n * @param {LatLng} latlng2\n * @param {number} R\n * @returns {number}\n */\nexport function haversineDistance(latlng1, latlng2, R) {\n\tconst rad = Math.PI / 180,\n\tlat1 = latlng1.lat * rad,\n\tlat2 = latlng2.lat * rad,\n\tsinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2),\n\tsinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2),\n\ta = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon,\n\tc = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n\treturn R * c;\n}\n"],"mappings":";;;AAIA,MAAM,aAAa,OAAO,GAAG;AAC7B,MAAA,YAAY,OAAO,GAAG;AAEtB,MAAA,UAAU,IAAI,OAAO,IAAI,aAAa,YAAY,WAAW,EAAE;AAE/D,MAAA,WAAW,IAAI,OAAO,gBAAgB,aAAa,UAAU,cAAc,WAAW,IAAI,GAAG;AAE7F,MAAA,WAAW,IAAI,OAA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