maplair 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/dist/esm/Maplair.js +14 -14
  3. package/dist/esm/control/AttributionControl.js +24 -14
  4. package/dist/esm/control/AttributionControl.js.map +1 -1
  5. package/dist/esm/control/ButtonControl.js +9 -11
  6. package/dist/esm/control/ButtonControl.js.map +1 -1
  7. package/dist/esm/control/ContextMenu.js +1 -3
  8. package/dist/esm/control/ContextMenu.js.map +1 -1
  9. package/dist/esm/control/Control.js +9 -16
  10. package/dist/esm/control/Control.js.map +1 -1
  11. package/dist/esm/control/FullscreenControl.js +5 -7
  12. package/dist/esm/control/FullscreenControl.js.map +1 -1
  13. package/dist/esm/control/LayersControl.js +144 -35
  14. package/dist/esm/control/LayersControl.js.map +1 -1
  15. package/dist/esm/control/LegendControl.js +7 -9
  16. package/dist/esm/control/LegendControl.js.map +1 -1
  17. package/dist/esm/control/MiniMapControl.js +14 -16
  18. package/dist/esm/control/MiniMapControl.js.map +1 -1
  19. package/dist/esm/control/RotateControl.js +1 -3
  20. package/dist/esm/control/RotateControl.js.map +1 -1
  21. package/dist/esm/control/ScaleControl.js +7 -9
  22. package/dist/esm/control/ScaleControl.js.map +1 -1
  23. package/dist/esm/control/SearchControl.js +99 -17
  24. package/dist/esm/control/SearchControl.js.map +1 -1
  25. package/dist/esm/control/SideBySideControl.js +1 -3
  26. package/dist/esm/control/SideBySideControl.js.map +1 -1
  27. package/dist/esm/control/TextControl.js +5 -7
  28. package/dist/esm/control/TextControl.js.map +1 -1
  29. package/dist/esm/control/TimeControl.js +408 -0
  30. package/dist/esm/control/TimeControl.js.map +1 -0
  31. package/dist/esm/control/ZoomControl.js +5 -7
  32. package/dist/esm/control/ZoomControl.js.map +1 -1
  33. package/dist/esm/core/Class.js +28 -37
  34. package/dist/esm/core/Class.js.map +1 -1
  35. package/dist/esm/core/Events.js +21 -8
  36. package/dist/esm/core/Events.js.map +1 -1
  37. package/dist/esm/core/Handler.js +13 -11
  38. package/dist/esm/core/Handler.js.map +1 -1
  39. package/dist/esm/core/Util.js +13 -1
  40. package/dist/esm/core/Util.js.map +1 -1
  41. package/dist/esm/dom/DomEvent.DoubleTap.js +25 -22
  42. package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -1
  43. package/dist/esm/dom/DomEvent.PointerEvents.js +2 -16
  44. package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
  45. package/dist/esm/dom/DomEvent.js +8 -42
  46. package/dist/esm/dom/DomEvent.js.map +1 -1
  47. package/dist/esm/dom/DomUtil.js +14 -68
  48. package/dist/esm/dom/DomUtil.js.map +1 -1
  49. package/dist/esm/dom/Draggable.js +17 -18
  50. package/dist/esm/dom/Draggable.js.map +1 -1
  51. package/dist/esm/dom/PosAnimation.js +3 -25
  52. package/dist/esm/dom/PosAnimation.js.map +1 -1
  53. package/dist/esm/geo/LatLng.js +15 -5
  54. package/dist/esm/geo/LatLng.js.map +1 -1
  55. package/dist/esm/geo/crs/EPSG3395.js +1 -1
  56. package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
  57. package/dist/esm/geo/crs/EPSG3857.js +1 -1
  58. package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
  59. package/dist/esm/geo/crs/EPSG4326.js +1 -1
  60. package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
  61. package/dist/esm/geo/crs/EarthCRS.js +2 -2
  62. package/dist/esm/geo/crs/EarthCRS.js.map +1 -1
  63. package/dist/esm/geo/crs/SimpleCRS.js +1 -1
  64. package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
  65. package/dist/esm/geo/projection/Projection.LonLat.js +1 -1
  66. package/dist/esm/geo/projection/Projection.LonLat.js.map +1 -1
  67. package/dist/esm/geo/projection/Projection.Mercator.js +1 -1
  68. package/dist/esm/geo/projection/Projection.Mercator.js.map +1 -1
  69. package/dist/esm/geo/projection/Projection.SphericalMercator.js +1 -1
  70. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +1 -1
  71. package/dist/esm/geometry/LineUtil.js +36 -30
  72. package/dist/esm/geometry/LineUtil.js.map +1 -1
  73. package/dist/esm/geometry/PolyUtil.js +8 -27
  74. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  75. package/dist/esm/layer/BlanketOverlay.js +6 -8
  76. package/dist/esm/layer/BlanketOverlay.js.map +1 -1
  77. package/dist/esm/layer/DivOverlay.js +15 -20
  78. package/dist/esm/layer/DivOverlay.js.map +1 -1
  79. package/dist/esm/layer/GeoJSON.js +9 -145
  80. package/dist/esm/layer/GeoJSON.js.map +1 -1
  81. package/dist/esm/layer/GeoJSONUtil.js +75 -0
  82. package/dist/esm/layer/GeoJSONUtil.js.map +1 -0
  83. package/dist/esm/layer/HeatLayer.js +15 -17
  84. package/dist/esm/layer/HeatLayer.js.map +1 -1
  85. package/dist/esm/layer/ImageOverlay.js +20 -26
  86. package/dist/esm/layer/ImageOverlay.js.map +1 -1
  87. package/dist/esm/layer/Layer.js +8 -10
  88. package/dist/esm/layer/Layer.js.map +1 -1
  89. package/dist/esm/layer/LayerGroup.js +51 -0
  90. package/dist/esm/layer/LayerGroup.js.map +1 -1
  91. package/dist/esm/layer/Popup.js +26 -42
  92. package/dist/esm/layer/Popup.js.map +1 -1
  93. package/dist/esm/layer/SVGOverlay.js +2 -5
  94. package/dist/esm/layer/SVGOverlay.js.map +1 -1
  95. package/dist/esm/layer/Tooltip.js +15 -17
  96. package/dist/esm/layer/Tooltip.js.map +1 -1
  97. package/dist/esm/layer/VideoOverlay.js +12 -15
  98. package/dist/esm/layer/VideoOverlay.js.map +1 -1
  99. package/dist/esm/layer/marker/DefaultIcon.js +15 -48
  100. package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
  101. package/dist/esm/layer/marker/DivIcon.js +7 -9
  102. package/dist/esm/layer/marker/DivIcon.js.map +1 -1
  103. package/dist/esm/layer/marker/Icon.js +7 -10
  104. package/dist/esm/layer/marker/Icon.js.map +1 -1
  105. package/dist/esm/layer/marker/Marker.Drag.js +1 -1
  106. package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
  107. package/dist/esm/layer/marker/Marker.Move.js +1 -2
  108. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  109. package/dist/esm/layer/marker/Marker.js +61 -33
  110. package/dist/esm/layer/marker/Marker.js.map +1 -1
  111. package/dist/esm/layer/marker/MarkerClusterGroup.js +302 -0
  112. package/dist/esm/layer/marker/MarkerClusterGroup.js.map +1 -0
  113. package/dist/esm/layer/marker/SvgIcon.js +6 -8
  114. package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
  115. package/dist/esm/layer/tile/GridLayer.js +85 -97
  116. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  117. package/dist/esm/layer/tile/TileLayer.js +28 -36
  118. package/dist/esm/layer/tile/TileLayer.js.map +1 -1
  119. package/dist/esm/layer/tile/WMSTileLayer.js +28 -23
  120. package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
  121. package/dist/esm/layer/vector/Canvas.js +1 -3
  122. package/dist/esm/layer/vector/Canvas.js.map +1 -1
  123. package/dist/esm/layer/vector/Circle.js +2 -2
  124. package/dist/esm/layer/vector/Circle.js.map +1 -1
  125. package/dist/esm/layer/vector/CircleMarker.js +17 -7
  126. package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
  127. package/dist/esm/layer/vector/Path.DashAnimation.js +2 -3
  128. package/dist/esm/layer/vector/Path.DashAnimation.js.map +1 -1
  129. package/dist/esm/layer/vector/Path.js +27 -20
  130. package/dist/esm/layer/vector/Path.js.map +1 -1
  131. package/dist/esm/layer/vector/Polygon.js +20 -4
  132. package/dist/esm/layer/vector/Polygon.js.map +1 -1
  133. package/dist/esm/layer/vector/Polyline.Decorations.js +2 -2
  134. package/dist/esm/layer/vector/Polyline.js +23 -7
  135. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  136. package/dist/esm/layer/vector/Renderer.getRenderer.js +14 -13
  137. package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
  138. package/dist/esm/layer/vector/SVG.js +5 -5
  139. package/dist/esm/layer/vector/SVG.js.map +1 -1
  140. package/dist/esm/map/Map.Rotation.js +10 -6
  141. package/dist/esm/map/Map.Rotation.js.map +1 -1
  142. package/dist/esm/map/Map.js +116 -110
  143. package/dist/esm/map/Map.js.map +1 -1
  144. package/dist/esm/map/handler/BoxZoomHandler.js +5 -7
  145. package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
  146. package/dist/esm/map/handler/DisplaceHandler.js +6 -8
  147. package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
  148. package/dist/esm/map/handler/DragHandler.js +19 -19
  149. package/dist/esm/map/handler/DragHandler.js.map +1 -1
  150. package/dist/esm/map/handler/KeyboardHandler.js +35 -35
  151. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  152. package/dist/esm/map/handler/PinchZoomHandler.js +12 -3
  153. package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
  154. package/dist/esm/map/handler/ScrollWheelZoomHandler.js +3 -4
  155. package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
  156. package/dist/esm/map/handler/TapHoldHandler.js +12 -5
  157. package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
  158. package/dist/esm/package.js +1 -1
  159. package/dist/maplair-global-src.js +8009 -7369
  160. package/dist/maplair-global-src.js.map +1 -1
  161. package/dist/maplair-global.js +2 -2
  162. package/dist/maplair-global.js.map +1 -1
  163. package/dist/maplair-src.js +10040 -9381
  164. package/dist/maplair-src.js.map +1 -1
  165. package/dist/maplair.css +148 -98
  166. package/dist/maplair.js +2 -2
  167. package/dist/maplair.js.map +1 -1
  168. package/i18n/cs.json +6 -0
  169. package/i18n/de.json +6 -0
  170. package/i18n/en.json +6 -0
  171. package/i18n/es.json +6 -0
  172. package/i18n/fr.json +6 -0
  173. package/i18n/hu.json +6 -0
  174. package/i18n/it.json +6 -0
  175. package/i18n/rm.json +6 -0
  176. package/i18n/sk.json +6 -0
  177. package/i18n/sl.json +6 -0
  178. package/package.json +9 -11
  179. package/src/control/AttributionControl.js +25 -18
  180. package/src/control/ButtonControl.js +9 -11
  181. package/src/control/ContextMenu.js +3 -5
  182. package/src/control/Control.js +9 -19
  183. package/src/control/FullscreenControl.js +5 -7
  184. package/src/control/LayersControl.js +159 -36
  185. package/src/control/LegendControl.js +7 -9
  186. package/src/control/MiniMapControl.js +9 -11
  187. package/src/control/RotateControl.js +3 -5
  188. package/src/control/ScaleControl.js +7 -9
  189. package/src/control/SearchControl.js +102 -19
  190. package/src/control/SideBySideControl.js +3 -5
  191. package/src/control/TextControl.js +5 -7
  192. package/src/control/TimeControl.js +471 -0
  193. package/src/control/ZoomControl.js +5 -7
  194. package/src/control/index.js +1 -0
  195. package/src/core/Class.js +35 -34
  196. package/src/core/Events.js +22 -3
  197. package/src/core/Handler.js +14 -12
  198. package/src/core/Util.js +19 -1
  199. package/src/core/index.js +0 -1
  200. package/src/dom/DomEvent.DoubleTap.js +18 -10
  201. package/src/dom/DomEvent.PointerEvents.js +3 -26
  202. package/src/dom/DomEvent.js +8 -66
  203. package/src/dom/DomUtil.js +22 -78
  204. package/src/dom/Draggable.js +27 -22
  205. package/src/dom/PosAnimation.js +3 -25
  206. package/src/dom/index.js +0 -1
  207. package/src/geo/LatLng.js +20 -3
  208. package/src/geo/crs/EPSG3395.js +1 -1
  209. package/src/geo/crs/EPSG3857.js +1 -1
  210. package/src/geo/crs/EPSG4326.js +1 -1
  211. package/src/geo/crs/EarthCRS.js +2 -8
  212. package/src/geo/crs/SimpleCRS.js +1 -1
  213. package/src/geo/projection/Projection.LonLat.js +1 -1
  214. package/src/geo/projection/Projection.Mercator.js +1 -1
  215. package/src/geo/projection/Projection.SphericalMercator.js +1 -1
  216. package/src/geometry/LineUtil.js +47 -48
  217. package/src/geometry/PolyUtil.js +14 -43
  218. package/src/layer/BlanketOverlay.js +6 -10
  219. package/src/layer/DivOverlay.js +15 -26
  220. package/src/layer/GeoJSON.js +7 -205
  221. package/src/layer/GeoJSONUtil.js +85 -0
  222. package/src/layer/HeatLayer.js +9 -11
  223. package/src/layer/ImageOverlay.js +19 -30
  224. package/src/layer/Layer.js +8 -10
  225. package/src/layer/LayerGroup.js +71 -0
  226. package/src/layer/Popup.js +28 -43
  227. package/src/layer/SVGOverlay.js +1 -5
  228. package/src/layer/Tooltip.js +15 -19
  229. package/src/layer/VideoOverlay.js +12 -15
  230. package/src/layer/marker/DefaultIcon.js +15 -61
  231. package/src/layer/marker/DivIcon.js +9 -11
  232. package/src/layer/marker/Icon.js +7 -10
  233. package/src/layer/marker/Marker.Drag.js +1 -1
  234. package/src/layer/marker/Marker.Move.js +1 -2
  235. package/src/layer/marker/Marker.js +81 -39
  236. package/src/layer/marker/MarkerClusterGroup.js +370 -0
  237. package/src/layer/marker/SvgIcon.js +7 -9
  238. package/src/layer/marker/index.js +1 -0
  239. package/src/layer/tile/GridLayer.js +103 -133
  240. package/src/layer/tile/TileLayer.js +35 -43
  241. package/src/layer/tile/WMSTileLayer.js +26 -24
  242. package/src/layer/vector/Canvas.js +3 -5
  243. package/src/layer/vector/Circle.js +5 -2
  244. package/src/layer/vector/CircleMarker.js +17 -6
  245. package/src/layer/vector/Path.DashAnimation.js +1 -2
  246. package/src/layer/vector/Path.js +30 -21
  247. package/src/layer/vector/Polygon.js +28 -5
  248. package/src/layer/vector/Polyline.js +25 -6
  249. package/src/layer/vector/Renderer.getRenderer.js +17 -17
  250. package/src/layer/vector/SVG.js +5 -5
  251. package/src/map/Map.Rotation.js +12 -4
  252. package/src/map/Map.js +142 -133
  253. package/src/map/handler/BoxZoomHandler.js +9 -8
  254. package/src/map/handler/DisplaceHandler.js +6 -8
  255. package/src/map/handler/DragHandler.js +25 -28
  256. package/src/map/handler/KeyboardHandler.js +42 -48
  257. package/src/map/handler/PinchZoomHandler.js +16 -5
  258. package/src/map/handler/ScrollWheelZoomHandler.js +6 -4
  259. package/src/map/handler/TapHoldHandler.js +15 -4
  260. package/src/map/index.js +1 -1
  261. package/src/maplair.css +148 -98
  262. package/dist/esm/core/Browser.js +0 -100
  263. package/dist/esm/core/Browser.js.map +0 -1
  264. package/dist/images/layers.svg +0 -1
  265. package/dist/images/marker-icon.svg +0 -1
  266. package/dist/images/marker-shadow.svg +0 -1
  267. package/src/core/Browser.js +0 -110
  268. package/src/images/layers.svg +0 -1
  269. package/src/images/marker-icon.svg +0 -1
  270. package/src/images/marker-shadow.svg +0 -1
package/src/map/Map.js CHANGED
@@ -5,7 +5,6 @@ import {Point} from '../geometry/Point.js';
5
5
  import {Bounds} from '../geometry/Bounds.js';
6
6
  import {LatLng} from '../geo/LatLng.js';
7
7
  import {LatLngBounds} from '../geo/LatLngBounds.js';
8
- import Browser from '../core/Browser.js';
9
8
  import * as DomEvent from '../dom/DomEvent.js';
10
9
  import * as DomUtil from '../dom/DomUtil.js';
11
10
  import {PosAnimation} from '../dom/PosAnimation.js';
@@ -35,7 +34,10 @@ import {TapDragZoomHandler} from './handler/TapDragZoomHandler.js';
35
34
  /** @import {CRS} from '../geo/crs/CRS.js' */
36
35
  /** @import {Handler} from '../core/Handler.js' */
37
36
  /** @import {Renderer} from '../layer/vector/Renderer.js' */
38
- /** @import {MaplairEvent, MaplairPointerEvent, MaplairKeyboardEvent, MaplairErrorEvent, LocationEvent, ResizeEvent, CrsChangeEvent, ZoomAnimEvent} from '../core/Events.js' */
37
+ /** @import {MaplairEvent, MaplairPointerEvent, MaplairKeyboardEvent, MaplairErrorEvent, LocationEvent, ResizeEvent, CrsChangeEvent, WorldCopyJumpEvent, ZoomAnimEvent} from '../core/Events.js' */
38
+
39
+ // matches the zoom transition in maplair.css
40
+ const zoomAnimDuration = 250;
39
41
 
40
42
  /**
41
43
  * Options of `MaplairMap`.
@@ -60,19 +62,18 @@ import {TapDragZoomHandler} from './handler/TapDragZoomHandler.js';
60
62
  * [`setMaxBounds`](#map-setmaxbounds) method.
61
63
  * @property {Renderer} [renderer] The default method for drawing vector layers on the
62
64
  * map. `SVG` or `Canvas` by default depending on browser support.
63
- * @property {boolean} [zoomAnimation] Whether the map zoom animation is enabled.
64
- * Animations are enabled by default unless the user has configured their browser for
65
- * reduced [motion](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-reduced-motion#user_preferences).
65
+ * @property {boolean} [zoomAnimation=true] Whether the map zoom animation is enabled.
66
66
  * @property {number} [zoomAnimationThreshold=4] Won't animate zoom if the zoom
67
- * difference exceeds this value.
67
+ * difference exceeds this value (or 1 if the user prefers
68
+ * [reduced motion](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-reduced-motion)
69
+ * and `animate: true` isn't passed).
68
70
  * @property {boolean} [continuousZoom=false] Whether zoom animations (e.g. of the zoom
69
71
  * control, double click and keyboard) change the view frame by frame through fractional
70
72
  * zoom levels, like `flyTo()` and pinch zoom, instead of scaling the map with a CSS
71
73
  * transition between two zoom levels. Also makes the scroll wheel zoom smoothly with
72
74
  * each wheel event (see `scrollWheelZoom`), snapping to `zoomSnap` when scrolling ends.
73
- * @property {boolean} [fadeAnimation] Whether the tile fade animation is enabled.
74
- * Animations are enabled by default unless the user has configured their browser for
75
- * reduced [motion](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-reduced-motion#user_preferences).
75
+ * @property {boolean} [fadeAnimation=true] Whether the tile and popup fade animation is
76
+ * enabled.
76
77
  * @property {boolean} [markerZoomAnimation=true] Whether markers animate their zoom
77
78
  * with the zoom animation, if disabled they will disappear for the length of the
78
79
  * animation.
@@ -122,18 +123,21 @@ import {TapDragZoomHandler} from './handler/TapDragZoomHandler.js';
122
123
  * Options of the `MaplairMap` methods which modify the zoom level.
123
124
  * @typedef {object} ZoomOptions
124
125
  * @property {boolean} [animate] If not specified, zoom animation will happen if the
125
- * zoom origin is inside the current view. If `true`, the map will attempt animating
126
- * zoom disregarding where zoom origin is. Setting `false` will make it always reset the
127
- * view completely without animation.
126
+ * zoom origin is inside the current view, and if the user prefers reduced motion, only
127
+ * when zooming by at most one level. If `true`, the map will attempt animating zoom
128
+ * disregarding where zoom origin is and the user's reduced motion preference. Setting
129
+ * `false` will make it always reset the view completely without animation.
128
130
  */
129
131
 
130
132
  /**
131
133
  * Options of the `MaplairMap` methods which modify the center of the map.
132
134
  * @typedef {object} PanOptions
133
- * @property {boolean} [animate] If `true`, panning will always be animated if possible.
134
- * If `false`, it will not animate panning, either resetting the map view if panning
135
- * more than a screen away, or just setting a new offset for the map pane (except for
136
- * `panBy` which always does the latter).
135
+ * @property {boolean} [animate] If `true`, panning will always be animated if possible,
136
+ * even if the user prefers reduced motion. If `false`, it will not animate panning,
137
+ * either resetting the map view if panning more than a screen away, or just setting a
138
+ * new offset for the map pane (except for `panBy` which always does the latter). If not
139
+ * specified, panning is animated, except for pans longer than half the map size when
140
+ * the user prefers reduced motion.
137
141
  * @property {number} [duration=0.25] Duration of animated panning, in seconds.
138
142
  * @property {number} [easeLinearity=0.25] The curvature factor of panning animation
139
143
  * easing (third parameter of the [Cubic Bezier curve](https://cubic-bezier.com/)).
@@ -257,16 +261,14 @@ import {TapDragZoomHandler} from './handler/TapDragZoomHandler.js';
257
261
  * @fires preclick {MaplairPointerEvent} Fired before pointer click on the map (sometimes
258
262
  * useful when you want something to happen on click before any existing click handlers
259
263
  * start running).
260
- * @fires keypress {MaplairKeyboardEvent} Fired when the user presses a key from the
261
- * keyboard that produces a character value while the map is focused.
262
264
  * @fires keydown {MaplairKeyboardEvent} Fired when the user presses a key from the
263
- * keyboard while the map is focused. Unlike the `keypress` event, the `keydown` event is
264
- * fired for keys that produce a character value and for keys that do not produce a
265
- * character value.
265
+ * keyboard while the map is focused.
266
266
  * @fires keyup {MaplairKeyboardEvent} Fired when the user releases a key from the
267
267
  * keyboard while the map is focused.
268
268
  * @fires crschange {CrsChangeEvent} Fired when the CRS of the map changes with
269
269
  * `setCrs()`, before the view is reset.
270
+ * @fires worldcopyjump {WorldCopyJumpEvent} Fired when [`worldCopyJump`](#maplairmapoptions-worldcopyjump)
271
+ * moves the map pane by one or more world widths.
270
272
  * @fires pixelratiochange {MaplairEvent} Fired when the `devicePixelRatio` of the browser
271
273
  * changes, e.g. when moving the window to a screen with another resolution or when
272
274
  * zooming the page. Tile layers with `detectRetina` and canvas renderers adapt to it.
@@ -275,31 +277,29 @@ import {TapDragZoomHandler} from './handler/TapDragZoomHandler.js';
275
277
  */
276
278
  export class MaplairMap extends Evented {
277
279
 
278
- static {
279
- this.setDefaultOptions({
280
- crs: EPSG3857,
281
- center: undefined,
282
- zoom: undefined,
283
- minZoom: undefined,
284
- maxZoom: undefined,
285
- layers: [],
286
- ariaLabel: undefined,
287
- maxBounds: undefined,
288
- renderer: undefined,
289
-
290
- zoomAnimation: !Browser.reducedMotion,
291
- zoomAnimationThreshold: 4,
292
- continuousZoom: false,
293
- fadeAnimation: !Browser.reducedMotion,
294
- markerZoomAnimation: true,
295
- markerCulling: false,
296
- transform3DLimit: 8388608, // Precision limit of a 32-bit float
297
-
298
- zoomSnap: 1,
299
- zoomDelta: 1,
300
- trackResize: true
301
- });
302
- }
280
+ static defaultOptions = {
281
+ crs: EPSG3857,
282
+ center: undefined,
283
+ zoom: undefined,
284
+ minZoom: undefined,
285
+ maxZoom: undefined,
286
+ layers: [],
287
+ ariaLabel: undefined,
288
+ maxBounds: undefined,
289
+ renderer: undefined,
290
+
291
+ zoomAnimation: true,
292
+ zoomAnimationThreshold: 4,
293
+ continuousZoom: false,
294
+ fadeAnimation: true,
295
+ markerZoomAnimation: true,
296
+ markerCulling: false,
297
+ transform3DLimit: 8388608, // Precision limit of a 32-bit float
298
+
299
+ zoomSnap: 1,
300
+ zoomDelta: 1,
301
+ trackResize: true
302
+ };
303
303
 
304
304
  /**
305
305
  * Instantiates a map object given the DOM ID of a `<div>` element or the element
@@ -328,6 +328,7 @@ export class MaplairMap extends Evented {
328
328
  this.on({
329
329
  movestart: this._onBusy,
330
330
  zoomstart: this._onBusy,
331
+ move: this._onMove,
331
332
  moveend: this._onViewChanged,
332
333
  layerremove: this._scheduleIdleCheck
333
334
  }, this);
@@ -532,9 +533,10 @@ export class MaplairMap extends Evented {
532
533
  panTo(center, options) {
533
534
  return this.setView(center, this._zoom, {pan: options});
534
535
  }
535
-
536
536
  /**
537
- * Pans the map by a given number of pixels (animated).
537
+ * Pans the map by a given number of pixels (animated unless `animate: false` is passed,
538
+ * or the user prefers reduced motion and the pan is longer than half the map size
539
+ * without `animate: true`).
538
540
  * @group Methods for modifying map state
539
541
  * @param {PointExpression} offset
540
542
  * @param {PanOptions} [options]
@@ -549,8 +551,10 @@ export class MaplairMap extends Evented {
549
551
  }
550
552
  // If we pan too far, Chrome gets issues with tiles
551
553
  // and makes them disappear or appear in the wrong place (slightly offset) #2602
552
- if (options.animate !== true && !this.getSize().contains(offset)) {
553
- this._resetView(this.unproject(this.project(this.getCenter()).add(offset)), this.getZoom());
554
+ const size = this.getSize();
555
+ if (options.animate !== true && !size.contains(offset)) {
556
+ const center = this.unproject(this.project(this.getCenter()).add(offset));
557
+ this._resetView(this.options.worldCopyJump ? this.wrapLatLng(center) : center, this.getZoom());
554
558
  return this;
555
559
  }
556
560
 
@@ -568,14 +572,16 @@ export class MaplairMap extends Evented {
568
572
  this.fire('movestart');
569
573
  }
570
574
 
571
- // animate pan unless browser prefers reduced motion or animate: false specified
572
- if (!Browser.reducedMotion && options.animate !== false) {
575
+ // with reduced motion, only short pans are animated unless animate: true is specified
576
+ const tooFarForReducedMotion = this._prefersReducedMotion() && !size.divideBy(2).contains(offset);
577
+ if (options.animate === true || (options.animate !== false && !tooFarForReducedMotion)) {
573
578
  this._mapPane.classList.add('maplair-pan-anim');
574
579
 
575
580
  const newPos = this._getMapPanePos().subtract(offset).round();
576
581
  this._panAnim.run(this._mapPane, newPos, options.duration || 0.25, options.easeLinearity);
577
582
  } else {
578
583
  this._rawPanBy(offset);
584
+ this._wrapWorldCopy();
579
585
  this.fire('move').fire('moveend');
580
586
  }
581
587
 
@@ -584,7 +590,8 @@ export class MaplairMap extends Evented {
584
590
 
585
591
  /**
586
592
  * Sets the view of the map (geographical center and zoom) performing a smooth
587
- * pan-zoom animation.
593
+ * pan-zoom animation. If the user prefers reduced motion (and `animate: true` isn't
594
+ * passed), it behaves like `setView` instead, only animating short pans and zooms.
588
595
  * @group Methods for modifying map state
589
596
  * @param {LatLngExpression} targetCenter
590
597
  * @param {number} [targetZoom]
@@ -594,20 +601,23 @@ export class MaplairMap extends Evented {
594
601
  flyTo(targetCenter, targetZoom, options) {
595
602
 
596
603
  options ??= {};
597
- if (Browser.reducedMotion || options.animate === false) {
604
+ if (options.animate === false) {
605
+ return this.setView(targetCenter, targetZoom, {...options, zoom: {...options.zoom, animate: false}});
606
+ }
607
+ if (options.animate !== true && this._prefersReducedMotion()) {
598
608
  return this.setView(targetCenter, targetZoom, options);
599
609
  }
600
610
 
601
611
  this._stop();
602
612
 
613
+ targetZoom = targetZoom === undefined ? this._zoom : this._limitZoom(targetZoom);
614
+ targetCenter = this._limitCenter(new LatLng(targetCenter), targetZoom, this.options.maxBounds);
615
+
603
616
  const from = this.project(this.getCenter()),
604
617
  to = this.project(targetCenter),
605
618
  size = this.getSize(),
606
619
  startZoom = this._zoom;
607
620
 
608
- targetCenter = new LatLng(targetCenter);
609
- targetZoom = targetZoom === undefined ? startZoom : this._limitZoom(targetZoom);
610
-
611
621
  const w0 = Math.max(size.x, size.y),
612
622
  w1 = w0 * this.getZoomScale(startZoom, targetZoom),
613
623
  u1 = (to.distanceTo(from)) || 1,
@@ -618,25 +628,15 @@ export class MaplairMap extends Evented {
618
628
  const s1 = i ? -1 : 1,
619
629
  s2 = i ? w1 : w0,
620
630
  t1 = w1 * w1 - w0 * w0 + s1 * rho2 * rho2 * u1 * u1,
621
- b1 = 2 * s2 * rho2 * u1,
622
- b = t1 / b1,
623
- sq = Math.sqrt(b * b + 1) - b;
624
-
625
- // workaround for floating point precision bug when sq = 0, log = -Infinite,
626
- // thus triggering an infinite loop in flyTo
627
- const log = sq < 0.000000015 ? -18 : Math.log(sq);
631
+ b1 = 2 * s2 * rho2 * u1;
628
632
 
629
- return log;
633
+ return -Math.asinh(t1 / b1);
630
634
  }
631
635
 
632
- function sinh(n) { return (Math.exp(n) - Math.exp(-n)) / 2; }
633
- function cosh(n) { return (Math.exp(n) + Math.exp(-n)) / 2; }
634
- function tanh(n) { return sinh(n) / cosh(n); }
635
-
636
636
  const r0 = r(0);
637
637
 
638
- function w(s) { return w0 * (cosh(r0) / cosh(r0 + rho * s)); }
639
- function u(s) { return w0 * (cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2; }
638
+ function w(s) { return w0 * (Math.cosh(r0) / Math.cosh(r0 + rho * s)); }
639
+ function u(s) { return w0 * (Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2; }
640
640
 
641
641
  function easeOut(t) { return 1 - (1 - t) ** 1.5; }
642
642
 
@@ -657,9 +657,12 @@ export class MaplairMap extends Evented {
657
657
  {flyTo: true});
658
658
 
659
659
  } else {
660
- this
661
- ._move(targetCenter, targetZoom)
662
- ._moveEnd(true);
660
+ // the last step shifts the pixel origin even at the same zoom, and layers like GridLayer only
661
+ // re-anchor on 'zoom' (#9438)
662
+ const zoomChanged = this._zoom !== targetZoom;
663
+ this._move(targetCenter, targetZoom);
664
+ if (!zoomChanged) { this.fire('zoom'); }
665
+ this._moveEnd(true);
663
666
  }
664
667
  };
665
668
 
@@ -1076,14 +1079,13 @@ export class MaplairMap extends Evented {
1076
1079
  if (this._clearControlPos) {
1077
1080
  this._clearControlPos();
1078
1081
  }
1079
- if (this._resizeRequest) {
1080
- cancelAnimationFrame(this._resizeRequest);
1081
- this._resizeRequest = null;
1082
- }
1082
+ cancelAnimationFrame(this._resizeRequest);
1083
1083
  cancelAnimationFrame(this._idleRequest);
1084
1084
  this._watchPixelRatio(true);
1085
1085
 
1086
- this._clearHandlers();
1086
+ for (const handler of this._handlers) {
1087
+ handler.disable();
1088
+ }
1087
1089
 
1088
1090
  clearTimeout(this._transitionEndTimer);
1089
1091
  clearTimeout(this._sizeTimer);
@@ -1092,8 +1094,6 @@ export class MaplairMap extends Evented {
1092
1094
  this.fire('unload');
1093
1095
  }
1094
1096
 
1095
- this._destroyAnimProxy();
1096
-
1097
1097
  for (const layer of Object.values(this._layers)) {
1098
1098
  layer.remove();
1099
1099
  }
@@ -1530,10 +1530,10 @@ export class MaplairMap extends Evented {
1530
1530
 
1531
1531
  this._fadeAnimated = this.options.fadeAnimation;
1532
1532
 
1533
+ // maplair-touch and maplair-retina have no rules in maplair.css, but custom stylesheets may still target them
1533
1534
  const classes = ['maplair-container', 'maplair-touch'];
1534
1535
 
1535
- if (Browser.retina) { classes.push('maplair-retina'); }
1536
- if (Browser.safari) { classes.push('maplair-safari'); }
1536
+ if (window.devicePixelRatio > 1) { classes.push('maplair-retina'); }
1537
1537
  if (this._fadeAnimated) { classes.push('maplair-fade-anim'); }
1538
1538
 
1539
1539
  container.classList.add(...classes);
@@ -1587,15 +1587,19 @@ export class MaplairMap extends Evented {
1587
1587
  // private methods that modify map state
1588
1588
 
1589
1589
  _resetView(center, zoom, noMoveStart) {
1590
- DomUtil.setPosition(this._mapPane, new Point(0, 0));
1591
-
1592
1590
  const loading = !this._loaded;
1593
1591
  this._loaded = true;
1594
1592
  zoom = this._limitZoom(zoom);
1595
1593
 
1596
- this.fire('viewprereset');
1594
+ // before the pane reset, so that listeners still see the current view
1595
+ this.fire('viewprereset', {center, zoom});
1596
+
1597
+ DomUtil.setPosition(this._mapPane, new Point(0, 0));
1597
1598
 
1598
1599
  const zoomChanged = this._zoom !== zoom;
1600
+ if (zoomChanged && !loading) {
1601
+ this._instantZoomEnd = Date.now() + zoomAnimDuration;
1602
+ }
1599
1603
  this
1600
1604
  ._moveStart(zoomChanged, noMoveStart)
1601
1605
  ._move(center, zoom)
@@ -1649,6 +1653,11 @@ export class MaplairMap extends Evented {
1649
1653
  this._idle = false;
1650
1654
  }
1651
1655
 
1656
+ // resets the bounds of the `markerCulling` option, computed once per view by `Marker._updateCulling()`
1657
+ _onMove() {
1658
+ this._cullingBounds = null;
1659
+ }
1660
+
1652
1661
  _onViewChanged() {
1653
1662
  this._viewChanging = false;
1654
1663
  this._scheduleIdleCheck();
@@ -1739,6 +1748,25 @@ export class MaplairMap extends Evented {
1739
1748
  DomUtil.setPosition(this._mapPane, this._getMapPanePos().subtract(offset));
1740
1749
  }
1741
1750
 
1751
+ // Shifts a map pane position by whole world widths to bring the view center back into the original world, moving
1752
+ // the pane and firing `worldcopyjump` if that makes it jump from where it is now.
1753
+ _wrapWorldCopy(pos = this._getMapPanePos()) {
1754
+ // an infinite CRS has no world to wrap around, and no pixel world bounds either
1755
+ if (!this._loaded || !this.options.worldCopyJump || this.options.crs.infinite) { return pos; }
1756
+
1757
+ const width = this.getPixelWorldBounds().getSize().x,
1758
+ x = pos.x - width * Math.round((pos.x + this.latLngToLayerPoint([0, 0]).x - this.getSize().x / 2) / width),
1759
+ worlds = Math.round((x - this._getMapPanePos().x) / width);
1760
+
1761
+ pos = new Point(x, pos.y);
1762
+
1763
+ if (worlds) {
1764
+ DomUtil.setPosition(this._mapPane, pos);
1765
+ this.fire('worldcopyjump', {worlds});
1766
+ }
1767
+ return pos;
1768
+ }
1769
+
1742
1770
  _getZoomSpan() {
1743
1771
  return this.getMaxZoom() - this.getMinZoom();
1744
1772
  }
@@ -1764,7 +1792,7 @@ export class MaplairMap extends Evented {
1764
1792
  const onOff = remove ? DomEvent.off : DomEvent.on;
1765
1793
 
1766
1794
  onOff(this._container, 'click dblclick pointerdown pointerup ' +
1767
- 'pointerover pointerout pointermove contextmenu keypress keydown keyup', this._handleDOMEvent, this);
1795
+ 'pointerover pointerout pointermove contextmenu keydown keyup', this._handleDOMEvent, this);
1768
1796
 
1769
1797
  if (this.options.trackResize) {
1770
1798
  if (!remove) {
@@ -1809,7 +1837,7 @@ export class MaplairMap extends Evented {
1809
1837
  _findEventTargets(e, type) {
1810
1838
  let targets = [],
1811
1839
  target,
1812
- src = e.target || e.srcElement,
1840
+ src = e.target,
1813
1841
  dragging = false;
1814
1842
  const isHover = type === 'pointerout' || type === 'pointerover';
1815
1843
 
@@ -1842,19 +1870,12 @@ export class MaplairMap extends Evented {
1842
1870
  }
1843
1871
 
1844
1872
  _handleDOMEvent(e) {
1845
- const el = e.target ?? e.srcElement;
1873
+ const el = e.target;
1846
1874
  if (!this._loaded || el['_maplair_disable_events'] || e.type === 'click' && this._isClickDisabled(el)) {
1847
1875
  return;
1848
1876
  }
1849
1877
 
1850
- const type = e.type;
1851
-
1852
- if (type === 'pointerdown') {
1853
- // prevents outline when clicking on keyboard-focusable element
1854
- DomUtil.preventOutline(el);
1855
- }
1856
-
1857
- this._fireDOMEvent(e, type);
1878
+ this._fireDOMEvent(e, e.type);
1858
1879
  };
1859
1880
 
1860
1881
  static _pointerEvents = ['click', 'dblclick', 'pointerover', 'pointerout', 'contextmenu'];
@@ -1886,7 +1907,7 @@ export class MaplairMap extends Evented {
1886
1907
  originalEvent: e
1887
1908
  };
1888
1909
 
1889
- if (e.type !== 'keypress' && e.type !== 'keydown' && e.type !== 'keyup') {
1910
+ if (e.type !== 'keydown' && e.type !== 'keyup') {
1890
1911
  const isMarker = target.getLatLng && (!target._pxRadius || target._pxRadius <= 10);
1891
1912
  data.containerPoint = isMarker ?
1892
1913
  this.latLngToContainerPoint(target.getLatLng()) : this.pointerEventToContainerPoint(e);
@@ -1896,8 +1917,10 @@ export class MaplairMap extends Evented {
1896
1917
 
1897
1918
  for (const t of targets) {
1898
1919
  t.fire(type, data, true);
1920
+ // bubblingMouseEvents is the Leaflet 1 name of the option
1921
+ const bubbling = t.options.bubblingMouseEvents ?? t.options.bubblingPointerEvents;
1899
1922
  if (data.originalEvent._stopped ||
1900
- (t.options.bubblingPointerEvents === false && MaplairMap._pointerEvents.includes(type))) { return; }
1923
+ (bubbling === false && MaplairMap._pointerEvents.includes(type))) { return; }
1901
1924
  }
1902
1925
  }
1903
1926
 
@@ -1906,12 +1929,6 @@ export class MaplairMap extends Evented {
1906
1929
  return obj.dragging?.moved() || this.boxZoom?.moved();
1907
1930
  }
1908
1931
 
1909
- _clearHandlers() {
1910
- for (const handler of this._handlers) {
1911
- handler.disable();
1912
- }
1913
- }
1914
-
1915
1932
 
1916
1933
  /**
1917
1934
  * Runs the given function `callback` when the map gets initialized with
@@ -1960,16 +1977,6 @@ export class MaplairMap extends Evented {
1960
1977
  return this.project(latlng, zoom)._subtract(topLeft);
1961
1978
  }
1962
1979
 
1963
- _latLngBoundsToNewLayerBounds(latLngBounds, zoom, center) {
1964
- const topLeft = this._getNewPixelOrigin(center, zoom);
1965
- return new Bounds([
1966
- this.project(latLngBounds.getSouthWest(), zoom)._subtract(topLeft),
1967
- this.project(latLngBounds.getNorthWest(), zoom)._subtract(topLeft),
1968
- this.project(latLngBounds.getSouthEast(), zoom)._subtract(topLeft),
1969
- this.project(latLngBounds.getNorthEast(), zoom)._subtract(topLeft)
1970
- ]);
1971
- }
1972
-
1973
1980
  // layer point of the current center
1974
1981
  _getCenterLayerPoint() {
1975
1982
  return this.containerPointToLayerPoint(this.getSize()._divideBy(2));
@@ -2000,6 +2007,11 @@ export class MaplairMap extends Evented {
2000
2007
  return this.unproject(centerPoint.add(offset), zoom);
2001
2008
  }
2002
2009
 
2010
+ // not cached, so that a preference changed mid-session applies right away
2011
+ _prefersReducedMotion() {
2012
+ return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
2013
+ }
2014
+
2003
2015
  // adjust offset for view to get inside bounds
2004
2016
  _limitOffset(offset, bounds) {
2005
2017
  if (!bounds) { return offset; }
@@ -2047,6 +2059,7 @@ export class MaplairMap extends Evented {
2047
2059
 
2048
2060
  _onPanTransitionEnd() {
2049
2061
  this._mapPane.classList.remove('maplair-pan-anim');
2062
+ this._wrapWorldCopy();
2050
2063
  this.fire('moveend');
2051
2064
  }
2052
2065
 
@@ -2100,20 +2113,6 @@ export class MaplairMap extends Evented {
2100
2113
  );
2101
2114
  }
2102
2115
 
2103
- _destroyAnimProxy() {
2104
- // Just make sure this method is safe to call from anywhere, without knowledge
2105
- // of whether the animation proxy was created in the first place.
2106
- if (this._proxy) {
2107
- DomEvent.off(this._proxy, 'transitionend', this._catchTransitionEnd, this);
2108
-
2109
- this._proxy.remove();
2110
- this.off('zoomanim', this._animateProxyZoom, this);
2111
- this.off('load moveend', this._animMoveEnd, this);
2112
-
2113
- delete this._proxy;
2114
- }
2115
- }
2116
-
2117
2116
  _catchTransitionEnd(e) {
2118
2117
  if (this._animatingZoom && e.propertyName.includes('transform')) {
2119
2118
  this._onZoomTransitionEnd();
@@ -2150,16 +2149,25 @@ export class MaplairMap extends Evented {
2150
2149
  this._flyToFrame = requestAnimationFrame(frame);
2151
2150
  }
2152
2151
 
2152
+ // an animated zoom drops zooms from input until it ends, so hold them as long after an instant zoom too,
2153
+ // or a trackpad swipe or a held key zooms several times as far
2154
+ _zoomInputBlocked() {
2155
+ return this._animatingZoom || Date.now() < this._instantZoomEnd;
2156
+ }
2157
+
2153
2158
  _tryAnimatedZoom(center, zoom, options) {
2154
2159
 
2155
2160
  if (this._animatingZoom) { return true; }
2156
2161
 
2157
2162
  options ??= {};
2158
2163
 
2159
- // don't animate if disabled, not supported or zoom difference is too large
2164
+ // don't animate if disabled, not supported or zoom difference is too large (over 1 with reduced motion,
2165
+ // unless animate: true is specified)
2166
+ const threshold = this.options.zoomAnimationThreshold,
2167
+ maxZoomDiff = this._prefersReducedMotion() && options.animate !== true ? Math.min(threshold, 1) : threshold;
2160
2168
  if (!this._zoomAnimated || options.animate === false ||
2161
2169
  (this._nothingToAnimate() && !this.options.continuousZoom) ||
2162
- Math.abs(zoom - this._zoom) > this.options.zoomAnimationThreshold) { return false; }
2170
+ Math.abs(zoom - this._zoom) > maxZoomDiff) { return false; }
2163
2171
 
2164
2172
  // offset is the pixel coords of the zoom origin relative to the current center
2165
2173
  const scale = this.getZoomScale(zoom),
@@ -2213,7 +2221,7 @@ export class MaplairMap extends Evented {
2213
2221
  this._move(this._animateToCenter, this._animateToZoom, undefined, true);
2214
2222
 
2215
2223
  // Work around webkit not firing 'transitionend', see https://github.com/Leaflet/Leaflet/issues/3689, 2693
2216
- this._transitionEndTimer = setTimeout(this._onZoomTransitionEnd.bind(this), 250);
2224
+ this._transitionEndTimer = setTimeout(this._onZoomTransitionEnd.bind(this), zoomAnimDuration);
2217
2225
  }
2218
2226
 
2219
2227
  _onZoomTransitionEnd() {
@@ -2272,4 +2280,5 @@ for (const feature of [
2272
2280
  feature.register(MaplairMap);
2273
2281
  }
2274
2282
 
2275
- export const Map = MaplairMap;
2283
+ export {MaplairMap as Map};
2284
+ export {MaplairMap as LeafletMap};
@@ -98,8 +98,9 @@ export class BoxZoomHandler extends Handler {
98
98
  this._clearDeferredResetState();
99
99
  this._resetState();
100
100
 
101
- DomUtil.disableTextSelection();
102
- DomUtil.disableImageDrag();
101
+ // stops both text selection and native image drag in every engine without restyling the page; it also
102
+ // suppresses compatibility mouse events, which is fine for a press that is already a box zoom gesture
103
+ DomEvent.preventDefault(e);
103
104
 
104
105
  this._startPoint = this._map.pointerEventToContainerPoint(e);
105
106
 
@@ -139,9 +140,6 @@ export class BoxZoomHandler extends Handler {
139
140
  this._container.classList.remove('maplair-crosshair');
140
141
  }
141
142
 
142
- DomUtil.enableTextSelection();
143
- DomUtil.enableImageDrag();
144
-
145
143
  DomEvent.off(this._container, {
146
144
  contextmenu: DomEvent.stop,
147
145
  pointermove: this._onPointerMove,
@@ -166,9 +164,12 @@ export class BoxZoomHandler extends Handler {
166
164
  this._map.containerPointToLatLng(this._point));
167
165
 
168
166
  this._map._setUserEvent(e);
169
- this._map
170
- .fitBounds(bounds)
171
- .fire('boxzoomend', {boxZoomBounds: bounds});
167
+ // a tiny box can collapse to a single LatLng at very high zoom, which fits at an Infinity zoom when no layer
168
+ // limits it; unlike fitBounds before a tile layer is added, no layer will come along to clamp it (#6709)
169
+ if (this._map.getBoundsZoom(bounds) !== Infinity) {
170
+ this._map.fitBounds(bounds);
171
+ }
172
+ this._map.fire('boxzoomend', {boxZoomBounds: bounds});
172
173
  }
173
174
 
174
175
  _onKeyDown(e) {
@@ -93,13 +93,11 @@ function displaceable(layer) {
93
93
  * ```
94
94
  */
95
95
  export class DisplaceHandler extends Handler {
96
- static {
97
- this.setDefaultOptions({
98
- gap: 2,
99
- iterations: 80,
100
- maxDistance: Infinity
101
- });
102
- }
96
+ static defaultOptions = {
97
+ gap: 2,
98
+ iterations: 80,
99
+ maxDistance: Infinity
100
+ };
103
101
 
104
102
  /**
105
103
  * @param {...MaplairMap} args The map.
@@ -317,7 +315,7 @@ export class DisplaceHandler extends Handler {
317
315
  export function displace(
318
316
  points,
319
317
  minSeparation,
320
- {iterations = DisplaceHandler.prototype.options.iterations, maxDisplacement = Infinity} = {},
318
+ {iterations = DisplaceHandler.defaultOptions.iterations, maxDisplacement = Infinity} = {},
321
319
  ) {
322
320
  const n = points.length;
323
321
  if (n < 2) { return points; }