maplair 4.0.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/CHANGELOG.md +178 -0
  2. package/dist/esm/Maplair.js +18 -17
  3. package/dist/esm/Maplair.js.map +1 -1
  4. package/dist/esm/_virtual/_rolldown/runtime.js +1 -2
  5. package/dist/esm/control/AttributionControl.js +25 -16
  6. package/dist/esm/control/AttributionControl.js.map +1 -1
  7. package/dist/esm/control/ButtonControl.js +10 -13
  8. package/dist/esm/control/ButtonControl.js.map +1 -1
  9. package/dist/esm/control/ContextMenu.js +2 -5
  10. package/dist/esm/control/ContextMenu.js.map +1 -1
  11. package/dist/esm/control/Control.js +10 -18
  12. package/dist/esm/control/Control.js.map +1 -1
  13. package/dist/esm/control/FullscreenControl.js +6 -9
  14. package/dist/esm/control/FullscreenControl.js.map +1 -1
  15. package/dist/esm/control/LayersControl.js +170 -65
  16. package/dist/esm/control/LayersControl.js.map +1 -1
  17. package/dist/esm/control/LegendControl.js +8 -11
  18. package/dist/esm/control/LegendControl.js.map +1 -1
  19. package/dist/esm/control/MiniMapControl.js +15 -18
  20. package/dist/esm/control/MiniMapControl.js.map +1 -1
  21. package/dist/esm/control/RotateControl.js +2 -5
  22. package/dist/esm/control/RotateControl.js.map +1 -1
  23. package/dist/esm/control/ScaleControl.js +8 -11
  24. package/dist/esm/control/ScaleControl.js.map +1 -1
  25. package/dist/esm/control/SearchControl.js +100 -19
  26. package/dist/esm/control/SearchControl.js.map +1 -1
  27. package/dist/esm/control/SideBySideControl.js +2 -5
  28. package/dist/esm/control/SideBySideControl.js.map +1 -1
  29. package/dist/esm/control/TextControl.js +6 -9
  30. package/dist/esm/control/TextControl.js.map +1 -1
  31. package/dist/esm/control/TimeControl.js +407 -0
  32. package/dist/esm/control/TimeControl.js.map +1 -0
  33. package/dist/esm/control/ZoomControl.js +23 -36
  34. package/dist/esm/control/ZoomControl.js.map +1 -1
  35. package/dist/esm/core/Class.js +28 -44
  36. package/dist/esm/core/Class.js.map +1 -1
  37. package/dist/esm/core/Events.js +22 -10
  38. package/dist/esm/core/Events.js.map +1 -1
  39. package/dist/esm/core/Handler.js +23 -14
  40. package/dist/esm/core/Handler.js.map +1 -1
  41. package/dist/esm/core/I18n.js +1 -2
  42. package/dist/esm/core/Util.js +15 -4
  43. package/dist/esm/core/Util.js.map +1 -1
  44. package/dist/esm/dom/DomEvent.DoubleTap.js +26 -24
  45. package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -1
  46. package/dist/esm/dom/DomEvent.PointerEvents.js +3 -18
  47. package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
  48. package/dist/esm/dom/DomEvent.js +18 -60
  49. package/dist/esm/dom/DomEvent.js.map +1 -1
  50. package/dist/esm/dom/DomUtil.js +15 -70
  51. package/dist/esm/dom/DomUtil.js.map +1 -1
  52. package/dist/esm/dom/Draggable.js +21 -21
  53. package/dist/esm/dom/Draggable.js.map +1 -1
  54. package/dist/esm/dom/PosAnimation.js +4 -27
  55. package/dist/esm/dom/PosAnimation.js.map +1 -1
  56. package/dist/esm/geo/LatLng.js +16 -7
  57. package/dist/esm/geo/LatLng.js.map +1 -1
  58. package/dist/esm/geo/LatLngBounds.js +9 -15
  59. package/dist/esm/geo/LatLngBounds.js.map +1 -1
  60. package/dist/esm/geo/crs/CRS.js +1 -2
  61. package/dist/esm/geo/crs/EPSG3395.js +5 -6
  62. package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
  63. package/dist/esm/geo/crs/EPSG3857.js +5 -6
  64. package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
  65. package/dist/esm/geo/crs/EPSG4326.js +4 -5
  66. package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
  67. package/dist/esm/geo/crs/EarthCRS.js +3 -4
  68. package/dist/esm/geo/crs/EarthCRS.js.map +1 -1
  69. package/dist/esm/geo/crs/SimpleCRS.js +4 -5
  70. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
  71. package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +5 -6
  72. package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
  73. package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +4 -5
  74. package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
  75. package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +5 -6
  76. package/dist/esm/geo/projection/SphericalMercatorProjection.js.map +1 -0
  77. package/dist/esm/geometry/Bounds.js +10 -14
  78. package/dist/esm/geometry/Bounds.js.map +1 -1
  79. package/dist/esm/geometry/LineUtil.js +37 -32
  80. package/dist/esm/geometry/LineUtil.js.map +1 -1
  81. package/dist/esm/geometry/Point.js +1 -2
  82. package/dist/esm/geometry/PolyUtil.js +24 -51
  83. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  84. package/dist/esm/geometry/Transformation.js +1 -2
  85. package/dist/esm/layer/BlanketOverlay.js +7 -10
  86. package/dist/esm/layer/BlanketOverlay.js.map +1 -1
  87. package/dist/esm/layer/Classification.js +1 -2
  88. package/dist/esm/layer/DivOverlay.js +16 -22
  89. package/dist/esm/layer/DivOverlay.js.map +1 -1
  90. package/dist/esm/layer/FeatureGroup.js +5 -4
  91. package/dist/esm/layer/FeatureGroup.js.map +1 -1
  92. package/dist/esm/layer/GeoJSON.Load.js +1 -2
  93. package/dist/esm/layer/GeoJSON.js +17 -155
  94. package/dist/esm/layer/GeoJSON.js.map +1 -1
  95. package/dist/esm/layer/GeoJSONUtil.js +74 -0
  96. package/dist/esm/layer/GeoJSONUtil.js.map +1 -0
  97. package/dist/esm/layer/HeatLayer.js +17 -20
  98. package/dist/esm/layer/HeatLayer.js.map +1 -1
  99. package/dist/esm/layer/ImageOverlay.js +22 -29
  100. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  101. package/dist/esm/layer/Layer.js +9 -12
  102. package/dist/esm/layer/Layer.js.map +1 -1
  103. package/dist/esm/layer/LayerGroup.js +53 -3
  104. package/dist/esm/layer/LayerGroup.js.map +1 -1
  105. package/dist/esm/layer/Popup.js +35 -58
  106. package/dist/esm/layer/Popup.js.map +1 -1
  107. package/dist/esm/layer/SVGOverlay.js +3 -7
  108. package/dist/esm/layer/SVGOverlay.js.map +1 -1
  109. package/dist/esm/layer/Tooltip.js +31 -34
  110. package/dist/esm/layer/Tooltip.js.map +1 -1
  111. package/dist/esm/layer/VideoOverlay.js +13 -17
  112. package/dist/esm/layer/VideoOverlay.js.map +1 -1
  113. package/dist/esm/layer/marker/DefaultIcon.js +38 -49
  114. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
  115. package/dist/esm/layer/marker/DivIcon.js +8 -11
  116. package/dist/esm/layer/marker/DivIcon.js.map +1 -1
  117. package/dist/esm/layer/marker/Icon.js +9 -12
  118. package/dist/esm/layer/marker/Icon.js.map +1 -1
  119. package/dist/esm/layer/marker/Marker.Drag.js +44 -5
  120. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  121. package/dist/esm/layer/marker/Marker.Move.js +5 -8
  122. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  123. package/dist/esm/layer/marker/Marker.js +115 -47
  124. package/dist/esm/layer/marker/Marker.js.map +1 -1
  125. package/dist/esm/layer/marker/MarkerClusterGroup.js +301 -0
  126. package/dist/esm/layer/marker/MarkerClusterGroup.js.map +1 -0
  127. package/dist/esm/layer/marker/SvgIcon.js +7 -10
  128. package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
  129. package/dist/esm/layer/tile/GridLayer.js +89 -101
  130. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  131. package/dist/esm/layer/tile/TileLayer.js +36 -44
  132. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  133. package/dist/esm/layer/tile/WMSTileLayer.js +33 -27
  134. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
  135. package/dist/esm/layer/vector/Canvas.js +8 -17
  136. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  137. package/dist/esm/layer/vector/Circle.js +6 -5
  138. package/dist/esm/layer/vector/Circle.js.map +1 -1
  139. package/dist/esm/layer/vector/CircleMarker.js +19 -10
  140. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  141. package/dist/esm/layer/vector/Path.DashAnimation.js +3 -5
  142. package/dist/esm/layer/vector/Path.DashAnimation.js.map +1 -1
  143. package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
  144. package/dist/esm/layer/vector/Path.js +28 -22
  145. package/dist/esm/layer/vector/Path.js.map +1 -1
  146. package/dist/esm/layer/vector/Polygon.js +22 -7
  147. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  148. package/dist/esm/layer/vector/Polyline.Decorations.js +3 -4
  149. package/dist/esm/layer/vector/Polyline.js +25 -10
  150. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  151. package/dist/esm/layer/vector/Rectangle.js +1 -2
  152. package/dist/esm/layer/vector/Renderer.getRenderer.js +17 -17
  153. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  154. package/dist/esm/layer/vector/Renderer.js +1 -2
  155. package/dist/esm/layer/vector/SVG.js +12 -9
  156. package/dist/esm/layer/vector/SVG.js.map +1 -1
  157. package/dist/esm/map/Hash.js +1 -2
  158. package/dist/esm/map/Map.Rotation.js +41 -22
  159. package/dist/esm/map/Map.Rotation.js.map +1 -1
  160. package/dist/esm/map/Map.js +125 -126
  161. package/dist/esm/map/Map.js.map +1 -1
  162. package/dist/esm/map/MapSync.js +1 -2
  163. package/dist/esm/map/handler/BoxZoomHandler.js +25 -47
  164. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  165. package/dist/esm/map/handler/DisplaceHandler.js +7 -10
  166. package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
  167. package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
  168. package/dist/esm/map/handler/DragHandler.js +20 -21
  169. package/dist/esm/map/handler/DragHandler.js.map +1 -1
  170. package/dist/esm/map/handler/KeyboardHandler.js +48 -68
  171. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  172. package/dist/esm/map/handler/PinchZoomHandler.js +13 -5
  173. package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
  174. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +4 -6
  175. package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
  176. package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
  177. package/dist/esm/map/handler/TapHoldHandler.js +13 -7
  178. package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
  179. package/dist/esm/package.js +2 -3
  180. package/dist/maplair-global-src.js +6495 -5981
  181. package/dist/maplair-global-src.js.map +1 -1
  182. package/dist/maplair-global.js +2 -2
  183. package/dist/maplair-global.js.map +1 -1
  184. package/dist/maplair-src.js +6206 -5673
  185. package/dist/maplair-src.js.map +1 -1
  186. package/dist/maplair.css +1 -1213
  187. package/dist/maplair.js +2 -2
  188. package/dist/maplair.js.map +1 -1
  189. package/i18n/cs.json +6 -0
  190. package/i18n/de.json +6 -0
  191. package/i18n/en.json +6 -0
  192. package/i18n/es.json +6 -0
  193. package/i18n/fr.json +6 -0
  194. package/i18n/hu.json +6 -0
  195. package/i18n/it.json +6 -0
  196. package/i18n/rm.json +6 -0
  197. package/i18n/sk.json +6 -0
  198. package/i18n/sl.json +6 -0
  199. package/package.json +11 -18
  200. package/src/Maplair.all.js +0 -1
  201. package/src/control/AttributionControl.js +25 -18
  202. package/src/control/ButtonControl.js +9 -11
  203. package/src/control/ContextMenu.js +3 -5
  204. package/src/control/Control.js +9 -19
  205. package/src/control/FullscreenControl.js +5 -7
  206. package/src/control/LayersControl.js +196 -86
  207. package/src/control/LegendControl.js +7 -9
  208. package/src/control/MiniMapControl.js +9 -11
  209. package/src/control/RotateControl.js +3 -5
  210. package/src/control/ScaleControl.js +7 -9
  211. package/src/control/SearchControl.js +102 -19
  212. package/src/control/SideBySideControl.js +3 -5
  213. package/src/control/TextControl.js +5 -7
  214. package/src/control/TimeControl.js +471 -0
  215. package/src/control/ZoomControl.js +22 -38
  216. package/src/control/index.js +1 -0
  217. package/src/core/Class.js +37 -45
  218. package/src/core/Events.js +22 -3
  219. package/src/core/Handler.js +25 -13
  220. package/src/core/Util.js +20 -2
  221. package/src/core/index.js +0 -1
  222. package/src/dom/DomEvent.DoubleTap.js +18 -10
  223. package/src/dom/DomEvent.PointerEvents.js +3 -26
  224. package/src/dom/DomEvent.js +17 -85
  225. package/src/dom/DomUtil.js +22 -78
  226. package/src/dom/Draggable.js +32 -23
  227. package/src/dom/PosAnimation.js +3 -25
  228. package/src/dom/index.js +0 -1
  229. package/src/geo/LatLng.js +20 -3
  230. package/src/geo/LatLngBounds.js +8 -15
  231. package/src/geo/crs/EPSG3395.js +4 -4
  232. package/src/geo/crs/EPSG3857.js +4 -4
  233. package/src/geo/crs/EPSG4326.js +3 -3
  234. package/src/geo/crs/EarthCRS.js +2 -8
  235. package/src/geo/crs/SimpleCRS.js +3 -3
  236. package/src/geo/index.js +1 -2
  237. package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +2 -2
  238. package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +2 -2
  239. package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +2 -2
  240. package/src/geo/projection/index.js +5 -5
  241. package/src/geometry/Bounds.js +12 -17
  242. package/src/geometry/LineUtil.js +48 -49
  243. package/src/geometry/PolyUtil.js +39 -76
  244. package/src/layer/BlanketOverlay.js +6 -10
  245. package/src/layer/DivOverlay.js +16 -27
  246. package/src/layer/FeatureGroup.js +8 -2
  247. package/src/layer/GeoJSON.js +17 -218
  248. package/src/layer/GeoJSONUtil.js +85 -0
  249. package/src/layer/HeatLayer.js +10 -12
  250. package/src/layer/ImageOverlay.js +21 -32
  251. package/src/layer/Layer.js +8 -10
  252. package/src/layer/LayerGroup.js +72 -1
  253. package/src/layer/Popup.js +37 -62
  254. package/src/layer/SVGOverlay.js +1 -5
  255. package/src/layer/Tooltip.js +34 -36
  256. package/src/layer/VideoOverlay.js +12 -15
  257. package/src/layer/marker/DefaultIcon.js +40 -58
  258. package/src/layer/marker/DivIcon.js +9 -11
  259. package/src/layer/marker/Icon.js +9 -10
  260. package/src/layer/marker/Marker.Drag.js +54 -6
  261. package/src/layer/marker/Marker.Move.js +4 -6
  262. package/src/layer/marker/Marker.js +145 -52
  263. package/src/layer/marker/MarkerClusterGroup.js +370 -0
  264. package/src/layer/marker/SvgIcon.js +7 -9
  265. package/src/layer/marker/index.js +1 -0
  266. package/src/layer/tile/GridLayer.js +108 -135
  267. package/src/layer/tile/TileLayer.js +44 -49
  268. package/src/layer/tile/WMSTileLayer.js +31 -26
  269. package/src/layer/vector/Canvas.js +13 -19
  270. package/src/layer/vector/Circle.js +9 -3
  271. package/src/layer/vector/CircleMarker.js +19 -7
  272. package/src/layer/vector/Path.DashAnimation.js +1 -2
  273. package/src/layer/vector/Path.js +30 -21
  274. package/src/layer/vector/Polygon.js +29 -6
  275. package/src/layer/vector/Polyline.js +26 -7
  276. package/src/layer/vector/Renderer.getRenderer.js +20 -19
  277. package/src/layer/vector/SVG.js +17 -7
  278. package/src/map/Map.Rotation.js +40 -8
  279. package/src/map/Map.js +158 -153
  280. package/src/map/handler/BoxZoomHandler.js +30 -50
  281. package/src/map/handler/DisplaceHandler.js +6 -8
  282. package/src/map/handler/DragHandler.js +25 -28
  283. package/src/map/handler/KeyboardHandler.js +65 -90
  284. package/src/map/handler/PinchZoomHandler.js +16 -5
  285. package/src/map/handler/ScrollWheelZoomHandler.js +6 -4
  286. package/src/map/handler/TapHoldHandler.js +15 -4
  287. package/src/map/index.js +1 -1
  288. package/src/maplair.css +153 -98
  289. package/dist/esm/core/Browser.js +0 -100
  290. package/dist/esm/core/Browser.js.map +0 -1
  291. package/dist/esm/geo/projection/Projection.LonLat.js.map +0 -1
  292. package/dist/esm/geo/projection/Projection.Mercator.js.map +0 -1
  293. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +0 -1
  294. package/dist/esm/geo/projection/index.js +0 -14
  295. package/dist/esm/geo/projection/index.js.map +0 -1
  296. package/dist/esm/layer/marker/Marker.Rotation.js +0 -70
  297. package/dist/esm/layer/marker/Marker.Rotation.js.map +0 -1
  298. package/dist/images/layers.svg +0 -1
  299. package/dist/images/marker-icon.svg +0 -1
  300. package/dist/images/marker-shadow.svg +0 -1
  301. package/src/core/Browser.js +0 -110
  302. package/src/images/layers.svg +0 -1
  303. package/src/images/marker-icon.svg +0 -1
  304. package/src/images/marker-shadow.svg +0 -1
  305. package/src/layer/marker/Marker.Rotation.js +0 -103
@@ -2,9 +2,9 @@ import { setOptions } from "../core/Util.js";
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
- //#region src/dom/Draggable.js
7
+ // src/dom/Draggable.js
8
8
  /** @import {MaplairEvent, DragEndEvent} from '../core/Events.js' */
9
9
  /**
10
10
  * Options of `Draggable`.
@@ -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
  /**
@@ -80,23 +77,23 @@ var Draggable = class Draggable extends Evented {
80
77
  _onDown(e) {
81
78
  this._moved = false;
82
79
  if (this._element.classList.contains("maplair-zoom-anim")) return;
83
- if (getPointers().length !== 1) {
80
+ const pointers = getPointers().length;
81
+ if (pointers > 1) {
84
82
  if (Draggable._dragging === this) this.finishDrag();
85
83
  return;
86
84
  }
87
85
  if (Draggable._dragging || e.shiftKey || e.button !== 0 && e.pointerType !== "touch") return;
88
86
  Draggable._dragging = this;
89
- if (this._preventOutline) preventOutline(this._element);
90
87
  disableImageDrag();
91
- disableTextSelection();
92
88
  if (this._moving) return;
89
+ if (!pointers && e.isTrusted) e.target.setPointerCapture(e.pointerId);
93
90
  this.fire("down");
94
91
  const sizedParent = getSizedParentNode(this._element);
95
92
  this._startPoint = new Point(e.clientX, e.clientY);
96
93
  this._startPos = getPosition(this._element);
97
94
  this._parentScale = getScale(sizedParent);
98
95
  on(this._dragStartTarget, "pointermove", this._onMove, this);
99
- on(this._dragStartTarget, "pointerup pointercancel", this._onUp, this);
96
+ on(this._dragStartTarget, "pointerup pointercancel lostpointercapture", this._onUp, this);
100
97
  }
101
98
  _onMove(e) {
102
99
  if (getPointers().length > 1) {
@@ -104,16 +101,17 @@ var Draggable = class Draggable extends Evented {
104
101
  return;
105
102
  }
106
103
  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;
104
+ const dist = Math.abs(offset.x) + Math.abs(offset.y);
105
+ if (!this._moved && (!dist || dist < this.options.clickTolerance)) return;
109
106
  offset.x /= this._parentScale.x;
110
107
  offset.y /= this._parentScale.y;
111
108
  if (e.cancelable) e.preventDefault();
112
109
  if (!this._moved) {
113
110
  this.fire("dragstart", { originalEvent: e });
114
111
  this._moved = true;
115
- this._element.ownerDocument.body.classList.add("maplair-dragging");
116
- this._lastTarget = e.target ?? e.srcElement;
112
+ this._draggingContainer = this._element.closest(".maplair-container") ?? this._element;
113
+ this._draggingContainer.classList.add("maplair-dragging");
114
+ this._lastTarget = e.target;
117
115
  this._lastTarget.classList.add("maplair-drag-target");
118
116
  }
119
117
  this._newPos = this._startPos.add(offset);
@@ -124,10 +122,13 @@ var Draggable = class Draggable extends Evented {
124
122
  _updatePosition() {
125
123
  const e = { originalEvent: this._lastEvent };
126
124
  this.fire("predrag", e);
125
+ const dpr = window.devicePixelRatio;
126
+ this._newPos = this._newPos.multiplyBy(dpr)._round()._divideBy(dpr);
127
127
  setPosition(this._element, this._newPos);
128
128
  this.fire("drag", e);
129
129
  }
130
- _onUp() {
130
+ _onUp(e) {
131
+ if (e.type === "lostpointercapture" && e.buttons) return;
131
132
  this.finishDrag();
132
133
  }
133
134
  /**
@@ -137,15 +138,15 @@ var Draggable = class Draggable extends Evented {
137
138
  * @returns {void}
138
139
  */
139
140
  finishDrag(noInertia) {
140
- this._element.ownerDocument.body.classList.remove("maplair-dragging");
141
+ this._draggingContainer?.classList.remove("maplair-dragging");
142
+ this._draggingContainer = null;
141
143
  if (this._lastTarget) {
142
144
  this._lastTarget.classList.remove("maplair-drag-target");
143
145
  this._lastTarget = null;
144
146
  }
145
147
  off(this._dragStartTarget, "pointermove", this._onMove, this);
146
- off(this._dragStartTarget, "pointerup pointercancel", this._onUp, this);
148
+ off(this._dragStartTarget, "pointerup pointercancel lostpointercapture", this._onUp, this);
147
149
  enableImageDrag();
148
- enableTextSelection();
149
150
  const fireDragend = this._moved && this._moving;
150
151
  this._moving = false;
151
152
  Draggable._dragging = false;
@@ -155,7 +156,6 @@ var Draggable = class Draggable extends Evented {
155
156
  });
156
157
  }
157
158
  };
158
- //#endregion
159
159
  export { Draggable };
160
160
 
161
161
  //# sourceMappingURL=Draggable.js.map
@@ -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;EAEvB,KAAK,cAAc,SAAS;CAC7B;;;;;CAMA,SAAS;EACR,IAAI,KAAK,UAAY;EAErB,GAAY,KAAK,kBAAkB,eAAe,KAAK,SAAS,IAAI;EAEpE,KAAK,WAAW;CACjB;;;;;CAMA,UAAU;EACT,IAAI,CAAC,KAAK,UAAY;EAItB,IAAI,UAAU,cAAc,MAC3B,KAAK,WAAW,IAAI;EAGrB,IAAa,KAAK,kBAAkB,eAAe,KAAK,SAAS,IAAI;EAErE,KAAK,WAAW;EAChB,KAAK,SAAS;CACf;CAEA,QAAQ,GAAG;EACV,KAAK,SAAS;EAEd,IAAI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,EAAE,UAAU,EAAE;GACjC,KAAK,YAAY,UAAU,IAAI,qBAAqB;EACrD;EAEA,KAAK,UAAU,KAAK,UAAU,IAAI,MAAM;EACxC,KAAK,UAAU;EAEf,KAAK,aAAa;EAClB,KAAK,gBAAgB;CACtB;CAEA,kBAAkB;EACjB,MAAM,IAAI,EAAC,eAAe,KAAK,WAAU;EAEzC,KAAK,KAAK,WAAW,CAAC;EACtB,YAAoB,KAAK,UAAU,KAAK,OAAO;EAE/C,KAAK,KAAK,QAAQ,CAAC;CACpB;CAEA,QAAQ;EACP,KAAK,WAAW;CACjB;;;;;;;CAQA,WAAW,WAAW;EACrB,KAAK,SAAS,cAAc,KAAK,UAAU,OAAO,kBAAkB;EAEpE,IAAI,KAAK,aAAa;GACrB,KAAK,YAAY,UAAU,OAAO,qBAAqB;GACvD,KAAK,cAAc;EACpB;EAEA,IAAa,KAAK,kBAAkB,eAAe,KAAK,SAAS,IAAI;EACrE,IAAa,KAAK,kBAAkB,2BAA2B,KAAK,OAAO,IAAI;EAE/E,gBAAwB;EACxB,oBAA4B;EAE5B,MAAM,cAAc,KAAK,UAAU,KAAK;EAExC,KAAK,UAAU;EACf,UAAU,YAAY;EAEtB,IAAI,aACH,KAAK,KAAK,WAAW;GACpB;GACA,UAAU,KAAK,QAAQ,WAAW,KAAK,SAAS;EACjD,CAAC;CAEH;AAED"}
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 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\tconst pointers = PointerEvents.getPointers().length;\n\t\tif (pointers > 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\t// outside a map, nothing tracks pointers or captures them, so capture this one to keep its moves coming\n\t\tif (!pointers && e.isTrusted) { e.target.setPointerCapture(e.pointerId); }\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;EACT,IAAI,CAAC,KAAK,UAAY;EAItB,IAAI,UAAU,cAAc,MAC3B,KAAK,WAAW,IAAI;EAGrB,IAAa,KAAK,kBAAkB,eAAe,KAAK,SAAS,IAAI;EAErE,KAAK,WAAW;EAChB,KAAK,SAAS;CACf;CAEA,QAAQ,GAAG;EACV,KAAK,SAAS;EAEd,IAAI,KAAK,SAAS,UAAU,SAAS,mBAAmB,GAAK;EAE7D,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IAAI,kBAAkB;GAExD,KAAK,cAAc,EAAE;GACrB,KAAK,YAAY,UAAU,IAAI,qBAAqB;EACrD;EAEA,KAAK,UAAU,KAAK,UAAU,IAAI,MAAM;EACxC,KAAK,UAAU;EAEf,KAAK,aAAa;EAClB,KAAK,gBAAgB;CACtB;CAEA,kBAAkB;EACjB,MAAM,IAAI,EAAC,eAAe,KAAK,WAAU;EAEzC,KAAK,KAAK,WAAW,CAAC;EAItB,MAAM,MAAM,OAAO;EACnB,KAAK,UAAU,KAAK,QAAQ,WAAW,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,GAAG;EAClE,YAAoB,KAAK,UAAU,KAAK,OAAO;EAE/C,KAAK,KAAK,QAAQ,CAAC;CACpB;CAEA,MAAM,GAAG;EAGR,IAAI,EAAE,SAAS,wBAAwB,EAAE,SAAW;EACpD,KAAK,WAAW;CACjB;;;;;;;CAQA,WAAW,WAAW;EACrB,KAAK,oBAAoB,UAAU,OAAO,kBAAkB;EAC5D,KAAK,qBAAqB;EAE1B,IAAI,KAAK,aAAa;GACrB,KAAK,YAAY,UAAU,OAAO,qBAAqB;GACvD,KAAK,cAAc;EACpB;EAEA,IAAa,KAAK,kBAAkB,eAAe,KAAK,SAAS,IAAI;EACrE,IAAa,KAAK,kBAAkB,8CAA8C,KAAK,OAAO,IAAI;EAElG,gBAAwB;EAExB,MAAM,cAAc,KAAK,UAAU,KAAK;EAExC,KAAK,UAAU;EACf,UAAU,YAAY;EAEtB,IAAI,aACH,KAAK,KAAK,WAAW;GACpB;GACA,UAAU,KAAK,QAAQ,WAAW,KAAK,SAAS;EACjD,CAAC;CAEH;AAED"}
@@ -1,34 +1,12 @@
1
1
  import { getPosition, setPosition } from "./DomUtil.js";
2
2
  import { Evented } from "../core/Events.js";
3
- //#region src/dom/PosAnimation.js
3
+ // src/dom/PosAnimation.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
  /**
@@ -98,7 +76,6 @@ var PosAnimation = class PosAnimation extends Evented {
98
76
  return 1 - (1 - t) ** this._easeOutPower;
99
77
  }
100
78
  };
101
- //#endregion
102
79
  export { PosAnimation };
103
80
 
104
81
  //# sourceMappingURL=PosAnimation.js.map
@@ -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,7 +1,6 @@
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
- //#region src/geo/LatLng.js
3
+ // src/geo/LatLng.js
5
4
  const coordinate = String.raw`([+-]?\d+(?:\.\d+)?)\s*°?`;
6
5
  const separator = String.raw`(?:\s*[,;]\s*|\s+)`;
7
6
  const plainRe = new RegExp(`^${coordinate}${separator}${coordinate}$`);
@@ -189,7 +188,7 @@ var LatLng = class LatLng {
189
188
  * @returns {number}
190
189
  */
191
190
  distanceTo(other) {
192
- return EarthCRS.distance(this, LatLng.from(other));
191
+ return haversineDistance(this, LatLng.from(other), 6371e3);
193
192
  }
194
193
  /**
195
194
  * Returns a new `LatLng` object with the longitude wrapped so it's always between
@@ -197,7 +196,7 @@ var LatLng = class LatLng {
197
196
  * @returns {LatLng}
198
197
  */
199
198
  wrap() {
200
- return EarthCRS.wrapLatLng(this);
199
+ return new LatLng(this.lat, wrapNum(this.lng, [-180, 180], true), this.alt);
201
200
  }
202
201
  /**
203
202
  * Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2`
@@ -210,7 +209,17 @@ var LatLng = class LatLng {
210
209
  return new LatLngBounds([this.lat - latAccuracy, this.lng - lngAccuracy], [this.lat + latAccuracy, this.lng + lngAccuracy]);
211
210
  }
212
211
  };
213
- //#endregion
214
- export { LatLng };
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
+ }
223
+ export { LatLng, haversineDistance };
215
224
 
216
225
  //# 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 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 EarthCRS.distance(this, LatLng.from(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,aAAa,UAAU,cAAc,WAAW,IAAI,GAAG;AAE7F,MAAA,WAAW,IAAI,OAAO,IAAI,WAAW,cAAc,YAAY,WAAW,gBAAgB,GAAG;AAC7F,MAAA,eAAe;AAEf,MAAA,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCX,IAAa,SAAb,MAAa,OAAO;;;;;;;;;;CAUnB,YAAY,KA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B,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,OAAO,KAAK,KAAK,CAAC;CAClD;;;;;;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,OAAO,IAAI,WAAW,cAAc,YAAY,WAAW,gBAAgB,GAAG;AAC7F,MAAA,eAAe;AAEf,MAAA,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;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3
3
  /** @import {LatLngExpression} from './LatLng.js' */
4
4
  /**
5
5
  * A geographical area: a `LatLngBounds`, or an array of geographical points (usually
@@ -79,19 +79,14 @@ var LatLngBounds = class LatLngBounds {
79
79
  extend(obj) {
80
80
  const sw = this._southWest, ne = this._northEast;
81
81
  let sw2, ne2;
82
- if (obj instanceof LatLng) {
83
- sw2 = obj;
84
- ne2 = obj;
85
- } else if (obj instanceof LatLngBounds) {
86
- sw2 = obj._southWest;
87
- ne2 = obj._northEast;
88
- if (!sw2 || !ne2) return this;
89
- } else {
90
- if (!obj) return this;
91
- if (LatLng.validate(obj)) return this.extend(LatLng.from(obj));
92
- return this.extend(LatLngBounds.from(obj));
93
- }
94
- if (!sw && !ne) {
82
+ if (obj instanceof LatLng) sw2 = ne2 = obj;
83
+ else if (obj instanceof LatLngBounds) {
84
+ ({_southWest: sw2, _northEast: ne2} = obj);
85
+ if (!sw2) return this;
86
+ } else if (!obj) return this;
87
+ else if (LatLng.validate(obj)) sw2 = ne2 = LatLng.from(obj);
88
+ else return this.extend(LatLngBounds.from(obj));
89
+ if (!sw) {
95
90
  this._southWest = new LatLng(sw2.lat, sw2.lng);
96
91
  this._northEast = new LatLng(ne2.lat, ne2.lng);
97
92
  } else {
@@ -249,7 +244,6 @@ var LatLngBounds = class LatLngBounds {
249
244
  return !!(this._southWest && this._northEast);
250
245
  }
251
246
  };
252
- //#endregion
253
247
  export { LatLngBounds };
254
248
 
255
249
  //# sourceMappingURL=LatLngBounds.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LatLngBounds.js","names":[],"sources":["../../../src/geo/LatLngBounds.js"],"sourcesContent":["import {LatLng} from './LatLng.js';\n/** @import {LatLngExpression} from './LatLng.js' */\n\n/**\n * A geographical area: a `LatLngBounds`, or an array of geographical points (usually\n * two diagonally opposite corners), e.g. `[[40.712, -74.227], [40.774, -74.125]]`.\n * Accepted by all Maplair methods which accept `LatLngBounds` objects (unless noted\n * otherwise).\n * @typedef {LatLngBounds|LatLngExpression[]} LatLngBoundsExpression\n */\n\n// TODO International date line?\n\n/**\n * Represents a rectangular geographical area on a map.\n *\n * @example\n * ```js\n * const corner1 = new LatLng(40.712, -74.227),\n * corner2 = new LatLng(40.774, -74.125),\n * bounds = new LatLngBounds(corner1, corner2);\n * ```\n *\n * All Maplair methods that accept LatLngBounds objects also accept them in a simple\n * Array form (unless noted otherwise), so the bounds example above can be passed like\n * this:\n *\n * ```js\n * map.fitBounds([\n * \t[40.712, -74.227],\n * \t[40.774, -74.125]\n * ]);\n * ```\n *\n * Caution: if the area crosses the antimeridian (often confused with the International\n * Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range.\n *\n * Note that `LatLngBounds` 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 LatLngBounds {\n\t/**\n\t * Creates a `LatLngBounds` object by defining two diagonally opposite corners of the\n\t * rectangle. Alternatively, creates a `LatLngBounds` object defined by the\n\t * geographical points it contains (very useful for zooming the map to fit a\n\t * particular set of locations with [`fitBounds`](#map-fitbounds)), or a copy of the\n\t * given `LatLngBounds` object.\n\t * @param {LatLngExpression|LatLngBoundsExpression} [corner1] The first corner, the\n\t * points or the bounds to copy.\n\t * @param {LatLngExpression} [corner2] The opposite corner.\n\t */\n\tconstructor(corner1, corner2) { // (LatLng, LatLng) or (LatLng[])\n\t\tif (!corner1) { return; }\n\n\t\tif (corner1 instanceof LatLngBounds) {\n\t\t\tif (corner1.isValid()) {\n\t\t\t\tthis._southWest = new LatLng(corner1._southWest);\n\t\t\t\tthis._northEast = new LatLng(corner1._northEast);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst latlngs = corner2 ? [corner1, corner2] : corner1;\n\n\t\tfor (const latlng of latlngs) {\n\t\t\tthis.extend(latlng);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the given `LatLngBounds` object as it is, or else a new `LatLngBounds`\n\t * object created from the given arguments (the same as of the constructor) — unlike\n\t * the constructor, which always creates a new object.\n\t * @param {LatLngExpression|LatLngBoundsExpression} [corner1] The first corner, the\n\t * points or the bounds.\n\t * @param {LatLngExpression} [corner2] The opposite corner.\n\t * @returns {LatLngBounds}\n\t */\n\tstatic from(corner1, corner2) {\n\t\treturn corner1 instanceof LatLngBounds ? corner1 : new LatLngBounds(corner1, corner2);\n\t}\n\n\t/**\n\t * Extend the bounds to contain the given point or bounds.\n\t * @param {LatLngExpression|LatLngBoundsExpression} obj\n\t * @returns {this}\n\t */\n\textend(obj) {\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast;\n\t\tlet sw2, ne2;\n\n\t\tif (obj instanceof LatLng) {\n\t\t\tsw2 = obj;\n\t\t\tne2 = obj;\n\n\t\t} else if (obj instanceof LatLngBounds) {\n\t\t\tsw2 = obj._southWest;\n\t\t\tne2 = obj._northEast;\n\n\t\t\tif (!sw2 || !ne2) { return this; }\n\n\t\t} else {\n\t\t\tif (!obj) {\n\t\t\t\treturn this;\n\t\t\t}\n\t\t\tif (LatLng.validate(obj)) {\n\t\t\t\treturn this.extend(LatLng.from(obj));\n\t\t\t}\n\t\t\treturn this.extend(LatLngBounds.from(obj));\n\t\t}\n\n\t\tif (!sw && !ne) {\n\t\t\tthis._southWest = new LatLng(sw2.lat, sw2.lng);\n\t\t\tthis._northEast = new LatLng(ne2.lat, ne2.lng);\n\t\t} else {\n\t\t\tsw.lat = Math.min(sw2.lat, sw.lat);\n\t\t\tsw.lng = Math.min(sw2.lng, sw.lng);\n\t\t\tne.lat = Math.max(ne2.lat, ne.lat);\n\t\t\tne.lng = Math.max(ne2.lng, ne.lng);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns bounds created by extending or retracting the current bounds by a given\n\t * ratio in each direction. For example, a ratio of 0.5 extends the bounds by 50% in\n\t * each direction. Negative values will retract the bounds.\n\t * @param {number} bufferRatio\n\t * @returns {LatLngBounds}\n\t */\n\tpad(bufferRatio) {\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast,\n\t\theightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,\n\t\twidthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;\n\n\t\treturn new LatLngBounds(\n\t\t\tnew LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer),\n\t\t\tnew LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));\n\t}\n\n\t/**\n\t * Returns the center point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetCenter() {\n\t\treturn new LatLng(\n\t\t\t(this._southWest.lat + this._northEast.lat) / 2,\n\t\t\t(this._southWest.lng + this._northEast.lng) / 2);\n\t}\n\n\t/**\n\t * Returns the south-west point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetSouthWest() {\n\t\treturn this._southWest;\n\t}\n\n\t/**\n\t * Returns the north-east point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetNorthEast() {\n\t\treturn this._northEast;\n\t}\n\n\t/**\n\t * Returns the north-west point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetNorthWest() {\n\t\treturn new LatLng(this.getNorth(), this.getWest());\n\t}\n\n\t/**\n\t * Returns the south-east point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetSouthEast() {\n\t\treturn new LatLng(this.getSouth(), this.getEast());\n\t}\n\n\t/**\n\t * Returns the west longitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetWest() {\n\t\treturn this._southWest.lng;\n\t}\n\n\t/**\n\t * Returns the south latitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetSouth() {\n\t\treturn this._southWest.lat;\n\t}\n\n\t/**\n\t * Returns the east longitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetEast() {\n\t\treturn this._northEast.lng;\n\t}\n\n\t/**\n\t * Returns the north latitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetNorth() {\n\t\treturn this._northEast.lat;\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle contains the given bounds or point.\n\t * @param {LatLngBoundsExpression|LatLngExpression} obj\n\t * @returns {boolean}\n\t */\n\tcontains(obj) { // (LatLngBounds) or (LatLng) -> Boolean\n\t\tif (LatLng.validate(obj)) {\n\t\t\tobj = LatLng.from(obj);\n\t\t} else {\n\t\t\tobj = LatLngBounds.from(obj);\n\t\t}\n\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast;\n\t\tlet sw2, ne2;\n\n\t\tif (obj instanceof LatLngBounds) {\n\t\t\tsw2 = obj.getSouthWest();\n\t\t\tne2 = obj.getNorthEast();\n\t\t} else {\n\t\t\tsw2 = ne2 = obj;\n\t\t}\n\n\t\treturn (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) &&\n\t\t (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle intersects the given bounds. Two bounds intersect\n\t * if they have at least one point in common.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\tintersects(bounds) {\n\t\tbounds = LatLngBounds.from(bounds);\n\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast,\n\t\tsw2 = bounds.getSouthWest(),\n\t\tne2 = bounds.getNorthEast(),\n\n\t\tlatIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat),\n\t\tlngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng);\n\n\t\treturn latIntersects && lngIntersects;\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if\n\t * their intersection is an area.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\toverlaps(bounds) {\n\t\tbounds = LatLngBounds.from(bounds);\n\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast,\n\t\tsw2 = bounds.getSouthWest(),\n\t\tne2 = bounds.getNorthEast(),\n\n\t\tlatOverlaps = (ne2.lat > sw.lat) && (sw2.lat < ne.lat),\n\t\tlngOverlaps = (ne2.lng > sw.lng) && (sw2.lng < ne.lng);\n\n\t\treturn latOverlaps && lngOverlaps;\n\t}\n\n\t/**\n\t * Returns a string with bounding box coordinates in a\n\t * 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for\n\t * sending requests to web services that return geo data.\n\t * @returns {string}\n\t */\n\ttoBBoxString() {\n\t\treturn [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',');\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle is equivalent (within a small margin of error) to\n\t * the given bounds. The margin of error can be overridden by setting `maxMargin` to\n\t * a small number.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @param {number} [maxMargin]\n\t * @returns {boolean}\n\t */\n\tequals(bounds, maxMargin) {\n\t\tif (!bounds) { return false; }\n\n\t\tbounds = LatLngBounds.from(bounds);\n\n\t\treturn this._southWest.equals(bounds.getSouthWest(), maxMargin) &&\n\t\t this._northEast.equals(bounds.getNorthEast(), maxMargin);\n\t}\n\n\t/**\n\t * Returns `true` if the bounds are properly initialized.\n\t * @returns {boolean}\n\t */\n\tisValid() {\n\t\treturn !!(this._southWest && this._northEast);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,eAAb,MAAa,aAAa;;;;;;;;;;;CAWzB,YAAY,SAAS,SAAS;EAC7B,IAAI,CAAC,SAAW;EAEhB,IAAI,mBAAmB,cAAc;GACpC,IAAI,QAAQ,QAAQ,GAAG;IACtB,KAAK,aAAa,IAAI,OAAO,QAAQ,UAAU;IAC/C,KAAK,aAAa,IAAI,OAAO,QAAQ,UAAU;GAChD;GACA;EACD;EAEA,MAAM,UAAU,UAAU,CAAC,SAAS,OAAO,IAAI;EAE/C,KAAK,MAAM,UAAU,SACpB,KAAK,OAAO,MAAM;CAEpB;;;;;;;;;;CAWA,OAAO,KAAK,SAAS,SAAS;EAC7B,OAAO,mBAAmB,eAAe,UAAU,IAAI,aAAa,SAAS,OAAO;CACrF;;;;;;CAOA,OAAO,KAAK;EACX,MAAM,KAAK,KA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IAAI,MAAM,GAAG,OAAS,IAAI,MAAM,GAAG,KAClD,cAAe,IAAI,MAAM,GAAG,OAAS,IAAI,MAAM,GAAG;EAElD,OAAO,eAAe;CACvB;;;;;;;CAQA,eAAe;EACd,OAAO;GAAC,KAAK,QAAQ;GAAG,KAAK,SAAS;GAAG,KAAK,QAAQ;GAAG,KAAK,SAAS;EAAC,CAAC,CAAC,KAAK,GAAG;CACnF;;;;;;;;;CAUA,OAAO,QAAQ,WAAW;EACzB,IAAI,CAAC,QAAU,OAAO;EAEtB,SAAS,aAAa,KAAK,MAAM;EAEjC,OAAO,KAAK,WAAW,OAAO,OAAO,aAAa,GAAG,SAAS,KACvD,KAAK,WAAW,OAAO,OAAO,aAAa,GAAG,SAAS;CAC/D;;;;;CAMA,UAAU;EACT,OAAO,CAAC,EAAE,KAAK,cAAc,KAAK;CACnC;AACD"}
1
+ {"version":3,"file":"LatLngBounds.js","names":[],"sources":["../../../src/geo/LatLngBounds.js"],"sourcesContent":["import {LatLng} from './LatLng.js';\n/** @import {LatLngExpression} from './LatLng.js' */\n\n/**\n * A geographical area: a `LatLngBounds`, or an array of geographical points (usually\n * two diagonally opposite corners), e.g. `[[40.712, -74.227], [40.774, -74.125]]`.\n * Accepted by all Maplair methods which accept `LatLngBounds` objects (unless noted\n * otherwise).\n * @typedef {LatLngBounds|LatLngExpression[]} LatLngBoundsExpression\n */\n\n// TODO International date line?\n\n/**\n * Represents a rectangular geographical area on a map.\n *\n * @example\n * ```js\n * const corner1 = new LatLng(40.712, -74.227),\n * corner2 = new LatLng(40.774, -74.125),\n * bounds = new LatLngBounds(corner1, corner2);\n * ```\n *\n * All Maplair methods that accept LatLngBounds objects also accept them in a simple\n * Array form (unless noted otherwise), so the bounds example above can be passed like\n * this:\n *\n * ```js\n * map.fitBounds([\n * \t[40.712, -74.227],\n * \t[40.774, -74.125]\n * ]);\n * ```\n *\n * Caution: if the area crosses the antimeridian (often confused with the International\n * Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range.\n *\n * Note that `LatLngBounds` 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 LatLngBounds {\n\t/**\n\t * Creates a `LatLngBounds` object by defining two diagonally opposite corners of the\n\t * rectangle. Alternatively, creates a `LatLngBounds` object defined by the\n\t * geographical points it contains (very useful for zooming the map to fit a\n\t * particular set of locations with [`fitBounds`](#map-fitbounds)), or a copy of the\n\t * given `LatLngBounds` object.\n\t * @param {LatLngExpression|LatLngBoundsExpression} [corner1] The first corner, the\n\t * points or the bounds to copy.\n\t * @param {LatLngExpression} [corner2] The opposite corner.\n\t */\n\tconstructor(corner1, corner2) { // (LatLng, LatLng) or (LatLng[])\n\t\tif (!corner1) { return; }\n\n\t\tif (corner1 instanceof LatLngBounds) {\n\t\t\tif (corner1.isValid()) {\n\t\t\t\tthis._southWest = new LatLng(corner1._southWest);\n\t\t\t\tthis._northEast = new LatLng(corner1._northEast);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tconst latlngs = corner2 ? [corner1, corner2] : corner1;\n\n\t\tfor (const latlng of latlngs) {\n\t\t\tthis.extend(latlng);\n\t\t}\n\t}\n\n\t/**\n\t * Returns the given `LatLngBounds` object as it is, or else a new `LatLngBounds`\n\t * object created from the given arguments (the same as of the constructor) — unlike\n\t * the constructor, which always creates a new object.\n\t * @param {LatLngExpression|LatLngBoundsExpression} [corner1] The first corner, the\n\t * points or the bounds.\n\t * @param {LatLngExpression} [corner2] The opposite corner.\n\t * @returns {LatLngBounds}\n\t */\n\tstatic from(corner1, corner2) {\n\t\treturn corner1 instanceof LatLngBounds ? corner1 : new LatLngBounds(corner1, corner2);\n\t}\n\n\t/**\n\t * Extend the bounds to contain the given point or bounds.\n\t * @param {LatLngExpression|LatLngBoundsExpression} obj\n\t * @returns {this}\n\t */\n\textend(obj) {\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast;\n\t\tlet sw2, ne2;\n\n\t\tif (obj instanceof LatLng) {\n\t\t\tsw2 = ne2 = obj;\n\t\t} else if (obj instanceof LatLngBounds) {\n\t\t\t({_southWest: sw2, _northEast: ne2} = obj);\n\t\t\tif (!sw2) { return this; }\n\t\t} else if (!obj) {\n\t\t\treturn this;\n\t\t} else if (LatLng.validate(obj)) {\n\t\t\tsw2 = ne2 = LatLng.from(obj);\n\t\t} else {\n\t\t\treturn this.extend(LatLngBounds.from(obj));\n\t\t}\n\n\t\tif (!sw) {\n\t\t\tthis._southWest = new LatLng(sw2.lat, sw2.lng);\n\t\t\tthis._northEast = new LatLng(ne2.lat, ne2.lng);\n\t\t} else {\n\t\t\tsw.lat = Math.min(sw2.lat, sw.lat);\n\t\t\tsw.lng = Math.min(sw2.lng, sw.lng);\n\t\t\tne.lat = Math.max(ne2.lat, ne.lat);\n\t\t\tne.lng = Math.max(ne2.lng, ne.lng);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns bounds created by extending or retracting the current bounds by a given\n\t * ratio in each direction. For example, a ratio of 0.5 extends the bounds by 50% in\n\t * each direction. Negative values will retract the bounds.\n\t * @param {number} bufferRatio\n\t * @returns {LatLngBounds}\n\t */\n\tpad(bufferRatio) {\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast,\n\t\theightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,\n\t\twidthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;\n\n\t\treturn new LatLngBounds(\n\t\t\tnew LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer),\n\t\t\tnew LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));\n\t}\n\n\t/**\n\t * Returns the center point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetCenter() {\n\t\treturn new LatLng(\n\t\t\t(this._southWest.lat + this._northEast.lat) / 2,\n\t\t\t(this._southWest.lng + this._northEast.lng) / 2);\n\t}\n\n\t/**\n\t * Returns the south-west point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetSouthWest() {\n\t\treturn this._southWest;\n\t}\n\n\t/**\n\t * Returns the north-east point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetNorthEast() {\n\t\treturn this._northEast;\n\t}\n\n\t/**\n\t * Returns the north-west point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetNorthWest() {\n\t\treturn new LatLng(this.getNorth(), this.getWest());\n\t}\n\n\t/**\n\t * Returns the south-east point of the bounds.\n\t * @returns {LatLng}\n\t */\n\tgetSouthEast() {\n\t\treturn new LatLng(this.getSouth(), this.getEast());\n\t}\n\n\t/**\n\t * Returns the west longitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetWest() {\n\t\treturn this._southWest.lng;\n\t}\n\n\t/**\n\t * Returns the south latitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetSouth() {\n\t\treturn this._southWest.lat;\n\t}\n\n\t/**\n\t * Returns the east longitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetEast() {\n\t\treturn this._northEast.lng;\n\t}\n\n\t/**\n\t * Returns the north latitude of the bounds.\n\t * @returns {number}\n\t */\n\tgetNorth() {\n\t\treturn this._northEast.lat;\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle contains the given bounds or point.\n\t * @param {LatLngBoundsExpression|LatLngExpression} obj\n\t * @returns {boolean}\n\t */\n\tcontains(obj) { // (LatLngBounds) or (LatLng) -> Boolean\n\t\tif (LatLng.validate(obj)) {\n\t\t\tobj = LatLng.from(obj);\n\t\t} else {\n\t\t\tobj = LatLngBounds.from(obj);\n\t\t}\n\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast;\n\t\tlet sw2, ne2;\n\n\t\tif (obj instanceof LatLngBounds) {\n\t\t\tsw2 = obj.getSouthWest();\n\t\t\tne2 = obj.getNorthEast();\n\t\t} else {\n\t\t\tsw2 = ne2 = obj;\n\t\t}\n\n\t\treturn (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) &&\n\t\t (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle intersects the given bounds. Two bounds intersect\n\t * if they have at least one point in common.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\tintersects(bounds) {\n\t\tbounds = LatLngBounds.from(bounds);\n\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast,\n\t\tsw2 = bounds.getSouthWest(),\n\t\tne2 = bounds.getNorthEast(),\n\n\t\tlatIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat),\n\t\tlngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng);\n\n\t\treturn latIntersects && lngIntersects;\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if\n\t * their intersection is an area.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @returns {boolean}\n\t */\n\toverlaps(bounds) {\n\t\tbounds = LatLngBounds.from(bounds);\n\n\t\tconst sw = this._southWest,\n\t\tne = this._northEast,\n\t\tsw2 = bounds.getSouthWest(),\n\t\tne2 = bounds.getNorthEast(),\n\n\t\tlatOverlaps = (ne2.lat > sw.lat) && (sw2.lat < ne.lat),\n\t\tlngOverlaps = (ne2.lng > sw.lng) && (sw2.lng < ne.lng);\n\n\t\treturn latOverlaps && lngOverlaps;\n\t}\n\n\t/**\n\t * Returns a string with bounding box coordinates in a\n\t * 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for\n\t * sending requests to web services that return geo data.\n\t * @returns {string}\n\t */\n\ttoBBoxString() {\n\t\treturn [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',');\n\t}\n\n\t/**\n\t * Returns `true` if the rectangle is equivalent (within a small margin of error) to\n\t * the given bounds. The margin of error can be overridden by setting `maxMargin` to\n\t * a small number.\n\t * @param {LatLngBoundsExpression} bounds\n\t * @param {number} [maxMargin]\n\t * @returns {boolean}\n\t */\n\tequals(bounds, maxMargin) {\n\t\tif (!bounds) { return false; }\n\n\t\tbounds = LatLngBounds.from(bounds);\n\n\t\treturn this._southWest.equals(bounds.getSouthWest(), maxMargin) &&\n\t\t this._northEast.equals(bounds.getNorthEast(), maxMargin);\n\t}\n\n\t/**\n\t * Returns `true` if the bounds are properly initialized.\n\t * @returns {boolean}\n\t */\n\tisValid() {\n\t\treturn !!(this._southWest && this._northEast);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,eAAb,MAAa,aAAa;;;;;;;;;;;CAWzB,YAAY,SAAS,SAAS;EAC7B,IAAI,CAAC,SAAW;EAEhB,IAAI,mBAAmB,cAAc;GACpC,IAAI,QAAQ,QAAQ,GAAG;IACtB,KAAK,aAAa,IAAI,OAAO,QAAQ,UAAU;IAC/C,KAAK,aAAa,IAAI,OAAO,QAAQ,UAAU;GAChD;GACA;EACD;EAEA,MAAM,UAAU,UAAU,CAAC,SAAS,OAAO,IAAI;EAE/C,KAAK,MAAM,UAAU,SACpB,KAAK,OAAO,MAAM;CAEpB;;;;;;;;;;CAWA,OAAO,KAAK,SAAS,SAAS;EAC7B,OAAO,mBAAmB,eAAe,UAAU,IAAI,aAAa,SAAS,OAAO;CACrF;;;;;;CAOA,OAAO,KAAK;EACX,MAAM,KAAK,KAAK,YAChB,KAAK,KAAK;EACV,IAAI,KAAK;EAET,IAAI,eAAe,QAClB,MAAM,MAAM;OACN,IAAI,eAAe,cAAc;GACvC,CAAC,CAAC,YAAY,KAAK,YAAY,OAAO;GACtC,IAAI,CAAC,KAAO,OAAO;EACpB,OAAO,IAAI,CAAC,KACX,OAAO;OACD,IAAI,OAAO,SAAS,GAAG,GAC7B,MAAM,MAAM,OAAO,KAAK,GAAG;OAE3B,OAAO,KAAK,OAAO,aAAa,KAAK,GAAG,CAAC;EAG1C,IAAI,CAAC,IAAI;GACR,KAAK,aAAa,IAAI,OAAO,IAAI,KAAK,IAAI,GAAG;GAC7C,KAAK,aAAa,IAAI,OAAO,IAAI,KAAK,IAAI,GAAG;EAC9C,OA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K;CACnC;AACD"}
@@ -2,7 +2,7 @@ import { wrapNum } from "../../core/Util.js";
2
2
  import { Bounds } from "../../geometry/Bounds.js";
3
3
  import { LatLngBounds } from "../LatLngBounds.js";
4
4
  import { LatLng } from "../LatLng.js";
5
- //#region src/geo/crs/CRS.js
5
+ // src/geo/crs/CRS.js
6
6
  /** @import {LatLngExpression} from '../LatLng.js' */
7
7
  /** @import {LatLngBoundsExpression} from '../LatLngBounds.js' */
8
8
  /** @import {Point} from '../../geometry/Point.js' */
@@ -146,7 +146,6 @@ var CRS = class {
146
146
  return new LatLngBounds(newSw, newNe);
147
147
  }
148
148
  };
149
- //#endregion
150
149
  export { CRS };
151
150
 
152
151
  //# sourceMappingURL=CRS.js.map
@@ -1,7 +1,7 @@
1
1
  import { EarthCRS } from "./EarthCRS.js";
2
2
  import { Transformation } from "../../geometry/Transformation.js";
3
- import { Mercator } from "../projection/Projection.Mercator.js";
4
- //#region src/geo/crs/EPSG3395.js
3
+ import { MercatorProjection } from "../projection/MercatorProjection.js";
4
+ // src/geo/crs/EPSG3395.js
5
5
  /** @import {Projection} from '../projection/index.js' */
6
6
  /**
7
7
  * Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.
@@ -10,14 +10,13 @@ var EPSG3395 = class extends EarthCRS {
10
10
  /** @type {string} */
11
11
  static code = "EPSG:3395";
12
12
  /** @type {Projection} */
13
- static projection = Mercator;
13
+ static projection = MercatorProjection;
14
14
  /** @type {Transformation} */
15
- static transformation = (() => {
16
- const scale = .5 / (Math.PI * Mercator.R);
15
+ static transformation = /* @__PURE__ */ (() => {
16
+ const scale = .5 / (Math.PI * MercatorProjection.R);
17
17
  return new Transformation(scale, .5, -scale, .5);
18
18
  })();
19
19
  };
20
- //#endregion
21
20
  export { EPSG3395 };
22
21
 
23
22
  //# sourceMappingURL=EPSG3395.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EPSG3395.js","names":[],"sources":["../../../../src/geo/crs/EPSG3395.js"],"sourcesContent":["import {EarthCRS} from './EarthCRS.js';\nimport {Mercator} from '../projection/Projection.Mercator.js';\nimport {Transformation} from '../../geometry/Transformation.js';\n/** @import {Projection} from '../projection/index.js' */\n\n/**\n * Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.\n */\nexport class EPSG3395 extends EarthCRS {\n\t/** @type {string} */\n\tstatic code = 'EPSG:3395';\n\t/** @type {Projection} */\n\tstatic projection = Mercator;\n\t/** @type {Transformation} */\n\tstatic transformation = (() => {\n\t\tconst scale = 0.5 / (Math.PI * Mercator.R);\n\t\treturn new Transformation(scale, 0.5, -scale, 0.5);\n\t})();\n}\n"],"mappings":";;;;;;;;AAQA,IAAa,WAAb,cAA8B,SAAS;;CAEtC,OAAO,OAAO;;CAEd,OAAO,aAAa;;CAEpB,OAAO,wBAAwB;EAC9B,MAAM,QAAQ,MAAO,KAAK,KAAK,SAAS;EACxC,OAAO,IAAI,eAAe,OAAO,IAAK,CAAC,OAAO,EAAG;CAClD,EAAA,CAAG;AACJ"}
1
+ {"version":3,"file":"EPSG3395.js","names":[],"sources":["../../../../src/geo/crs/EPSG3395.js"],"sourcesContent":["import {EarthCRS} from './EarthCRS.js';\nimport {MercatorProjection} from '../projection/MercatorProjection.js';\nimport {Transformation} from '../../geometry/Transformation.js';\n/** @import {Projection} from '../projection/index.js' */\n\n/**\n * Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.\n */\nexport class EPSG3395 extends EarthCRS {\n\t/** @type {string} */\n\tstatic code = 'EPSG:3395';\n\t/** @type {Projection} */\n\tstatic projection = MercatorProjection;\n\t/** @type {Transformation} */\n\tstatic transformation = /* @__PURE__ */ (() => {\n\t\tconst scale = 0.5 / (Math.PI * MercatorProjection.R);\n\t\treturn new Transformation(scale, 0.5, -scale, 0.5);\n\t})();\n}\n"],"mappings":";;;;;;;;AAQA,IAAa,WAAb,cAA8B,SAAS;;CAEtC,OAAO,OAAO;;CAEd,OAAO,aAAa;;CAEpB,OAAO,iBAAiC,uBAAO;EAC9C,MAAM,QAAQ,MAAO,KAAK,KAAK,mBAAmB;EAClD,OAAO,IAAI,eAAe,OAAO,IAAK,CAAC,OAAO,EAAG;CAClD,EAAA,CAAG;AACJ"}
@@ -1,7 +1,7 @@
1
1
  import { EarthCRS } from "./EarthCRS.js";
2
- import { SphericalMercator } from "../projection/Projection.SphericalMercator.js";
2
+ import { SphericalMercatorProjection } from "../projection/SphericalMercatorProjection.js";
3
3
  import { Transformation } from "../../geometry/Transformation.js";
4
- //#region src/geo/crs/EPSG3857.js
4
+ // src/geo/crs/EPSG3857.js
5
5
  /** @import {Projection} from '../projection/index.js' */
6
6
  /**
7
7
  * The most common CRS for online maps, used by almost all free and commercial
@@ -12,10 +12,10 @@ var EPSG3857 = class extends EarthCRS {
12
12
  /** @type {string} */
13
13
  static code = "EPSG:3857";
14
14
  /** @type {Projection} */
15
- static projection = SphericalMercator;
15
+ static projection = SphericalMercatorProjection;
16
16
  /** @type {Transformation} */
17
- static transformation = (() => {
18
- const scale = .5 / (Math.PI * SphericalMercator.R);
17
+ static transformation = /* @__PURE__ */ (() => {
18
+ const scale = .5 / (Math.PI * SphericalMercatorProjection.R);
19
19
  return new Transformation(scale, .5, -scale, .5);
20
20
  })();
21
21
  };
@@ -26,7 +26,6 @@ var EPSG900913 = class extends EPSG3857 {
26
26
  /** @type {string} */
27
27
  static code = "EPSG:900913";
28
28
  };
29
- //#endregion
30
29
  export { EPSG3857, EPSG900913 };
31
30
 
32
31
  //# sourceMappingURL=EPSG3857.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EPSG3857.js","names":[],"sources":["../../../../src/geo/crs/EPSG3857.js"],"sourcesContent":["import {EarthCRS} from './EarthCRS.js';\nimport {SphericalMercator} from '../projection/Projection.SphericalMercator.js';\nimport {Transformation} from '../../geometry/Transformation.js';\n/** @import {Projection} from '../projection/index.js' */\n\n/**\n * The most common CRS for online maps, used by almost all free and commercial\n * tile providers. Uses Spherical Mercator projection. Set in by default in\n * Map's `crs` option.\n */\nexport class EPSG3857 extends EarthCRS {\n\t/** @type {string} */\n\tstatic code = 'EPSG:3857';\n\t/** @type {Projection} */\n\tstatic projection = SphericalMercator;\n\t/** @type {Transformation} */\n\tstatic transformation = (() => {\n\t\tconst scale = 0.5 / (Math.PI * SphericalMercator.R);\n\t\treturn new Transformation(scale, 0.5, -scale, 0.5);\n\t})();\n}\n\n/**\n * The same as `EPSG3857`, with its former unofficial code `EPSG:900913`.\n */\nexport class EPSG900913 extends EPSG3857 {\n\t/** @type {string} */\n\tstatic code = 'EPSG:900913';\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAa,WAAb,cAA8B,SAAS;;CAEtC,OAAO,OAAO;;CAEd,OAAO,aAAa;;CAEpB,OAAO,wBAAwB;EAC9B,MAAM,QAAQ,MAAO,KAAK,KAAK,kBAAkB;EACjD,OAAO,IAAI,eAAe,OAAO,IAAK,CAAC,OAAO,EAAG;CAClD,EAAA,CAAG;AACJ;;;;AAKA,IAAa,aAAb,cAAgC,SAAS;;CAExC,OAAO,OAAO;AACf"}
1
+ {"version":3,"file":"EPSG3857.js","names":[],"sources":["../../../../src/geo/crs/EPSG3857.js"],"sourcesContent":["import {EarthCRS} from './EarthCRS.js';\nimport {SphericalMercatorProjection} from '../projection/SphericalMercatorProjection.js';\nimport {Transformation} from '../../geometry/Transformation.js';\n/** @import {Projection} from '../projection/index.js' */\n\n/**\n * The most common CRS for online maps, used by almost all free and commercial\n * tile providers. Uses Spherical Mercator projection. Set in by default in\n * Map's `crs` option.\n */\nexport class EPSG3857 extends EarthCRS {\n\t/** @type {string} */\n\tstatic code = 'EPSG:3857';\n\t/** @type {Projection} */\n\tstatic projection = SphericalMercatorProjection;\n\t/** @type {Transformation} */\n\tstatic transformation = /* @__PURE__ */ (() => {\n\t\tconst scale = 0.5 / (Math.PI * SphericalMercatorProjection.R);\n\t\treturn new Transformation(scale, 0.5, -scale, 0.5);\n\t})();\n}\n\n/**\n * The same as `EPSG3857`, with its former unofficial code `EPSG:900913`.\n */\nexport class EPSG900913 extends EPSG3857 {\n\t/** @type {string} */\n\tstatic code = 'EPSG:900913';\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAa,WAAb,cAA8B,SAAS;;CAEtC,OAAO,OAAO;;CAEd,OAAO,aAAa;;CAEpB,OAAO,iBAAiC,uBAAO;EAC9C,MAAM,QAAQ,MAAO,KAAK,KAAK,4BAA4B;EAC3D,OAAO,IAAI,eAAe,OAAO,IAAK,CAAC,OAAO,EAAG;CAClD,EAAA,CAAG;AACJ;;;;AAKA,IAAa,aAAb,cAAgC,SAAS;;CAExC,OAAO,OAAO;AACf"}
@@ -1,7 +1,7 @@
1
1
  import { EarthCRS } from "./EarthCRS.js";
2
2
  import { Transformation } from "../../geometry/Transformation.js";
3
- import { LonLat } from "../projection/Projection.LonLat.js";
4
- //#region src/geo/crs/EPSG4326.js
3
+ import { LonLatProjection } from "../projection/LonLatProjection.js";
4
+ // src/geo/crs/EPSG4326.js
5
5
  /** @import {Projection} from '../projection/index.js' */
6
6
  /**
7
7
  * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.
@@ -17,11 +17,10 @@ var EPSG4326 = class extends EarthCRS {
17
17
  /** @type {string} */
18
18
  static code = "EPSG:4326";
19
19
  /** @type {Projection} */
20
- static projection = LonLat;
20
+ static projection = LonLatProjection;
21
21
  /** @type {Transformation} */
22
- static transformation = new Transformation(1 / 180, 1, -1 / 180, .5);
22
+ static transformation = /* @__PURE__ */ new Transformation(1 / 180, 1, -1 / 180, .5);
23
23
  };
24
- //#endregion
25
24
  export { EPSG4326 };
26
25
 
27
26
  //# sourceMappingURL=EPSG4326.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EPSG4326.js","names":[],"sources":["../../../../src/geo/crs/EPSG4326.js"],"sourcesContent":["import {EarthCRS} from './EarthCRS.js';\nimport {LonLat} from '../projection/Projection.LonLat.js';\nimport {Transformation} from '../../geometry/Transformation.js';\n/** @import {Projection} from '../projection/index.js' */\n\n/**\n * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.\n *\n * Maplair complies with the\n * [TMS coordinate scheme for EPSG:4326](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic).\n * If you are using a `TileLayer` with this CRS, ensure that there are two 256x256\n * pixel tiles covering the whole earth at zoom level zero, and that the tile\n * coordinate origin is (-180,+90), or (-180,-90) for `TileLayer`s with\n * [the `tms` option](#tilelayer-tms) set.\n */\nexport class EPSG4326 extends EarthCRS {\n\t/** @type {string} */\n\tstatic code = 'EPSG:4326';\n\t/** @type {Projection} */\n\tstatic projection = LonLat;\n\t/** @type {Transformation} */\n\tstatic transformation = new Transformation(1 / 180, 1, -1 / 180, 0.5);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAa,WAAb,cAA8B,SAAS;;CAEtC,OAAO,OAAO;;CAEd,OAAO,aAAa;;CAEpB,OAAO,iBAAiB,IAAI,eAAe,IAAI,KAAK,GAAG,KAAK,KAAK,EAAG;AACrE"}
1
+ {"version":3,"file":"EPSG4326.js","names":[],"sources":["../../../../src/geo/crs/EPSG4326.js"],"sourcesContent":["import {EarthCRS} from './EarthCRS.js';\nimport {LonLatProjection} from '../projection/LonLatProjection.js';\nimport {Transformation} from '../../geometry/Transformation.js';\n/** @import {Projection} from '../projection/index.js' */\n\n/**\n * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.\n *\n * Maplair complies with the\n * [TMS coordinate scheme for EPSG:4326](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic).\n * If you are using a `TileLayer` with this CRS, ensure that there are two 256x256\n * pixel tiles covering the whole earth at zoom level zero, and that the tile\n * coordinate origin is (-180,+90), or (-180,-90) for `TileLayer`s with\n * [the `tms` option](#tilelayer-tms) set.\n */\nexport class EPSG4326 extends EarthCRS {\n\t/** @type {string} */\n\tstatic code = 'EPSG:4326';\n\t/** @type {Projection} */\n\tstatic projection = LonLatProjection;\n\t/** @type {Transformation} */\n\tstatic transformation = /* @__PURE__ */ new Transformation(1 / 180, 1, -1 / 180, 0.5);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAa,WAAb,cAA8B,SAAS;;CAEtC,OAAO,OAAO;;CAEd,OAAO,aAAa;;CAEpB,OAAO,iCAAiC,IAAI,eAAe,IAAI,KAAK,GAAG,KAAK,KAAK,EAAG;AACrF"}
@@ -1,5 +1,6 @@
1
+ import { haversineDistance } from "../LatLng.js";
1
2
  import { CRS } from "./CRS.js";
2
- //#region src/geo/crs/EarthCRS.js
3
+ // src/geo/crs/EarthCRS.js
3
4
  /** @import {LatLng} from '../LatLng.js' */
4
5
  /**
5
6
  * Serves as the base for CRS that are global such that they cover the earth.
@@ -28,11 +29,9 @@ var EarthCRS = class extends CRS {
28
29
  * @returns {number}
29
30
  */
30
31
  static distance(latlng1, latlng2) {
31
- 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, c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
32
- return this.R * c;
32
+ return haversineDistance(latlng1, latlng2, this.R);
33
33
  }
34
34
  };
35
- //#endregion
36
35
  export { EarthCRS };
37
36
 
38
37
  //# sourceMappingURL=EarthCRS.js.map