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
@@ -1,6 +1,5 @@
1
1
  import {Point} from '../geometry/Point.js';
2
2
  import * as Util from '../core/Util.js';
3
- import Browser from '../core/Browser.js';
4
3
  import {addDoubleTapListener, removeDoubleTapListener} from './DomEvent.DoubleTap.js';
5
4
  import {getScale} from './DomUtil.js';
6
5
 
@@ -24,7 +23,7 @@ export {PointerEvents};
24
23
  * @param {string|Record<string, (ev: any) => void>} types
25
24
  * @param {((ev: any) => void)|object} [fn]
26
25
  * @param {object} [context]
27
- * @returns {typeof import('./DomEvent.js')}
26
+ * @returns {void}
28
27
  */
29
28
  export function on(obj, types, fn, context) {
30
29
 
@@ -37,8 +36,6 @@ export function on(obj, types, fn, context) {
37
36
  addOne(obj, type, fn, context);
38
37
  }
39
38
  }
40
-
41
- return this;
42
39
  }
43
40
 
44
41
  const eventsKey = '_maplair_events';
@@ -54,7 +51,7 @@ const eventsKey = '_maplair_events';
54
51
  * @param {string|Record<string, (ev: any) => void>} [types]
55
52
  * @param {((ev: any) => void)|object} [fn]
56
53
  * @param {object} [context]
57
- * @returns {typeof import('./DomEvent.js')}
54
+ * @returns {void}
58
55
  */
59
56
  export function off(obj, types, fn, context) {
60
57
 
@@ -78,8 +75,6 @@ export function off(obj, types, fn, context) {
78
75
  }
79
76
  }
80
77
  }
81
-
82
- return this;
83
78
  }
84
79
 
85
80
  const DIGIT_RE = /\d/;
@@ -93,44 +88,19 @@ function batchRemove(obj, filterFn) {
93
88
  }
94
89
  }
95
90
 
96
- const pointerSubst = {
97
- pointerenter: 'pointerover',
98
- pointerleave: 'pointerout',
99
- wheel: typeof window === 'undefined' ? false : !('onwheel' in window) && 'mousewheel'
100
- };
101
-
102
91
  function addOne(obj, type, fn, context) {
103
92
  const id = type + Util.stamp(fn) + (context ? `_${Util.stamp(context)}` : '');
104
93
 
105
- if (obj[eventsKey] && obj[eventsKey][id]) { return this; }
94
+ if (obj[eventsKey] && obj[eventsKey][id]) { return; }
106
95
 
107
96
  let handler = function (e) {
108
97
  return fn.call(context || obj, e);
109
98
  };
110
99
 
111
- const originalHandler = handler;
112
-
113
- if (Browser.touch && (type === 'dblclick')) {
100
+ if (type === 'dblclick') {
114
101
  handler = addDoubleTapListener(obj, handler);
115
-
116
- } else if ('addEventListener' in obj) {
117
-
118
- if (type === 'wheel' || type === 'mousewheel') {
119
- obj.addEventListener(pointerSubst[type] || type, handler, {passive: false});
120
- } else if (type === 'pointerenter' || type === 'pointerleave') {
121
- handler = function (e) {
122
- if (isExternalTarget(obj, e)) {
123
- originalHandler(e);
124
- }
125
- };
126
- obj.addEventListener(pointerSubst[type], handler, false);
127
-
128
- } else {
129
- obj.addEventListener(type, originalHandler, false);
130
- }
131
-
132
102
  } else {
133
- obj.attachEvent(`on${type}`, handler);
103
+ obj.addEventListener(type, handler, type === 'wheel' ? {passive: false} : false);
134
104
  }
135
105
 
136
106
  obj[eventsKey] ??= {};
@@ -141,17 +111,12 @@ function removeOne(obj, type, fn, context, id) {
141
111
  id ??= type + Util.stamp(fn) + (context ? `_${Util.stamp(context)}` : '');
142
112
  const handler = obj[eventsKey] && obj[eventsKey][id];
143
113
 
144
- if (!handler) { return this; }
114
+ if (!handler) { return; }
145
115
 
146
- if (Browser.touch && (type === 'dblclick')) {
116
+ if (type === 'dblclick') {
147
117
  removeDoubleTapListener(obj, handler);
148
-
149
- } else if ('removeEventListener' in obj) {
150
-
151
- obj.removeEventListener(pointerSubst[type] || type, handler, false);
152
-
153
118
  } else {
154
- obj.detachEvent(`on${type}`, handler);
119
+ obj.removeEventListener(type, handler, false);
155
120
  }
156
121
 
157
122
  obj[eventsKey][id] = null;
@@ -165,7 +130,7 @@ function removeOne(obj, type, fn, context, id) {
165
130
  * ```
166
131
  * Also accepts a Maplair event with an `originalEvent`.
167
132
  * @param {Event|{originalEvent: Event}} e
168
- * @returns {typeof import('./DomEvent.js')}
133
+ * @returns {void}
169
134
  */
170
135
  export function stopPropagation(e) {
171
136
 
@@ -178,18 +143,15 @@ export function stopPropagation(e) {
178
143
  // custom Maplair event
179
144
  console.debug('Unsupported event', e);
180
145
  }
181
-
182
- return this;
183
146
  }
184
147
 
185
148
  /**
186
149
  * Adds `stopPropagation` to the element's `'wheel'` events (plus browser variants).
187
150
  * @param {HTMLElement} el
188
- * @returns {typeof import('./DomEvent.js')}
151
+ * @returns {void}
189
152
  */
190
153
  export function disableScrollPropagation(el) {
191
154
  addOne(el, 'wheel', stopPropagation);
192
- return this;
193
155
  }
194
156
 
195
157
  /**
@@ -198,12 +160,11 @@ export function disableScrollPropagation(el) {
198
160
  * For `'click'` events, prevents the map from handling the click
199
161
  * while still allowing the native DOM click event to propagate normally.
200
162
  * @param {HTMLElement} el
201
- * @returns {typeof import('./DomEvent.js')}
163
+ * @returns {void}
202
164
  */
203
165
  export function disableClickPropagation(el) {
204
166
  on(el, 'pointerdown dblclick contextmenu', stopPropagation);
205
167
  el['_maplair_disable_click'] = true;
206
- return this;
207
168
  }
208
169
 
209
170
  /**
@@ -212,35 +173,22 @@ export function disableClickPropagation(el) {
212
173
  * with page reload when a `<form>` is submitted).
213
174
  * Use it inside listener functions.
214
175
  * @param {Event} e
215
- * @returns {typeof import('./DomEvent.js')}
176
+ * @returns {void}
216
177
  */
217
178
  export function preventDefault(e) {
218
179
  e.preventDefault?.();
219
- return this;
220
180
  }
221
181
 
222
182
  /**
223
183
  * Does `stopPropagation` and `preventDefault` at the same time.
224
184
  * @param {Event} e
225
- * @returns {typeof import('./DomEvent.js')}
185
+ * @returns {void}
226
186
  */
227
187
  export function stop(e) {
228
188
  preventDefault(e);
229
189
  stopPropagation(e);
230
- return this;
231
- }
232
-
233
- /**
234
- * Returns an array containing the `HTMLElement`s that the given DOM event
235
- * should propagate to (if not stopped).
236
- * @param {Event} ev
237
- * @returns {EventTarget[]}
238
- */
239
- export function getPropagationPath(ev) {
240
- return ev.composedPath();
241
190
  }
242
191
 
243
-
244
192
  /**
245
193
  * Gets normalized pointer position from a DOM event relative to the
246
194
  * `container` (border excluded) or to the whole page if not specified.
@@ -269,12 +217,8 @@ export function getPointerPosition(e, container) {
269
217
  * @returns {number}
270
218
  */
271
219
  export function getWheelPxFactor() {
272
- // We need double the scroll pixels (see #7403 and #4538) for all Browsers
273
- // except OSX (Mac) -> 3x, Chrome running on Linux 1x
274
- const ratio = window.devicePixelRatio;
275
- return Browser.linux && Browser.chrome ? ratio :
276
- Browser.mac ? ratio * 3 :
277
- ratio > 0 ? 2 * ratio : 1;
220
+ // We need double the scroll pixels (see #7403 and #4538)
221
+ return window.devicePixelRatio * 2;
278
222
  }
279
223
 
280
224
  /**
@@ -295,24 +239,12 @@ export function getWheelDelta(e) {
295
239
 
296
240
  /**
297
241
  * Checks if the pointer really left/entered the element `el` (for
298
- * `pointerenter`/`pointerleave`).
242
+ * `pointerover`/`pointerout`).
299
243
  * @internal
300
244
  * @param {Node} el
301
245
  * @param {MouseEvent} e
302
246
  * @returns {boolean}
303
247
  */
304
248
  export function isExternalTarget(el, e) {
305
-
306
- let related = e.relatedTarget;
307
-
308
- if (!related) { return true; }
309
-
310
- try {
311
- while (related && (related !== el)) {
312
- related = related.parentNode;
313
- }
314
- } catch (err) {
315
- return false;
316
- }
317
- return (related !== el);
249
+ return !el.contains(e.relatedTarget);
318
250
  }
@@ -43,7 +43,13 @@ export function create(tagName, className, container) {
43
43
  */
44
44
  export function toFront(el) {
45
45
  const parent = el.parentNode;
46
- if (parent && parent.lastChild !== el) {
46
+ if (!parent || parent.lastChild === el) { return; }
47
+
48
+ // re-inserting a hovered node (e.g. bringToFront in a pointerover handler) makes Chromium 144+ fire a repeated
49
+ // pointerover and lose the next pointerout (#10129), so move the nodes after it instead
50
+ if (el.matches(':hover')) {
51
+ while (el.nextSibling) { parent.insertBefore(el.nextSibling, el); }
52
+ } else {
47
53
  parent.appendChild(el);
48
54
  }
49
55
  }
@@ -55,7 +61,11 @@ export function toFront(el) {
55
61
  */
56
62
  export function toBack(el) {
57
63
  const parent = el.parentNode;
58
- if (parent && parent.firstChild !== el) {
64
+ if (!parent || parent.firstChild === el) { return; }
65
+
66
+ if (el.matches(':hover')) { // see toFront
67
+ while (el.previousSibling) { parent.insertBefore(el.previousSibling, el.nextSibling); }
68
+ } else {
59
69
  parent.insertBefore(el, parent.firstChild);
60
70
  }
61
71
  }
@@ -82,16 +92,21 @@ export function setTransform(el, offset, scale) {
82
92
  const positions = new WeakMap();
83
93
 
84
94
  /**
85
- * Sets the position of `el` to coordinates specified by `point`,
86
- * using CSS translate or top/left positioning depending on the browser
87
- * (used by Maplair internally to position its layers).
95
+ * Sets the position of `el` to coordinates specified by `point` using a CSS translate
96
+ * (used by Maplair internally to position its layers). With `flat`, the translate is 2D,
97
+ * so `el` is painted into its parent's compositor layer instead of getting a layer of its own.
88
98
  * @param {HTMLElement|SVGElement} el
89
99
  * @param {Point} point
100
+ * @param {boolean} [flat]
90
101
  * @returns {void}
91
102
  */
92
- export function setPosition(el, point) {
103
+ export function setPosition(el, point, flat) {
93
104
  positions.set(el, point);
94
- setTransform(el, point);
105
+ if (flat) {
106
+ el.style.transform = `translate(${point.x}px, ${point.y}px)`;
107
+ } else {
108
+ setTransform(el, point);
109
+ }
95
110
  }
96
111
 
97
112
  /**
@@ -105,42 +120,6 @@ export function getPosition(el) {
105
120
  return positions.get(el) ?? new Point(0, 0);
106
121
  }
107
122
 
108
- const documentStyle = typeof document === 'undefined' ? {} : document.documentElement.style;
109
- // Safari still needs a vendor prefix, we need to detect with property name is supported.
110
- const userSelectProp = ['userSelect', 'WebkitUserSelect'].find(prop => prop in documentStyle);
111
- let prevUserSelect;
112
-
113
- /**
114
- * Prevents the user from selecting text in the document. Used internally
115
- * by Maplair to override the behaviour of any click-and-drag interaction on
116
- * the map. Affects drag interactions on the whole document.
117
- * @returns {void}
118
- */
119
- export function disableTextSelection() {
120
- const value = documentStyle[userSelectProp];
121
-
122
- if (value === 'none') {
123
- return;
124
- }
125
-
126
- prevUserSelect = value;
127
- documentStyle[userSelectProp] = 'none';
128
- }
129
-
130
- /**
131
- * Cancels the effects of a previous
132
- * [`DomUtil.disableTextSelection`](#domutil-disabletextselection).
133
- * @returns {void}
134
- */
135
- export function enableTextSelection() {
136
- if (typeof prevUserSelect === 'undefined') {
137
- return;
138
- }
139
-
140
- documentStyle[userSelectProp] = prevUserSelect;
141
- prevUserSelect = undefined;
142
- }
143
-
144
123
  /**
145
124
  * Prevents the user from generating `dragstart` DOM events, usually generated when
146
125
  * the user drags an image.
@@ -159,41 +138,6 @@ export function enableImageDrag() {
159
138
  DomEvent.off(window, 'dragstart', DomEvent.preventDefault);
160
139
  }
161
140
 
162
- let _outlineElement, _outlineStyle;
163
-
164
- /**
165
- * Makes the [outline](https://developer.mozilla.org/docs/Web/CSS/outline)
166
- * of the element `element` invisible. Used internally by Maplair to prevent
167
- * focusable elements from displaying an outline when the user performs a
168
- * drag interaction on them.
169
- * @param {HTMLElement} element
170
- * @returns {void}
171
- */
172
- export function preventOutline(element) {
173
- while (element.tabIndex === -1) {
174
- element = element.parentNode;
175
- }
176
- if (!element.style) { return; }
177
- restoreOutline();
178
- _outlineElement = element;
179
- _outlineStyle = element.style.outlineStyle;
180
- element.style.outlineStyle = 'none';
181
- DomEvent.on(window, 'keydown', restoreOutline);
182
- }
183
-
184
- /**
185
- * Cancels the effects of a previous
186
- * [`DomUtil.preventOutline`](#domutil-preventoutline).
187
- * @returns {void}
188
- */
189
- export function restoreOutline() {
190
- if (!_outlineElement) { return; }
191
- _outlineElement.style.outlineStyle = _outlineStyle;
192
- _outlineElement = undefined;
193
- _outlineStyle = undefined;
194
- DomEvent.off(window, 'keydown', restoreOutline);
195
- }
196
-
197
141
  /**
198
142
  * Finds the closest parent node which size (width and height) is not null.
199
143
  * @param {HTMLElement} element
@@ -41,27 +41,26 @@ import * as PointerEvents from './DomEvent.PointerEvents.js';
41
41
  */
42
42
  export class Draggable extends Evented {
43
43
 
44
- static {
45
- this.setDefaultOptions({
46
- clickTolerance: 3
47
- });
48
- }
44
+ static defaultOptions = {
45
+ clickTolerance: 3
46
+ };
49
47
 
50
48
  /**
51
49
  * Creates a `Draggable` object for moving `element` when you start dragging the
52
50
  * `dragStartTarget` element (equals `element` itself by default).
53
51
  * @param {HTMLElement} element
54
52
  * @param {HTMLElement} [dragStartTarget]
55
- * @param {boolean} [preventOutline]
56
53
  * @param {DraggableOptions} [options]
57
54
  */
58
- constructor(element, dragStartTarget, preventOutline, options) {
55
+ constructor(element, dragStartTarget, options) {
56
+ if (typeof options === 'boolean') {
57
+ throw new Error('Draggable: the preventOutline argument is removed in Maplair. Pass options as the third argument.');
58
+ }
59
59
  super();
60
60
  Util.setOptions(this, options);
61
61
 
62
62
  this._element = element;
63
63
  this._dragStartTarget = dragStartTarget ?? element;
64
- this._preventOutline = preventOutline;
65
64
 
66
65
  this.callInitHooks(Draggable);
67
66
  }
@@ -102,7 +101,8 @@ export class Draggable extends Evented {
102
101
 
103
102
  if (this._element.classList.contains('maplair-zoom-anim')) { return; }
104
103
 
105
- if (PointerEvents.getPointers().length !== 1) {
104
+ const pointers = PointerEvents.getPointers().length;
105
+ if (pointers > 1) {
106
106
  // Finish dragging to avoid conflict with touchZoom
107
107
  if (Draggable._dragging === this) {
108
108
  this.finishDrag();
@@ -113,15 +113,13 @@ export class Draggable extends Evented {
113
113
  if (Draggable._dragging || e.shiftKey || (e.button !== 0 && e.pointerType !== 'touch')) { return; }
114
114
  Draggable._dragging = this; // Prevent dragging multiple objects at once.
115
115
 
116
- if (this._preventOutline) {
117
- DomUtil.preventOutline(this._element);
118
- }
119
-
120
116
  DomUtil.disableImageDrag();
121
- DomUtil.disableTextSelection();
122
117
 
123
118
  if (this._moving) { return; }
124
119
 
120
+ // outside a map, nothing tracks pointers or captures them, so capture this one to keep its moves coming
121
+ if (!pointers && e.isTrusted) { e.target.setPointerCapture(e.pointerId); }
122
+
125
123
  this.fire('down');
126
124
 
127
125
  const sizedParent = DomUtil.getSizedParentNode(this._element);
@@ -133,7 +131,7 @@ export class Draggable extends Evented {
133
131
  this._parentScale = DomUtil.getScale(sizedParent);
134
132
 
135
133
  DomEvent.on(this._dragStartTarget, 'pointermove', this._onMove, this);
136
- DomEvent.on(this._dragStartTarget, 'pointerup pointercancel', this._onUp, this);
134
+ DomEvent.on(this._dragStartTarget, 'pointerup pointercancel lostpointercapture', this._onUp, this);
137
135
  }
138
136
 
139
137
  _onMove(e) {
@@ -144,8 +142,9 @@ export class Draggable extends Evented {
144
142
 
145
143
  const offset = new Point(e.clientX, e.clientY)._subtract(this._startPoint);
146
144
 
147
- if (!offset.x && !offset.y) { return; }
148
- if (Math.abs(offset.x) + Math.abs(offset.y) < this.options.clickTolerance) { return; }
145
+ // once the drag has started, the pointer must be followed even when it comes back near the start point
146
+ const dist = Math.abs(offset.x) + Math.abs(offset.y);
147
+ if (!this._moved && (!dist || dist < this.options.clickTolerance)) { return; }
149
148
 
150
149
  // We assume that the parent container's position, border and scale do not change for the duration of the drag.
151
150
  // Therefore there is no need to account for the position and border (they are eliminated by the subtraction)
@@ -162,9 +161,11 @@ export class Draggable extends Evented {
162
161
 
163
162
  this._moved = true;
164
163
 
165
- this._element.ownerDocument.body.classList.add('maplair-dragging');
164
+ // on the map container rather than the body, so that toggling it doesn't restyle the whole page
165
+ this._draggingContainer = this._element.closest('.maplair-container') ?? this._element;
166
+ this._draggingContainer.classList.add('maplair-dragging');
166
167
 
167
- this._lastTarget = e.target ?? e.srcElement;
168
+ this._lastTarget = e.target;
168
169
  this._lastTarget.classList.add('maplair-drag-target');
169
170
  }
170
171
 
@@ -179,12 +180,20 @@ export class Draggable extends Evented {
179
180
  const e = {originalEvent: this._lastEvent};
180
181
 
181
182
  this.fire('predrag', e);
183
+
184
+ // pointer events can have fractional coordinates; snap them to device pixels, since an edge in the middle of
185
+ // one is drawn partly transparent on both sides and shows a seam between tiles
186
+ const dpr = window.devicePixelRatio;
187
+ this._newPos = this._newPos.multiplyBy(dpr)._round()._divideBy(dpr);
182
188
  DomUtil.setPosition(this._element, this._newPos);
183
189
 
184
190
  this.fire('drag', e);
185
191
  }
186
192
 
187
- _onUp() {
193
+ _onUp(e) {
194
+ // releasing the button outside the window may fire no pointerup, only a lostpointercapture with no buttons;
195
+ // capture lost while the button is still held (e.g. the pressed element was removed) shouldn't end the drag
196
+ if (e.type === 'lostpointercapture' && e.buttons) { return; }
188
197
  this.finishDrag();
189
198
  }
190
199
 
@@ -195,7 +204,8 @@ export class Draggable extends Evented {
195
204
  * @returns {void}
196
205
  */
197
206
  finishDrag(noInertia) {
198
- this._element.ownerDocument.body.classList.remove('maplair-dragging');
207
+ this._draggingContainer?.classList.remove('maplair-dragging');
208
+ this._draggingContainer = null;
199
209
 
200
210
  if (this._lastTarget) {
201
211
  this._lastTarget.classList.remove('maplair-drag-target');
@@ -203,10 +213,9 @@ export class Draggable extends Evented {
203
213
  }
204
214
 
205
215
  DomEvent.off(this._dragStartTarget, 'pointermove', this._onMove, this);
206
- DomEvent.off(this._dragStartTarget, 'pointerup pointercancel', this._onUp, this);
216
+ DomEvent.off(this._dragStartTarget, 'pointerup pointercancel lostpointercapture', this._onUp, this);
207
217
 
208
218
  DomUtil.enableImageDrag();
209
- DomUtil.enableTextSelection();
210
219
 
211
220
  const fireDragend = this._moved && this._moving;
212
221
 
@@ -4,31 +4,9 @@ import * as DomUtil from '../dom/DomUtil.js';
4
4
  /** @import {MaplairEvent} from '../core/Events.js' */
5
5
 
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
  export class PosAnimation extends Evented {
34
12
  /**
package/src/dom/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export {PosAnimation} from './PosAnimation.js';
2
1
 
3
2
  import * as DomEvent from './DomEvent.js';
4
3
  export {DomEvent};
package/src/geo/LatLng.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import * as Util from '../core/Util.js';
2
- import {EarthCRS} from './crs/EarthCRS.js';
3
2
  import {LatLngBounds} from './LatLngBounds.js';
4
3
 
5
4
  // a coordinate in decimal degrees, with an optional degree sign
@@ -229,7 +228,7 @@ export class LatLng {
229
228
  * @returns {number}
230
229
  */
231
230
  distanceTo(other) {
232
- return EarthCRS.distance(this, LatLng.from(other));
231
+ return haversineDistance(this, LatLng.from(other), 6371000);
233
232
  }
234
233
 
235
234
  /**
@@ -238,7 +237,7 @@ export class LatLng {
238
237
  * @returns {LatLng}
239
238
  */
240
239
  wrap() {
241
- return EarthCRS.wrapLatLng(this);
240
+ return new LatLng(this.lat, Util.wrapNum(this.lng, [-180, 180], true), this.alt);
242
241
  }
243
242
 
244
243
  /**
@@ -257,3 +256,21 @@ export class LatLng {
257
256
  }
258
257
 
259
258
  };
259
+
260
+ /**
261
+ * The great-circle distance on a sphere of radius `R`, shared with `EarthCRS.distance()`.
262
+ * @param {LatLng} latlng1
263
+ * @param {LatLng} latlng2
264
+ * @param {number} R
265
+ * @returns {number}
266
+ */
267
+ export function haversineDistance(latlng1, latlng2, R) {
268
+ const rad = Math.PI / 180,
269
+ lat1 = latlng1.lat * rad,
270
+ lat2 = latlng2.lat * rad,
271
+ sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2),
272
+ sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2),
273
+ a = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon,
274
+ c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
275
+ return R * c;
276
+ }
@@ -92,26 +92,19 @@ export class LatLngBounds {
92
92
  let sw2, ne2;
93
93
 
94
94
  if (obj instanceof LatLng) {
95
- sw2 = obj;
96
- ne2 = obj;
97
-
95
+ sw2 = ne2 = obj;
98
96
  } else if (obj instanceof LatLngBounds) {
99
- sw2 = obj._southWest;
100
- ne2 = obj._northEast;
101
-
102
- if (!sw2 || !ne2) { return this; }
103
-
97
+ ({_southWest: sw2, _northEast: ne2} = obj);
98
+ if (!sw2) { return this; }
99
+ } else if (!obj) {
100
+ return this;
101
+ } else if (LatLng.validate(obj)) {
102
+ sw2 = ne2 = LatLng.from(obj);
104
103
  } else {
105
- if (!obj) {
106
- return this;
107
- }
108
- if (LatLng.validate(obj)) {
109
- return this.extend(LatLng.from(obj));
110
- }
111
104
  return this.extend(LatLngBounds.from(obj));
112
105
  }
113
106
 
114
- if (!sw && !ne) {
107
+ if (!sw) {
115
108
  this._southWest = new LatLng(sw2.lat, sw2.lng);
116
109
  this._northEast = new LatLng(ne2.lat, ne2.lng);
117
110
  } else {
@@ -1,5 +1,5 @@
1
1
  import {EarthCRS} from './EarthCRS.js';
2
- import {Mercator} from '../projection/Projection.Mercator.js';
2
+ import {MercatorProjection} from '../projection/MercatorProjection.js';
3
3
  import {Transformation} from '../../geometry/Transformation.js';
4
4
  /** @import {Projection} from '../projection/index.js' */
5
5
 
@@ -10,10 +10,10 @@ export class EPSG3395 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 = 0.5 / (Math.PI * Mercator.R);
15
+ static transformation = /* @__PURE__ */ (() => {
16
+ const scale = 0.5 / (Math.PI * MercatorProjection.R);
17
17
  return new Transformation(scale, 0.5, -scale, 0.5);
18
18
  })();
19
19
  }
@@ -1,5 +1,5 @@
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
4
  /** @import {Projection} from '../projection/index.js' */
5
5
 
@@ -12,10 +12,10 @@ export class EPSG3857 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 = 0.5 / (Math.PI * SphericalMercator.R);
17
+ static transformation = /* @__PURE__ */ (() => {
18
+ const scale = 0.5 / (Math.PI * SphericalMercatorProjection.R);
19
19
  return new Transformation(scale, 0.5, -scale, 0.5);
20
20
  })();
21
21
  }