maplair 4.0.0-alpha.2 → 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.
- package/CHANGELOG.md +140 -38
- package/LICENSE +1 -1
- package/README.md +10 -9
- package/dist/esm/Maplair.js +14 -14
- package/dist/esm/control/AttributionControl.js +24 -14
- package/dist/esm/control/AttributionControl.js.map +1 -1
- package/dist/esm/control/ButtonControl.js +9 -11
- package/dist/esm/control/ButtonControl.js.map +1 -1
- package/dist/esm/control/ContextMenu.js +1 -3
- package/dist/esm/control/ContextMenu.js.map +1 -1
- package/dist/esm/control/Control.js +9 -16
- package/dist/esm/control/Control.js.map +1 -1
- package/dist/esm/control/FullscreenControl.js +5 -7
- package/dist/esm/control/FullscreenControl.js.map +1 -1
- package/dist/esm/control/LayersControl.js +144 -35
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/LegendControl.js +7 -9
- package/dist/esm/control/LegendControl.js.map +1 -1
- package/dist/esm/control/MiniMapControl.js +14 -16
- package/dist/esm/control/MiniMapControl.js.map +1 -1
- package/dist/esm/control/RotateControl.js +1 -3
- package/dist/esm/control/RotateControl.js.map +1 -1
- package/dist/esm/control/ScaleControl.js +7 -9
- package/dist/esm/control/ScaleControl.js.map +1 -1
- package/dist/esm/control/SearchControl.js +100 -18
- package/dist/esm/control/SearchControl.js.map +1 -1
- package/dist/esm/control/SideBySideControl.js +1 -3
- package/dist/esm/control/SideBySideControl.js.map +1 -1
- package/dist/esm/control/TextControl.js +5 -7
- package/dist/esm/control/TextControl.js.map +1 -1
- package/dist/esm/control/TimeControl.js +408 -0
- package/dist/esm/control/TimeControl.js.map +1 -0
- package/dist/esm/control/ZoomControl.js +5 -7
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Class.js +28 -37
- package/dist/esm/core/Class.js.map +1 -1
- package/dist/esm/core/Events.js +21 -8
- package/dist/esm/core/Events.js.map +1 -1
- package/dist/esm/core/Handler.js +13 -11
- package/dist/esm/core/Handler.js.map +1 -1
- package/dist/esm/core/Util.js +13 -1
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.DoubleTap.js +25 -22
- package/dist/esm/dom/DomEvent.DoubleTap.js.map +1 -1
- package/dist/esm/dom/DomEvent.PointerEvents.js +2 -16
- package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
- package/dist/esm/dom/DomEvent.js +8 -42
- package/dist/esm/dom/DomEvent.js.map +1 -1
- package/dist/esm/dom/DomUtil.js +14 -68
- package/dist/esm/dom/DomUtil.js.map +1 -1
- package/dist/esm/dom/Draggable.js +17 -18
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/dom/PosAnimation.js +3 -25
- package/dist/esm/dom/PosAnimation.js.map +1 -1
- package/dist/esm/geo/LatLng.js +34 -6
- package/dist/esm/geo/LatLng.js.map +1 -1
- package/dist/esm/geo/LatLngBounds.js +19 -7
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geo/crs/CRS.js +4 -3
- package/dist/esm/geo/crs/CRS.js.map +1 -1
- package/dist/esm/geo/crs/EPSG3395.js +1 -1
- package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
- package/dist/esm/geo/crs/EPSG3857.js +1 -1
- package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
- package/dist/esm/geo/crs/EPSG4326.js +1 -1
- package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
- package/dist/esm/geo/crs/EarthCRS.js +2 -2
- package/dist/esm/geo/crs/EarthCRS.js.map +1 -1
- package/dist/esm/geo/crs/SimpleCRS.js +1 -1
- package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
- package/dist/esm/geo/projection/Projection.LonLat.js +3 -3
- package/dist/esm/geo/projection/Projection.LonLat.js.map +1 -1
- package/dist/esm/geo/projection/Projection.Mercator.js +3 -3
- package/dist/esm/geo/projection/Projection.Mercator.js.map +1 -1
- package/dist/esm/geo/projection/Projection.SphericalMercator.js +3 -3
- package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +1 -1
- package/dist/esm/geometry/Bounds.js +19 -7
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/LineUtil.js +36 -30
- package/dist/esm/geometry/LineUtil.js.map +1 -1
- package/dist/esm/geometry/Point.js +23 -5
- package/dist/esm/geometry/Point.js.map +1 -1
- package/dist/esm/geometry/PolyUtil.js +9 -28
- package/dist/esm/geometry/PolyUtil.js.map +1 -1
- package/dist/esm/layer/BlanketOverlay.js +6 -8
- package/dist/esm/layer/BlanketOverlay.js.map +1 -1
- package/dist/esm/layer/DivOverlay.js +15 -20
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/GeoJSON.js +9 -145
- package/dist/esm/layer/GeoJSON.js.map +1 -1
- package/dist/esm/layer/GeoJSONUtil.js +75 -0
- package/dist/esm/layer/GeoJSONUtil.js.map +1 -0
- package/dist/esm/layer/HeatLayer.js +15 -17
- package/dist/esm/layer/HeatLayer.js.map +1 -1
- package/dist/esm/layer/ImageOverlay.js +20 -26
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +8 -10
- package/dist/esm/layer/Layer.js.map +1 -1
- package/dist/esm/layer/LayerGroup.js +51 -0
- package/dist/esm/layer/LayerGroup.js.map +1 -1
- package/dist/esm/layer/Popup.js +27 -43
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/SVGOverlay.js +2 -5
- package/dist/esm/layer/SVGOverlay.js.map +1 -1
- package/dist/esm/layer/Tooltip.js +15 -17
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/VideoOverlay.js +12 -15
- package/dist/esm/layer/VideoOverlay.js.map +1 -1
- package/dist/esm/layer/marker/DefaultIcon.js +15 -48
- package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
- package/dist/esm/layer/marker/DivIcon.js +8 -10
- 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 +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Move.js +2 -3
- package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +63 -35
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/marker/MarkerClusterGroup.js +302 -0
- package/dist/esm/layer/marker/MarkerClusterGroup.js.map +1 -0
- package/dist/esm/layer/marker/SvgIcon.js +6 -8
- package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
- package/dist/esm/layer/tile/GridLayer.js +86 -98
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +28 -36
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/tile/WMSTileLayer.js +28 -23
- package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +1 -3
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +2 -2
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +17 -7
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.DashAnimation.js +2 -3
- package/dist/esm/layer/vector/Path.DashAnimation.js.map +1 -1
- package/dist/esm/layer/vector/Path.js +27 -20
- package/dist/esm/layer/vector/Path.js.map +1 -1
- package/dist/esm/layer/vector/Polygon.js +20 -4
- package/dist/esm/layer/vector/Polygon.js.map +1 -1
- package/dist/esm/layer/vector/Polyline.Decorations.js +2 -2
- package/dist/esm/layer/vector/Polyline.js +24 -8
- package/dist/esm/layer/vector/Polyline.js.map +1 -1
- package/dist/esm/layer/vector/Renderer.getRenderer.js +14 -13
- package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
- package/dist/esm/layer/vector/SVG.js +5 -5
- package/dist/esm/layer/vector/SVG.js.map +1 -1
- package/dist/esm/map/Map.Rotation.js +15 -11
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +135 -129
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/handler/BoxZoomHandler.js +5 -7
- package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DisplaceHandler.js +6 -8
- package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
- package/dist/esm/map/handler/DragHandler.js +20 -20
- package/dist/esm/map/handler/DragHandler.js.map +1 -1
- package/dist/esm/map/handler/KeyboardHandler.js +37 -37
- package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +12 -3
- package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +3 -4
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/TapHoldHandler.js +12 -5
- package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
- package/dist/esm/package.js +1 -1
- package/dist/maplair-global-src.js +6326 -5625
- package/dist/maplair-global-src.js.map +1 -1
- package/dist/maplair-global.js +3 -3
- package/dist/maplair-global.js.map +1 -1
- package/dist/maplair-src.js +9010 -8290
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.css +148 -98
- package/dist/maplair.js +3 -3
- 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 +12 -14
- 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 +159 -36
- 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 +104 -21
- 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 +5 -7
- package/src/control/index.js +1 -0
- package/src/core/Class.js +35 -34
- package/src/core/Events.js +22 -3
- package/src/core/Handler.js +14 -12
- package/src/core/Util.js +19 -1
- 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 +8 -66
- package/src/dom/DomUtil.js +22 -78
- package/src/dom/Draggable.js +27 -22
- package/src/dom/PosAnimation.js +3 -25
- package/src/dom/index.js +0 -1
- package/src/geo/LatLng.js +40 -4
- package/src/geo/LatLngBounds.js +20 -7
- package/src/geo/crs/CRS.js +4 -3
- package/src/geo/crs/EPSG3395.js +1 -1
- package/src/geo/crs/EPSG3857.js +1 -1
- package/src/geo/crs/EPSG4326.js +1 -1
- package/src/geo/crs/EarthCRS.js +2 -8
- package/src/geo/crs/SimpleCRS.js +1 -1
- package/src/geo/projection/Projection.LonLat.js +3 -3
- package/src/geo/projection/Projection.Mercator.js +3 -3
- package/src/geo/projection/Projection.SphericalMercator.js +3 -3
- package/src/geometry/Bounds.js +20 -7
- package/src/geometry/LineUtil.js +47 -48
- package/src/geometry/Point.js +24 -5
- package/src/geometry/PolyUtil.js +15 -44
- package/src/layer/BlanketOverlay.js +6 -10
- package/src/layer/DivOverlay.js +15 -26
- package/src/layer/GeoJSON.js +7 -205
- package/src/layer/GeoJSONUtil.js +85 -0
- package/src/layer/HeatLayer.js +9 -11
- package/src/layer/ImageOverlay.js +19 -30
- package/src/layer/Layer.js +8 -10
- package/src/layer/LayerGroup.js +71 -0
- package/src/layer/Popup.js +31 -46
- package/src/layer/SVGOverlay.js +1 -5
- package/src/layer/Tooltip.js +15 -19
- package/src/layer/VideoOverlay.js +12 -15
- package/src/layer/marker/DefaultIcon.js +15 -61
- package/src/layer/marker/DivIcon.js +10 -12
- package/src/layer/marker/Icon.js +9 -12
- package/src/layer/marker/Marker.Drag.js +1 -1
- package/src/layer/marker/Marker.Move.js +2 -3
- package/src/layer/marker/Marker.js +83 -41
- 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 +104 -134
- package/src/layer/tile/TileLayer.js +35 -43
- package/src/layer/tile/WMSTileLayer.js +26 -24
- package/src/layer/vector/Canvas.js +3 -5
- package/src/layer/vector/Circle.js +5 -2
- package/src/layer/vector/CircleMarker.js +17 -6
- package/src/layer/vector/Path.DashAnimation.js +1 -2
- package/src/layer/vector/Path.js +30 -21
- package/src/layer/vector/Polygon.js +28 -5
- package/src/layer/vector/Polyline.js +26 -7
- package/src/layer/vector/Renderer.getRenderer.js +17 -17
- package/src/layer/vector/SVG.js +5 -5
- package/src/map/Map.Rotation.js +19 -11
- package/src/map/Map.js +163 -154
- package/src/map/handler/BoxZoomHandler.js +9 -8
- package/src/map/handler/DisplaceHandler.js +6 -8
- package/src/map/handler/DragHandler.js +26 -29
- package/src/map/handler/KeyboardHandler.js +44 -50
- 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 +148 -98
- package/dist/esm/core/Browser.js +0 -100
- package/dist/esm/core/Browser.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/dist/esm/map/Map.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { setOptions, stamp } from "../core/Util.js";
|
|
2
2
|
import { Point } from "../geometry/Point.js";
|
|
3
|
-
import Browser_default from "../core/Browser.js";
|
|
4
3
|
import { disablePointerDetection, enablePointerDetection } from "../dom/DomEvent.PointerEvents.js";
|
|
5
4
|
import { getPointerPosition, isExternalTarget, off, on } from "../dom/DomEvent.js";
|
|
6
|
-
import { create, get, getPosition,
|
|
5
|
+
import { create, get, getPosition, setPosition, setTransform } from "../dom/DomUtil.js";
|
|
7
6
|
import { Control } from "../control/Control.js";
|
|
8
7
|
import { I18n } from "../core/I18n.js";
|
|
9
8
|
import { AttributionControl } from "../control/AttributionControl.js";
|
|
@@ -35,7 +34,8 @@ 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
|
+
const zoomAnimDuration = 250;
|
|
39
39
|
/**
|
|
40
40
|
* Options of `MaplairMap`.
|
|
41
41
|
* @typedef {object} MaplairMapOptions
|
|
@@ -59,19 +59,18 @@ import { TapDragZoomHandler } from "./handler/TapDragZoomHandler.js";
|
|
|
59
59
|
* [`setMaxBounds`](#map-setmaxbounds) method.
|
|
60
60
|
* @property {Renderer} [renderer] The default method for drawing vector layers on the
|
|
61
61
|
* map. `SVG` or `Canvas` by default depending on browser support.
|
|
62
|
-
* @property {boolean} [zoomAnimation] Whether the map zoom animation is enabled.
|
|
63
|
-
* Animations are enabled by default unless the user has configured their browser for
|
|
64
|
-
* reduced [motion](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-reduced-motion#user_preferences).
|
|
62
|
+
* @property {boolean} [zoomAnimation=true] Whether the map zoom animation is enabled.
|
|
65
63
|
* @property {number} [zoomAnimationThreshold=4] Won't animate zoom if the zoom
|
|
66
|
-
* difference exceeds this value
|
|
64
|
+
* difference exceeds this value (or 1 if the user prefers
|
|
65
|
+
* [reduced motion](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-reduced-motion)
|
|
66
|
+
* and `animate: true` isn't passed).
|
|
67
67
|
* @property {boolean} [continuousZoom=false] Whether zoom animations (e.g. of the zoom
|
|
68
68
|
* control, double click and keyboard) change the view frame by frame through fractional
|
|
69
69
|
* zoom levels, like `flyTo()` and pinch zoom, instead of scaling the map with a CSS
|
|
70
70
|
* transition between two zoom levels. Also makes the scroll wheel zoom smoothly with
|
|
71
71
|
* each wheel event (see `scrollWheelZoom`), snapping to `zoomSnap` when scrolling ends.
|
|
72
|
-
* @property {boolean} [fadeAnimation] Whether the tile fade animation is
|
|
73
|
-
*
|
|
74
|
-
* reduced [motion](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@media/prefers-reduced-motion#user_preferences).
|
|
72
|
+
* @property {boolean} [fadeAnimation=true] Whether the tile and popup fade animation is
|
|
73
|
+
* enabled.
|
|
75
74
|
* @property {boolean} [markerZoomAnimation=true] Whether markers animate their zoom
|
|
76
75
|
* with the zoom animation, if disabled they will disappear for the length of the
|
|
77
76
|
* animation.
|
|
@@ -119,17 +118,20 @@ import { TapDragZoomHandler } from "./handler/TapDragZoomHandler.js";
|
|
|
119
118
|
* Options of the `MaplairMap` methods which modify the zoom level.
|
|
120
119
|
* @typedef {object} ZoomOptions
|
|
121
120
|
* @property {boolean} [animate] If not specified, zoom animation will happen if the
|
|
122
|
-
* zoom origin is inside the current view
|
|
123
|
-
*
|
|
124
|
-
*
|
|
121
|
+
* zoom origin is inside the current view, and if the user prefers reduced motion, only
|
|
122
|
+
* when zooming by at most one level. If `true`, the map will attempt animating zoom
|
|
123
|
+
* disregarding where zoom origin is and the user's reduced motion preference. Setting
|
|
124
|
+
* `false` will make it always reset the view completely without animation.
|
|
125
125
|
*/
|
|
126
126
|
/**
|
|
127
127
|
* Options of the `MaplairMap` methods which modify the center of the map.
|
|
128
128
|
* @typedef {object} PanOptions
|
|
129
|
-
* @property {boolean} [animate] If `true`, panning will always be animated if possible
|
|
130
|
-
* If `false`, it will not animate panning,
|
|
131
|
-
* more than a screen away, or just setting a
|
|
132
|
-
* `panBy` which always does the latter).
|
|
129
|
+
* @property {boolean} [animate] If `true`, panning will always be animated if possible,
|
|
130
|
+
* even if the user prefers reduced motion. If `false`, it will not animate panning,
|
|
131
|
+
* either resetting the map view if panning more than a screen away, or just setting a
|
|
132
|
+
* new offset for the map pane (except for `panBy` which always does the latter). If not
|
|
133
|
+
* specified, panning is animated, except for pans longer than half the map size when
|
|
134
|
+
* the user prefers reduced motion.
|
|
133
135
|
* @property {number} [duration=0.25] Duration of animated panning, in seconds.
|
|
134
136
|
* @property {number} [easeLinearity=0.25] The curvature factor of panning animation
|
|
135
137
|
* easing (third parameter of the [Cubic Bezier curve](https://cubic-bezier.com/)).
|
|
@@ -248,16 +250,14 @@ import { TapDragZoomHandler } from "./handler/TapDragZoomHandler.js";
|
|
|
248
250
|
* @fires preclick {MaplairPointerEvent} Fired before pointer click on the map (sometimes
|
|
249
251
|
* useful when you want something to happen on click before any existing click handlers
|
|
250
252
|
* start running).
|
|
251
|
-
* @fires keypress {MaplairKeyboardEvent} Fired when the user presses a key from the
|
|
252
|
-
* keyboard that produces a character value while the map is focused.
|
|
253
253
|
* @fires keydown {MaplairKeyboardEvent} Fired when the user presses a key from the
|
|
254
|
-
* keyboard while the map is focused.
|
|
255
|
-
* fired for keys that produce a character value and for keys that do not produce a
|
|
256
|
-
* character value.
|
|
254
|
+
* keyboard while the map is focused.
|
|
257
255
|
* @fires keyup {MaplairKeyboardEvent} Fired when the user releases a key from the
|
|
258
256
|
* keyboard while the map is focused.
|
|
259
257
|
* @fires crschange {CrsChangeEvent} Fired when the CRS of the map changes with
|
|
260
258
|
* `setCrs()`, before the view is reset.
|
|
259
|
+
* @fires worldcopyjump {WorldCopyJumpEvent} Fired when [`worldCopyJump`](#maplairmapoptions-worldcopyjump)
|
|
260
|
+
* moves the map pane by one or more world widths.
|
|
261
261
|
* @fires pixelratiochange {MaplairEvent} Fired when the `devicePixelRatio` of the browser
|
|
262
262
|
* changes, e.g. when moving the window to a screen with another resolution or when
|
|
263
263
|
* zooming the page. Tile layers with `detectRetina` and canvas renderers adapt to it.
|
|
@@ -265,29 +265,27 @@ import { TapDragZoomHandler } from "./handler/TapDragZoomHandler.js";
|
|
|
265
265
|
* zoom, like pinch zooming, fired once per frame during zoom.
|
|
266
266
|
*/
|
|
267
267
|
var MaplairMap = class MaplairMap extends Evented {
|
|
268
|
-
static {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
});
|
|
290
|
-
}
|
|
268
|
+
static defaultOptions = {
|
|
269
|
+
crs: EPSG3857,
|
|
270
|
+
center: void 0,
|
|
271
|
+
zoom: void 0,
|
|
272
|
+
minZoom: void 0,
|
|
273
|
+
maxZoom: void 0,
|
|
274
|
+
layers: [],
|
|
275
|
+
ariaLabel: void 0,
|
|
276
|
+
maxBounds: void 0,
|
|
277
|
+
renderer: void 0,
|
|
278
|
+
zoomAnimation: true,
|
|
279
|
+
zoomAnimationThreshold: 4,
|
|
280
|
+
continuousZoom: false,
|
|
281
|
+
fadeAnimation: true,
|
|
282
|
+
markerZoomAnimation: true,
|
|
283
|
+
markerCulling: false,
|
|
284
|
+
transform3DLimit: 8388608,
|
|
285
|
+
zoomSnap: 1,
|
|
286
|
+
zoomDelta: 1,
|
|
287
|
+
trackResize: true
|
|
288
|
+
};
|
|
291
289
|
/**
|
|
292
290
|
* Instantiates a map object given the DOM ID of a `<div>` element or the element
|
|
293
291
|
* itself, and optionally an object literal with `MaplairMap` options.
|
|
@@ -308,12 +306,13 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
308
306
|
this.on({
|
|
309
307
|
movestart: this._onBusy,
|
|
310
308
|
zoomstart: this._onBusy,
|
|
309
|
+
move: this._onMove,
|
|
311
310
|
moveend: this._onViewChanged,
|
|
312
311
|
layerremove: this._scheduleIdleCheck
|
|
313
312
|
}, this);
|
|
314
313
|
if (options.maxBounds) this.setMaxBounds(options.maxBounds);
|
|
315
314
|
if (options.zoom !== void 0) this._zoom = this._limitZoom(options.zoom);
|
|
316
|
-
if (options.center && options.zoom !== void 0) this.setView(
|
|
315
|
+
if (options.center && options.zoom !== void 0) this.setView(LatLng.from(options.center), options.zoom, { reset: true });
|
|
317
316
|
this.callInitHooks(MaplairMap);
|
|
318
317
|
this._zoomAnimated = this.options.zoomAnimation;
|
|
319
318
|
if (this._zoomAnimated) this._createAnimProxy();
|
|
@@ -406,8 +405,8 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
406
405
|
}
|
|
407
406
|
_getBoundsCenterZoom(bounds, options) {
|
|
408
407
|
options ??= {};
|
|
409
|
-
bounds = bounds.getBounds ? bounds.getBounds() :
|
|
410
|
-
const paddingTL =
|
|
408
|
+
bounds = bounds.getBounds ? bounds.getBounds() : LatLngBounds.from(bounds);
|
|
409
|
+
const paddingTL = Point.from(options.paddingTopLeft || options.padding || [0, 0]), paddingBR = Point.from(options.paddingBottomRight || options.padding || [0, 0]);
|
|
411
410
|
let zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR));
|
|
412
411
|
zoom = typeof options.maxZoom === "number" ? Math.min(options.maxZoom, zoom) : zoom;
|
|
413
412
|
if (zoom === Infinity) return {
|
|
@@ -429,7 +428,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
429
428
|
* @returns {this}
|
|
430
429
|
*/
|
|
431
430
|
fitBounds(bounds, options) {
|
|
432
|
-
bounds =
|
|
431
|
+
bounds = LatLngBounds.from(bounds);
|
|
433
432
|
if (!bounds.isValid()) throw new Error("Bounds are not valid.");
|
|
434
433
|
const target = this._getBoundsCenterZoom(bounds, options);
|
|
435
434
|
return this.setView(target.center, target.zoom, options);
|
|
@@ -455,18 +454,22 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
455
454
|
return this.setView(center, this._zoom, { pan: options });
|
|
456
455
|
}
|
|
457
456
|
/**
|
|
458
|
-
* Pans the map by a given number of pixels (animated
|
|
457
|
+
* Pans the map by a given number of pixels (animated unless `animate: false` is passed,
|
|
458
|
+
* or the user prefers reduced motion and the pan is longer than half the map size
|
|
459
|
+
* without `animate: true`).
|
|
459
460
|
* @group Methods for modifying map state
|
|
460
461
|
* @param {PointExpression} offset
|
|
461
462
|
* @param {PanOptions} [options]
|
|
462
463
|
* @returns {this}
|
|
463
464
|
*/
|
|
464
465
|
panBy(offset, options) {
|
|
465
|
-
offset =
|
|
466
|
+
offset = Point.from(offset).round();
|
|
466
467
|
options ??= {};
|
|
467
468
|
if (!offset.x && !offset.y) return this.fire("moveend");
|
|
468
|
-
|
|
469
|
-
|
|
469
|
+
const size = this.getSize();
|
|
470
|
+
if (options.animate !== true && !size.contains(offset)) {
|
|
471
|
+
const center = this.unproject(this.project(this.getCenter()).add(offset));
|
|
472
|
+
this._resetView(this.options.worldCopyJump ? this.wrapLatLng(center) : center, this.getZoom());
|
|
470
473
|
return this;
|
|
471
474
|
}
|
|
472
475
|
if (!this._panAnim) {
|
|
@@ -477,19 +480,22 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
477
480
|
}, this);
|
|
478
481
|
}
|
|
479
482
|
if (!options.noMoveStart) this.fire("movestart");
|
|
480
|
-
|
|
483
|
+
const tooFarForReducedMotion = this._prefersReducedMotion() && !size.divideBy(2).contains(offset);
|
|
484
|
+
if (options.animate === true || options.animate !== false && !tooFarForReducedMotion) {
|
|
481
485
|
this._mapPane.classList.add("maplair-pan-anim");
|
|
482
486
|
const newPos = this._getMapPanePos().subtract(offset).round();
|
|
483
487
|
this._panAnim.run(this._mapPane, newPos, options.duration || .25, options.easeLinearity);
|
|
484
488
|
} else {
|
|
485
489
|
this._rawPanBy(offset);
|
|
490
|
+
this._wrapWorldCopy();
|
|
486
491
|
this.fire("move").fire("moveend");
|
|
487
492
|
}
|
|
488
493
|
return this;
|
|
489
494
|
}
|
|
490
495
|
/**
|
|
491
496
|
* Sets the view of the map (geographical center and zoom) performing a smooth
|
|
492
|
-
* pan-zoom animation.
|
|
497
|
+
* pan-zoom animation. If the user prefers reduced motion (and `animate: true` isn't
|
|
498
|
+
* passed), it behaves like `setView` instead, only animating short pans and zooms.
|
|
493
499
|
* @group Methods for modifying map state
|
|
494
500
|
* @param {LatLngExpression} targetCenter
|
|
495
501
|
* @param {number} [targetZoom]
|
|
@@ -498,31 +504,29 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
498
504
|
*/
|
|
499
505
|
flyTo(targetCenter, targetZoom, options) {
|
|
500
506
|
options ??= {};
|
|
501
|
-
if (
|
|
507
|
+
if (options.animate === false) return this.setView(targetCenter, targetZoom, {
|
|
508
|
+
...options,
|
|
509
|
+
zoom: {
|
|
510
|
+
...options.zoom,
|
|
511
|
+
animate: false
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
if (options.animate !== true && this._prefersReducedMotion()) return this.setView(targetCenter, targetZoom, options);
|
|
502
515
|
this._stop();
|
|
516
|
+
targetZoom = targetZoom === void 0 ? this._zoom : this._limitZoom(targetZoom);
|
|
517
|
+
targetCenter = this._limitCenter(new LatLng(targetCenter), targetZoom, this.options.maxBounds);
|
|
503
518
|
const from = this.project(this.getCenter()), to = this.project(targetCenter), size = this.getSize(), startZoom = this._zoom;
|
|
504
|
-
targetCenter = new LatLng(targetCenter);
|
|
505
|
-
targetZoom = targetZoom === void 0 ? startZoom : this._limitZoom(targetZoom);
|
|
506
519
|
const w0 = Math.max(size.x, size.y), w1 = w0 * this.getZoomScale(startZoom, targetZoom), u1 = to.distanceTo(from) || 1, rho = 1.42, rho2 = rho * rho;
|
|
507
520
|
function r(i) {
|
|
508
|
-
const s1 = i ? -1 : 1, s2 = i ? w1 : w0,
|
|
509
|
-
return
|
|
510
|
-
}
|
|
511
|
-
function sinh(n) {
|
|
512
|
-
return (Math.exp(n) - Math.exp(-n)) / 2;
|
|
513
|
-
}
|
|
514
|
-
function cosh(n) {
|
|
515
|
-
return (Math.exp(n) + Math.exp(-n)) / 2;
|
|
516
|
-
}
|
|
517
|
-
function tanh(n) {
|
|
518
|
-
return sinh(n) / cosh(n);
|
|
521
|
+
const s1 = i ? -1 : 1, s2 = i ? w1 : w0, t1 = w1 * w1 - w0 * w0 + s1 * rho2 * rho2 * u1 * u1, b1 = 2 * s2 * rho2 * u1;
|
|
522
|
+
return -Math.asinh(t1 / b1);
|
|
519
523
|
}
|
|
520
524
|
const r0 = r(0);
|
|
521
525
|
function w(s) {
|
|
522
|
-
return w0 * (cosh(r0) / cosh(r0 + rho * s));
|
|
526
|
+
return w0 * (Math.cosh(r0) / Math.cosh(r0 + rho * s));
|
|
523
527
|
}
|
|
524
528
|
function u(s) {
|
|
525
|
-
return w0 * (cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2;
|
|
529
|
+
return w0 * (Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2;
|
|
526
530
|
}
|
|
527
531
|
function easeOut(t) {
|
|
528
532
|
return 1 - (1 - t) ** 1.5;
|
|
@@ -533,7 +537,12 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
533
537
|
if (t <= 1) {
|
|
534
538
|
this._flyToFrame = requestAnimationFrame(frame);
|
|
535
539
|
this._move(this.unproject(from.add(to.subtract(from).multiplyBy(u(s) / u1)), startZoom), this.getScaleZoom(w0 / w(s), startZoom), { flyTo: true });
|
|
536
|
-
} else
|
|
540
|
+
} else {
|
|
541
|
+
const zoomChanged = this._zoom !== targetZoom;
|
|
542
|
+
this._move(targetCenter, targetZoom);
|
|
543
|
+
if (!zoomChanged) this.fire("zoom");
|
|
544
|
+
this._moveEnd(true);
|
|
545
|
+
}
|
|
537
546
|
};
|
|
538
547
|
this._moveStart(true, options.noMoveStart);
|
|
539
548
|
frame(this);
|
|
@@ -643,7 +652,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
643
652
|
*/
|
|
644
653
|
panInsideBounds(bounds, options) {
|
|
645
654
|
this._enforcingBounds = true;
|
|
646
|
-
const center = this.getCenter(), newCenter = this._limitCenter(center, this._zoom,
|
|
655
|
+
const center = this.getCenter(), newCenter = this._limitCenter(center, this._zoom, LatLngBounds.from(bounds));
|
|
647
656
|
if (!center.equals(newCenter)) this.panTo(newCenter, options);
|
|
648
657
|
this._enforcingBounds = false;
|
|
649
658
|
return this;
|
|
@@ -660,7 +669,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
660
669
|
*/
|
|
661
670
|
panInside(latlng, options) {
|
|
662
671
|
options ??= {};
|
|
663
|
-
const paddingTL =
|
|
672
|
+
const paddingTL = Point.from(options.paddingTopLeft || options.padding || [0, 0]), paddingBR = Point.from(options.paddingBottomRight || options.padding || [0, 0]), pixelCenter = this.project(this.getCenter()), pixelPoint = this.project(latlng), pixelBounds = this.getPixelBounds(), paddedBounds = new Bounds([pixelBounds.min.add(paddingTL), pixelBounds.max.subtract(paddingBR)]), paddedSize = paddedBounds.getSize();
|
|
664
673
|
if (!paddedBounds.contains(pixelPoint)) {
|
|
665
674
|
this._enforcingBounds = true;
|
|
666
675
|
const centerOffset = pixelPoint.subtract(paddedBounds.getCenter());
|
|
@@ -819,17 +828,13 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
819
828
|
this._mapPane.remove();
|
|
820
829
|
for (const name of this._ariaAttributes) this._container.removeAttribute(name);
|
|
821
830
|
if (this._clearControlPos) this._clearControlPos();
|
|
822
|
-
|
|
823
|
-
cancelAnimationFrame(this._resizeRequest);
|
|
824
|
-
this._resizeRequest = null;
|
|
825
|
-
}
|
|
831
|
+
cancelAnimationFrame(this._resizeRequest);
|
|
826
832
|
cancelAnimationFrame(this._idleRequest);
|
|
827
833
|
this._watchPixelRatio(true);
|
|
828
|
-
this.
|
|
834
|
+
for (const handler of this._handlers) handler.disable();
|
|
829
835
|
clearTimeout(this._transitionEndTimer);
|
|
830
836
|
clearTimeout(this._sizeTimer);
|
|
831
837
|
if (this._loaded) this.fire("unload");
|
|
832
|
-
this._destroyAnimProxy();
|
|
833
838
|
for (const layer of Object.values(this._layers)) layer.remove();
|
|
834
839
|
for (const pane of Object.values(this._panes)) pane.remove();
|
|
835
840
|
this._layers = {};
|
|
@@ -909,8 +914,8 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
909
914
|
* @returns {number}
|
|
910
915
|
*/
|
|
911
916
|
getBoundsZoom(bounds, inside, padding) {
|
|
912
|
-
bounds =
|
|
913
|
-
padding =
|
|
917
|
+
bounds = LatLngBounds.from(bounds);
|
|
918
|
+
padding = Point.from(padding ?? [0, 0]);
|
|
914
919
|
let zoom = this.getZoom() ?? 0;
|
|
915
920
|
const min = this.getMinZoom(), max = this.getMaxZoom(), nw = bounds.getNorthWest(), se = bounds.getSouthEast(), size = this.getSize().subtract(padding), boundsSize = new Bounds(this.project(se, zoom), this.project(nw, zoom)).getSize(), snap = this.options.zoomSnap, scalex = size.x / boundsSize.x, scaley = size.y / boundsSize.y, scale = inside ? Math.max(scalex, scaley) : Math.min(scalex, scaley);
|
|
916
921
|
zoom = this.getScaleZoom(scale, zoom);
|
|
@@ -1031,7 +1036,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1031
1036
|
*/
|
|
1032
1037
|
project(latlng, zoom) {
|
|
1033
1038
|
zoom ??= this._zoom;
|
|
1034
|
-
return this.options.crs.latLngToPoint(
|
|
1039
|
+
return this.options.crs.latLngToPoint(LatLng.from(latlng), zoom);
|
|
1035
1040
|
}
|
|
1036
1041
|
/**
|
|
1037
1042
|
* Inverse of [`project`](#map-project).
|
|
@@ -1042,7 +1047,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1042
1047
|
*/
|
|
1043
1048
|
unproject(point, zoom) {
|
|
1044
1049
|
zoom ??= this._zoom;
|
|
1045
|
-
return this.options.crs.pointToLatLng(
|
|
1050
|
+
return this.options.crs.pointToLatLng(Point.from(point), zoom);
|
|
1046
1051
|
}
|
|
1047
1052
|
/**
|
|
1048
1053
|
* Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin),
|
|
@@ -1052,7 +1057,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1052
1057
|
* @returns {LatLng}
|
|
1053
1058
|
*/
|
|
1054
1059
|
layerPointToLatLng(point) {
|
|
1055
|
-
const projectedPoint =
|
|
1060
|
+
const projectedPoint = Point.from(point).add(this.getPixelOrigin());
|
|
1056
1061
|
return this.unproject(projectedPoint);
|
|
1057
1062
|
}
|
|
1058
1063
|
/**
|
|
@@ -1063,7 +1068,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1063
1068
|
* @returns {Point}
|
|
1064
1069
|
*/
|
|
1065
1070
|
latLngToLayerPoint(latlng) {
|
|
1066
|
-
return this.project(
|
|
1071
|
+
return this.project(LatLng.from(latlng))._round()._subtract(this.getPixelOrigin());
|
|
1067
1072
|
}
|
|
1068
1073
|
/**
|
|
1069
1074
|
* Returns a `LatLng` where `lat` and `lng` has been wrapped according to the
|
|
@@ -1076,7 +1081,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1076
1081
|
* @returns {LatLng}
|
|
1077
1082
|
*/
|
|
1078
1083
|
wrapLatLng(latlng) {
|
|
1079
|
-
return this.options.crs.wrapLatLng(
|
|
1084
|
+
return this.options.crs.wrapLatLng(LatLng.from(latlng));
|
|
1080
1085
|
}
|
|
1081
1086
|
/**
|
|
1082
1087
|
* Returns a `LatLngBounds` with the same size as the given one, ensuring that
|
|
@@ -1100,7 +1105,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1100
1105
|
* @returns {number}
|
|
1101
1106
|
*/
|
|
1102
1107
|
distance(latlng1, latlng2) {
|
|
1103
|
-
return this.options.crs.distance(
|
|
1108
|
+
return this.options.crs.distance(LatLng.from(latlng1), LatLng.from(latlng2));
|
|
1104
1109
|
}
|
|
1105
1110
|
/**
|
|
1106
1111
|
* Given a pixel coordinate relative to the map container, returns the corresponding
|
|
@@ -1110,7 +1115,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1110
1115
|
* @returns {Point}
|
|
1111
1116
|
*/
|
|
1112
1117
|
containerPointToLayerPoint(point) {
|
|
1113
|
-
return
|
|
1118
|
+
return Point.from(point).subtract(this._getMapPanePos());
|
|
1114
1119
|
}
|
|
1115
1120
|
/**
|
|
1116
1121
|
* Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin),
|
|
@@ -1120,7 +1125,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1120
1125
|
* @returns {Point}
|
|
1121
1126
|
*/
|
|
1122
1127
|
layerPointToContainerPoint(point) {
|
|
1123
|
-
return
|
|
1128
|
+
return Point.from(point).add(this._getMapPanePos());
|
|
1124
1129
|
}
|
|
1125
1130
|
/**
|
|
1126
1131
|
* Given a pixel coordinate relative to the map container, returns
|
|
@@ -1130,7 +1135,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1130
1135
|
* @returns {LatLng}
|
|
1131
1136
|
*/
|
|
1132
1137
|
containerPointToLatLng(point) {
|
|
1133
|
-
const layerPoint = this.containerPointToLayerPoint(
|
|
1138
|
+
const layerPoint = this.containerPointToLayerPoint(Point.from(point));
|
|
1134
1139
|
return this.layerPointToLatLng(layerPoint);
|
|
1135
1140
|
}
|
|
1136
1141
|
/**
|
|
@@ -1141,7 +1146,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1141
1146
|
* @returns {Point}
|
|
1142
1147
|
*/
|
|
1143
1148
|
latLngToContainerPoint(latlng) {
|
|
1144
|
-
return this.layerPointToContainerPoint(this.latLngToLayerPoint(
|
|
1149
|
+
return this.layerPointToContainerPoint(this.latLngToLayerPoint(LatLng.from(latlng)));
|
|
1145
1150
|
}
|
|
1146
1151
|
/**
|
|
1147
1152
|
* Given a PointerEvent object, returns the pixel coordinate relative to the
|
|
@@ -1185,8 +1190,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1185
1190
|
const container = this._container;
|
|
1186
1191
|
this._fadeAnimated = this.options.fadeAnimation;
|
|
1187
1192
|
const classes = ["maplair-container", "maplair-touch"];
|
|
1188
|
-
if (
|
|
1189
|
-
if (Browser_default.safari) classes.push("maplair-safari");
|
|
1193
|
+
if (window.devicePixelRatio > 1) classes.push("maplair-retina");
|
|
1190
1194
|
if (this._fadeAnimated) classes.push("maplair-fade-anim");
|
|
1191
1195
|
container.classList.add(...classes);
|
|
1192
1196
|
this._ariaAttributes = [];
|
|
@@ -1220,12 +1224,16 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1220
1224
|
}
|
|
1221
1225
|
}
|
|
1222
1226
|
_resetView(center, zoom, noMoveStart) {
|
|
1223
|
-
setPosition(this._mapPane, new Point(0, 0));
|
|
1224
1227
|
const loading = !this._loaded;
|
|
1225
1228
|
this._loaded = true;
|
|
1226
1229
|
zoom = this._limitZoom(zoom);
|
|
1227
|
-
this.fire("viewprereset"
|
|
1230
|
+
this.fire("viewprereset", {
|
|
1231
|
+
center,
|
|
1232
|
+
zoom
|
|
1233
|
+
});
|
|
1234
|
+
setPosition(this._mapPane, new Point(0, 0));
|
|
1228
1235
|
const zoomChanged = this._zoom !== zoom;
|
|
1236
|
+
if (zoomChanged && !loading) this._instantZoomEnd = Date.now() + zoomAnimDuration;
|
|
1229
1237
|
this._moveStart(zoomChanged, noMoveStart)._move(center, zoom)._moveEnd(zoomChanged);
|
|
1230
1238
|
this.fire("viewreset");
|
|
1231
1239
|
if (loading) this.fire("load");
|
|
@@ -1273,6 +1281,9 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1273
1281
|
this._viewChanging = true;
|
|
1274
1282
|
this._idle = false;
|
|
1275
1283
|
}
|
|
1284
|
+
_onMove() {
|
|
1285
|
+
this._cullingBounds = null;
|
|
1286
|
+
}
|
|
1276
1287
|
_onViewChanged() {
|
|
1277
1288
|
this._viewChanging = false;
|
|
1278
1289
|
this._scheduleIdleCheck();
|
|
@@ -1327,6 +1338,16 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1327
1338
|
_rawPanBy(offset) {
|
|
1328
1339
|
setPosition(this._mapPane, this._getMapPanePos().subtract(offset));
|
|
1329
1340
|
}
|
|
1341
|
+
_wrapWorldCopy(pos = this._getMapPanePos()) {
|
|
1342
|
+
if (!this._loaded || !this.options.worldCopyJump || this.options.crs.infinite) return pos;
|
|
1343
|
+
const width = this.getPixelWorldBounds().getSize().x, x = pos.x - width * Math.round((pos.x + this.latLngToLayerPoint([0, 0]).x - this.getSize().x / 2) / width), worlds = Math.round((x - this._getMapPanePos().x) / width);
|
|
1344
|
+
pos = new Point(x, pos.y);
|
|
1345
|
+
if (worlds) {
|
|
1346
|
+
setPosition(this._mapPane, pos);
|
|
1347
|
+
this.fire("worldcopyjump", { worlds });
|
|
1348
|
+
}
|
|
1349
|
+
return pos;
|
|
1350
|
+
}
|
|
1330
1351
|
_getZoomSpan() {
|
|
1331
1352
|
return this.getMaxZoom() - this.getMinZoom();
|
|
1332
1353
|
}
|
|
@@ -1339,7 +1360,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1339
1360
|
_initEvents(remove) {
|
|
1340
1361
|
this._targets = {};
|
|
1341
1362
|
this._targets[stamp(this._container)] = this;
|
|
1342
|
-
(remove ? off : on)(this._container, "click dblclick pointerdown pointerup pointerover pointerout pointermove contextmenu
|
|
1363
|
+
(remove ? off : on)(this._container, "click dblclick pointerdown pointerup pointerover pointerout pointermove contextmenu keydown keyup", this._handleDOMEvent, this);
|
|
1343
1364
|
if (this.options.trackResize) {
|
|
1344
1365
|
if (!remove) {
|
|
1345
1366
|
if (!this._resizeObserver) this._resizeObserver = new ResizeObserver(this._onResize.bind(this));
|
|
@@ -1363,7 +1384,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1363
1384
|
if (Math.max(Math.abs(pos.x), Math.abs(pos.y)) >= this.options.transform3DLimit) this._resetView(this.getCenter(), this.getZoom());
|
|
1364
1385
|
}
|
|
1365
1386
|
_findEventTargets(e, type) {
|
|
1366
|
-
let targets = [], target, src = e.target
|
|
1387
|
+
let targets = [], target, src = e.target, dragging = false;
|
|
1367
1388
|
const isHover = type === "pointerout" || type === "pointerover";
|
|
1368
1389
|
while (src) {
|
|
1369
1390
|
target = this._targets[stamp(src)];
|
|
@@ -1389,11 +1410,9 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1389
1410
|
}
|
|
1390
1411
|
}
|
|
1391
1412
|
_handleDOMEvent(e) {
|
|
1392
|
-
const el = e.target
|
|
1413
|
+
const el = e.target;
|
|
1393
1414
|
if (!this._loaded || el["_maplair_disable_events"] || e.type === "click" && this._isClickDisabled(el)) return;
|
|
1394
|
-
|
|
1395
|
-
if (type === "pointerdown") preventOutline(el);
|
|
1396
|
-
this._fireDOMEvent(e, type);
|
|
1415
|
+
this._fireDOMEvent(e, e.type);
|
|
1397
1416
|
}
|
|
1398
1417
|
static _pointerEvents = [
|
|
1399
1418
|
"click",
|
|
@@ -1410,7 +1429,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1410
1429
|
if (type === "contextmenu") e.preventDefault();
|
|
1411
1430
|
const target = targets[0];
|
|
1412
1431
|
const data = { originalEvent: e };
|
|
1413
|
-
if (e.type !== "
|
|
1432
|
+
if (e.type !== "keydown" && e.type !== "keyup") {
|
|
1414
1433
|
const isMarker = target.getLatLng && (!target._pxRadius || target._pxRadius <= 10);
|
|
1415
1434
|
data.containerPoint = isMarker ? this.latLngToContainerPoint(target.getLatLng()) : this.pointerEventToContainerPoint(e);
|
|
1416
1435
|
data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
|
|
@@ -1418,16 +1437,14 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1418
1437
|
}
|
|
1419
1438
|
for (const t of targets) {
|
|
1420
1439
|
t.fire(type, data, true);
|
|
1421
|
-
|
|
1440
|
+
const bubbling = t.options.bubblingMouseEvents ?? t.options.bubblingPointerEvents;
|
|
1441
|
+
if (data.originalEvent._stopped || bubbling === false && MaplairMap._pointerEvents.includes(type)) return;
|
|
1422
1442
|
}
|
|
1423
1443
|
}
|
|
1424
1444
|
_draggableMoved(obj) {
|
|
1425
1445
|
obj = obj.dragging?.enabled() ? obj : this;
|
|
1426
1446
|
return obj.dragging?.moved() || this.boxZoom?.moved();
|
|
1427
1447
|
}
|
|
1428
|
-
_clearHandlers() {
|
|
1429
|
-
for (const handler of this._handlers) handler.disable();
|
|
1430
|
-
}
|
|
1431
1448
|
/**
|
|
1432
1449
|
* Runs the given function `callback` when the map gets initialized with
|
|
1433
1450
|
* a view (center and zoom) and at least one layer, or immediately
|
|
@@ -1460,15 +1477,6 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1460
1477
|
const topLeft = this._getNewPixelOrigin(center, zoom);
|
|
1461
1478
|
return this.project(latlng, zoom)._subtract(topLeft);
|
|
1462
1479
|
}
|
|
1463
|
-
_latLngBoundsToNewLayerBounds(latLngBounds, zoom, center) {
|
|
1464
|
-
const topLeft = this._getNewPixelOrigin(center, zoom);
|
|
1465
|
-
return new Bounds([
|
|
1466
|
-
this.project(latLngBounds.getSouthWest(), zoom)._subtract(topLeft),
|
|
1467
|
-
this.project(latLngBounds.getNorthWest(), zoom)._subtract(topLeft),
|
|
1468
|
-
this.project(latLngBounds.getSouthEast(), zoom)._subtract(topLeft),
|
|
1469
|
-
this.project(latLngBounds.getNorthEast(), zoom)._subtract(topLeft)
|
|
1470
|
-
]);
|
|
1471
|
-
}
|
|
1472
1480
|
_getCenterLayerPoint() {
|
|
1473
1481
|
return this.containerPointToLayerPoint(this.getSize()._divideBy(2));
|
|
1474
1482
|
}
|
|
@@ -1481,6 +1489,9 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1481
1489
|
if (Math.abs(offset.x) <= 1 && Math.abs(offset.y) <= 1) return center;
|
|
1482
1490
|
return this.unproject(centerPoint.add(offset), zoom);
|
|
1483
1491
|
}
|
|
1492
|
+
_prefersReducedMotion() {
|
|
1493
|
+
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1494
|
+
}
|
|
1484
1495
|
_limitOffset(offset, bounds) {
|
|
1485
1496
|
if (!bounds) return offset;
|
|
1486
1497
|
const viewBounds = this.getPixelBounds(), newBounds = new Bounds(viewBounds.min.add(offset), viewBounds.max.add(offset));
|
|
@@ -1503,6 +1514,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1503
1514
|
}
|
|
1504
1515
|
_onPanTransitionEnd() {
|
|
1505
1516
|
this._mapPane.classList.remove("maplair-pan-anim");
|
|
1517
|
+
this._wrapWorldCopy();
|
|
1506
1518
|
this.fire("moveend");
|
|
1507
1519
|
}
|
|
1508
1520
|
_tryAnimatedPan(center, options) {
|
|
@@ -1528,15 +1540,6 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1528
1540
|
const z = this.getZoom();
|
|
1529
1541
|
setTransform(this._proxy, this.project(c, z), this.getZoomScale(z, 1));
|
|
1530
1542
|
}
|
|
1531
|
-
_destroyAnimProxy() {
|
|
1532
|
-
if (this._proxy) {
|
|
1533
|
-
off(this._proxy, "transitionend", this._catchTransitionEnd, this);
|
|
1534
|
-
this._proxy.remove();
|
|
1535
|
-
this.off("zoomanim", this._animateProxyZoom, this);
|
|
1536
|
-
this.off("load moveend", this._animMoveEnd, this);
|
|
1537
|
-
delete this._proxy;
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
1543
|
_catchTransitionEnd(e) {
|
|
1541
1544
|
if (this._animatingZoom && e.propertyName.includes("transform")) this._onZoomTransitionEnd();
|
|
1542
1545
|
}
|
|
@@ -1556,10 +1559,14 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1556
1559
|
};
|
|
1557
1560
|
this._flyToFrame = requestAnimationFrame(frame);
|
|
1558
1561
|
}
|
|
1562
|
+
_zoomInputBlocked() {
|
|
1563
|
+
return this._animatingZoom || Date.now() < this._instantZoomEnd;
|
|
1564
|
+
}
|
|
1559
1565
|
_tryAnimatedZoom(center, zoom, options) {
|
|
1560
1566
|
if (this._animatingZoom) return true;
|
|
1561
1567
|
options ??= {};
|
|
1562
|
-
|
|
1568
|
+
const threshold = this.options.zoomAnimationThreshold, maxZoomDiff = this._prefersReducedMotion() && options.animate !== true ? Math.min(threshold, 1) : threshold;
|
|
1569
|
+
if (!this._zoomAnimated || options.animate === false || this._nothingToAnimate() && !this.options.continuousZoom || Math.abs(zoom - this._zoom) > maxZoomDiff) return false;
|
|
1563
1570
|
const scale = this.getZoomScale(zoom), offset = this._getCenterOffset(center)._divideBy(1 - 1 / scale);
|
|
1564
1571
|
if (options.animate !== true && !this.getSize().contains(offset)) return false;
|
|
1565
1572
|
if (this.options.continuousZoom) {
|
|
@@ -1589,7 +1596,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1589
1596
|
});
|
|
1590
1597
|
if (!this._tempFireZoomEvent) this._tempFireZoomEvent = this._zoom !== this._animateToZoom;
|
|
1591
1598
|
this._move(this._animateToCenter, this._animateToZoom, void 0, true);
|
|
1592
|
-
this._transitionEndTimer = setTimeout(this._onZoomTransitionEnd.bind(this),
|
|
1599
|
+
this._transitionEndTimer = setTimeout(this._onZoomTransitionEnd.bind(this), zoomAnimDuration);
|
|
1593
1600
|
}
|
|
1594
1601
|
_onZoomTransitionEnd() {
|
|
1595
1602
|
if (!this._animatingZoom) return;
|
|
@@ -1621,8 +1628,7 @@ for (const feature of [
|
|
|
1621
1628
|
ZoomControl,
|
|
1622
1629
|
FullscreenControl
|
|
1623
1630
|
]) feature.register(MaplairMap);
|
|
1624
|
-
const Map = MaplairMap;
|
|
1625
1631
|
//#endregion
|
|
1626
|
-
export { Map, MaplairMap };
|
|
1632
|
+
export { MaplairMap as LeafletMap, MaplairMap as Map, MaplairMap };
|
|
1627
1633
|
|
|
1628
1634
|
//# sourceMappingURL=Map.js.map
|