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.
- package/CHANGELOG.md +178 -0
- package/dist/esm/Maplair.js +18 -17
- package/dist/esm/Maplair.js.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.js +1 -2
- package/dist/esm/control/AttributionControl.js +25 -16
- package/dist/esm/control/AttributionControl.js.map +1 -1
- package/dist/esm/control/ButtonControl.js +10 -13
- package/dist/esm/control/ButtonControl.js.map +1 -1
- package/dist/esm/control/ContextMenu.js +2 -5
- package/dist/esm/control/ContextMenu.js.map +1 -1
- package/dist/esm/control/Control.js +10 -18
- package/dist/esm/control/Control.js.map +1 -1
- package/dist/esm/control/FullscreenControl.js +6 -9
- package/dist/esm/control/FullscreenControl.js.map +1 -1
- package/dist/esm/control/LayersControl.js +170 -65
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/LegendControl.js +8 -11
- package/dist/esm/control/LegendControl.js.map +1 -1
- package/dist/esm/control/MiniMapControl.js +15 -18
- package/dist/esm/control/MiniMapControl.js.map +1 -1
- package/dist/esm/control/RotateControl.js +2 -5
- package/dist/esm/control/RotateControl.js.map +1 -1
- package/dist/esm/control/ScaleControl.js +8 -11
- package/dist/esm/control/ScaleControl.js.map +1 -1
- package/dist/esm/control/SearchControl.js +100 -19
- package/dist/esm/control/SearchControl.js.map +1 -1
- package/dist/esm/control/SideBySideControl.js +2 -5
- package/dist/esm/control/SideBySideControl.js.map +1 -1
- package/dist/esm/control/TextControl.js +6 -9
- package/dist/esm/control/TextControl.js.map +1 -1
- package/dist/esm/control/TimeControl.js +407 -0
- package/dist/esm/control/TimeControl.js.map +1 -0
- package/dist/esm/control/ZoomControl.js +23 -36
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Class.js +28 -44
- package/dist/esm/core/Class.js.map +1 -1
- package/dist/esm/core/Events.js +22 -10
- package/dist/esm/core/Events.js.map +1 -1
- package/dist/esm/core/Handler.js +23 -14
- package/dist/esm/core/Handler.js.map +1 -1
- package/dist/esm/core/I18n.js +1 -2
- package/dist/esm/core/Util.js +15 -4
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.DoubleTap.js +26 -24
- package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -1
- package/dist/esm/dom/DomEvent.PointerEvents.js +3 -18
- package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
- package/dist/esm/dom/DomEvent.js +18 -60
- package/dist/esm/dom/DomEvent.js.map +1 -1
- package/dist/esm/dom/DomUtil.js +15 -70
- package/dist/esm/dom/DomUtil.js.map +1 -1
- package/dist/esm/dom/Draggable.js +21 -21
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/dom/PosAnimation.js +4 -27
- package/dist/esm/dom/PosAnimation.js.map +1 -1
- package/dist/esm/geo/LatLng.js +16 -7
- package/dist/esm/geo/LatLng.js.map +1 -1
- package/dist/esm/geo/LatLngBounds.js +9 -15
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geo/crs/CRS.js +1 -2
- package/dist/esm/geo/crs/EPSG3395.js +5 -6
- package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
- package/dist/esm/geo/crs/EPSG3857.js +5 -6
- package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
- package/dist/esm/geo/crs/EPSG4326.js +4 -5
- package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
- package/dist/esm/geo/crs/EarthCRS.js +3 -4
- package/dist/esm/geo/crs/EarthCRS.js.map +1 -1
- package/dist/esm/geo/crs/SimpleCRS.js +4 -5
- package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
- package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +5 -6
- package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +4 -5
- package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +5 -6
- package/dist/esm/geo/projection/SphericalMercatorProjection.js.map +1 -0
- package/dist/esm/geometry/Bounds.js +10 -14
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/LineUtil.js +37 -32
- package/dist/esm/geometry/LineUtil.js.map +1 -1
- package/dist/esm/geometry/Point.js +1 -2
- package/dist/esm/geometry/PolyUtil.js +24 -51
- package/dist/esm/geometry/PolyUtil.js.map +1 -1
- package/dist/esm/geometry/Transformation.js +1 -2
- package/dist/esm/layer/BlanketOverlay.js +7 -10
- package/dist/esm/layer/BlanketOverlay.js.map +1 -1
- package/dist/esm/layer/Classification.js +1 -2
- package/dist/esm/layer/DivOverlay.js +16 -22
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/FeatureGroup.js +5 -4
- package/dist/esm/layer/FeatureGroup.js.map +1 -1
- package/dist/esm/layer/GeoJSON.Load.js +1 -2
- package/dist/esm/layer/GeoJSON.js +17 -155
- package/dist/esm/layer/GeoJSON.js.map +1 -1
- package/dist/esm/layer/GeoJSONUtil.js +74 -0
- package/dist/esm/layer/GeoJSONUtil.js.map +1 -0
- package/dist/esm/layer/HeatLayer.js +17 -20
- package/dist/esm/layer/HeatLayer.js.map +1 -1
- package/dist/esm/layer/ImageOverlay.js +22 -29
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +9 -12
- package/dist/esm/layer/Layer.js.map +1 -1
- package/dist/esm/layer/LayerGroup.js +53 -3
- package/dist/esm/layer/LayerGroup.js.map +1 -1
- package/dist/esm/layer/Popup.js +35 -58
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/SVGOverlay.js +3 -7
- package/dist/esm/layer/SVGOverlay.js.map +1 -1
- package/dist/esm/layer/Tooltip.js +31 -34
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/VideoOverlay.js +13 -17
- package/dist/esm/layer/VideoOverlay.js.map +1 -1
- package/dist/esm/layer/marker/DefaultIcon.js +38 -49
- package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
- package/dist/esm/layer/marker/DivIcon.js +8 -11
- package/dist/esm/layer/marker/DivIcon.js.map +1 -1
- package/dist/esm/layer/marker/Icon.js +9 -12
- package/dist/esm/layer/marker/Icon.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js +44 -5
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Move.js +5 -8
- package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +115 -47
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/marker/MarkerClusterGroup.js +301 -0
- package/dist/esm/layer/marker/MarkerClusterGroup.js.map +1 -0
- package/dist/esm/layer/marker/SvgIcon.js +7 -10
- package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
- package/dist/esm/layer/tile/GridLayer.js +89 -101
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +36 -44
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/tile/WMSTileLayer.js +33 -27
- package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +8 -17
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +6 -5
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +19 -10
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.DashAnimation.js +3 -5
- package/dist/esm/layer/vector/Path.DashAnimation.js.map +1 -1
- package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
- package/dist/esm/layer/vector/Path.js +28 -22
- package/dist/esm/layer/vector/Path.js.map +1 -1
- package/dist/esm/layer/vector/Polygon.js +22 -7
- package/dist/esm/layer/vector/Polygon.js.map +1 -1
- package/dist/esm/layer/vector/Polyline.Decorations.js +3 -4
- package/dist/esm/layer/vector/Polyline.js +25 -10
- package/dist/esm/layer/vector/Polyline.js.map +1 -1
- package/dist/esm/layer/vector/Rectangle.js +1 -2
- package/dist/esm/layer/vector/Renderer.getRenderer.js +17 -17
- package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
- package/dist/esm/layer/vector/Renderer.js +1 -2
- package/dist/esm/layer/vector/SVG.js +12 -9
- package/dist/esm/layer/vector/SVG.js.map +1 -1
- package/dist/esm/map/Hash.js +1 -2
- package/dist/esm/map/Map.Rotation.js +41 -22
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +125 -126
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/MapSync.js +1 -2
- package/dist/esm/map/handler/BoxZoomHandler.js +25 -47
- package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DisplaceHandler.js +7 -10
- package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
- package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
- package/dist/esm/map/handler/DragHandler.js +20 -21
- package/dist/esm/map/handler/DragHandler.js.map +1 -1
- package/dist/esm/map/handler/KeyboardHandler.js +48 -68
- package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +13 -5
- package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +4 -6
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
- package/dist/esm/map/handler/TapHoldHandler.js +13 -7
- package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
- package/dist/esm/package.js +2 -3
- package/dist/maplair-global-src.js +6495 -5981
- package/dist/maplair-global-src.js.map +1 -1
- package/dist/maplair-global.js +2 -2
- package/dist/maplair-global.js.map +1 -1
- package/dist/maplair-src.js +6206 -5673
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.css +1 -1213
- package/dist/maplair.js +2 -2
- package/dist/maplair.js.map +1 -1
- package/i18n/cs.json +6 -0
- package/i18n/de.json +6 -0
- package/i18n/en.json +6 -0
- package/i18n/es.json +6 -0
- package/i18n/fr.json +6 -0
- package/i18n/hu.json +6 -0
- package/i18n/it.json +6 -0
- package/i18n/rm.json +6 -0
- package/i18n/sk.json +6 -0
- package/i18n/sl.json +6 -0
- package/package.json +11 -18
- package/src/Maplair.all.js +0 -1
- package/src/control/AttributionControl.js +25 -18
- package/src/control/ButtonControl.js +9 -11
- package/src/control/ContextMenu.js +3 -5
- package/src/control/Control.js +9 -19
- package/src/control/FullscreenControl.js +5 -7
- package/src/control/LayersControl.js +196 -86
- package/src/control/LegendControl.js +7 -9
- package/src/control/MiniMapControl.js +9 -11
- package/src/control/RotateControl.js +3 -5
- package/src/control/ScaleControl.js +7 -9
- package/src/control/SearchControl.js +102 -19
- package/src/control/SideBySideControl.js +3 -5
- package/src/control/TextControl.js +5 -7
- package/src/control/TimeControl.js +471 -0
- package/src/control/ZoomControl.js +22 -38
- package/src/control/index.js +1 -0
- package/src/core/Class.js +37 -45
- package/src/core/Events.js +22 -3
- package/src/core/Handler.js +25 -13
- package/src/core/Util.js +20 -2
- package/src/core/index.js +0 -1
- package/src/dom/DomEvent.DoubleTap.js +18 -10
- package/src/dom/DomEvent.PointerEvents.js +3 -26
- package/src/dom/DomEvent.js +17 -85
- package/src/dom/DomUtil.js +22 -78
- package/src/dom/Draggable.js +32 -23
- package/src/dom/PosAnimation.js +3 -25
- package/src/dom/index.js +0 -1
- package/src/geo/LatLng.js +20 -3
- package/src/geo/LatLngBounds.js +8 -15
- package/src/geo/crs/EPSG3395.js +4 -4
- package/src/geo/crs/EPSG3857.js +4 -4
- package/src/geo/crs/EPSG4326.js +3 -3
- package/src/geo/crs/EarthCRS.js +2 -8
- package/src/geo/crs/SimpleCRS.js +3 -3
- package/src/geo/index.js +1 -2
- package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +2 -2
- package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +2 -2
- package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +2 -2
- package/src/geo/projection/index.js +5 -5
- package/src/geometry/Bounds.js +12 -17
- package/src/geometry/LineUtil.js +48 -49
- package/src/geometry/PolyUtil.js +39 -76
- package/src/layer/BlanketOverlay.js +6 -10
- package/src/layer/DivOverlay.js +16 -27
- package/src/layer/FeatureGroup.js +8 -2
- package/src/layer/GeoJSON.js +17 -218
- package/src/layer/GeoJSONUtil.js +85 -0
- package/src/layer/HeatLayer.js +10 -12
- package/src/layer/ImageOverlay.js +21 -32
- package/src/layer/Layer.js +8 -10
- package/src/layer/LayerGroup.js +72 -1
- package/src/layer/Popup.js +37 -62
- package/src/layer/SVGOverlay.js +1 -5
- package/src/layer/Tooltip.js +34 -36
- package/src/layer/VideoOverlay.js +12 -15
- package/src/layer/marker/DefaultIcon.js +40 -58
- package/src/layer/marker/DivIcon.js +9 -11
- package/src/layer/marker/Icon.js +9 -10
- package/src/layer/marker/Marker.Drag.js +54 -6
- package/src/layer/marker/Marker.Move.js +4 -6
- package/src/layer/marker/Marker.js +145 -52
- package/src/layer/marker/MarkerClusterGroup.js +370 -0
- package/src/layer/marker/SvgIcon.js +7 -9
- package/src/layer/marker/index.js +1 -0
- package/src/layer/tile/GridLayer.js +108 -135
- package/src/layer/tile/TileLayer.js +44 -49
- package/src/layer/tile/WMSTileLayer.js +31 -26
- package/src/layer/vector/Canvas.js +13 -19
- package/src/layer/vector/Circle.js +9 -3
- package/src/layer/vector/CircleMarker.js +19 -7
- package/src/layer/vector/Path.DashAnimation.js +1 -2
- package/src/layer/vector/Path.js +30 -21
- package/src/layer/vector/Polygon.js +29 -6
- package/src/layer/vector/Polyline.js +26 -7
- package/src/layer/vector/Renderer.getRenderer.js +20 -19
- package/src/layer/vector/SVG.js +17 -7
- package/src/map/Map.Rotation.js +40 -8
- package/src/map/Map.js +158 -153
- package/src/map/handler/BoxZoomHandler.js +30 -50
- package/src/map/handler/DisplaceHandler.js +6 -8
- package/src/map/handler/DragHandler.js +25 -28
- package/src/map/handler/KeyboardHandler.js +65 -90
- package/src/map/handler/PinchZoomHandler.js +16 -5
- package/src/map/handler/ScrollWheelZoomHandler.js +6 -4
- package/src/map/handler/TapHoldHandler.js +15 -4
- package/src/map/index.js +1 -1
- package/src/maplair.css +153 -98
- package/dist/esm/core/Browser.js +0 -100
- package/dist/esm/core/Browser.js.map +0 -1
- package/dist/esm/geo/projection/Projection.LonLat.js.map +0 -1
- package/dist/esm/geo/projection/Projection.Mercator.js.map +0 -1
- package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +0 -1
- package/dist/esm/geo/projection/index.js +0 -14
- package/dist/esm/geo/projection/index.js.map +0 -1
- package/dist/esm/layer/marker/Marker.Rotation.js +0 -70
- package/dist/esm/layer/marker/Marker.Rotation.js.map +0 -1
- package/dist/images/layers.svg +0 -1
- package/dist/images/marker-icon.svg +0 -1
- package/dist/images/marker-shadow.svg +0 -1
- package/src/core/Browser.js +0 -110
- package/src/images/layers.svg +0 -1
- package/src/images/marker-icon.svg +0 -1
- package/src/images/marker-shadow.svg +0 -1
- package/src/layer/marker/Marker.Rotation.js +0 -103
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
|
|
74
|
-
*
|
|
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
|
|
126
|
-
*
|
|
127
|
-
*
|
|
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,
|
|
135
|
-
* more than a screen away, or just setting a
|
|
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.
|
|
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
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
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);
|
|
@@ -450,12 +451,14 @@ export class MaplairMap extends Evented {
|
|
|
450
451
|
* @returns {this}
|
|
451
452
|
*/
|
|
452
453
|
setZoomAround(latlng, zoom, options) {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
454
|
+
// work in unrounded projected coordinates so that zooming back and forth around the same point
|
|
455
|
+
// doesn't accumulate pixel rounding errors (amplified by the zoom scale) and drift the view;
|
|
456
|
+
// a pixel offset goes through layer points, which account for a rotation of the map
|
|
457
|
+
const center = this.project(this.getCenter()),
|
|
458
|
+
offset = latlng instanceof Point ?
|
|
459
|
+
this.containerPointToLayerPoint(latlng).subtract(this.containerPointToLayerPoint(this.getSize().divideBy(2))) :
|
|
460
|
+
this.project(latlng).subtract(center),
|
|
461
|
+
newCenter = this.unproject(center.add(offset.multiplyBy(1 - 1 / this.getZoomScale(zoom))));
|
|
459
462
|
|
|
460
463
|
return this.setView(newCenter, zoom, {zoom: options});
|
|
461
464
|
}
|
|
@@ -532,9 +535,10 @@ export class MaplairMap extends Evented {
|
|
|
532
535
|
panTo(center, options) {
|
|
533
536
|
return this.setView(center, this._zoom, {pan: options});
|
|
534
537
|
}
|
|
535
|
-
|
|
536
538
|
/**
|
|
537
|
-
* Pans the map by a given number of pixels (animated
|
|
539
|
+
* Pans the map by a given number of pixels (animated unless `animate: false` is passed,
|
|
540
|
+
* or the user prefers reduced motion and the pan is longer than half the map size
|
|
541
|
+
* without `animate: true`).
|
|
538
542
|
* @group Methods for modifying map state
|
|
539
543
|
* @param {PointExpression} offset
|
|
540
544
|
* @param {PanOptions} [options]
|
|
@@ -549,8 +553,10 @@ export class MaplairMap extends Evented {
|
|
|
549
553
|
}
|
|
550
554
|
// If we pan too far, Chrome gets issues with tiles
|
|
551
555
|
// and makes them disappear or appear in the wrong place (slightly offset) #2602
|
|
552
|
-
|
|
553
|
-
|
|
556
|
+
const size = this.getSize();
|
|
557
|
+
if (options.animate !== true && !size.contains(offset)) {
|
|
558
|
+
const center = this.unproject(this.project(this.getCenter()).add(offset));
|
|
559
|
+
this._resetView(this.options.worldCopyJump ? this.wrapLatLng(center) : center, this.getZoom());
|
|
554
560
|
return this;
|
|
555
561
|
}
|
|
556
562
|
|
|
@@ -568,14 +574,16 @@ export class MaplairMap extends Evented {
|
|
|
568
574
|
this.fire('movestart');
|
|
569
575
|
}
|
|
570
576
|
|
|
571
|
-
//
|
|
572
|
-
|
|
577
|
+
// with reduced motion, only short pans are animated unless animate: true is specified
|
|
578
|
+
const tooFarForReducedMotion = this._prefersReducedMotion() && !size.divideBy(2).contains(offset);
|
|
579
|
+
if (options.animate === true || (options.animate !== false && !tooFarForReducedMotion)) {
|
|
573
580
|
this._mapPane.classList.add('maplair-pan-anim');
|
|
574
581
|
|
|
575
582
|
const newPos = this._getMapPanePos().subtract(offset).round();
|
|
576
583
|
this._panAnim.run(this._mapPane, newPos, options.duration || 0.25, options.easeLinearity);
|
|
577
584
|
} else {
|
|
578
585
|
this._rawPanBy(offset);
|
|
586
|
+
this._wrapWorldCopy();
|
|
579
587
|
this.fire('move').fire('moveend');
|
|
580
588
|
}
|
|
581
589
|
|
|
@@ -584,7 +592,8 @@ export class MaplairMap extends Evented {
|
|
|
584
592
|
|
|
585
593
|
/**
|
|
586
594
|
* Sets the view of the map (geographical center and zoom) performing a smooth
|
|
587
|
-
* pan-zoom animation.
|
|
595
|
+
* pan-zoom animation. If the user prefers reduced motion (and `animate: true` isn't
|
|
596
|
+
* passed), it behaves like `setView` instead, only animating short pans and zooms.
|
|
588
597
|
* @group Methods for modifying map state
|
|
589
598
|
* @param {LatLngExpression} targetCenter
|
|
590
599
|
* @param {number} [targetZoom]
|
|
@@ -594,20 +603,23 @@ export class MaplairMap extends Evented {
|
|
|
594
603
|
flyTo(targetCenter, targetZoom, options) {
|
|
595
604
|
|
|
596
605
|
options ??= {};
|
|
597
|
-
if (
|
|
606
|
+
if (options.animate === false) {
|
|
607
|
+
return this.setView(targetCenter, targetZoom, {...options, zoom: {...options.zoom, animate: false}});
|
|
608
|
+
}
|
|
609
|
+
if (options.animate !== true && this._prefersReducedMotion()) {
|
|
598
610
|
return this.setView(targetCenter, targetZoom, options);
|
|
599
611
|
}
|
|
600
612
|
|
|
601
613
|
this._stop();
|
|
602
614
|
|
|
615
|
+
targetZoom = targetZoom === undefined ? this._zoom : this._limitZoom(targetZoom);
|
|
616
|
+
targetCenter = this._limitCenter(new LatLng(targetCenter), targetZoom, this.options.maxBounds);
|
|
617
|
+
|
|
603
618
|
const from = this.project(this.getCenter()),
|
|
604
619
|
to = this.project(targetCenter),
|
|
605
620
|
size = this.getSize(),
|
|
606
621
|
startZoom = this._zoom;
|
|
607
622
|
|
|
608
|
-
targetCenter = new LatLng(targetCenter);
|
|
609
|
-
targetZoom = targetZoom === undefined ? startZoom : this._limitZoom(targetZoom);
|
|
610
|
-
|
|
611
623
|
const w0 = Math.max(size.x, size.y),
|
|
612
624
|
w1 = w0 * this.getZoomScale(startZoom, targetZoom),
|
|
613
625
|
u1 = (to.distanceTo(from)) || 1,
|
|
@@ -618,25 +630,14 @@ export class MaplairMap extends Evented {
|
|
|
618
630
|
const s1 = i ? -1 : 1,
|
|
619
631
|
s2 = i ? w1 : w0,
|
|
620
632
|
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);
|
|
633
|
+
b1 = 2 * s2 * rho2 * u1;
|
|
628
634
|
|
|
629
|
-
return
|
|
635
|
+
return -Math.asinh(t1 / b1);
|
|
630
636
|
}
|
|
631
637
|
|
|
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
638
|
const r0 = r(0);
|
|
637
639
|
|
|
638
|
-
function
|
|
639
|
-
function u(s) { return w0 * (cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2; }
|
|
640
|
+
function u(s) { return w0 * (Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2; }
|
|
640
641
|
|
|
641
642
|
function easeOut(t) { return 1 - (1 - t) ** 1.5; }
|
|
642
643
|
|
|
@@ -653,13 +654,16 @@ export class MaplairMap extends Evented {
|
|
|
653
654
|
|
|
654
655
|
this._move(
|
|
655
656
|
this.unproject(from.add(to.subtract(from).multiplyBy(u(s) / u1)), startZoom),
|
|
656
|
-
this.getScaleZoom(
|
|
657
|
+
this.getScaleZoom(Math.cosh(r0 + rho * s) / Math.cosh(r0), startZoom),
|
|
657
658
|
{flyTo: true});
|
|
658
659
|
|
|
659
660
|
} else {
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
661
|
+
// the last step shifts the pixel origin even at the same zoom, and layers like GridLayer only
|
|
662
|
+
// re-anchor on 'zoom' (#9438)
|
|
663
|
+
const zoomChanged = this._zoom !== targetZoom;
|
|
664
|
+
this._move(targetCenter, targetZoom);
|
|
665
|
+
if (!zoomChanged) { this.fire('zoom'); }
|
|
666
|
+
this._moveEnd(true);
|
|
663
667
|
}
|
|
664
668
|
};
|
|
665
669
|
|
|
@@ -1076,14 +1080,13 @@ export class MaplairMap extends Evented {
|
|
|
1076
1080
|
if (this._clearControlPos) {
|
|
1077
1081
|
this._clearControlPos();
|
|
1078
1082
|
}
|
|
1079
|
-
|
|
1080
|
-
cancelAnimationFrame(this._resizeRequest);
|
|
1081
|
-
this._resizeRequest = null;
|
|
1082
|
-
}
|
|
1083
|
+
cancelAnimationFrame(this._resizeRequest);
|
|
1083
1084
|
cancelAnimationFrame(this._idleRequest);
|
|
1084
1085
|
this._watchPixelRatio(true);
|
|
1085
1086
|
|
|
1086
|
-
this.
|
|
1087
|
+
for (const handler of this._handlers) {
|
|
1088
|
+
handler.disable();
|
|
1089
|
+
}
|
|
1087
1090
|
|
|
1088
1091
|
clearTimeout(this._transitionEndTimer);
|
|
1089
1092
|
clearTimeout(this._sizeTimer);
|
|
@@ -1092,8 +1095,6 @@ export class MaplairMap extends Evented {
|
|
|
1092
1095
|
this.fire('unload');
|
|
1093
1096
|
}
|
|
1094
1097
|
|
|
1095
|
-
this._destroyAnimProxy();
|
|
1096
|
-
|
|
1097
1098
|
for (const layer of Object.values(this._layers)) {
|
|
1098
1099
|
layer.remove();
|
|
1099
1100
|
}
|
|
@@ -1137,7 +1138,7 @@ export class MaplairMap extends Evented {
|
|
|
1137
1138
|
getCenter() {
|
|
1138
1139
|
this._checkIfLoaded();
|
|
1139
1140
|
|
|
1140
|
-
if (this._lastCenter &&
|
|
1141
|
+
if (this._lastCenter && this._getMapPanePos().equals(this._lastCenterPanePos)) {
|
|
1141
1142
|
return new LatLng(this._lastCenter);
|
|
1142
1143
|
}
|
|
1143
1144
|
return this.layerPointToLatLng(this._getCenterLayerPoint());
|
|
@@ -1385,8 +1386,7 @@ export class MaplairMap extends Evented {
|
|
|
1385
1386
|
* @returns {Point}
|
|
1386
1387
|
*/
|
|
1387
1388
|
latLngToLayerPoint(latlng) {
|
|
1388
|
-
|
|
1389
|
-
return projectedPoint._subtract(this.getPixelOrigin());
|
|
1389
|
+
return this.project(LatLng.from(latlng))._subtract(this.getPixelOrigin());
|
|
1390
1390
|
}
|
|
1391
1391
|
|
|
1392
1392
|
/**
|
|
@@ -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 (
|
|
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
|
-
|
|
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();
|
|
@@ -1706,6 +1715,7 @@ export class MaplairMap extends Evented {
|
|
|
1706
1715
|
|
|
1707
1716
|
this._zoom = zoom;
|
|
1708
1717
|
this._lastCenter = center;
|
|
1718
|
+
this._lastCenterPanePos = this._getMapPanePos();
|
|
1709
1719
|
this._pixelOrigin = this._getNewPixelOrigin(center);
|
|
1710
1720
|
|
|
1711
1721
|
if (!suppressEvent) {
|
|
@@ -1739,6 +1749,25 @@ export class MaplairMap extends Evented {
|
|
|
1739
1749
|
DomUtil.setPosition(this._mapPane, this._getMapPanePos().subtract(offset));
|
|
1740
1750
|
}
|
|
1741
1751
|
|
|
1752
|
+
// Shifts a map pane position by whole world widths to bring the view center back into the original world, moving
|
|
1753
|
+
// the pane and firing `worldcopyjump` if that makes it jump from where it is now.
|
|
1754
|
+
_wrapWorldCopy(pos = this._getMapPanePos()) {
|
|
1755
|
+
// an infinite CRS has no world to wrap around, and no pixel world bounds either
|
|
1756
|
+
if (!this._loaded || !this.options.worldCopyJump || this.options.crs.infinite) { return pos; }
|
|
1757
|
+
|
|
1758
|
+
const width = this.getPixelWorldBounds().getSize().x,
|
|
1759
|
+
x = pos.x - width * Math.round((pos.x + this.latLngToLayerPoint([0, 0]).x - this.getSize().x / 2) / width),
|
|
1760
|
+
worlds = Math.round((x - this._getMapPanePos().x) / width);
|
|
1761
|
+
|
|
1762
|
+
pos = new Point(x, pos.y);
|
|
1763
|
+
|
|
1764
|
+
if (worlds) {
|
|
1765
|
+
DomUtil.setPosition(this._mapPane, pos);
|
|
1766
|
+
this.fire('worldcopyjump', {worlds});
|
|
1767
|
+
}
|
|
1768
|
+
return pos;
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1742
1771
|
_getZoomSpan() {
|
|
1743
1772
|
return this.getMaxZoom() - this.getMinZoom();
|
|
1744
1773
|
}
|
|
@@ -1764,7 +1793,7 @@ export class MaplairMap extends Evented {
|
|
|
1764
1793
|
const onOff = remove ? DomEvent.off : DomEvent.on;
|
|
1765
1794
|
|
|
1766
1795
|
onOff(this._container, 'click dblclick pointerdown pointerup ' +
|
|
1767
|
-
'pointerover pointerout pointermove contextmenu
|
|
1796
|
+
'pointerover pointerout pointermove contextmenu keydown keyup', this._handleDOMEvent, this);
|
|
1768
1797
|
|
|
1769
1798
|
if (this.options.trackResize) {
|
|
1770
1799
|
if (!remove) {
|
|
@@ -1809,7 +1838,7 @@ export class MaplairMap extends Evented {
|
|
|
1809
1838
|
_findEventTargets(e, type) {
|
|
1810
1839
|
let targets = [],
|
|
1811
1840
|
target,
|
|
1812
|
-
src = e.target
|
|
1841
|
+
src = e.target,
|
|
1813
1842
|
dragging = false;
|
|
1814
1843
|
const isHover = type === 'pointerout' || type === 'pointerover';
|
|
1815
1844
|
|
|
@@ -1842,19 +1871,12 @@ export class MaplairMap extends Evented {
|
|
|
1842
1871
|
}
|
|
1843
1872
|
|
|
1844
1873
|
_handleDOMEvent(e) {
|
|
1845
|
-
const el = e.target
|
|
1874
|
+
const el = e.target;
|
|
1846
1875
|
if (!this._loaded || el['_maplair_disable_events'] || e.type === 'click' && this._isClickDisabled(el)) {
|
|
1847
1876
|
return;
|
|
1848
1877
|
}
|
|
1849
1878
|
|
|
1850
|
-
|
|
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);
|
|
1879
|
+
this._fireDOMEvent(e, e.type);
|
|
1858
1880
|
};
|
|
1859
1881
|
|
|
1860
1882
|
static _pointerEvents = ['click', 'dblclick', 'pointerover', 'pointerout', 'contextmenu'];
|
|
@@ -1886,18 +1908,20 @@ export class MaplairMap extends Evented {
|
|
|
1886
1908
|
originalEvent: e
|
|
1887
1909
|
};
|
|
1888
1910
|
|
|
1889
|
-
if (e.type !== '
|
|
1890
|
-
const
|
|
1891
|
-
data.containerPoint =
|
|
1892
|
-
this.latLngToContainerPoint(
|
|
1911
|
+
if (e.type !== 'keydown' && e.type !== 'keyup') {
|
|
1912
|
+
const latlng = (!target._pxRadius || target._pxRadius <= 10) && target.getLatLng?.();
|
|
1913
|
+
data.containerPoint = latlng ?
|
|
1914
|
+
this.latLngToContainerPoint(latlng) : this.pointerEventToContainerPoint(e);
|
|
1893
1915
|
data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
|
|
1894
|
-
data.latlng =
|
|
1916
|
+
data.latlng = latlng || this.layerPointToLatLng(data.layerPoint);
|
|
1895
1917
|
}
|
|
1896
1918
|
|
|
1897
1919
|
for (const t of targets) {
|
|
1898
1920
|
t.fire(type, data, true);
|
|
1921
|
+
// bubblingMouseEvents is the Leaflet 1 name of the option
|
|
1922
|
+
const bubbling = t.options.bubblingMouseEvents ?? t.options.bubblingPointerEvents;
|
|
1899
1923
|
if (data.originalEvent._stopped ||
|
|
1900
|
-
(
|
|
1924
|
+
(bubbling === false && MaplairMap._pointerEvents.includes(type))) { return; }
|
|
1901
1925
|
}
|
|
1902
1926
|
}
|
|
1903
1927
|
|
|
@@ -1906,12 +1930,6 @@ export class MaplairMap extends Evented {
|
|
|
1906
1930
|
return obj.dragging?.moved() || this.boxZoom?.moved();
|
|
1907
1931
|
}
|
|
1908
1932
|
|
|
1909
|
-
_clearHandlers() {
|
|
1910
|
-
for (const handler of this._handlers) {
|
|
1911
|
-
handler.disable();
|
|
1912
|
-
}
|
|
1913
|
-
}
|
|
1914
|
-
|
|
1915
1933
|
|
|
1916
1934
|
/**
|
|
1917
1935
|
* Runs the given function `callback` when the map gets initialized with
|
|
@@ -1938,11 +1956,6 @@ export class MaplairMap extends Evented {
|
|
|
1938
1956
|
return DomUtil.getPosition(this._mapPane);
|
|
1939
1957
|
}
|
|
1940
1958
|
|
|
1941
|
-
_moved() {
|
|
1942
|
-
const pos = this._getMapPanePos();
|
|
1943
|
-
return pos && !pos.equals([0, 0]);
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
1959
|
_getTopLeftPoint(center, zoom) {
|
|
1947
1960
|
const pixelOrigin = center && zoom !== undefined ?
|
|
1948
1961
|
this._getNewPixelOrigin(center, zoom) :
|
|
@@ -1960,16 +1973,6 @@ export class MaplairMap extends Evented {
|
|
|
1960
1973
|
return this.project(latlng, zoom)._subtract(topLeft);
|
|
1961
1974
|
}
|
|
1962
1975
|
|
|
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
1976
|
// layer point of the current center
|
|
1974
1977
|
_getCenterLayerPoint() {
|
|
1975
1978
|
return this.containerPointToLayerPoint(this.getSize()._divideBy(2));
|
|
@@ -1977,7 +1980,7 @@ export class MaplairMap extends Evented {
|
|
|
1977
1980
|
|
|
1978
1981
|
// offset of the specified place to the current center in pixels
|
|
1979
1982
|
_getCenterOffset(latlng) {
|
|
1980
|
-
return this.latLngToLayerPoint(latlng).
|
|
1983
|
+
return this.latLngToLayerPoint(latlng)._round()._subtract(this._getCenterLayerPoint());
|
|
1981
1984
|
}
|
|
1982
1985
|
|
|
1983
1986
|
// adjust center for view to get inside bounds
|
|
@@ -2000,6 +2003,11 @@ export class MaplairMap extends Evented {
|
|
|
2000
2003
|
return this.unproject(centerPoint.add(offset), zoom);
|
|
2001
2004
|
}
|
|
2002
2005
|
|
|
2006
|
+
// not cached, so that a preference changed mid-session applies right away
|
|
2007
|
+
_prefersReducedMotion() {
|
|
2008
|
+
return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2003
2011
|
// adjust offset for view to get inside bounds
|
|
2004
2012
|
_limitOffset(offset, bounds) {
|
|
2005
2013
|
if (!bounds) { return offset; }
|
|
@@ -2047,6 +2055,7 @@ export class MaplairMap extends Evented {
|
|
|
2047
2055
|
|
|
2048
2056
|
_onPanTransitionEnd() {
|
|
2049
2057
|
this._mapPane.classList.remove('maplair-pan-anim');
|
|
2058
|
+
this._wrapWorldCopy();
|
|
2050
2059
|
this.fire('moveend');
|
|
2051
2060
|
}
|
|
2052
2061
|
|
|
@@ -2100,20 +2109,6 @@ export class MaplairMap extends Evented {
|
|
|
2100
2109
|
);
|
|
2101
2110
|
}
|
|
2102
2111
|
|
|
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
2112
|
_catchTransitionEnd(e) {
|
|
2118
2113
|
if (this._animatingZoom && e.propertyName.includes('transform')) {
|
|
2119
2114
|
this._onZoomTransitionEnd();
|
|
@@ -2150,16 +2145,25 @@ export class MaplairMap extends Evented {
|
|
|
2150
2145
|
this._flyToFrame = requestAnimationFrame(frame);
|
|
2151
2146
|
}
|
|
2152
2147
|
|
|
2148
|
+
// an animated zoom drops zooms from input until it ends, so hold them as long after an instant zoom too,
|
|
2149
|
+
// or a trackpad swipe or a held key zooms several times as far
|
|
2150
|
+
_zoomInputBlocked() {
|
|
2151
|
+
return this._animatingZoom || Date.now() < this._instantZoomEnd;
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2153
2154
|
_tryAnimatedZoom(center, zoom, options) {
|
|
2154
2155
|
|
|
2155
2156
|
if (this._animatingZoom) { return true; }
|
|
2156
2157
|
|
|
2157
2158
|
options ??= {};
|
|
2158
2159
|
|
|
2159
|
-
// don't animate if disabled, not supported or zoom difference is too large
|
|
2160
|
+
// don't animate if disabled, not supported or zoom difference is too large (over 1 with reduced motion,
|
|
2161
|
+
// unless animate: true is specified)
|
|
2162
|
+
const threshold = this.options.zoomAnimationThreshold,
|
|
2163
|
+
maxZoomDiff = this._prefersReducedMotion() && options.animate !== true ? Math.min(threshold, 1) : threshold;
|
|
2160
2164
|
if (!this._zoomAnimated || options.animate === false ||
|
|
2161
2165
|
(this._nothingToAnimate() && !this.options.continuousZoom) ||
|
|
2162
|
-
Math.abs(zoom - this._zoom) >
|
|
2166
|
+
Math.abs(zoom - this._zoom) > maxZoomDiff) { return false; }
|
|
2163
2167
|
|
|
2164
2168
|
// offset is the pixel coords of the zoom origin relative to the current center
|
|
2165
2169
|
const scale = this.getZoomScale(zoom),
|
|
@@ -2213,7 +2217,7 @@ export class MaplairMap extends Evented {
|
|
|
2213
2217
|
this._move(this._animateToCenter, this._animateToZoom, undefined, true);
|
|
2214
2218
|
|
|
2215
2219
|
// Work around webkit not firing 'transitionend', see https://github.com/Leaflet/Leaflet/issues/3689, 2693
|
|
2216
|
-
this._transitionEndTimer = setTimeout(this._onZoomTransitionEnd.bind(this),
|
|
2220
|
+
this._transitionEndTimer = setTimeout(this._onZoomTransitionEnd.bind(this), zoomAnimDuration);
|
|
2217
2221
|
}
|
|
2218
2222
|
|
|
2219
2223
|
_onZoomTransitionEnd() {
|
|
@@ -2272,4 +2276,5 @@ for (const feature of [
|
|
|
2272
2276
|
feature.register(MaplairMap);
|
|
2273
2277
|
}
|
|
2274
2278
|
|
|
2275
|
-
export
|
|
2279
|
+
export {MaplairMap as Map};
|
|
2280
|
+
export {MaplairMap as LeafletMap};
|