maplair 4.4.0 → 4.5.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 +62 -0
- package/dist/esm/control/AttributionControl.js +20 -3
- package/dist/esm/control/AttributionControl.js.map +1 -1
- package/dist/esm/control/LayersControl.js +35 -20
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/ScaleControl.js +3 -3
- package/dist/esm/control/ScaleControl.js.map +1 -1
- package/dist/esm/control/ZoomControl.js +1 -0
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Util.js +1 -1
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.PointerEvents.js +19 -2
- package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
- package/dist/esm/dom/Draggable.js +6 -2
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/geo/LatLng.js +1 -1
- package/dist/esm/geo/LatLng.js.map +1 -1
- package/dist/esm/geo/LatLngBounds.js +1 -1
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geometry/Bounds.js +1 -1
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/Point.js +4 -2
- package/dist/esm/geometry/Point.js.map +1 -1
- package/dist/esm/geometry/PolyUtil.js +10 -3
- package/dist/esm/geometry/PolyUtil.js.map +1 -1
- package/dist/esm/layer/BlanketOverlay.js +2 -1
- package/dist/esm/layer/BlanketOverlay.js.map +1 -1
- package/dist/esm/layer/DivOverlay.js +3 -3
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/ImageOverlay.js +1 -1
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +1 -1
- package/dist/esm/layer/Layer.js.map +1 -1
- package/dist/esm/layer/Popup.js +3 -4
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/Tooltip.js +31 -22
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/marker/Icon.js +25 -6
- package/dist/esm/layer/marker/Icon.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js +5 -5
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +5 -5
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/tile/GridLayer.js +11 -5
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +10 -6
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/tile/WMSTileLayer.js +7 -3
- package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +2 -2
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +2 -3
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +6 -3
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.ZoomStyles.js +4 -1
- package/dist/esm/layer/vector/Path.ZoomStyles.js.map +1 -1
- package/dist/esm/map/Map.Rotation.js +3 -2
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +58 -26
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/MapSync.js +1 -1
- package/dist/esm/map/MapSync.js.map +1 -1
- package/dist/esm/map/handler/BoxZoomHandler.js +2 -0
- package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DragHandler.js +7 -2
- package/dist/esm/map/handler/DragHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +1 -1
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/TapDragZoomHandler.js +1 -1
- package/dist/esm/map/handler/TapDragZoomHandler.js.map +1 -1
- package/dist/esm/package.js +1 -1
- package/dist/maplair-global-src.js +289 -140
- 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 +289 -140
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.css +1 -1
- package/dist/maplair.js +2 -2
- package/dist/maplair.js.map +1 -1
- package/package.json +1 -1
- package/src/control/AttributionControl.js +29 -3
- package/src/control/LayersControl.js +47 -27
- package/src/control/ScaleControl.js +6 -3
- package/src/control/ZoomControl.js +1 -0
- package/src/core/Util.js +1 -1
- package/src/dom/DomEvent.PointerEvents.js +22 -2
- package/src/dom/Draggable.js +6 -2
- package/src/geo/LatLng.js +2 -1
- package/src/geo/LatLngBounds.js +1 -1
- package/src/geometry/Bounds.js +1 -1
- package/src/geometry/Point.js +4 -2
- package/src/geometry/PolyUtil.js +12 -3
- package/src/layer/BlanketOverlay.js +5 -2
- package/src/layer/DivOverlay.js +3 -3
- package/src/layer/ImageOverlay.js +3 -2
- package/src/layer/Layer.js +1 -1
- package/src/layer/Popup.js +3 -4
- package/src/layer/Tooltip.js +34 -27
- package/src/layer/marker/Icon.js +25 -5
- package/src/layer/marker/Marker.Drag.js +6 -6
- package/src/layer/marker/Marker.js +5 -5
- package/src/layer/tile/GridLayer.js +20 -7
- package/src/layer/tile/TileLayer.js +14 -7
- package/src/layer/tile/WMSTileLayer.js +4 -2
- package/src/layer/vector/Canvas.js +2 -2
- package/src/layer/vector/Circle.js +3 -5
- package/src/layer/vector/CircleMarker.js +5 -2
- package/src/layer/vector/Path.ZoomStyles.js +5 -3
- package/src/map/Map.Rotation.js +6 -3
- package/src/map/Map.js +63 -32
- package/src/map/MapSync.js +1 -1
- package/src/map/handler/BoxZoomHandler.js +3 -0
- package/src/map/handler/DragHandler.js +5 -5
- package/src/map/handler/PinchZoomHandler.js +1 -1
- package/src/map/handler/ScrollWheelZoomHandler.js +1 -1
- package/src/map/handler/TapDragZoomHandler.js +1 -1
- package/src/maplair.css +12 -1
package/src/layer/marker/Icon.js
CHANGED
|
@@ -19,8 +19,11 @@ import {Point} from '../../geometry/Point.js';
|
|
|
19
19
|
* can be set in CSS with negative margins.
|
|
20
20
|
* @property {PointExpression} [popupAnchor=[0, 0]] The coordinates of the point from
|
|
21
21
|
* which popups will "open", relative to the icon anchor.
|
|
22
|
-
* @property {PointExpression} [tooltipAnchor=[0, 0]]
|
|
23
|
-
*
|
|
22
|
+
* @property {PointExpression} [tooltipAnchor=[0, 0]] Where tooltips opening to the side
|
|
23
|
+
* attach, relative to the icon anchor: `x` is how far to the right (mirrored for tooltips
|
|
24
|
+
* opening to the left) and `y` how far down. Tooltips opening to the top or bottom attach
|
|
25
|
+
* to the middle of the icon's top or bottom edge, and `center` ones to the middle of the
|
|
26
|
+
* icon at the `y` height.
|
|
24
27
|
* @property {string} [shadowUrl] The URL to the icon shadow image. If not specified, no
|
|
25
28
|
* shadow image will be created.
|
|
26
29
|
* @property {string} [shadowRetinaUrl] The URL to a retina sized version of the shadow
|
|
@@ -120,17 +123,34 @@ export class Icon extends Class {
|
|
|
120
123
|
return img;
|
|
121
124
|
}
|
|
122
125
|
|
|
123
|
-
|
|
126
|
+
// The size and anchor of the icon or shadow in pixels; a side that isn't a number, like
|
|
127
|
+
// 'auto' in [100, 'auto'], is left to CSS and comes out as NaN.
|
|
128
|
+
_getBox(name) {
|
|
124
129
|
const options = this.options;
|
|
125
130
|
const sizeOption = options[`${name}Size`];
|
|
126
|
-
|
|
127
|
-
// a side that isn't a number, like 'auto' in [100, 'auto'], is left to CSS
|
|
128
131
|
const [width, height] = (typeof sizeOption === 'number' ? [sizeOption, sizeOption] :
|
|
129
132
|
Array.isArray(sizeOption) ? sizeOption : [sizeOption?.x, sizeOption?.y]).map(toNumber);
|
|
130
133
|
|
|
131
134
|
const anchorOption = name === 'shadow' && options.shadowAnchor || options.iconAnchor;
|
|
132
135
|
const anchor = Point.validate(anchorOption) ? Point.from(anchorOption) :
|
|
133
136
|
{x: Math.round(width / 2), y: Math.round(height / 2)};
|
|
137
|
+
return {width, height, anchor};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Where a tooltip opening in the given direction attaches, relative to the icon anchor.
|
|
141
|
+
_getTooltipAnchor(direction) {
|
|
142
|
+
const {x, y} = Point.from(this.options.tooltipAnchor);
|
|
143
|
+
if (direction === 'left') { return new Point(-x, y); }
|
|
144
|
+
if (direction === 'center') { return new Point(0, y); }
|
|
145
|
+
if (direction !== 'top' && direction !== 'bottom') { return new Point(x, y); }
|
|
146
|
+
|
|
147
|
+
const {height, anchor} = this._getBox('icon');
|
|
148
|
+
return new Point(0, (direction === 'top' ? -anchor.y : height - anchor.y) || 0);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
_setIconStyles(img, name) {
|
|
152
|
+
const options = this.options;
|
|
153
|
+
const {width, height, anchor} = this._getBox(name);
|
|
134
154
|
|
|
135
155
|
img.className = `maplair-marker-${name} ${options.className || ''}`;
|
|
136
156
|
|
|
@@ -14,8 +14,8 @@ const arrows = {ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowD
|
|
|
14
14
|
* The handler of `Marker` which makes the markers draggable, see the
|
|
15
15
|
* [`dragging`](#marker-dragging) property of markers and its `draggable` option.
|
|
16
16
|
*
|
|
17
|
-
* @fires Marker#dragstart {
|
|
18
|
-
* @fires Marker#movestart {
|
|
17
|
+
* @fires Marker#dragstart {DraggableEvent} Fired when the user starts dragging the marker.
|
|
18
|
+
* @fires Marker#movestart {DraggableEvent} Fired when the marker starts moving (because of
|
|
19
19
|
* dragging).
|
|
20
20
|
* @fires Marker#drag {MarkerMoveEvent} Fired repeatedly while the user drags the marker.
|
|
21
21
|
* @fires Marker#dragend {DragEndEvent} Fired when the user stops dragging the marker.
|
|
@@ -115,15 +115,15 @@ export class MarkerDrag extends Handler {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
_onDragStart() {
|
|
118
|
+
_onDragStart({originalEvent}) {
|
|
119
119
|
this._oldLatLng = this._marker.getLatLng();
|
|
120
120
|
|
|
121
121
|
// When using ES6 imports it could not be set when `Popup` was not imported as well
|
|
122
122
|
this._marker.closePopup?.();
|
|
123
123
|
|
|
124
124
|
this._marker
|
|
125
|
-
.fire('movestart')
|
|
126
|
-
.fire('dragstart');
|
|
125
|
+
.fire('movestart', {originalEvent})
|
|
126
|
+
.fire('dragstart', {originalEvent});
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
_onPreDrag(e) {
|
|
@@ -185,7 +185,7 @@ export class MarkerDrag extends Handler {
|
|
|
185
185
|
draggable._startPos = DomUtil.getPosition(draggable._element);
|
|
186
186
|
draggable._moved = draggable._moving = true;
|
|
187
187
|
this._keyOffset = new Point(0, 0);
|
|
188
|
-
draggable.fire('dragstart');
|
|
188
|
+
draggable.fire('dragstart', {originalEvent: k});
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
// in container pixels, which the map rotation (if any) turns to the frame of the rotated pane
|
|
@@ -262,7 +262,7 @@ export class Marker extends Layer {
|
|
|
262
262
|
update() {
|
|
263
263
|
|
|
264
264
|
if (this._icon && this._map && !this._culled) {
|
|
265
|
-
const pos = this._map.latLngToLayerPoint(this._latlng)
|
|
265
|
+
const pos = this._map._snapLayerPoint(this._map.latLngToLayerPoint(this._latlng));
|
|
266
266
|
this._setPos(pos);
|
|
267
267
|
}
|
|
268
268
|
|
|
@@ -398,7 +398,7 @@ export class Marker extends Layer {
|
|
|
398
398
|
_setPos(pos) {
|
|
399
399
|
this._positionElements(pos);
|
|
400
400
|
|
|
401
|
-
this._zIndex = pos.y + this.options.zIndexOffset;
|
|
401
|
+
this._zIndex = Math.round(pos.y) + this.options.zIndexOffset;
|
|
402
402
|
|
|
403
403
|
this._updateRise();
|
|
404
404
|
}
|
|
@@ -428,7 +428,7 @@ export class Marker extends Layer {
|
|
|
428
428
|
|
|
429
429
|
_animateZoom(opt) {
|
|
430
430
|
if (this._culled) { return; }
|
|
431
|
-
const pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center)
|
|
431
|
+
const pos = this._map._snapLayerPoint(this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center));
|
|
432
432
|
|
|
433
433
|
this._setPos(pos);
|
|
434
434
|
}
|
|
@@ -595,8 +595,8 @@ export class Marker extends Layer {
|
|
|
595
595
|
return this._rotateAnchor(this.options.icon.options.popupAnchor);
|
|
596
596
|
}
|
|
597
597
|
|
|
598
|
-
_getTooltipAnchor() {
|
|
599
|
-
return this._rotateAnchor(this.options.icon.
|
|
598
|
+
_getTooltipAnchor(direction) {
|
|
599
|
+
return this._rotateAnchor(this.options.icon._getTooltipAnchor(direction));
|
|
600
600
|
}
|
|
601
601
|
|
|
602
602
|
// anchors are offsets from the icon anchor, which is also the rotation origin
|
|
@@ -379,7 +379,7 @@ export class GridLayer extends Layer {
|
|
|
379
379
|
_initContainer() {
|
|
380
380
|
if (this._container) { return; }
|
|
381
381
|
|
|
382
|
-
this._container = DomUtil.create('div', `maplair-layer ${this.options.className ?? ''}`);
|
|
382
|
+
this._container = DomUtil.create('div', `maplair-layer maplair-zoom-animated ${this.options.className ?? ''}`);
|
|
383
383
|
this._container.classList.toggle('maplair-pixelated', !!this.options.pixelated);
|
|
384
384
|
this._updateZIndex();
|
|
385
385
|
|
|
@@ -476,9 +476,6 @@ export class GridLayer extends Layer {
|
|
|
476
476
|
|
|
477
477
|
this._setZoomTransform(level, map.getCenter(), map.getZoom());
|
|
478
478
|
|
|
479
|
-
// force reading offsetWidth so the browser considers the newly added element for transition
|
|
480
|
-
Util.falseFn(level.el.offsetWidth);
|
|
481
|
-
|
|
482
479
|
this._onCreateLevel(level);
|
|
483
480
|
}
|
|
484
481
|
|
|
@@ -585,7 +582,15 @@ export class GridLayer extends Layer {
|
|
|
585
582
|
}
|
|
586
583
|
|
|
587
584
|
_animateZoom(e) {
|
|
585
|
+
const map = this._map, center = map.getCenter(), zoom = map.getZoom(), scale = map.getZoomScale(e.zoom, zoom);
|
|
586
|
+
|
|
588
587
|
this._setView(e.center, e.zoom, true, e.noUpdate);
|
|
588
|
+
|
|
589
|
+
// the levels stay put and the container zooms as a whole, since a level created just now would only
|
|
590
|
+
// transition after a forced style recalc, which covers every pending style change on the page
|
|
591
|
+
this._setZoomTransforms(center, zoom);
|
|
592
|
+
DomUtil.setTransform(this._container, map._getNewPixelOrigin(center, zoom).multiplyBy(scale)
|
|
593
|
+
.subtract(map._getNewPixelOrigin(e.center, e.zoom)), scale);
|
|
589
594
|
}
|
|
590
595
|
|
|
591
596
|
// The zoom of the tiles for the map zoom `zoom`, or undefined outside of the
|
|
@@ -641,6 +646,7 @@ export class GridLayer extends Layer {
|
|
|
641
646
|
}
|
|
642
647
|
|
|
643
648
|
_setZoomTransforms(center, zoom) {
|
|
649
|
+
if (this._container.style.transform) { this._container.style.transform = ''; }
|
|
644
650
|
for (const level of Object.values(this._levels)) {
|
|
645
651
|
this._setZoomTransform(level, center, zoom);
|
|
646
652
|
}
|
|
@@ -648,8 +654,11 @@ export class GridLayer extends Layer {
|
|
|
648
654
|
|
|
649
655
|
_setZoomTransform(level, center, zoom) {
|
|
650
656
|
const scale = this._map.getZoomScale(zoom, level.zoom),
|
|
651
|
-
translate = level.origin.multiplyBy(scale)
|
|
652
|
-
|
|
657
|
+
translate = level.origin.multiplyBy(scale).subtract(this._map._getNewPixelOrigin(center, zoom));
|
|
658
|
+
|
|
659
|
+
// a scaled level is resampled anyway, and rounding where its origin lands would make its tiles away from the
|
|
660
|
+
// origin jitter against the zoom motion
|
|
661
|
+
if (scale === 1) { this._map._snapLayerPoint(translate); }
|
|
653
662
|
|
|
654
663
|
DomUtil.setTransform(level.el, translate, scale);
|
|
655
664
|
}
|
|
@@ -676,7 +685,11 @@ export class GridLayer extends Layer {
|
|
|
676
685
|
}
|
|
677
686
|
|
|
678
687
|
_onMoveEnd() {
|
|
679
|
-
|
|
688
|
+
const map = this._map;
|
|
689
|
+
if (!map || map._animatingZoom) { return; }
|
|
690
|
+
|
|
691
|
+
// a zoom animation that ends at the same zoom (e.g. a pinch snapping back) fires no zoom event
|
|
692
|
+
if (this._container.style.transform) { this._setZoomTransforms(map.getCenter(), map.getZoom()); }
|
|
680
693
|
|
|
681
694
|
this._update();
|
|
682
695
|
}
|
|
@@ -18,6 +18,12 @@ function isOSMUrl(url) {
|
|
|
18
18
|
// OSM tiles are upgraded to HTTPS so that the referrer policy works
|
|
19
19
|
const upgradeOSMUrl = url => (isOSMUrl(url) ? url.replace(httpRe, 'https:') : url);
|
|
20
20
|
|
|
21
|
+
// 0 at a pixel ratio of 1, 1 above it (the `{r}` of tile URLs), 2 from 1.5 on (`detectRetina`)
|
|
22
|
+
function retinaLevel() {
|
|
23
|
+
const dpr = window.devicePixelRatio;
|
|
24
|
+
return dpr >= 1.5 ? 2 : dpr > 1 ? 1 : 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
21
27
|
/**
|
|
22
28
|
* Options of `TileLayer`.
|
|
23
29
|
* @typedef {object} TileLayerOptions
|
|
@@ -36,9 +42,9 @@ const upgradeOSMUrl = url => (isOSMUrl(url) ? url.replace(httpRe, 'https:') : ur
|
|
|
36
42
|
* this on for [TMS](https://en.wikipedia.org/wiki/Tile_Map_Service) services).
|
|
37
43
|
* @property {boolean} [zoomReverse=false] If set to true, the zoom number used in tile
|
|
38
44
|
* URLs will be reversed (`maxZoom - zoom` instead of `zoom`).
|
|
39
|
-
* @property {boolean} [detectRetina=false] If `true` and
|
|
40
|
-
* will request four tiles of half the specified size and a bigger zoom level
|
|
41
|
-
* of one to utilize the high resolution.
|
|
45
|
+
* @property {boolean} [detectRetina=false] If `true` and the device pixel ratio is 1.5 or
|
|
46
|
+
* higher, it will request four tiles of half the specified size and a bigger zoom level
|
|
47
|
+
* in place of one to utilize the high resolution.
|
|
42
48
|
* @property {boolean|string} [crossOrigin=false] Whether the crossOrigin attribute will
|
|
43
49
|
* be added to the tiles. If a String is provided, all tiles will have their crossOrigin
|
|
44
50
|
* attribute set to the String provided. This is needed if you want to access tile pixel
|
|
@@ -144,12 +150,13 @@ export class TileLayer extends GridLayer {
|
|
|
144
150
|
this.callInitHooks(TileLayer);
|
|
145
151
|
}
|
|
146
152
|
|
|
147
|
-
// Detects retina displays (if `detectRetina` is set), adjusting tileSize and zoom levels.
|
|
153
|
+
// Detects retina displays (if `detectRetina` is set), adjusting tileSize and zoom levels. Below a
|
|
154
|
+
// pixel ratio of 1.5 (e.g. 125% scaling), half-size tiles of the next zoom make labels too small to read.
|
|
148
155
|
_applyRetina() {
|
|
149
156
|
Object.assign(this.options, this._nonRetinaOptions);
|
|
150
|
-
this._retina =
|
|
157
|
+
this._retina = retinaLevel();
|
|
151
158
|
|
|
152
|
-
if (this.options.detectRetina && this._retina && this.options.maxZoom > 0) {
|
|
159
|
+
if (this.options.detectRetina && this._retina === 2 && this.options.maxZoom > 0) {
|
|
153
160
|
|
|
154
161
|
const tileSize = this.options.tileSize;
|
|
155
162
|
this.options.tileSize = tileSize instanceof Point ? tileSize.divideBy(2).floor() : Math.floor(tileSize / 2);
|
|
@@ -193,7 +200,7 @@ export class TileLayer extends GridLayer {
|
|
|
193
200
|
|
|
194
201
|
// Loads the tiles for the new resolution, see the map's `pixelratiochange` event.
|
|
195
202
|
_onPixelRatioChange() {
|
|
196
|
-
if ((
|
|
203
|
+
if (retinaLevel() === this._retina) { return; }
|
|
197
204
|
const map = this._map;
|
|
198
205
|
this._applyRetina();
|
|
199
206
|
if (this.options.detectRetina) {
|
|
@@ -93,7 +93,7 @@ export class WMSTileLayer extends TileLayer {
|
|
|
93
93
|
|
|
94
94
|
// The size of the requested images: the tile size, doubled on retina displays with `detectRetina`.
|
|
95
95
|
_updateWmsSize() {
|
|
96
|
-
const realRetina = this.options.detectRetina && window.devicePixelRatio
|
|
96
|
+
const realRetina = this.options.detectRetina && window.devicePixelRatio >= 1.5 ? 2 : 1;
|
|
97
97
|
const tileSize = this.getTileSize();
|
|
98
98
|
|
|
99
99
|
this.wmsParams.width = tileSize.x * realRetina;
|
|
@@ -154,6 +154,7 @@ export class WMSTileLayer extends TileLayer {
|
|
|
154
154
|
[min.x, min.y, max.x, max.y]).join(',');
|
|
155
155
|
const url = new URL(super.getTileUrl(coords), document.baseURI);
|
|
156
156
|
for (const [k, v] of Object.entries({...this.wmsParams, bbox})) {
|
|
157
|
+
if (v == null) { continue; } // unset, e.g. cleared with `setParams`
|
|
157
158
|
url.searchParams.append(this.options.uppercase ? k.toUpperCase() : k, `${v}`);
|
|
158
159
|
}
|
|
159
160
|
return url.toString();
|
|
@@ -191,7 +192,8 @@ export class WMSTileLayer extends TileLayer {
|
|
|
191
192
|
/**
|
|
192
193
|
* Merges an object with the new parameters and re-requests tiles on the current screen
|
|
193
194
|
* (unless `noRedraw` was set to true). The current tiles stay visible until the new
|
|
194
|
-
* tiles have loaded, to avoid flickering.
|
|
195
|
+
* tiles have loaded, to avoid flickering. Set a parameter to `undefined` or `null` to
|
|
196
|
+
* leave it out of the requests.
|
|
195
197
|
* @param {Record<string, any>} params
|
|
196
198
|
* @param {boolean} [noRedraw]
|
|
197
199
|
* @returns {this}
|
|
@@ -88,7 +88,7 @@ export class Canvas extends Renderer {
|
|
|
88
88
|
// the map hit-tests canvas renderers topmost first: by pane z-index, then DOM order
|
|
89
89
|
const z = r => +getComputedStyle(r._container.parentNode).zIndex || 0;
|
|
90
90
|
map._canvases.push(this);
|
|
91
|
-
map._canvases.sort((a, b) => z(b) - z(a) || (a._container.compareDocumentPosition(b._container) & 2)
|
|
91
|
+
map._canvases.sort((a, b) => z(b) - z(a) || 1 - (a._container.compareDocumentPosition(b._container) & 2));
|
|
92
92
|
|
|
93
93
|
// Redraw vectors since canvas is cleared upon removal,
|
|
94
94
|
// in case of removing the renderer itself from the map.
|
|
@@ -329,7 +329,7 @@ export class Canvas extends Renderer {
|
|
|
329
329
|
ctx.fill(options.fillRule || 'evenodd');
|
|
330
330
|
}
|
|
331
331
|
|
|
332
|
-
if (options.stroke && options.weight !== 0) {
|
|
332
|
+
if (options.stroke && +options.weight !== 0) {
|
|
333
333
|
ctx.lineDashOffset = Number(options.dashOffset ?? 0);
|
|
334
334
|
ctx.setLineDash(layer._dashArray ?? []);
|
|
335
335
|
ctx.globalAlpha = options.opacity;
|
|
@@ -37,9 +37,6 @@ export class Circle extends CircleMarker {
|
|
|
37
37
|
throw new Error('Circle: the radius is an option in Maplair. Use new Circle(latlng, {radius}).');
|
|
38
38
|
}
|
|
39
39
|
super(latlng, options);
|
|
40
|
-
|
|
41
|
-
if (isNaN(this.options.radius)) { throw new Error('Circle radius cannot be NaN'); }
|
|
42
|
-
|
|
43
40
|
this.callInitHooks(Circle);
|
|
44
41
|
}
|
|
45
42
|
|
|
@@ -85,8 +82,9 @@ export class Circle extends CircleMarker {
|
|
|
85
82
|
}
|
|
86
83
|
|
|
87
84
|
this._point = p.subtract(renderer._pathOrigin);
|
|
88
|
-
|
|
89
|
-
this.
|
|
85
|
+
// distances rather than x/y deltas, for projections that rotate the axes
|
|
86
|
+
this._pxRadius = isNaN(lngR) ? 0 : p.distanceTo(map.project([lat2, lng - lngR], zoom));
|
|
87
|
+
this._pxRadiusY = p.distanceTo(top);
|
|
90
88
|
|
|
91
89
|
} else {
|
|
92
90
|
const latlng2 = crs.unproject(crs.project(this._latlng).subtract([this._radius, 0]));
|
|
@@ -50,7 +50,7 @@ export class CircleMarker extends Path {
|
|
|
50
50
|
super();
|
|
51
51
|
Util.setOptions(this, options);
|
|
52
52
|
this._latlng = new LatLng(latlng);
|
|
53
|
-
this.
|
|
53
|
+
this.setRadius(this.options.radius);
|
|
54
54
|
|
|
55
55
|
this.callInitHooks(CircleMarker);
|
|
56
56
|
}
|
|
@@ -91,7 +91,10 @@ export class CircleMarker extends Path {
|
|
|
91
91
|
* @returns {this}
|
|
92
92
|
*/
|
|
93
93
|
setRadius(radius) {
|
|
94
|
-
|
|
94
|
+
const r = Util.toNumber(radius);
|
|
95
|
+
if (isNaN(r)) { throw new Error(`Invalid radius: ${radius}`); }
|
|
96
|
+
/** @type {number} */
|
|
97
|
+
this._radius = this.options.radius = r;
|
|
95
98
|
return this.redraw();
|
|
96
99
|
}
|
|
97
100
|
|
|
@@ -92,9 +92,11 @@ Path.include({
|
|
|
92
92
|
CircleMarker.include({
|
|
93
93
|
setRadius(radius) {
|
|
94
94
|
this._takeZoomStyles({radius});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
if (!this._zoomStyles?.radius) { return setRadius.call(this, radius); }
|
|
96
|
+
if (this._map) { return setRadius.call(this, evaluate(radius, this._map.getZoom())); }
|
|
97
|
+
// evaluated when the circle marker is added to a map
|
|
98
|
+
this.options.radius = this._radius = radius;
|
|
99
|
+
return this;
|
|
98
100
|
}
|
|
99
101
|
});
|
|
100
102
|
|
package/src/map/Map.Rotation.js
CHANGED
|
@@ -415,8 +415,11 @@ const blanketOverlayRotationMethods = {
|
|
|
415
415
|
viewHalf = this._map._getViewSize().multiplyBy(0.5 + this.options.padding),
|
|
416
416
|
currentCenterPoint = this._map.project(this._center, zoom),
|
|
417
417
|
topLeftOffset = viewHalf.multiplyBy(-scale)._add(currentCenterPoint)
|
|
418
|
-
._subtract(this._map._getNewPixelOrigin(center, zoom))
|
|
419
|
-
|
|
418
|
+
._subtract(this._map._getNewPixelOrigin(center, zoom));
|
|
419
|
+
|
|
420
|
+
// a scaled container is resampled anyway, and rounding where its corner lands would make its content away
|
|
421
|
+
// from the corner jitter against the zoom motion
|
|
422
|
+
if (scale === 1) { this._map._snapLayerPoint(topLeftOffset); }
|
|
420
423
|
|
|
421
424
|
DomUtil.setTransform(this._container, topLeftOffset, scale);
|
|
422
425
|
},
|
|
@@ -471,7 +474,7 @@ const divOverlayRotationMethods = {
|
|
|
471
474
|
if (!this._map) { return; }
|
|
472
475
|
|
|
473
476
|
const map = this._map,
|
|
474
|
-
pos = map.latLngToLayerPoint(this._latlng)
|
|
477
|
+
pos = map._snapLayerPoint(map.latLngToLayerPoint(this._latlng)),
|
|
475
478
|
// on a rotated map, the anchor is relative to the upright overlay
|
|
476
479
|
anchor = map._rotateToPane(new Point(this._getAnchor()));
|
|
477
480
|
let offset = Point.from(this.options.offset);
|
package/src/map/Map.js
CHANGED
|
@@ -642,6 +642,11 @@ export class MaplairMap extends Evented {
|
|
|
642
642
|
this._stop();
|
|
643
643
|
this._targetView = {center: requestedCenter, zoom: targetZoom};
|
|
644
644
|
|
|
645
|
+
// layers round their positions against the pixel origin, and while zoom changes, projected coordinates move
|
|
646
|
+
// fast in absolute terms even when the view barely moves on screen, so rounding the origin too would make
|
|
647
|
+
// everything jitter by up to a pixel against the motion; the last frame rounds it again
|
|
648
|
+
this._subpixelOrigin = true;
|
|
649
|
+
|
|
645
650
|
const from = this.project(this.getCenter()),
|
|
646
651
|
to = this.project(targetCenter),
|
|
647
652
|
size = this.getSize(),
|
|
@@ -688,6 +693,7 @@ export class MaplairMap extends Evented {
|
|
|
688
693
|
// the last step shifts the pixel origin even at the same zoom, and layers like GridLayer only
|
|
689
694
|
// re-anchor on 'zoom' (#9438)
|
|
690
695
|
const zoomChanged = this._zoom !== targetZoom;
|
|
696
|
+
this._subpixelOrigin = false;
|
|
691
697
|
this._move(targetCenter, targetZoom);
|
|
692
698
|
if (!zoomChanged) { this.fire('zoom'); }
|
|
693
699
|
this._moveEnd(true);
|
|
@@ -794,7 +800,7 @@ export class MaplairMap extends Evented {
|
|
|
794
800
|
if (this._loaded && oldZoom !== zoom) {
|
|
795
801
|
this.fire('zoomlevelschange');
|
|
796
802
|
|
|
797
|
-
if (this.
|
|
803
|
+
if (this._targetZoom() < this.options.minZoom) {
|
|
798
804
|
return this.setZoom(zoom);
|
|
799
805
|
}
|
|
800
806
|
}
|
|
@@ -815,7 +821,7 @@ export class MaplairMap extends Evented {
|
|
|
815
821
|
if (this._loaded && oldZoom !== zoom) {
|
|
816
822
|
this.fire('zoomlevelschange');
|
|
817
823
|
|
|
818
|
-
if (this.
|
|
824
|
+
if (this._targetZoom() > this.options.maxZoom) {
|
|
819
825
|
return this.setZoom(zoom);
|
|
820
826
|
}
|
|
821
827
|
}
|
|
@@ -1233,10 +1239,10 @@ export class MaplairMap extends Evented {
|
|
|
1233
1239
|
let zoom = this.getZoom() ?? 0;
|
|
1234
1240
|
const min = this.getMinZoom(),
|
|
1235
1241
|
max = this.getMaxZoom(),
|
|
1236
|
-
nw = bounds.getNorthWest(),
|
|
1237
|
-
se = bounds.getSouthEast(),
|
|
1238
1242
|
size = this.getSize().subtract(padding),
|
|
1239
|
-
|
|
1243
|
+
// any corner can be an extreme when the projection rotates the axes
|
|
1244
|
+
corners = [bounds.getNorthWest(), bounds.getNorthEast(), bounds.getSouthEast(), bounds.getSouthWest()],
|
|
1245
|
+
boundsSize = new Bounds(corners.map(c => this.project(c, zoom))).getSize(),
|
|
1240
1246
|
snap = this.options.zoomSnap,
|
|
1241
1247
|
// padding larger than the map leaves no room: zoom out, not in
|
|
1242
1248
|
scalex = Math.max(size.x, 0) / boundsSize.x,
|
|
@@ -1512,7 +1518,16 @@ export class MaplairMap extends Evented {
|
|
|
1512
1518
|
* @returns {Point}
|
|
1513
1519
|
*/
|
|
1514
1520
|
pointerEventToContainerPoint(e) {
|
|
1515
|
-
return DomEvent.getPointerPosition(e, this._container);
|
|
1521
|
+
if (!this._animatingZoom) { return DomEvent.getPointerPosition(e, this._container); }
|
|
1522
|
+
|
|
1523
|
+
// reading the container's layout recalcs styles, which a zoom animation keeps changing for every animated
|
|
1524
|
+
// element; the container doesn't move during one, so read it once per animation
|
|
1525
|
+
if (!this._containerRect) {
|
|
1526
|
+
const el = this._container, {x, y, boundingClientRect: r} = DomUtil.getScale(el);
|
|
1527
|
+
this._containerRect = {x, y, left: r.left + el.clientLeft * x, top: r.top + el.clientTop * y};
|
|
1528
|
+
}
|
|
1529
|
+
const c = this._containerRect;
|
|
1530
|
+
return new Point((e.clientX - c.left) / c.x, (e.clientY - c.top) / c.y);
|
|
1516
1531
|
}
|
|
1517
1532
|
|
|
1518
1533
|
/**
|
|
@@ -1749,7 +1764,8 @@ export class MaplairMap extends Evented {
|
|
|
1749
1764
|
this._pixelOrigin = this._getNewPixelOrigin(center);
|
|
1750
1765
|
|
|
1751
1766
|
if (!suppressEvent) {
|
|
1752
|
-
|
|
1767
|
+
// always fire 'zoom' if pinching (#3530) or flying, where layers must follow the subpixel origin
|
|
1768
|
+
if (zoomChanged || data?.pinch || data?.flyTo) {
|
|
1753
1769
|
this.fire('zoom', data);
|
|
1754
1770
|
}
|
|
1755
1771
|
|
|
@@ -1776,6 +1792,11 @@ export class MaplairMap extends Evented {
|
|
|
1776
1792
|
this._targetView = null;
|
|
1777
1793
|
cancelAnimationFrame(this._flyToFrame);
|
|
1778
1794
|
cancelAnimationFrame(this._zoomAnimFrame);
|
|
1795
|
+
if (this._subpixelOrigin) {
|
|
1796
|
+
// an interrupted flight would leave layers between pixels, so snap them where it stopped
|
|
1797
|
+
this._subpixelOrigin = false;
|
|
1798
|
+
this._move(this._lastCenter, this._zoom, {flyTo: true});
|
|
1799
|
+
}
|
|
1779
1800
|
this._panAnim?.stop();
|
|
1780
1801
|
return this;
|
|
1781
1802
|
}
|
|
@@ -1900,17 +1921,10 @@ export class MaplairMap extends Evented {
|
|
|
1900
1921
|
return targets;
|
|
1901
1922
|
}
|
|
1902
1923
|
|
|
1903
|
-
_isClickDisabled(el) {
|
|
1904
|
-
while (el && el !== this._container) {
|
|
1905
|
-
if (el['_maplair_disable_click'] || !el.parentNode) { return true; }
|
|
1906
|
-
el = el.parentNode;
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
1924
|
_handleDOMEvent(e) {
|
|
1911
1925
|
const el = e.target;
|
|
1912
1926
|
if (e.type === 'click') { PointerEvents.simulateDblclick(e, this._container); }
|
|
1913
|
-
if (!this._loaded || e.type === 'click' &&
|
|
1927
|
+
if (!this._loaded || e.type === 'click' && PointerEvents.isClickDisabled(el, this._container)) {
|
|
1914
1928
|
return;
|
|
1915
1929
|
}
|
|
1916
1930
|
|
|
@@ -1921,8 +1935,17 @@ export class MaplairMap extends Evented {
|
|
|
1921
1935
|
hovered = this._hoveredCanvasLayer,
|
|
1922
1936
|
skip = type === 'pointerover' || type === 'pointerout' || type.startsWith('key') ||
|
|
1923
1937
|
this._animatingZoom || move && this.dragging?.moving(),
|
|
1924
|
-
layer = skip ? undefined : this._canvasLayerAt(e, type === 'click'),
|
|
1925
1938
|
leftMap = type === 'pointerout' && !this._container.contains(e.relatedTarget);
|
|
1939
|
+
let layer = skip ? undefined : this._canvasLayerAt(e, type === 'click');
|
|
1940
|
+
|
|
1941
|
+
// a click is fired on what both the press and the release were on, but for canvas layers the browser only sees
|
|
1942
|
+
// the map, so a pointer click goes to a canvas layer only if the press was on that layer too
|
|
1943
|
+
if (type === 'pointerdown') {
|
|
1944
|
+
this._pressedCanvasLayer = skip ? undefined : layer ?? null;
|
|
1945
|
+
} else if (type === 'click' && e.detail > 0 && this._pressedCanvasLayer !== undefined) {
|
|
1946
|
+
if (layer !== this._pressedCanvasLayer) { layer = undefined; }
|
|
1947
|
+
this._pressedCanvasLayer = undefined;
|
|
1948
|
+
}
|
|
1926
1949
|
|
|
1927
1950
|
if (layer !== hovered && (move && !skip || leftMap)) {
|
|
1928
1951
|
if (hovered) { this._fireDOMEvent(e, 'pointerout', [hovered]); }
|
|
@@ -2033,7 +2056,14 @@ export class MaplairMap extends Evented {
|
|
|
2033
2056
|
|
|
2034
2057
|
_getNewPixelOrigin(center, zoom) {
|
|
2035
2058
|
const viewHalf = this.getSize()._divideBy(2);
|
|
2036
|
-
|
|
2059
|
+
const origin = this.project(center, zoom)._subtract(viewHalf)._add(this._getMapPanePos());
|
|
2060
|
+
return this._subpixelOrigin ? origin : origin._round();
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
// Snaps a layer point to whole pixels for crisp rendering, except during flyTo frames, where snapped layers
|
|
2064
|
+
// would step against the smoothly moving tiles. Modifies the point in place.
|
|
2065
|
+
_snapLayerPoint(point) {
|
|
2066
|
+
return this._subpixelOrigin ? point : point._round();
|
|
2037
2067
|
}
|
|
2038
2068
|
|
|
2039
2069
|
_latLngToNewLayerPoint(latlng, zoom, center) {
|
|
@@ -2088,10 +2118,9 @@ export class MaplairMap extends Evented {
|
|
|
2088
2118
|
|
|
2089
2119
|
// returns offset needed for pxBounds to get inside maxBounds at a specified zoom
|
|
2090
2120
|
_getBoundsOffset(pxBounds, maxBounds, zoom) {
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
),
|
|
2121
|
+
// any corner can be an extreme when the projection rotates the axes
|
|
2122
|
+
const corners = [maxBounds.getNorthWest(), maxBounds.getNorthEast(), maxBounds.getSouthEast(), maxBounds.getSouthWest()],
|
|
2123
|
+
projectedMaxBounds = new Bounds(corners.map(c => this.project(c, zoom))),
|
|
2095
2124
|
minOffset = projectedMaxBounds.min.subtract(pxBounds.min),
|
|
2096
2125
|
maxOffset = projectedMaxBounds.max.subtract(pxBounds.max),
|
|
2097
2126
|
|
|
@@ -2258,24 +2287,22 @@ export class MaplairMap extends Evented {
|
|
|
2258
2287
|
}
|
|
2259
2288
|
this
|
|
2260
2289
|
._moveStart(true, options.noMoveStart ?? false)
|
|
2261
|
-
._animateZoom(center, zoom
|
|
2290
|
+
._animateZoom(center, zoom);
|
|
2262
2291
|
});
|
|
2263
2292
|
|
|
2264
2293
|
return true;
|
|
2265
2294
|
}
|
|
2266
2295
|
|
|
2267
|
-
_animateZoom(center, zoom,
|
|
2296
|
+
_animateZoom(center, zoom, noUpdate) {
|
|
2268
2297
|
if (!this._mapPane) { return; }
|
|
2269
2298
|
|
|
2270
|
-
|
|
2271
|
-
this._animatingZoom = true;
|
|
2299
|
+
this._animatingZoom = true;
|
|
2272
2300
|
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2301
|
+
// remember what center/zoom to set after animation
|
|
2302
|
+
this._animateToCenter = center;
|
|
2303
|
+
this._animateToZoom = zoom;
|
|
2276
2304
|
|
|
2277
|
-
|
|
2278
|
-
}
|
|
2305
|
+
this._mapPane.classList.add('maplair-zoom-anim');
|
|
2279
2306
|
|
|
2280
2307
|
this.fire('zoomanim', {
|
|
2281
2308
|
center,
|
|
@@ -2289,13 +2316,17 @@ export class MaplairMap extends Evented {
|
|
|
2289
2316
|
|
|
2290
2317
|
this._move(this._animateToCenter, this._animateToZoom, undefined, true);
|
|
2291
2318
|
|
|
2292
|
-
//
|
|
2293
|
-
|
|
2319
|
+
// in case 'transitionend' never comes (Leaflet #3689, #2693); the transition only starts once the browser
|
|
2320
|
+
// renders the next frame, which takes ~200 ms with 5k markers, so a timer of the transition's length cuts it short
|
|
2321
|
+
clearTimeout(this._transitionEndTimer);
|
|
2322
|
+
this._transitionEndTimer = setTimeout(this._onZoomTransitionEnd.bind(this), 1000);
|
|
2294
2323
|
}
|
|
2295
2324
|
|
|
2296
2325
|
_onZoomTransitionEnd() {
|
|
2297
2326
|
if (!this._animatingZoom) { return; }
|
|
2298
2327
|
|
|
2328
|
+
clearTimeout(this._transitionEndTimer);
|
|
2329
|
+
this._containerRect = null;
|
|
2299
2330
|
this._mapPane?.classList.remove('maplair-zoom-anim');
|
|
2300
2331
|
|
|
2301
2332
|
this._animatingZoom = false;
|
package/src/map/MapSync.js
CHANGED
|
@@ -153,7 +153,7 @@ export class MapSync {
|
|
|
153
153
|
for (const other of this._followers(map)) {
|
|
154
154
|
if (other._zoomAnimated) {
|
|
155
155
|
this._animating.add(other);
|
|
156
|
-
other._animateZoom(e.center, this._zoomFor(other, map, e.zoom),
|
|
156
|
+
other._animateZoom(e.center, this._zoomFor(other, map, e.zoom), e.noUpdate);
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
}
|
|
@@ -60,6 +60,9 @@ export class BoxZoomHandler extends Handler {
|
|
|
60
60
|
removeHooks() {
|
|
61
61
|
DomEvent.off(this._map._container, 'pointerdown', this._onPointerDown, this);
|
|
62
62
|
this._map._container.classList.remove('maplair-box-zoom');
|
|
63
|
+
// cancel a box being drawn, as Escape does
|
|
64
|
+
this._finish();
|
|
65
|
+
this._resetState();
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
/**
|
|
@@ -116,12 +116,12 @@ export class DragHandler extends Handler {
|
|
|
116
116
|
map._stop();
|
|
117
117
|
map._setUserEvent(e.originalEvent);
|
|
118
118
|
if (this._map.options.maxBounds && this._map.options.maxBoundsViscosity) {
|
|
119
|
-
const bounds = LatLngBounds.from(this._map.options.maxBounds)
|
|
119
|
+
const bounds = LatLngBounds.from(this._map.options.maxBounds),
|
|
120
|
+
// any corner can be an extreme when the projection rotates the axes
|
|
121
|
+
corners = [bounds.getNorthWest(), bounds.getNorthEast(), bounds.getSouthEast(), bounds.getSouthWest()],
|
|
122
|
+
{min, max} = new Bounds(corners.map(c => this._map.latLngToContainerPoint(c)));
|
|
120
123
|
|
|
121
|
-
this._offsetLimit = new Bounds(
|
|
122
|
-
this._map.latLngToContainerPoint(bounds.getNorthWest()).multiplyBy(-1),
|
|
123
|
-
this._map.latLngToContainerPoint(bounds.getSouthEast()).multiplyBy(-1)
|
|
124
|
-
.add(this._map.getSize()));
|
|
124
|
+
this._offsetLimit = new Bounds(max.multiplyBy(-1), min.multiplyBy(-1).add(this._map.getSize()));
|
|
125
125
|
|
|
126
126
|
this._viscosity = Math.min(1.0, Math.max(0.0, this._map.options.maxBoundsViscosity));
|
|
127
127
|
} else {
|
|
@@ -150,7 +150,7 @@ export class PinchZoomHandler extends Handler {
|
|
|
150
150
|
|
|
151
151
|
// Pinch updates GridLayers' levels only when zoomSnap is off, so zoomSnap becomes noUpdate.
|
|
152
152
|
if (this._map._zoomAnimated) {
|
|
153
|
-
this._map._animateZoom(this._center, this._map._limitZoom(this._zoom),
|
|
153
|
+
this._map._animateZoom(this._center, this._map._limitZoom(this._zoom), this._map.options.zoomSnap);
|
|
154
154
|
} else {
|
|
155
155
|
this._map._resetView(this._center, this._map._limitZoom(this._zoom));
|
|
156
156
|
}
|
|
@@ -165,7 +165,7 @@ export class ScrollWheelZoomHandler extends Handler {
|
|
|
165
165
|
this._pinch = null;
|
|
166
166
|
|
|
167
167
|
if (map.options.zoomAnimation && Math.abs(zoom - map.getZoom()) > 1e-9) {
|
|
168
|
-
map._animateZoom(center, zoom,
|
|
168
|
+
map._animateZoom(center, zoom, map.options.zoomSnap);
|
|
169
169
|
} else {
|
|
170
170
|
// `_moveStart()` has already been called on the first event
|
|
171
171
|
map._move(center, zoom)._moveEnd(true);
|
|
@@ -187,7 +187,7 @@ export class TapDragZoomHandler extends Handler {
|
|
|
187
187
|
const map = this._map,
|
|
188
188
|
zoom = map._limitZoom(this._zoom);
|
|
189
189
|
if (map.options.zoomAnimation) {
|
|
190
|
-
map._animateZoom(this._center, zoom,
|
|
190
|
+
map._animateZoom(this._center, zoom, map.options.zoomSnap);
|
|
191
191
|
} else {
|
|
192
192
|
// `_moveStart()` has already been called on the first move
|
|
193
193
|
map._move(this._center, zoom)._moveEnd(true);
|