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
@@ -41,13 +41,11 @@ import {I18n} from '../core/I18n.js';
41
41
  */
42
42
  export class ZoomControl extends Control {
43
43
 
44
- static {
45
- this.setDefaultOptions({
46
- position: 'topleft',
47
- zoomInText: '<span aria-hidden="true">+</span>',
48
- zoomOutText: '<span aria-hidden="true">&#x2212;</span>',
49
- });
50
- }
44
+ static defaultOptions = {
45
+ position: 'topleft',
46
+ zoomInText: '<span aria-hidden="true">+</span>',
47
+ zoomOutText: '<span aria-hidden="true">&#x2212;</span>',
48
+ };
51
49
 
52
50
  /**
53
51
  * Creates a zoom control.
@@ -69,9 +67,9 @@ export class ZoomControl extends Control {
69
67
  options = this.options;
70
68
 
71
69
  this._zoomInButton = this._createButton(options.zoomInText, I18n.translate('Zoom in'),
72
- `${zoomName}-in`, container, this._zoomIn);
70
+ `${zoomName}-in`, container, e => this._zoom(e, 1));
73
71
  this._zoomOutButton = this._createButton(options.zoomOutText, I18n.translate('Zoom out'),
74
- `${zoomName}-out`, container, this._zoomOut);
72
+ `${zoomName}-out`, container, e => this._zoom(e, -1));
75
73
 
76
74
  this._updateDisabled();
77
75
  map.on('zoomend zoomlevelschange', this._updateDisabled, this);
@@ -107,17 +105,11 @@ export class ZoomControl extends Control {
107
105
  return this;
108
106
  }
109
107
 
110
- _zoomIn(e) {
111
- if (!this._disabled && this._map._zoom < this._map.getMaxZoom()) {
112
- this._map._setUserEvent(e);
113
- this._map.zoomIn(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));
114
- }
115
- }
116
-
117
- _zoomOut(e) {
118
- if (!this._disabled && this._map._zoom > this._map.getMinZoom()) {
119
- this._map._setUserEvent(e);
120
- this._map.zoomOut(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));
108
+ _zoom(e, dir) {
109
+ const map = this._map;
110
+ if (!this._disabled && (dir > 0 ? map._zoom < map.getMaxZoom() : map._zoom > map.getMinZoom())) {
111
+ map._setUserEvent(e);
112
+ map.zoomIn(dir * map.options.zoomDelta * (e.shiftKey ? 3 : 1));
121
113
  }
122
114
  }
123
115
 
@@ -129,29 +121,21 @@ export class ZoomControl extends Control {
129
121
  link.setAttribute('aria-label', title);
130
122
 
131
123
  DomEvent.disableClickPropagation(link);
132
- DomEvent.on(link, 'click', DomEvent.stop);
133
- DomEvent.on(link, 'click', fn, this);
134
- DomEvent.on(link, 'click', this._refocusOnMap, this);
124
+ DomEvent.on(link, 'click', (e) => {
125
+ DomEvent.stop(e);
126
+ fn.call(this, e);
127
+ this._refocusOnMap(e);
128
+ });
135
129
 
136
130
  return link;
137
131
  }
138
132
 
139
133
  _updateDisabled() {
140
- const map = this._map,
141
- className = 'maplair-disabled';
142
-
143
- this._zoomInButton.classList.remove(className);
144
- this._zoomOutButton.classList.remove(className);
145
- this._zoomInButton.setAttribute('aria-disabled', 'false');
146
- this._zoomOutButton.setAttribute('aria-disabled', 'false');
147
-
148
- if (this._disabled || map._zoom === map.getMinZoom()) {
149
- this._zoomOutButton.classList.add(className);
150
- this._zoomOutButton.setAttribute('aria-disabled', 'true');
151
- }
152
- if (this._disabled || map._zoom === map.getMaxZoom()) {
153
- this._zoomInButton.classList.add(className);
154
- this._zoomInButton.setAttribute('aria-disabled', 'true');
134
+ const map = this._map;
135
+ for (const [button, limit] of [[this._zoomInButton, map.getMaxZoom()], [this._zoomOutButton, map.getMinZoom()]]) {
136
+ const disabled = this._disabled || map._zoom === limit;
137
+ button.classList.toggle('maplair-disabled', disabled);
138
+ button.setAttribute('aria-disabled', `${disabled}`);
155
139
  }
156
140
  }
157
141
 
@@ -10,4 +10,5 @@ export {ScaleControl} from './ScaleControl.js';
10
10
  export {SearchControl} from './SearchControl.js';
11
11
  export {SideBySideControl} from './SideBySideControl.js';
12
12
  export {TextControl} from './TextControl.js';
13
+ export {TimeControl} from './TimeControl.js';
13
14
  export {ZoomControl} from './ZoomControl.js';
package/src/core/Class.js CHANGED
@@ -12,28 +12,24 @@ import * as Util from './Util.js';
12
12
  *
13
13
  * <h3 id="class-options">Options</h3>
14
14
  *
15
- * `options` is a special property that will be merged with the parent class options
16
- * instead of overriding them completely, which makes managing configuration of objects
17
- * and default values convenient. Use `setDefaultOptions()` in a static block to
18
- * configure options:
15
+ * `options` is a special property whose defaults, the static `defaultOptions` of the
16
+ * class, are merged with those of the parent class instead of overriding them
17
+ * completely, which makes managing configuration of objects and default values
18
+ * convenient:
19
19
  *
20
20
  * ```js
21
21
  * class MyClass extends Class {
22
- * static {
23
- * this.setDefaultOptions({
24
- * myOption1: 'foo',
25
- * myOption2: 'bar'
26
- * });
27
- * }
22
+ * static defaultOptions = {
23
+ * myOption1: 'foo',
24
+ * myOption2: 'bar'
25
+ * };
28
26
  * }
29
27
  *
30
28
  * class MyChildClass extends MyClass {
31
- * static {
32
- * this.setDefaultOptions({
33
- * myOption1: 'baz',
34
- * myOption3: 5
35
- * });
36
- * }
29
+ * static defaultOptions = {
30
+ * myOption1: 'baz',
31
+ * myOption3: 5
32
+ * };
37
33
  * }
38
34
  *
39
35
  * const a = new MyChildClass();
@@ -48,12 +44,10 @@ import * as Util from './Util.js';
48
44
  *
49
45
  * ```js
50
46
  * class MyClass extends Class {
51
- * static {
52
- * this.setDefaultOptions({
53
- * foo: 'bar',
54
- * bla: 5
55
- * });
56
- * }
47
+ * static defaultOptions = {
48
+ * foo: 'bar',
49
+ * bla: 5
50
+ * };
57
51
  *
58
52
  * constructor(options) {
59
53
  * super();
@@ -165,51 +159,44 @@ export class Class {
165
159
  * @returns {T}
166
160
  */
167
161
  static include(props) {
168
- const parentOptions = this.prototype.options;
169
- for (const k of getAllMethodNames(props)) {
170
- this.prototype[k] = props[k];
162
+ for (let obj = props; obj && obj !== Object.prototype; obj = Object.getPrototypeOf(obj)) {
163
+ for (const k of Object.getOwnPropertyNames(obj)) {
164
+ if (k !== 'constructor' && k !== 'options') {
165
+ this.prototype[k] = props[k];
166
+ }
167
+ }
171
168
  }
172
169
  if (props.options) {
173
- this.prototype.options = parentOptions;
174
170
  this.mergeOptions(props.options);
175
171
  }
176
172
  return this;
177
-
178
- function *getAllMethodNames(obj) {
179
- do {
180
- if (obj === Object || obj === Object.prototype) {
181
- break;
182
- }
183
- for (const k of Object.getOwnPropertyNames(obj)) {
184
- yield k;
185
- }
186
- } while ((obj = Object.getPrototypeOf(obj)) !== undefined);
187
- }
188
173
  }
189
174
 
190
175
  /**
191
- * Configures the [default `options`](#class-options) on the prototype of this class.
176
+ * [Merges `options`](#class-options) into the `defaultOptions` of the class.
192
177
  * @template {typeof Class} T
193
178
  * @this {T}
194
179
  * @param {object} options
195
180
  * @returns {T}
196
181
  */
197
- static setDefaultOptions(options) {
198
- Util.setOptions(this.prototype, options);
182
+ static mergeOptions(options) {
183
+ if (!Object.hasOwn(this, 'defaultOptions')) {
184
+ this.defaultOptions = Object.create(this.defaultOptions ?? Object.prototype);
185
+ }
186
+ Object.assign(this.defaultOptions, options);
199
187
  return this;
200
188
  }
201
189
 
202
190
  /**
203
- * [Merges `options`](#class-options) into the defaults of the class.
191
+ * Deprecated alias of `mergeOptions()`, kept for code written for Maplair 4.0.
192
+ * @deprecated Use `static defaultOptions = {…}` or `mergeOptions()`.
204
193
  * @template {typeof Class} T
205
194
  * @this {T}
206
195
  * @param {object} options
207
196
  * @returns {T}
208
197
  */
209
- static mergeOptions(options) {
210
- this.prototype.options ??= {};
211
- Object.assign(this.prototype.options, options);
212
- return this;
198
+ static setDefaultOptions(options) {
199
+ return this.mergeOptions(options);
213
200
  }
214
201
 
215
202
  /**
@@ -235,6 +222,11 @@ export class Class {
235
222
  }
236
223
 
237
224
  constructor() {
225
+ if (this.initialize) {
226
+ throw new Error(`${this.constructor.name}: initialize() is not called in Maplair. ` +
227
+ 'Rename it to constructor() and call super() at its start.');
228
+ }
229
+
238
230
  Util.setOptions(this);
239
231
  }
240
232
 
@@ -1,5 +1,7 @@
1
1
  import {Class} from './Class.js';
2
2
  import * as Util from './Util.js';
3
+
4
+ const warnedEvents = new Set();
3
5
  /** @import {LatLng} from '../geo/LatLng.js' */
4
6
  /** @import {LatLngBounds} from '../geo/LatLngBounds.js' */
5
7
  /** @import {Point} from '../geometry/Point.js' */
@@ -95,6 +97,8 @@ import * as Util from './Util.js';
95
97
  * @typedef {object} LayersControlEvent
96
98
  * @property {Layer} layer The layer that was added or removed.
97
99
  * @property {string} name The name of the layer that was added or removed.
100
+ * @property {Event} [originalEvent] The DOM event of the click on the entry in the
101
+ * layers control, `undefined` if the layer was added or removed by code.
98
102
  * @extends MaplairEvent
99
103
  */
100
104
 
@@ -129,6 +133,13 @@ import * as Util from './Util.js';
129
133
  * @extends MaplairEvent
130
134
  */
131
135
 
136
+ /**
137
+ * The event object of `worldcopyjump`.
138
+ * @typedef {object} WorldCopyJumpEvent
139
+ * @property {number} worlds The signed number of world widths by which the map pane moved.
140
+ * @extends MaplairEvent
141
+ */
142
+
132
143
  /**
133
144
  * The event object of adding GeoJSON features.
134
145
  * @typedef {object} GeoJSONEvent
@@ -259,13 +270,21 @@ export class Evented extends Class {
259
270
  return this;
260
271
  }
261
272
 
262
- static __REMOVED_EVENTS = ['mousedown', 'mouseup', 'mouseover', 'mouseout', 'mousemove'];
273
+ static __REMOVED_EVENTS = {
274
+ mousedown: 'pointerdown',
275
+ mouseup: 'pointerup',
276
+ mouseover: 'pointerover',
277
+ mouseout: 'pointerout',
278
+ mousemove: 'pointermove',
279
+ keypress: 'keydown'
280
+ };
263
281
 
264
282
  // attach listener (without syntactic sugar now)
265
283
  _on(type, fn, context, _once) {
266
284
  // To be removed in maplair 3
267
- if (Evented.__REMOVED_EVENTS.includes(type)) {
268
- console.error(`The event ${type} has been removed. Use the PointerEvent variant instead.`);
285
+ if (Object.hasOwn(Evented.__REMOVED_EVENTS, type) && !warnedEvents.has(type)) {
286
+ warnedEvents.add(type);
287
+ console.error(`The event ${type} has been removed in Maplair. Use ${Evented.__REMOVED_EVENTS[type]} instead.`);
269
288
  }
270
289
 
271
290
  if (typeof fn !== 'function') {
@@ -6,7 +6,7 @@ import {Class} from './Class.js';
6
6
  * are used internally to inject interaction features like dragging to classes like
7
7
  * `MaplairMap` and `Marker`.
8
8
  *
9
- * Classes inheriting from `Handler` must implement the two following extension methods:
9
+ * Classes inheriting from `Handler` implement the two following extension methods:
10
10
  *
11
11
  * * `addHooks()` is called when the handler is enabled, should add event hooks.
12
12
  * * `removeHooks()` is called when the handler is disabled, should remove the event
@@ -54,16 +54,28 @@ export class Handler extends Class {
54
54
  enabled() {
55
55
  return !!this._enabled;
56
56
  }
57
- }
58
57
 
59
- /**
60
- * Adds a new handler of this class to the given map with the given name, which is
61
- * then available as the property of the map with this name.
62
- * @param {MaplairMap} map
63
- * @param {string} name
64
- * @returns {typeof Handler}
65
- */
66
- Handler.addTo = function (map, name) {
67
- map.addHandler(name, this);
68
- return this;
69
- };
58
+ /**
59
+ * Called when the handler is enabled, should add event hooks.
60
+ */
61
+ addHooks() {}
62
+
63
+ /**
64
+ * Called when the handler is disabled, should remove the event hooks added previously.
65
+ */
66
+ removeHooks() {}
67
+
68
+ /**
69
+ * Adds a new handler of this class to the given map with the given name, which is
70
+ * then available as the property of the map with this name.
71
+ * @template {typeof Handler} T
72
+ * @this {T}
73
+ * @param {MaplairMap} map
74
+ * @param {string} name
75
+ * @returns {T}
76
+ */
77
+ static addTo(map, name) {
78
+ map.addHandler(name, this);
79
+ return this;
80
+ }
81
+ }
package/src/core/Util.js CHANGED
@@ -59,7 +59,7 @@ export function throttle(fn, time, context) {
59
59
 
60
60
  /**
61
61
  * Returns the number `x` modulo `range` in such a way so it lies within
62
- * `range[0]` and `range[1]`. The returned value will be always smaller than
62
+ * `range[0]` and `range[1]`. The returned value will always be smaller than
63
63
  * `range[1]` unless `includeMax` is set to `true`.
64
64
  * @param {number} x
65
65
  * @param {[number, number]} range
@@ -113,7 +113,8 @@ export function splitWords(str) {
113
113
  */
114
114
  export function setOptions(obj, options) {
115
115
  if (!Object.hasOwn(obj, 'options')) {
116
- obj.options = obj.options ? Object.create(obj.options) : {};
116
+ const defaults = getDefaultOptions(obj.constructor) ?? obj.options;
117
+ obj.options = defaults ? Object.create(defaults) : {};
117
118
  }
118
119
  for (const i in options) {
119
120
  if (Object.hasOwn(options, i)) {
@@ -123,6 +124,23 @@ export function setOptions(obj, options) {
123
124
  return obj.options;
124
125
  }
125
126
 
127
+ const chainedDefaults = new WeakMap(); // class -> the defaultOptions object it was chained with
128
+
129
+ // Links the `defaultOptions` of each class in the chain to its parent's, so defaults are inherited and stay live.
130
+ // Done on first use because a static field can't do it in its initializer and stay tree-shakeable.
131
+ function getDefaultOptions(cls) {
132
+ const defaults = cls?.defaultOptions;
133
+ if (defaults && chainedDefaults.get(cls) !== defaults) {
134
+ for (let c = cls; c.defaultOptions; c = Object.getPrototypeOf(c)) {
135
+ if (Object.hasOwn(c, 'defaultOptions')) {
136
+ Object.setPrototypeOf(c.defaultOptions, Object.getPrototypeOf(c).defaultOptions ?? Object.prototype);
137
+ }
138
+ }
139
+ chainedDefaults.set(cls, defaults);
140
+ }
141
+ return defaults;
142
+ }
143
+
126
144
  const templateRe = /\{ *([\w_ -]+) *\}/g;
127
145
 
128
146
  /**
package/src/core/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export {default as Browser} from './Browser.js';
2
1
  export {Class} from './Class.js';
3
2
  export {Evented} from './Events.js';
4
3
  export {Handler} from './Handler.js';
@@ -1,5 +1,3 @@
1
- import * as DomEvent from './DomEvent.js';
2
-
3
1
  /*
4
2
  * Extends the event handling code with double tap support for mobile browsers.
5
3
  *
@@ -8,7 +6,7 @@ import * as DomEvent from './DomEvent.js';
8
6
  */
9
7
 
10
8
  function makeDblclick(ev) {
11
- let init = {
9
+ const init = {
12
10
  // EventInit
13
11
  bubbles: ev.bubbles,
14
12
  cancelable: ev.cancelable,
@@ -37,7 +35,7 @@ function makeDblclick(ev) {
37
35
  // The `click` event received should be a PointerEvent - but some
38
36
  // Firefox versions still use MouseEvent.
39
37
  if (ev instanceof PointerEvent) {
40
- init = {
38
+ newEvent = new PointerEvent('dblclick', {
41
39
  ...init,
42
40
  pointerId: ev.pointerId,
43
41
  width: ev.width,
@@ -49,8 +47,7 @@ function makeDblclick(ev) {
49
47
  twist: ev.twist,
50
48
  pointerType: ev.pointerType,
51
49
  isPrimary: ev.isPrimary,
52
- };
53
- newEvent = new PointerEvent('dblclick', init);
50
+ });
54
51
  } else {
55
52
  newEvent = new MouseEvent('dblclick', init);
56
53
  }
@@ -75,14 +72,22 @@ export function addDoubleTapListener(obj, handler) {
75
72
  // It seems that in all such cases `detail` property of `click` event is always `1`.
76
73
  // So here we rely on that fact to avoid excessive 'dblclick' simulation when not needed.
77
74
  let last = 0,
78
- detail;
75
+ detail,
76
+ pointerType;
77
+
78
+ // iOS Safari reports `pointerType: 'mouse'` on clicks from touch (WebKit bug 282988), so we take it from the
79
+ // pointerdown instead; capturing so that it's seen even if a child (e.g. a control) stops its propagation.
80
+ function onPointerDown(ev) {
81
+ pointerType = ev.pointerType;
82
+ }
83
+
79
84
  function simDblclick(ev) {
80
85
  if (ev.detail !== 1) {
81
86
  detail = ev.detail; // keep in sync to avoid false dblclick in some cases
82
87
  return;
83
88
  }
84
89
 
85
- if (ev.pointerType === 'mouse' ||
90
+ if (pointerType === 'mouse' ||
86
91
  (ev.sourceCapabilities && !ev.sourceCapabilities.firesTouchEvents)) {
87
92
 
88
93
  return;
@@ -93,8 +98,8 @@ export function addDoubleTapListener(obj, handler) {
93
98
  // This ignores clicks on elements which are a label with a 'for'
94
99
  // attribute (or children of such a label), but not children of
95
100
  // a <input>.
96
- const path = DomEvent.getPropagationPath(ev);
97
- if (path.some(el => el instanceof HTMLLabelElement && el.attributes.for) &&
101
+ const path = ev.composedPath();
102
+ if (path.some(el => el instanceof HTMLLabelElement && el.htmlFor) &&
98
103
  !path.some(el => (
99
104
  el instanceof HTMLInputElement ||
100
105
  el instanceof HTMLSelectElement
@@ -115,10 +120,12 @@ export function addDoubleTapListener(obj, handler) {
115
120
  last = now;
116
121
  }
117
122
 
123
+ obj.addEventListener('pointerdown', onPointerDown, true);
118
124
  obj.addEventListener('click', simDblclick);
119
125
 
120
126
  return {
121
127
  dblclick: handler,
128
+ onPointerDown,
122
129
  simDblclick
123
130
  };
124
131
  }
@@ -131,5 +138,6 @@ export function addDoubleTapListener(obj, handler) {
131
138
  */
132
139
  export function removeDoubleTapListener(obj, handlers) {
133
140
  obj.removeEventListener('dblclick', handlers.dblclick);
141
+ obj.removeEventListener('pointerdown', handlers.onPointerDown, true);
134
142
  obj.removeEventListener('click', handlers.simDblclick);
135
143
  }
@@ -30,12 +30,9 @@ function disablePointerDetection(el) {
30
30
  el.removeEventListener('pointercancel', _onDelete, {capture: true});
31
31
  }
32
32
 
33
- // NOTE: pointers are captured unconditionally, which can become a problem for
34
- // synthetic events. The prosthetic-hand library does handle pointer capture,
35
- // but others don't.
36
- // If this becomers an issue, replace with `e.isTrusted && e.target.setPointerCapture()`
33
+ // capturing throws for synthetic pointers the browser doesn't know about, so only capture real ones
37
34
  function _onSet(e) {
38
- e.target.setPointerCapture(e.pointerId);
35
+ if (e.isTrusted) { e.target.setPointerCapture(e.pointerId); }
39
36
  activePointers.set(e.pointerId, e);
40
37
  }
41
38
 
@@ -45,7 +42,6 @@ function _onUpdate(e) {
45
42
  }
46
43
  }
47
44
 
48
- // NOTE: idem as _onSet.
49
45
  function _onDelete(e) {
50
46
  // released already if the document has nested maps (e.g. an overview map)
51
47
  if (e.target.hasPointerCapture(e.pointerId)) {
@@ -63,28 +59,9 @@ function getPointers() {
63
59
  return [...activePointers.values()];
64
60
  }
65
61
 
66
- /**
67
- * Clears the detected pointers on the document.
68
- * Note: This function should be not necessary to call, as the pointers are
69
- * automatically cleared with `pointerup`, `pointercancel` and `pointerout` events.
70
- * @group Pointer detection
71
- * @returns {void}
72
- */
73
- function cleanupPointers() {
74
- for (const e of activePointers.values()) {
75
- try {
76
- e.target.releasePointerCapture(e.pointerId);
77
- } catch {
78
- // target may already be detached; capture was on a dead node
79
- }
80
- }
81
- activePointers.clear();
82
- }
83
-
84
62
  export {
85
63
  enablePointerDetection,
86
64
  disablePointerDetection,
87
- getPointers,
88
- cleanupPointers
65
+ getPointers
89
66
  };
90
67