maplair 4.3.0 → 4.4.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 +89 -8
- package/dist/esm/control/AttributionControl.js +10 -10
- package/dist/esm/control/AttributionControl.js.map +1 -1
- package/dist/esm/control/ButtonControl.js +0 -1
- package/dist/esm/control/ButtonControl.js.map +1 -1
- package/dist/esm/control/ContextMenu.js +1 -1
- package/dist/esm/control/ContextMenu.js.map +1 -1
- package/dist/esm/control/Control.js +16 -11
- package/dist/esm/control/Control.js.map +1 -1
- package/dist/esm/control/FullscreenControl.js +0 -1
- package/dist/esm/control/FullscreenControl.js.map +1 -1
- package/dist/esm/control/LayersControl.js +13 -9
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/RotateControl.js +0 -1
- package/dist/esm/control/RotateControl.js.map +1 -1
- package/dist/esm/control/ScaleControl.js +4 -5
- package/dist/esm/control/ScaleControl.js.map +1 -1
- package/dist/esm/control/SideBySideControl.js +3 -2
- package/dist/esm/control/SideBySideControl.js.map +1 -1
- package/dist/esm/control/ZoomControl.js +13 -13
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Events.js +3 -2
- package/dist/esm/core/Events.js.map +1 -1
- package/dist/esm/core/Util.js +16 -4
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.PointerEvents.js +55 -2
- package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
- package/dist/esm/dom/DomEvent.js +4 -7
- package/dist/esm/dom/DomEvent.js.map +1 -1
- package/dist/esm/dom/DomUtil.js +5 -5
- package/dist/esm/dom/DomUtil.js.map +1 -1
- package/dist/esm/dom/Draggable.js +4 -6
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/geo/LatLng.js +23 -34
- package/dist/esm/geo/LatLng.js.map +1 -1
- package/dist/esm/geo/LatLngBounds.js +6 -3
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geometry/Bounds.js +2 -2
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/Point.js +12 -17
- package/dist/esm/geometry/Point.js.map +1 -1
- package/dist/esm/geometry/Transformation.js +1 -7
- package/dist/esm/geometry/Transformation.js.map +1 -1
- package/dist/esm/layer/BlanketOverlay.js +1 -1
- package/dist/esm/layer/BlanketOverlay.js.map +1 -1
- package/dist/esm/layer/DivOverlay.js +23 -23
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/ImageOverlay.js +7 -4
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +11 -6
- package/dist/esm/layer/Layer.js.map +1 -1
- package/dist/esm/layer/Popup.js +30 -11
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/Tooltip.js +18 -35
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/VideoOverlay.js +2 -2
- package/dist/esm/layer/VideoOverlay.js.map +1 -1
- package/dist/esm/layer/marker/DivIcon.js +4 -8
- package/dist/esm/layer/marker/DivIcon.js.map +1 -1
- package/dist/esm/layer/marker/Icon.js +16 -15
- package/dist/esm/layer/marker/Icon.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js +6 -7
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +49 -48
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/marker/SvgIcon.js +1 -1
- package/dist/esm/layer/marker/SvgIcon.js.map +1 -1
- package/dist/esm/layer/tile/GridLayer.js +18 -16
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +9 -9
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +44 -93
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +7 -7
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +9 -1
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.js +10 -5
- package/dist/esm/layer/vector/Path.js.map +1 -1
- package/dist/esm/layer/vector/Polygon.js +10 -11
- package/dist/esm/layer/vector/Polygon.js.map +1 -1
- package/dist/esm/layer/vector/Polyline.js +19 -26
- package/dist/esm/layer/vector/Polyline.js.map +1 -1
- package/dist/esm/layer/vector/Renderer.getRenderer.js +2 -1
- package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
- package/dist/esm/layer/vector/Renderer.js +16 -0
- package/dist/esm/layer/vector/Renderer.js.map +1 -1
- package/dist/esm/layer/vector/SVG.js +3 -3
- package/dist/esm/layer/vector/SVG.js.map +1 -1
- package/dist/esm/map/Map.Rotation.js +6 -9
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +104 -49
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/MapSync.js +1 -4
- 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/DisplaceHandler.js +68 -30
- package/dist/esm/map/handler/DisplaceHandler.js.map +1 -1
- package/dist/esm/map/handler/KeyboardHandler.js +3 -5
- package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +3 -6
- package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +3 -6
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/TapDragZoomHandler.js +1 -4
- package/dist/esm/map/handler/TapDragZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/TapHoldHandler.js +8 -20
- package/dist/esm/map/handler/TapHoldHandler.js.map +1 -1
- package/dist/esm/package.js +1 -1
- package/dist/maplair-global-src.js +698 -687
- 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 +698 -687
- 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/i18n/en.json +1 -0
- package/package.json +1 -1
- package/src/control/AttributionControl.js +9 -9
- package/src/control/ButtonControl.js +0 -1
- package/src/control/ContextMenu.js +1 -1
- package/src/control/Control.js +13 -16
- package/src/control/FullscreenControl.js +0 -1
- package/src/control/LayersControl.js +14 -10
- package/src/control/RotateControl.js +0 -1
- package/src/control/ScaleControl.js +4 -5
- package/src/control/SideBySideControl.js +4 -2
- package/src/control/ZoomControl.js +10 -13
- package/src/core/Events.js +6 -2
- package/src/core/Util.js +16 -3
- package/src/dom/DomEvent.PointerEvents.js +47 -1
- package/src/dom/DomEvent.js +5 -17
- package/src/dom/DomUtil.js +5 -5
- package/src/dom/Draggable.js +5 -6
- package/src/geo/LatLng.js +22 -36
- package/src/geo/LatLngBounds.js +10 -4
- package/src/geometry/Bounds.js +3 -3
- package/src/geometry/Point.js +18 -26
- package/src/geometry/Transformation.js +1 -8
- package/src/layer/BlanketOverlay.js +1 -1
- package/src/layer/DivOverlay.js +28 -30
- package/src/layer/ImageOverlay.js +9 -7
- package/src/layer/Layer.js +18 -6
- package/src/layer/Popup.js +38 -17
- package/src/layer/Tooltip.js +17 -44
- package/src/layer/VideoOverlay.js +2 -2
- package/src/layer/marker/DivIcon.js +3 -6
- package/src/layer/marker/Icon.js +19 -18
- package/src/layer/marker/Marker.Drag.js +16 -18
- package/src/layer/marker/Marker.js +66 -59
- package/src/layer/marker/SvgIcon.js +1 -1
- package/src/layer/tile/GridLayer.js +21 -23
- package/src/layer/tile/TileLayer.js +17 -14
- package/src/layer/vector/Canvas.js +52 -148
- package/src/layer/vector/Circle.js +11 -9
- package/src/layer/vector/CircleMarker.js +11 -1
- package/src/layer/vector/Path.js +11 -5
- package/src/layer/vector/Polygon.js +11 -10
- package/src/layer/vector/Polyline.js +20 -21
- package/src/layer/vector/Renderer.getRenderer.js +2 -1
- package/src/layer/vector/Renderer.js +21 -3
- package/src/layer/vector/SVG.js +3 -3
- package/src/map/Map.Rotation.js +7 -6
- package/src/map/Map.js +135 -54
- package/src/map/MapSync.js +1 -1
- package/src/map/handler/BoxZoomHandler.js +2 -0
- package/src/map/handler/DisplaceHandler.js +53 -7
- package/src/map/handler/KeyboardHandler.js +5 -10
- package/src/map/handler/PinchZoomHandler.js +3 -3
- package/src/map/handler/ScrollWheelZoomHandler.js +3 -3
- package/src/map/handler/TapDragZoomHandler.js +1 -1
- package/src/map/handler/TapHoldHandler.js +13 -25
- package/src/maplair.css +38 -9
- package/dist/esm/dom/DomEvent.DoubleTap.js +0 -90
- package/dist/esm/dom/DomEvent.DoubleTap.js.map +0 -1
- package/src/dom/DomEvent.DoubleTap.js +0 -143
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* Maplair 4.
|
|
2
|
+
* Maplair 4.4.0, a JS library for interactive maps. https://maplair.org
|
|
3
3
|
* (c) 2026 Simon Legner and Maplair contributors, (c) 2010-2026 Volodymyr Agafonkin, (c) 2010-2011 CloudMade
|
|
4
4
|
*/
|
|
5
5
|
(function (previousL) {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
return target;
|
|
19
19
|
};
|
|
20
20
|
// package.json
|
|
21
|
-
var version$1 = "4.
|
|
21
|
+
var version$1 = "4.4.0";
|
|
22
22
|
// src/core/Util.js
|
|
23
23
|
var Util_exports = /* @__PURE__ */ __exportAll({
|
|
24
24
|
falseFn: () => falseFn,
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
stamp: () => stamp,
|
|
30
30
|
template: () => template,
|
|
31
31
|
throttle: () => throttle,
|
|
32
|
+
toNumber: () => toNumber,
|
|
32
33
|
wrapNum: () => wrapNum
|
|
33
34
|
});
|
|
34
35
|
/**
|
|
@@ -103,11 +104,21 @@
|
|
|
103
104
|
* @param {number|false} [precision]
|
|
104
105
|
* @returns {number}
|
|
105
106
|
*/
|
|
106
|
-
function formatNum(num, precision) {
|
|
107
|
+
function formatNum(num, precision = 6) {
|
|
107
108
|
if (precision === false) return num;
|
|
108
|
-
const pow = 10 **
|
|
109
|
+
const pow = 10 ** precision;
|
|
109
110
|
return Math.round(num * pow) / pow;
|
|
110
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Returns `value` if it's a number (including `Infinity`), converts it if it's a
|
|
114
|
+
* numeric string, and returns `NaN` for anything else, unlike `Number()`, which turns
|
|
115
|
+
* `''`, `null` and booleans into `0` or `1`.
|
|
116
|
+
* @param {unknown} value
|
|
117
|
+
* @returns {number}
|
|
118
|
+
*/
|
|
119
|
+
function toNumber(value) {
|
|
120
|
+
return typeof value === "number" ? value : typeof value === "string" && value.trim() !== "" ? +value : NaN;
|
|
121
|
+
}
|
|
111
122
|
const WHITESPACE_RE = /\s+/;
|
|
112
123
|
/**
|
|
113
124
|
* Trims and splits the string on whitespace and returns the array of parts.
|
|
@@ -115,7 +126,8 @@
|
|
|
115
126
|
* @returns {string[]}
|
|
116
127
|
*/
|
|
117
128
|
function splitWords(str) {
|
|
118
|
-
|
|
129
|
+
const trimmed = str.trim();
|
|
130
|
+
return WHITESPACE_RE.test(trimmed) ? trimmed.split(WHITESPACE_RE) : [trimmed];
|
|
119
131
|
}
|
|
120
132
|
/**
|
|
121
133
|
* Merges the given properties to the `options` of the `obj` object, returning the
|
|
@@ -422,31 +434,25 @@
|
|
|
422
434
|
* @param {boolean} [round]
|
|
423
435
|
*/
|
|
424
436
|
constructor(x, y, round) {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
if (x instanceof Point) {
|
|
428
|
-
_x = x.x;
|
|
429
|
-
_y = x.y;
|
|
430
|
-
} else if (Array.isArray(x)) {
|
|
437
|
+
let _x = x, _y = y;
|
|
438
|
+
if (Array.isArray(x)) {
|
|
431
439
|
_x = x[0];
|
|
432
440
|
_y = x[1];
|
|
433
|
-
} else if (typeof x === "object" &&
|
|
441
|
+
} else if (typeof x === "object" && x !== null) {
|
|
434
442
|
_x = x.x;
|
|
435
443
|
_y = x.y;
|
|
436
|
-
} else {
|
|
437
|
-
_x = x;
|
|
438
|
-
_y = y;
|
|
439
444
|
}
|
|
440
445
|
/**
|
|
441
446
|
* The `x` coordinate of the point.
|
|
442
447
|
* @type {number}
|
|
443
448
|
*/
|
|
444
|
-
this.x = round ? Math.round(_x) : _x;
|
|
449
|
+
this.x = round ? Math.round(toNumber(_x)) : toNumber(_x);
|
|
445
450
|
/**
|
|
446
451
|
* The `y` coordinate of the point.
|
|
447
452
|
* @type {number}
|
|
448
453
|
*/
|
|
449
|
-
this.y = round ? Math.round(_y) : _y;
|
|
454
|
+
this.y = round ? Math.round(toNumber(_y)) : toNumber(_y);
|
|
455
|
+
if (this.x !== this.x || this.y !== this.y) throw new Error(`Invalid Point object: (${_x}, ${_y})`);
|
|
450
456
|
}
|
|
451
457
|
/**
|
|
452
458
|
* Returns the given `Point` object as it is (unless `round` is set), or else a new
|
|
@@ -474,10 +480,11 @@
|
|
|
474
480
|
* @returns {boolean}
|
|
475
481
|
*/
|
|
476
482
|
static validate(x, y) {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
483
|
+
try {
|
|
484
|
+
return !!new Point(x, y);
|
|
485
|
+
} catch {
|
|
486
|
+
return false;
|
|
487
|
+
}
|
|
481
488
|
}
|
|
482
489
|
/**
|
|
483
490
|
* Returns the result of addition of the current and the given points.
|
|
@@ -637,100 +644,15 @@
|
|
|
637
644
|
return `Point(${formatNum(this.x)}, ${formatNum(this.y)})`;
|
|
638
645
|
}
|
|
639
646
|
};
|
|
640
|
-
// src/dom/DomEvent.DoubleTap.js
|
|
641
|
-
function makeDblclick(ev) {
|
|
642
|
-
const init = {
|
|
643
|
-
bubbles: ev.bubbles,
|
|
644
|
-
cancelable: ev.cancelable,
|
|
645
|
-
composed: ev.composed,
|
|
646
|
-
detail: 2,
|
|
647
|
-
view: ev.view,
|
|
648
|
-
screenX: ev.screenX,
|
|
649
|
-
screenY: ev.screenY,
|
|
650
|
-
clientX: ev.clientX,
|
|
651
|
-
clientY: ev.clientY,
|
|
652
|
-
ctrlKey: ev.ctrlKey,
|
|
653
|
-
shiftKey: ev.shiftKey,
|
|
654
|
-
altKey: ev.altKey,
|
|
655
|
-
metaKey: ev.metaKey,
|
|
656
|
-
button: ev.button,
|
|
657
|
-
buttons: ev.buttons,
|
|
658
|
-
relatedTarget: ev.relatedTarget,
|
|
659
|
-
region: ev.region
|
|
660
|
-
};
|
|
661
|
-
let newEvent;
|
|
662
|
-
if (ev instanceof PointerEvent) newEvent = new PointerEvent("dblclick", {
|
|
663
|
-
...init,
|
|
664
|
-
pointerId: ev.pointerId,
|
|
665
|
-
width: ev.width,
|
|
666
|
-
height: ev.height,
|
|
667
|
-
pressure: ev.pressure,
|
|
668
|
-
tangentialPressure: ev.tangentialPressure,
|
|
669
|
-
tiltX: ev.tiltX,
|
|
670
|
-
tiltY: ev.tiltY,
|
|
671
|
-
twist: ev.twist,
|
|
672
|
-
pointerType: ev.pointerType,
|
|
673
|
-
isPrimary: ev.isPrimary
|
|
674
|
-
});
|
|
675
|
-
else newEvent = new MouseEvent("dblclick", init);
|
|
676
|
-
return newEvent;
|
|
677
|
-
}
|
|
678
|
-
const delay$1 = 200;
|
|
679
|
-
/**
|
|
680
|
-
* Adds a `dblclick` listener which also handles double taps (simulating `dblclick`
|
|
681
|
-
* on platforms which don't fire it for touch events).
|
|
682
|
-
* @param {EventTarget} obj
|
|
683
|
-
* @param {(ev: MouseEvent) => void} handler
|
|
684
|
-
* @returns {{dblclick: (ev: MouseEvent) => void, simDblclick: (ev: PointerEvent) => void}}
|
|
685
|
-
* The listeners to pass to `removeDoubleTapListener`.
|
|
686
|
-
*/
|
|
687
|
-
function addDoubleTapListener(obj, handler) {
|
|
688
|
-
obj.addEventListener("dblclick", handler);
|
|
689
|
-
let last = 0, detail, pointerType;
|
|
690
|
-
function onPointerDown(ev) {
|
|
691
|
-
pointerType = ev.pointerType;
|
|
692
|
-
}
|
|
693
|
-
function simDblclick(ev) {
|
|
694
|
-
if (ev.detail !== 1) {
|
|
695
|
-
detail = ev.detail;
|
|
696
|
-
return;
|
|
697
|
-
}
|
|
698
|
-
if (pointerType === "mouse" || ev.sourceCapabilities && !ev.sourceCapabilities.firesTouchEvents) return;
|
|
699
|
-
const path = ev.composedPath();
|
|
700
|
-
if (path.some((el) => el instanceof HTMLLabelElement && el.htmlFor) && !path.some((el) => el instanceof HTMLInputElement || el instanceof HTMLSelectElement)) return;
|
|
701
|
-
const now = Date.now();
|
|
702
|
-
if (now - last <= delay$1) {
|
|
703
|
-
detail++;
|
|
704
|
-
if (detail === 2) ev.target.dispatchEvent(makeDblclick(ev));
|
|
705
|
-
} else detail = 1;
|
|
706
|
-
last = now;
|
|
707
|
-
}
|
|
708
|
-
obj.addEventListener("pointerdown", onPointerDown, true);
|
|
709
|
-
obj.addEventListener("click", simDblclick);
|
|
710
|
-
return {
|
|
711
|
-
dblclick: handler,
|
|
712
|
-
onPointerDown,
|
|
713
|
-
simDblclick
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* Removes the listeners added by `addDoubleTapListener`.
|
|
718
|
-
* @param {EventTarget} obj
|
|
719
|
-
* @param {{dblclick: (ev: MouseEvent) => void, simDblclick: (ev: PointerEvent) => void}} handlers
|
|
720
|
-
* @returns {void}
|
|
721
|
-
*/
|
|
722
|
-
function removeDoubleTapListener(obj, handlers) {
|
|
723
|
-
obj.removeEventListener("dblclick", handlers.dblclick);
|
|
724
|
-
obj.removeEventListener("pointerdown", handlers.onPointerDown, true);
|
|
725
|
-
obj.removeEventListener("click", handlers.simDblclick);
|
|
726
|
-
}
|
|
727
647
|
// src/dom/DomEvent.PointerEvents.js
|
|
728
648
|
var DomEvent_PointerEvents_exports = /* @__PURE__ */ __exportAll({
|
|
729
649
|
disablePointerDetection: () => disablePointerDetection,
|
|
730
650
|
enablePointerDetection: () => enablePointerDetection,
|
|
731
|
-
getPointers: () => getPointers
|
|
651
|
+
getPointers: () => getPointers,
|
|
652
|
+
simulateDblclick: () => simulateDblclick
|
|
732
653
|
});
|
|
733
654
|
const activePointers = /* @__PURE__ */ new Map();
|
|
655
|
+
let lastPointerType;
|
|
734
656
|
/**
|
|
735
657
|
* Enables pointer detection and capture for the document.
|
|
736
658
|
* @group Pointer detection
|
|
@@ -759,6 +681,7 @@
|
|
|
759
681
|
function _onSet(e) {
|
|
760
682
|
if (e.isTrusted) e.target.setPointerCapture(e.pointerId);
|
|
761
683
|
activePointers.set(e.pointerId, e);
|
|
684
|
+
lastPointerType = e.pointerType;
|
|
762
685
|
}
|
|
763
686
|
function _onUpdate(e) {
|
|
764
687
|
if (activePointers.has(e.pointerId)) activePointers.set(e.pointerId, e);
|
|
@@ -775,6 +698,56 @@
|
|
|
775
698
|
function getPointers() {
|
|
776
699
|
return [...activePointers.values()];
|
|
777
700
|
}
|
|
701
|
+
const dblclickProps = [
|
|
702
|
+
"bubbles",
|
|
703
|
+
"cancelable",
|
|
704
|
+
"composed",
|
|
705
|
+
"view",
|
|
706
|
+
"screenX",
|
|
707
|
+
"screenY",
|
|
708
|
+
"clientX",
|
|
709
|
+
"clientY",
|
|
710
|
+
"ctrlKey",
|
|
711
|
+
"shiftKey",
|
|
712
|
+
"altKey",
|
|
713
|
+
"metaKey",
|
|
714
|
+
"button",
|
|
715
|
+
"buttons",
|
|
716
|
+
"relatedTarget"
|
|
717
|
+
];
|
|
718
|
+
let lastClickTime = 0;
|
|
719
|
+
let lastClick;
|
|
720
|
+
let lastClickMap;
|
|
721
|
+
let clickCount = 0;
|
|
722
|
+
/**
|
|
723
|
+
* Fires a `dblclick` on double tap where the browser doesn't (like iOS Safari),
|
|
724
|
+
* which is where it always reports `detail: 1` on clicks (see Leaflet#7012). The
|
|
725
|
+
* pointer type comes from `pointerdown`, because iOS Safari reports `mouse` on
|
|
726
|
+
* clicks from touch (WebKit bug 282988). Called by the map for clicks in it.
|
|
727
|
+
* @internal
|
|
728
|
+
* @param {MouseEvent} e
|
|
729
|
+
* @param {HTMLElement} mapContainer The container of the map, two taps make a double
|
|
730
|
+
* tap only in the same map.
|
|
731
|
+
* @returns {void}
|
|
732
|
+
*/
|
|
733
|
+
function simulateDblclick(e, mapContainer) {
|
|
734
|
+
if (e === lastClick) return;
|
|
735
|
+
lastClick = e;
|
|
736
|
+
const target = e.target;
|
|
737
|
+
if (e.detail !== 1 || lastPointerType === "mouse" || target.closest("label")) {
|
|
738
|
+
clickCount = 0;
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
const now = Date.now();
|
|
742
|
+
clickCount = now - lastClickTime <= 200 && mapContainer === lastClickMap ? clickCount + 1 : 1;
|
|
743
|
+
lastClickTime = now;
|
|
744
|
+
lastClickMap = mapContainer;
|
|
745
|
+
if (clickCount === 2) {
|
|
746
|
+
const init = { detail: 2 };
|
|
747
|
+
for (const prop of dblclickProps) init[prop] = e[prop];
|
|
748
|
+
target.dispatchEvent(new MouseEvent("dblclick", init));
|
|
749
|
+
}
|
|
750
|
+
}
|
|
778
751
|
// src/dom/DomEvent.js
|
|
779
752
|
var DomEvent_exports = /* @__PURE__ */ __exportAll({
|
|
780
753
|
PointerEvents: () => DomEvent_PointerEvents_exports,
|
|
@@ -842,11 +815,10 @@
|
|
|
842
815
|
function addOne(obj, type, fn, context) {
|
|
843
816
|
const id = type + stamp(fn) + (context ? `_${stamp(context)}` : "");
|
|
844
817
|
if (obj[eventsKey] && obj[eventsKey][id]) return;
|
|
845
|
-
|
|
818
|
+
const handler = function(e) {
|
|
846
819
|
return fn.call(context || obj, e);
|
|
847
820
|
};
|
|
848
|
-
|
|
849
|
-
else obj.addEventListener(type, handler, type === "wheel" ? { passive: false } : false);
|
|
821
|
+
obj.addEventListener(type, handler, type === "wheel" ? { passive: false } : false);
|
|
850
822
|
obj[eventsKey] ??= {};
|
|
851
823
|
obj[eventsKey][id] = handler;
|
|
852
824
|
}
|
|
@@ -854,8 +826,7 @@
|
|
|
854
826
|
id ??= type + stamp(fn) + (context ? `_${stamp(context)}` : "");
|
|
855
827
|
const handler = obj[eventsKey] && obj[eventsKey][id];
|
|
856
828
|
if (!handler) return;
|
|
857
|
-
|
|
858
|
-
else obj.removeEventListener(type, handler, false);
|
|
829
|
+
obj.removeEventListener(type, handler, false);
|
|
859
830
|
obj[eventsKey][id] = null;
|
|
860
831
|
}
|
|
861
832
|
/**
|
|
@@ -941,7 +912,7 @@
|
|
|
941
912
|
* @returns {number}
|
|
942
913
|
*/
|
|
943
914
|
function getWheelDelta(e) {
|
|
944
|
-
return e.deltaY
|
|
915
|
+
return -e.deltaY * (e.deltaMode ? e.deltaMode === 1 ? 20 : 60 : 1 / getWheelPxFactor()) || 0;
|
|
945
916
|
}
|
|
946
917
|
/**
|
|
947
918
|
* Checks if the pointer really left/entered the element `el` (for
|
|
@@ -988,7 +959,7 @@
|
|
|
988
959
|
function create(tagName, className, container) {
|
|
989
960
|
const el = document.createElement(tagName);
|
|
990
961
|
el.className = className ?? "";
|
|
991
|
-
container?.
|
|
962
|
+
container?.append(el);
|
|
992
963
|
return el;
|
|
993
964
|
}
|
|
994
965
|
/**
|
|
@@ -1000,8 +971,8 @@
|
|
|
1000
971
|
function toFront(el) {
|
|
1001
972
|
const parent = el.parentNode;
|
|
1002
973
|
if (!parent || parent.lastChild === el) return;
|
|
1003
|
-
if (el.matches(":hover")) while (el.nextSibling)
|
|
1004
|
-
else parent.
|
|
974
|
+
if (el.matches(":hover")) while (el.nextSibling) el.before(el.nextSibling);
|
|
975
|
+
else parent.append(el);
|
|
1005
976
|
}
|
|
1006
977
|
/**
|
|
1007
978
|
* Makes `el` the first child of its parent, so it renders behind the other children.
|
|
@@ -1011,8 +982,8 @@
|
|
|
1011
982
|
function toBack(el) {
|
|
1012
983
|
const parent = el.parentNode;
|
|
1013
984
|
if (!parent || parent.firstChild === el) return;
|
|
1014
|
-
if (el.matches(":hover")) while (el.previousSibling)
|
|
1015
|
-
else parent.
|
|
985
|
+
if (el.matches(":hover")) while (el.previousSibling) el.after(el.previousSibling);
|
|
986
|
+
else parent.prepend(el);
|
|
1016
987
|
}
|
|
1017
988
|
/**
|
|
1018
989
|
* Resets the 3D CSS transform of `el` so it is translated by `offset` pixels
|
|
@@ -1151,12 +1122,16 @@
|
|
|
1151
1122
|
* @property {(map: MaplairMap) => void} [onRemove] Should contain all clean up code that
|
|
1152
1123
|
* removes the listeners previously added in `onAdd`. Called on
|
|
1153
1124
|
* [`control.remove()`](#control-remove).
|
|
1125
|
+
* @property {() => Record<string, Function>} [getEvents] Should return an object like
|
|
1126
|
+
* `{zoomend: this._update}` for [`on`](#evented-on). The event handlers in this object
|
|
1127
|
+
* will be automatically added and removed from the map with your control.
|
|
1154
1128
|
* @lends Control
|
|
1155
1129
|
*/
|
|
1156
1130
|
const controlOrders = /* @__PURE__ */ new WeakMap();
|
|
1157
1131
|
/**
|
|
1158
|
-
*
|
|
1159
|
-
*
|
|
1132
|
+
* Base class for map controls such as `ZoomControl`, `AttributionControl`,
|
|
1133
|
+
* `LayersControl` and `ScaleControl`, which handles positioning them. Extend it to
|
|
1134
|
+
* create your own controls.
|
|
1160
1135
|
*
|
|
1161
1136
|
* Every control should extend from `Control` and (re-)implement the following methods:
|
|
1162
1137
|
*
|
|
@@ -1166,6 +1141,9 @@
|
|
|
1166
1141
|
* * `onRemove(map: MaplairMap)` (optional) should contain all clean up code that removes
|
|
1167
1142
|
* the listeners previously added in [`onAdd`](#control-onadd). Called on
|
|
1168
1143
|
* [`control.remove()`](#control-remove).
|
|
1144
|
+
* * `getEvents(): Object` (optional) should return an object like
|
|
1145
|
+
* `{zoomend: this._update}` for [`on`](#evented-on). The event handlers in this
|
|
1146
|
+
* object will be automatically added and removed from the map with your control.
|
|
1169
1147
|
*/
|
|
1170
1148
|
var Control = class Control extends Class {
|
|
1171
1149
|
static defaultOptions = {
|
|
@@ -1219,7 +1197,11 @@
|
|
|
1219
1197
|
const order = this.options.order ?? 0, bottom = pos.includes("bottom"), children = [...corner.children];
|
|
1220
1198
|
controlOrders.set(container, order);
|
|
1221
1199
|
corner.insertBefore(container, children.find((el) => bottom ? (controlOrders.get(el) ?? 0) <= order : (controlOrders.get(el) ?? 0) > order) ?? null);
|
|
1222
|
-
this.
|
|
1200
|
+
this._mapEvents = {
|
|
1201
|
+
...this.getEvents?.(),
|
|
1202
|
+
unload: this.remove
|
|
1203
|
+
};
|
|
1204
|
+
map.on(this._mapEvents, this);
|
|
1223
1205
|
return this;
|
|
1224
1206
|
}
|
|
1225
1207
|
/**
|
|
@@ -1229,17 +1211,11 @@
|
|
|
1229
1211
|
remove() {
|
|
1230
1212
|
if (!this._map) return this;
|
|
1231
1213
|
this._container.remove();
|
|
1232
|
-
|
|
1233
|
-
this.
|
|
1214
|
+
this._map.off(this._mapEvents, this);
|
|
1215
|
+
this.onRemove?.(this._map);
|
|
1234
1216
|
this._map = null;
|
|
1235
1217
|
return this;
|
|
1236
1218
|
}
|
|
1237
|
-
_refocusOnMap(e) {
|
|
1238
|
-
if (this._map && e && !(e.screenX === 0 && e.screenY === 0)) this._map.getContainer().focus({
|
|
1239
|
-
preventScroll: true,
|
|
1240
|
-
focusVisible: false
|
|
1241
|
-
});
|
|
1242
|
-
}
|
|
1243
1219
|
/**
|
|
1244
1220
|
* Registers this default feature on the map class, called by `MaplairMap` itself.
|
|
1245
1221
|
* @internal
|
|
@@ -1385,21 +1361,22 @@
|
|
|
1385
1361
|
disableClickPropagation(this._container);
|
|
1386
1362
|
if (map._loaded) map.eachLayer((layer) => this._addLayer({ layer }));
|
|
1387
1363
|
this._update();
|
|
1388
|
-
map.on({
|
|
1389
|
-
layeradd: this._addLayer,
|
|
1390
|
-
layerremove: this._removeLayer
|
|
1391
|
-
}, this);
|
|
1392
1364
|
return this._container;
|
|
1393
1365
|
}
|
|
1394
1366
|
/**
|
|
1395
1367
|
* @internal
|
|
1396
|
-
* @
|
|
1368
|
+
* @returns {Record<string, Function>}
|
|
1397
1369
|
*/
|
|
1398
|
-
|
|
1399
|
-
|
|
1370
|
+
getEvents() {
|
|
1371
|
+
return {
|
|
1400
1372
|
layeradd: this._addLayer,
|
|
1401
1373
|
layerremove: this._removeLayer
|
|
1402
|
-
}
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
/**
|
|
1377
|
+
* @internal
|
|
1378
|
+
*/
|
|
1379
|
+
onRemove() {
|
|
1403
1380
|
for (const layer of this._layerAttributions.keys()) this._removeLayer({ layer });
|
|
1404
1381
|
}
|
|
1405
1382
|
_addLayer({ layer }) {
|
|
@@ -1433,8 +1410,7 @@
|
|
|
1433
1410
|
addAttribution(text, order = 0) {
|
|
1434
1411
|
if (!text) return this;
|
|
1435
1412
|
this._orders[text] = order;
|
|
1436
|
-
|
|
1437
|
-
this._attributions[text]++;
|
|
1413
|
+
this._attributions[text] = (this._attributions[text] || 0) + 1;
|
|
1438
1414
|
this._update();
|
|
1439
1415
|
return this;
|
|
1440
1416
|
}
|
|
@@ -1569,7 +1545,6 @@
|
|
|
1569
1545
|
disableClickPropagation(button);
|
|
1570
1546
|
on(button, "click", stop);
|
|
1571
1547
|
on(button, "click", this._onClick, this);
|
|
1572
|
-
on(button, "click", this._refocusOnMap, this);
|
|
1573
1548
|
this._update();
|
|
1574
1549
|
return button;
|
|
1575
1550
|
}
|
|
@@ -1931,8 +1906,9 @@
|
|
|
1931
1906
|
};
|
|
1932
1907
|
if (_once) newListener.once = true;
|
|
1933
1908
|
this._events ??= {};
|
|
1934
|
-
this._events[type] ??= /* @__PURE__ */ new Set();
|
|
1935
|
-
this._events[type]
|
|
1909
|
+
let listeners = this._events[type] ??= /* @__PURE__ */ new Set();
|
|
1910
|
+
if (this._firingCount) this._events[type] = listeners = new Set(listeners);
|
|
1911
|
+
listeners.add(newListener);
|
|
1936
1912
|
if (contexts) contexts.set(context, newListener);
|
|
1937
1913
|
else this._listenerIndex[type].set(fn, /* @__PURE__ */ new Map([[context, newListener]]));
|
|
1938
1914
|
}
|
|
@@ -2207,8 +2183,8 @@
|
|
|
2207
2183
|
const oldZoomSpan = this._getZoomSpan();
|
|
2208
2184
|
for (const l of Object.values(this._zoomBoundLayers)) {
|
|
2209
2185
|
const options = l.options;
|
|
2210
|
-
minZoom = Math.min(minZoom, options.minZoom
|
|
2211
|
-
maxZoom = Math.max(maxZoom, options.maxZoom
|
|
2186
|
+
if (options.minZoom != null && !Number.isNaN(options.minZoom)) minZoom = Math.min(minZoom, options.minZoom);
|
|
2187
|
+
if (options.maxZoom != null && !Number.isNaN(options.maxZoom)) maxZoom = Math.max(maxZoom, options.maxZoom);
|
|
2212
2188
|
}
|
|
2213
2189
|
this._layersMaxZoom = maxZoom === -Infinity ? void 0 : maxZoom;
|
|
2214
2190
|
this._layersMinZoom = minZoom === Infinity ? void 0 : minZoom;
|
|
@@ -2330,8 +2306,10 @@
|
|
|
2330
2306
|
}
|
|
2331
2307
|
_updateInteractive() {}
|
|
2332
2308
|
/**
|
|
2333
|
-
*
|
|
2334
|
-
*
|
|
2309
|
+
* Registers `targetEl`, one of the layer's DOM elements, so that pointer, click and
|
|
2310
|
+
* keyboard events on it (or its descendants) fire on the layer and bubble through its
|
|
2311
|
+
* parent groups to the map, the way they do for markers and paths. Custom layers call
|
|
2312
|
+
* it in [`onAdd`](#layer-onadd), once the layer is on a map.
|
|
2335
2313
|
* @param {HTMLElement} targetEl
|
|
2336
2314
|
* @returns {this}
|
|
2337
2315
|
*/
|
|
@@ -2340,8 +2318,8 @@
|
|
|
2340
2318
|
return this;
|
|
2341
2319
|
}
|
|
2342
2320
|
/**
|
|
2343
|
-
*
|
|
2344
|
-
*
|
|
2321
|
+
* Undoes [`addInteractiveTarget`](#layer-addinteractivetarget), typically in
|
|
2322
|
+
* [`onRemove`](#layer-onremove).
|
|
2345
2323
|
* @param {HTMLElement} targetEl
|
|
2346
2324
|
* @returns {this}
|
|
2347
2325
|
*/
|
|
@@ -2349,6 +2327,9 @@
|
|
|
2349
2327
|
delete this._map._targets[stamp(targetEl)];
|
|
2350
2328
|
return this;
|
|
2351
2329
|
}
|
|
2330
|
+
_togglesPopupOnClick() {
|
|
2331
|
+
return true;
|
|
2332
|
+
}
|
|
2352
2333
|
/**
|
|
2353
2334
|
* Used by the `attribution control`, returns the [attribution option](#layeroptions-attribution).
|
|
2354
2335
|
* @returns {string|null}
|
|
@@ -2516,7 +2497,7 @@
|
|
|
2516
2497
|
}
|
|
2517
2498
|
_createMenu(parent) {
|
|
2518
2499
|
const container = this._container ??= create("div", `maplair-contextmenu ${this.options.className}`);
|
|
2519
|
-
if (container.parentNode !== parent) parent.
|
|
2500
|
+
if (container.parentNode !== parent) parent.append(container);
|
|
2520
2501
|
container.popover = "auto";
|
|
2521
2502
|
container.setAttribute("role", "menu");
|
|
2522
2503
|
container.replaceChildren();
|
|
@@ -2683,7 +2664,6 @@
|
|
|
2683
2664
|
disableClickPropagation(button);
|
|
2684
2665
|
on(button, "click", stop);
|
|
2685
2666
|
on(button, "click", this._toggleFullscreen, this);
|
|
2686
|
-
on(button, "click", this._refocusOnMap, this);
|
|
2687
2667
|
this._update();
|
|
2688
2668
|
map.on("fullscreenchange", this._update, this);
|
|
2689
2669
|
return container;
|
|
@@ -2767,6 +2747,8 @@
|
|
|
2767
2747
|
* `maplair-control-layers-group-name` element, and each entry shows only its label.
|
|
2768
2748
|
* Events like `baselayerchange` still carry the full `name`. When combined with
|
|
2769
2749
|
* `sortLayers`, the entries are sorted first and grouped afterwards.
|
|
2750
|
+
* @property {string} [title] The title of the toggle button and the accessible label
|
|
2751
|
+
* of the layers list, the translation of `'Layers'` by default.
|
|
2770
2752
|
* @property {string|HTMLElement} [toggleContent] The content of the toggle button of a
|
|
2771
2753
|
* collapsed control instead of the layers icon: HTML (e.g. an icon or a character) or an
|
|
2772
2754
|
* element. String content is rendered as HTML; do not pass untrusted input.
|
|
@@ -2851,6 +2833,7 @@
|
|
|
2851
2833
|
collapsed: true,
|
|
2852
2834
|
inline: false,
|
|
2853
2835
|
groupBy: void 0,
|
|
2836
|
+
title: void 0,
|
|
2854
2837
|
toggleContent: void 0,
|
|
2855
2838
|
collapseDelay: 0,
|
|
2856
2839
|
position: "topright",
|
|
@@ -2997,13 +2980,16 @@
|
|
|
2997
2980
|
else this._container.classList.remove("maplair-control-layers-expanded");
|
|
2998
2981
|
return this;
|
|
2999
2982
|
}
|
|
2983
|
+
_getTitle() {
|
|
2984
|
+
return this.options.title ?? I18n.translate("Layers");
|
|
2985
|
+
}
|
|
3000
2986
|
_initLayout() {
|
|
3001
2987
|
const className = "maplair-control-layers", container = this._container = create("div", className), collapsed = this._isCollapsible();
|
|
3002
2988
|
if (this.options.inline) container.classList.add(`${className}-inline`);
|
|
3003
2989
|
disableClickPropagation(container);
|
|
3004
2990
|
disableScrollPropagation(container);
|
|
3005
2991
|
const section = this._section = create("fieldset", `${className}-list`);
|
|
3006
|
-
section.setAttribute("aria-label",
|
|
2992
|
+
section.setAttribute("aria-label", this._getTitle());
|
|
3007
2993
|
if (collapsed) {
|
|
3008
2994
|
this._map.on("click", this.collapse, this);
|
|
3009
2995
|
on(container, {
|
|
@@ -3016,8 +3002,8 @@
|
|
|
3016
3002
|
if (!this.options.inline) {
|
|
3017
3003
|
const link = this._layersLink = create("button", `${className}-toggle`, container);
|
|
3018
3004
|
link.type = "button";
|
|
3019
|
-
link.title =
|
|
3020
|
-
link.setAttribute("aria-label",
|
|
3005
|
+
link.title = this._getTitle();
|
|
3006
|
+
link.setAttribute("aria-label", link.title);
|
|
3021
3007
|
const { toggleContent } = this.options;
|
|
3022
3008
|
if (typeof toggleContent === "string") link.innerHTML = toggleContent;
|
|
3023
3009
|
else if (toggleContent) link.replaceChildren(toggleContent);
|
|
@@ -3035,7 +3021,7 @@
|
|
|
3035
3021
|
this._baseLayersList = create("div", `${className}-base`, section);
|
|
3036
3022
|
this._separator = create("div", `${className}-separator`, section);
|
|
3037
3023
|
this._overlaysList = create("div", `${className}-overlays`, section);
|
|
3038
|
-
container.
|
|
3024
|
+
container.append(section);
|
|
3039
3025
|
}
|
|
3040
3026
|
_addLayer(layer, name, overlay) {
|
|
3041
3027
|
if (this._map) layer.on("add remove", this._onLayerChange, this);
|
|
@@ -3094,11 +3080,10 @@
|
|
|
3094
3080
|
const name = document.createElement("span");
|
|
3095
3081
|
name.innerHTML = ` ${group ? group.label : obj.name}`;
|
|
3096
3082
|
const holder = document.createElement("span");
|
|
3097
|
-
label.
|
|
3098
|
-
holder.
|
|
3099
|
-
holder.appendChild(name);
|
|
3083
|
+
label.append(holder);
|
|
3084
|
+
holder.append(input, name);
|
|
3100
3085
|
const list = obj.overlay ? this._overlaysList : this._baseLayersList;
|
|
3101
|
-
(group ? this._getGroupContainer(list, group.group) : list).
|
|
3086
|
+
(group ? this._getGroupContainer(list, group.group) : list).append(label);
|
|
3102
3087
|
this._checkDisabledLayers();
|
|
3103
3088
|
return label;
|
|
3104
3089
|
}
|
|
@@ -3139,7 +3124,6 @@
|
|
|
3139
3124
|
this._update();
|
|
3140
3125
|
break;
|
|
3141
3126
|
}
|
|
3142
|
-
this._refocusOnMap(e);
|
|
3143
3127
|
}
|
|
3144
3128
|
_checkDisabledLayers() {
|
|
3145
3129
|
const inputs = this._layerControlInputs, zoom = this._map.getZoom();
|
|
@@ -3332,7 +3316,7 @@
|
|
|
3332
3316
|
*/
|
|
3333
3317
|
overlaps(bounds) {
|
|
3334
3318
|
bounds = Bounds.from(bounds);
|
|
3335
|
-
const min = this.min, max = this.max, min2 = bounds.min, max2 = bounds.max, xOverlaps =
|
|
3319
|
+
const min = this.min, max = this.max, min2 = bounds.min, max2 = bounds.max, xOverlaps = Math.max(min.x, min2.x) < Math.min(max.x, max2.x), yOverlaps = Math.max(min.y, min2.y) < Math.min(max.y, max2.y);
|
|
3336
3320
|
return xOverlaps && yOverlaps;
|
|
3337
3321
|
}
|
|
3338
3322
|
/**
|
|
@@ -3365,7 +3349,7 @@
|
|
|
3365
3349
|
}
|
|
3366
3350
|
};
|
|
3367
3351
|
function isPointExpression(obj) {
|
|
3368
|
-
return obj instanceof Point || (Array.isArray(obj) ? typeof obj[0]
|
|
3352
|
+
return obj instanceof Point || (Array.isArray(obj) ? typeof obj[0] !== "object" : "x" in obj);
|
|
3369
3353
|
}
|
|
3370
3354
|
// src/layer/BlanketOverlay.js
|
|
3371
3355
|
/** @import {LayerOptions} from './Layer.js' */
|
|
@@ -3428,7 +3412,7 @@
|
|
|
3428
3412
|
this._initContainer();
|
|
3429
3413
|
this._container.classList.add("maplair-zoom-animated");
|
|
3430
3414
|
}
|
|
3431
|
-
this.getPane().
|
|
3415
|
+
this.getPane().append(this._container);
|
|
3432
3416
|
this._resizeContainer();
|
|
3433
3417
|
this._onMoveEnd();
|
|
3434
3418
|
}
|
|
@@ -3500,6 +3484,8 @@
|
|
|
3500
3484
|
/** @import {BlanketOverlayOptions} from '../BlanketOverlay.js' */
|
|
3501
3485
|
/** @import {MaplairEvent} from '../../core/Events.js' */
|
|
3502
3486
|
/** @import {MaplairMap} from '../../map/Map.js' */
|
|
3487
|
+
/** @import {LatLngExpression} from '../../geo/LatLng.js' */
|
|
3488
|
+
/** @import {Point} from '../../geometry/Point.js' */
|
|
3503
3489
|
/**
|
|
3504
3490
|
* Options of `Renderer`, `SVG` and `Canvas`. The `continuous` option inherited from
|
|
3505
3491
|
* `BlanketOverlay` cannot be set to `true`.
|
|
@@ -3541,6 +3527,7 @@
|
|
|
3541
3527
|
* @param {MaplairMap} map
|
|
3542
3528
|
*/
|
|
3543
3529
|
onAdd(map) {
|
|
3530
|
+
this._setPathView();
|
|
3544
3531
|
super.onAdd(map);
|
|
3545
3532
|
this.on("update", this._updatePaths, this);
|
|
3546
3533
|
}
|
|
@@ -3552,12 +3539,25 @@
|
|
|
3552
3539
|
this.off("update", this._updatePaths, this);
|
|
3553
3540
|
}
|
|
3554
3541
|
_onZoomEnd() {
|
|
3542
|
+
this._setPathView();
|
|
3555
3543
|
for (const layer of Object.values(this._layers)) layer._project();
|
|
3556
3544
|
}
|
|
3545
|
+
_setPathView() {
|
|
3546
|
+
this._pathZoom = this._map.getZoom();
|
|
3547
|
+
this._pathOrigin = this._map.getPixelOrigin();
|
|
3548
|
+
}
|
|
3549
|
+
/**
|
|
3550
|
+
* @param {LatLngExpression} latlng
|
|
3551
|
+
* @returns {Point}
|
|
3552
|
+
*/
|
|
3553
|
+
_latLngToLayerPoint(latlng) {
|
|
3554
|
+
return this._map.project(latlng, this._pathZoom)._subtract(this._pathOrigin);
|
|
3555
|
+
}
|
|
3557
3556
|
_updatePaths() {
|
|
3558
3557
|
for (const layer of Object.values(this._layers)) layer._update();
|
|
3559
3558
|
}
|
|
3560
3559
|
_onViewReset() {
|
|
3560
|
+
this._setPathView();
|
|
3561
3561
|
for (const layer of Object.values(this._layers)) layer._reset();
|
|
3562
3562
|
}
|
|
3563
3563
|
_onSettled() {
|
|
@@ -3607,7 +3607,7 @@
|
|
|
3607
3607
|
this._container = SVG.create("svg");
|
|
3608
3608
|
this._container.setAttribute("pointer-events", "none");
|
|
3609
3609
|
this._rootGroup = SVG.create("g");
|
|
3610
|
-
this._container.
|
|
3610
|
+
this._container.append(this._rootGroup);
|
|
3611
3611
|
}
|
|
3612
3612
|
_destroyContainer() {
|
|
3613
3613
|
super._destroyContainer();
|
|
@@ -3616,7 +3616,7 @@
|
|
|
3616
3616
|
}
|
|
3617
3617
|
_resizeContainer() {
|
|
3618
3618
|
const size = super._resizeContainer();
|
|
3619
|
-
if (!this._svgSize
|
|
3619
|
+
if (!this._svgSize?.equals(size)) {
|
|
3620
3620
|
this._svgSize = size;
|
|
3621
3621
|
this._container.setAttribute("width", `${size.x}`);
|
|
3622
3622
|
this._container.setAttribute("height", `${size.y}`);
|
|
@@ -3652,7 +3652,7 @@
|
|
|
3652
3652
|
}
|
|
3653
3653
|
_addPath(layer) {
|
|
3654
3654
|
if (!this._rootGroup) this._initContainer();
|
|
3655
|
-
this._rootGroup.
|
|
3655
|
+
this._rootGroup.append(layer._path);
|
|
3656
3656
|
layer.addInteractiveTarget(layer._path);
|
|
3657
3657
|
}
|
|
3658
3658
|
_removePath(layer) {
|
|
@@ -3761,13 +3761,15 @@
|
|
|
3761
3761
|
* Applied when the element is created; [`setStyle`](#path-setstyle) does not update it
|
|
3762
3762
|
* afterwards.
|
|
3763
3763
|
* @property {Renderer} [renderer] Use this specific instance of `Renderer` for this
|
|
3764
|
-
* path. If not set, the path uses the map's [renderer](#maplairmapoptions-renderer)
|
|
3765
|
-
*
|
|
3764
|
+
* path. If not set, the path uses the map's [renderer](#maplairmapoptions-renderer)
|
|
3765
|
+
* (`SVG` by default), or in a custom pane, a renderer of the same kind created for
|
|
3766
|
+
* that pane. If set, it overrides the `pane` option.
|
|
3766
3767
|
* @extends InteractiveLayerOptions
|
|
3767
3768
|
*/
|
|
3768
3769
|
/**
|
|
3769
|
-
* An abstract class that contains options and
|
|
3770
|
-
*
|
|
3770
|
+
* An abstract class that contains options and methods shared between vector overlays
|
|
3771
|
+
* (`Polyline`, `Polygon`, `Rectangle`, `Circle`, `CircleMarker`). Do not use it
|
|
3772
|
+
* directly. Extends `Layer`.
|
|
3771
3773
|
*/
|
|
3772
3774
|
var Path = class extends Layer {
|
|
3773
3775
|
static defaultOptions = {
|
|
@@ -3864,8 +3866,11 @@
|
|
|
3864
3866
|
this._project();
|
|
3865
3867
|
this._update();
|
|
3866
3868
|
}
|
|
3869
|
+
_togglesPopupOnClick() {
|
|
3870
|
+
return false;
|
|
3871
|
+
}
|
|
3867
3872
|
_clickTolerance() {
|
|
3868
|
-
return (this.options.stroke ? this.options.weight / 2 : 0) + (this._renderer.options.tolerance || 0);
|
|
3873
|
+
return (this.options.stroke ? this.options.weight / 2 || 0 : 0) + (this._renderer.options.tolerance || 0);
|
|
3869
3874
|
}
|
|
3870
3875
|
};
|
|
3871
3876
|
// src/geo/LatLngBounds.js
|
|
@@ -3953,7 +3958,7 @@
|
|
|
3953
3958
|
({_southWest: sw2, _northEast: ne2} = obj);
|
|
3954
3959
|
if (!sw2) return this;
|
|
3955
3960
|
} else if (!obj) return this;
|
|
3956
|
-
else if (
|
|
3961
|
+
else if (isLatLngExpression(obj)) sw2 = ne2 = LatLng.from(obj);
|
|
3957
3962
|
else return this.extend(LatLngBounds.from(obj));
|
|
3958
3963
|
if (!sw) {
|
|
3959
3964
|
this._southWest = new LatLng(sw2.lat, sw2.lng);
|
|
@@ -4046,7 +4051,7 @@
|
|
|
4046
4051
|
* @returns {boolean}
|
|
4047
4052
|
*/
|
|
4048
4053
|
contains(obj) {
|
|
4049
|
-
if (
|
|
4054
|
+
if (isLatLngExpression(obj)) obj = LatLng.from(obj);
|
|
4050
4055
|
else obj = LatLngBounds.from(obj);
|
|
4051
4056
|
const sw = this._southWest, ne = this._northEast;
|
|
4052
4057
|
let sw2, ne2;
|
|
@@ -4075,7 +4080,7 @@
|
|
|
4075
4080
|
*/
|
|
4076
4081
|
overlaps(bounds) {
|
|
4077
4082
|
bounds = LatLngBounds.from(bounds);
|
|
4078
|
-
const sw = this._southWest, ne = this._northEast, sw2 = bounds.getSouthWest(), ne2 = bounds.getNorthEast(), latOverlaps =
|
|
4083
|
+
const sw = this._southWest, ne = this._northEast, sw2 = bounds.getSouthWest(), ne2 = bounds.getNorthEast(), latOverlaps = Math.max(sw.lat, sw2.lat) < Math.min(ne.lat, ne2.lat), lngOverlaps = Math.max(sw.lng, sw2.lng) < Math.min(ne.lng, ne2.lng);
|
|
4079
4084
|
return latOverlaps && lngOverlaps;
|
|
4080
4085
|
}
|
|
4081
4086
|
/**
|
|
@@ -4113,6 +4118,9 @@
|
|
|
4113
4118
|
return !!(this._southWest && this._northEast);
|
|
4114
4119
|
}
|
|
4115
4120
|
};
|
|
4121
|
+
function isLatLngExpression(obj) {
|
|
4122
|
+
return obj instanceof LatLng || (Array.isArray(obj) ? typeof obj[0] !== "object" : typeof obj === "object" && obj !== null && "lat" in obj);
|
|
4123
|
+
}
|
|
4116
4124
|
// src/geo/LatLng.js
|
|
4117
4125
|
const coordinate = String.raw`([+-]?\d+(?:\.\d+)?)\s*°?`;
|
|
4118
4126
|
const separator = String.raw`(?:\s*[,;]\s*|\s+)`;
|
|
@@ -4162,46 +4170,36 @@
|
|
|
4162
4170
|
* @param {number} [alt] Altitude in meters.
|
|
4163
4171
|
*/
|
|
4164
4172
|
constructor(lat, lng, alt) {
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
if (lat
|
|
4168
|
-
_lat = lat.lat;
|
|
4169
|
-
_lng = lat
|
|
4170
|
-
_alt = lat
|
|
4171
|
-
} else if (
|
|
4172
|
-
if (lat.length === 3) {
|
|
4173
|
-
_lat = lat[0];
|
|
4174
|
-
_lng = lat[1];
|
|
4175
|
-
_alt = lat[2];
|
|
4176
|
-
} else if (lat.length === 2) {
|
|
4177
|
-
_lat = lat[0];
|
|
4178
|
-
_lng = lat[1];
|
|
4179
|
-
}
|
|
4180
|
-
} else if (typeof lat === "object" && "lat" in lat) {
|
|
4173
|
+
let _lat = lat, _lng = lng, _alt = alt;
|
|
4174
|
+
if (lat instanceof LatLng) ({lat: _lat, lng: _lng, alt: _alt} = lat);
|
|
4175
|
+
else if (Array.isArray(lat)) {
|
|
4176
|
+
_lat = lat.length <= 3 ? lat[0] : NaN;
|
|
4177
|
+
_lng = lat[1];
|
|
4178
|
+
_alt = lat[2];
|
|
4179
|
+
} else if (typeof lat === "object" && lat !== null) {
|
|
4181
4180
|
_lat = lat.lat;
|
|
4182
4181
|
_lng = "lng" in lat ? lat.lng : lat.lon;
|
|
4183
4182
|
_alt = lat.alt;
|
|
4184
|
-
} else {
|
|
4185
|
-
_lat = lat;
|
|
4186
|
-
_lng = lng;
|
|
4187
|
-
_alt = alt;
|
|
4188
4183
|
}
|
|
4189
4184
|
/**
|
|
4190
4185
|
* Latitude in degrees.
|
|
4191
4186
|
* @type {number}
|
|
4192
4187
|
*/
|
|
4193
|
-
this.lat =
|
|
4188
|
+
this.lat = toNumber(_lat);
|
|
4194
4189
|
/**
|
|
4195
4190
|
* Longitude in degrees.
|
|
4196
4191
|
* @type {number}
|
|
4197
4192
|
*/
|
|
4198
|
-
this.lng =
|
|
4199
|
-
if (
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4193
|
+
this.lng = toNumber(_lng);
|
|
4194
|
+
if (isNaN(this.lat) || isNaN(this.lng)) throw new Error(`Invalid LatLng object: (${_lat}, ${_lng})`);
|
|
4195
|
+
if (_alt != null) {
|
|
4196
|
+
/**
|
|
4197
|
+
* Altitude in meters (optional).
|
|
4198
|
+
* @type {number|undefined}
|
|
4199
|
+
*/
|
|
4200
|
+
this.alt = toNumber(_alt);
|
|
4201
|
+
if (isNaN(this.alt)) throw new Error(`Invalid LatLng altitude: ${_alt}`);
|
|
4202
|
+
}
|
|
4205
4203
|
}
|
|
4206
4204
|
/**
|
|
4207
4205
|
* Returns the given `LatLng` object as it is, or else a new `LatLng` object created
|
|
@@ -4230,12 +4228,11 @@
|
|
|
4230
4228
|
* @returns {boolean}
|
|
4231
4229
|
*/
|
|
4232
4230
|
static validate(lat, lng, alt) {
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4231
|
+
try {
|
|
4232
|
+
return !!new LatLng(lat, lng, alt);
|
|
4233
|
+
} catch {
|
|
4236
4234
|
return false;
|
|
4237
|
-
}
|
|
4238
|
-
return false;
|
|
4235
|
+
}
|
|
4239
4236
|
}
|
|
4240
4237
|
/**
|
|
4241
4238
|
* Parses coordinates in decimal degrees: a pair of numbers (latitude first), e.g.
|
|
@@ -4625,6 +4622,7 @@
|
|
|
4625
4622
|
});
|
|
4626
4623
|
}
|
|
4627
4624
|
// src/layer/vector/CircleMarker.js
|
|
4625
|
+
/** @import {MaplairMap} from '../../map/Map.js' */
|
|
4628
4626
|
/** @import {Feature} from 'geojson' */
|
|
4629
4627
|
/** @import {LatLngExpression} from '../../geo/LatLng.js' */
|
|
4630
4628
|
/** @import {MaplairEvent} from '../../core/Events.js' */
|
|
@@ -4669,6 +4667,13 @@
|
|
|
4669
4667
|
this.callInitHooks(CircleMarker);
|
|
4670
4668
|
}
|
|
4671
4669
|
/**
|
|
4670
|
+
* @param {MaplairMap} map
|
|
4671
|
+
*/
|
|
4672
|
+
beforeAdd(map) {
|
|
4673
|
+
super.beforeAdd(map);
|
|
4674
|
+
map._displaceHandler?._beforeMarkerAdd(this);
|
|
4675
|
+
}
|
|
4676
|
+
/**
|
|
4672
4677
|
* Sets the position of a circle marker to a new location.
|
|
4673
4678
|
* @param {LatLngExpression} latlng
|
|
4674
4679
|
* @returns {this}
|
|
@@ -4716,7 +4721,7 @@
|
|
|
4716
4721
|
return this;
|
|
4717
4722
|
}
|
|
4718
4723
|
_project() {
|
|
4719
|
-
this._point = this.
|
|
4724
|
+
this._point = this._renderer._latLngToLayerPoint(this._latlng)._round();
|
|
4720
4725
|
this._pxRadius = this._radius;
|
|
4721
4726
|
this._updateBounds();
|
|
4722
4727
|
}
|
|
@@ -5193,13 +5198,7 @@
|
|
|
5193
5198
|
* @param {number} [d]
|
|
5194
5199
|
*/
|
|
5195
5200
|
constructor(a, b, c, d) {
|
|
5196
|
-
if (Array.isArray(a))
|
|
5197
|
-
this._a = a[0];
|
|
5198
|
-
this._b = a[1];
|
|
5199
|
-
this._c = a[2];
|
|
5200
|
-
this._d = a[3];
|
|
5201
|
-
return;
|
|
5202
|
-
}
|
|
5201
|
+
if (Array.isArray(a)) [a, b, c, d] = a;
|
|
5203
5202
|
this._a = a;
|
|
5204
5203
|
this._b = b;
|
|
5205
5204
|
this._c = c;
|
|
@@ -5343,10 +5342,10 @@
|
|
|
5343
5342
|
* @property {string} [position='topleft'] The position of the control (one of the map
|
|
5344
5343
|
* corners). Possible values are `'topleft'`, `'topright'`, `'bottomleft'` or
|
|
5345
5344
|
* `'bottomright'`.
|
|
5346
|
-
* @property {string} [zoomInText
|
|
5347
|
-
*
|
|
5348
|
-
* @property {string} [zoomOutText
|
|
5349
|
-
*
|
|
5345
|
+
* @property {string} [zoomInText] The HTML of the 'zoom in' button, a plus sign drawn
|
|
5346
|
+
* in SVG by default.
|
|
5347
|
+
* @property {string} [zoomOutText] The HTML of the 'zoom out' button, a minus sign
|
|
5348
|
+
* drawn in SVG by default.
|
|
5350
5349
|
* @extends ControlOptions
|
|
5351
5350
|
*/
|
|
5352
5351
|
/**
|
|
@@ -5370,8 +5369,8 @@
|
|
|
5370
5369
|
var ZoomControl = class ZoomControl extends Control {
|
|
5371
5370
|
static defaultOptions = {
|
|
5372
5371
|
position: "topleft",
|
|
5373
|
-
zoomInText: "<
|
|
5374
|
-
zoomOutText: "<
|
|
5372
|
+
zoomInText: "<svg width=\"12\" height=\"12\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M0 6h12M6 0v12\"/></svg>",
|
|
5373
|
+
zoomOutText: "<svg width=\"12\" height=\"12\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M0 6h12\"/></svg>"
|
|
5375
5374
|
};
|
|
5376
5375
|
/**
|
|
5377
5376
|
* Creates a zoom control.
|
|
@@ -5383,23 +5382,24 @@
|
|
|
5383
5382
|
}
|
|
5384
5383
|
/**
|
|
5385
5384
|
* @internal
|
|
5386
|
-
* @param {MaplairMap} map
|
|
5387
5385
|
* @returns {HTMLElement}
|
|
5388
5386
|
*/
|
|
5389
|
-
onAdd(
|
|
5387
|
+
onAdd() {
|
|
5390
5388
|
const zoomName = "maplair-control-zoom", container = create("div", `${zoomName} maplair-bar`), options = this.options;
|
|
5391
5389
|
this._zoomInButton = this._createButton(options.zoomInText, I18n.translate("Zoom in"), `${zoomName}-in`, container, (e) => this._zoom(e, 1));
|
|
5392
5390
|
this._zoomOutButton = this._createButton(options.zoomOutText, I18n.translate("Zoom out"), `${zoomName}-out`, container, (e) => this._zoom(e, -1));
|
|
5393
5391
|
this._updateDisabled();
|
|
5394
|
-
map.on("zoomend zoomlevelschange", this._updateDisabled, this);
|
|
5395
5392
|
return container;
|
|
5396
5393
|
}
|
|
5397
5394
|
/**
|
|
5398
5395
|
* @internal
|
|
5399
|
-
* @
|
|
5396
|
+
* @returns {Record<string, Function>}
|
|
5400
5397
|
*/
|
|
5401
|
-
|
|
5402
|
-
|
|
5398
|
+
getEvents() {
|
|
5399
|
+
return {
|
|
5400
|
+
zoomend: this._updateDisabled,
|
|
5401
|
+
zoomlevelschange: this._updateDisabled
|
|
5402
|
+
};
|
|
5403
5403
|
}
|
|
5404
5404
|
/**
|
|
5405
5405
|
* Disables the zoom buttons.
|
|
@@ -5436,7 +5436,6 @@
|
|
|
5436
5436
|
on(link, "click", (e) => {
|
|
5437
5437
|
stop(e);
|
|
5438
5438
|
fn.call(this, e);
|
|
5439
|
-
this._refocusOnMap(e);
|
|
5440
5439
|
});
|
|
5441
5440
|
return link;
|
|
5442
5441
|
}
|
|
@@ -5756,9 +5755,12 @@
|
|
|
5756
5755
|
/** @import {EventListener, MaplairEvent} from '../core/Events.js' */
|
|
5757
5756
|
/**
|
|
5758
5757
|
* The content of a `DivOverlay` (`Popup`, `Tooltip`): a string rendered as HTML, an
|
|
5759
|
-
* `HTMLElement`, or a function receiving the source layer and
|
|
5760
|
-
*
|
|
5758
|
+
* `HTMLElement` or `DocumentFragment`, or a function receiving the source layer and
|
|
5759
|
+
* returning one of them.
|
|
5760
|
+
* @typedef {string|HTMLElement|DocumentFragment|
|
|
5761
|
+
* ((layer: Layer) => string|HTMLElement|DocumentFragment)} DivOverlayContent
|
|
5761
5762
|
*/
|
|
5763
|
+
const fragmentNodes = /* @__PURE__ */ new WeakMap();
|
|
5762
5764
|
/**
|
|
5763
5765
|
* Options of `DivOverlay`.
|
|
5764
5766
|
* @typedef {object} DivOverlayOptions
|
|
@@ -5774,8 +5776,8 @@
|
|
|
5774
5776
|
* in the DOM (for styling and events).
|
|
5775
5777
|
* @property {DivOverlayContent} [content=''] Sets the HTML content of the overlay while
|
|
5776
5778
|
* initializing. If a function is passed the source layer will be passed to the
|
|
5777
|
-
* function. The function should return a `String` or `
|
|
5778
|
-
* overlay. String content is rendered as HTML; sanitize untrusted input or pass an
|
|
5779
|
+
* function. The function should return a `String`, `HTMLElement` or `DocumentFragment`
|
|
5780
|
+
* to be used in the overlay. String content is rendered as HTML; sanitize untrusted input or pass an
|
|
5779
5781
|
* `HTMLElement` with safe `textContent` instead.
|
|
5780
5782
|
* @extends InteractiveLayerOptions
|
|
5781
5783
|
*/
|
|
@@ -5807,7 +5809,8 @@
|
|
|
5807
5809
|
} };
|
|
5808
5810
|
/** @typedef {typeof layerDivOverlayMethods} LayerDivOverlayMethods */
|
|
5809
5811
|
/**
|
|
5810
|
-
* Base model for Popup and Tooltip
|
|
5812
|
+
* Base model for `Popup` and `Tooltip`; use those to show content on the map. Inherit
|
|
5813
|
+
* from it for custom overlays like plugins.
|
|
5811
5814
|
*
|
|
5812
5815
|
* @fires contentupdate {MaplairEvent} Fired when the content of the overlay is updated.
|
|
5813
5816
|
*/
|
|
@@ -5884,8 +5887,7 @@
|
|
|
5884
5887
|
else {
|
|
5885
5888
|
if (arguments.length) this._source = layer;
|
|
5886
5889
|
else layer = this._source;
|
|
5887
|
-
this._prepareOpen();
|
|
5888
|
-
this.openOn(layer._map);
|
|
5890
|
+
if (this._prepareOpen()) this.openOn(layer._map);
|
|
5889
5891
|
}
|
|
5890
5892
|
return this;
|
|
5891
5893
|
}
|
|
@@ -5897,7 +5899,7 @@
|
|
|
5897
5899
|
if (!this._container) this._initLayout();
|
|
5898
5900
|
if (map._fadeAnimated) this._container.style.opacity = "0";
|
|
5899
5901
|
clearTimeout(this._removeTimeout);
|
|
5900
|
-
this.getPane().
|
|
5902
|
+
this.getPane().append(this._container);
|
|
5901
5903
|
if (this.options.overflow) {
|
|
5902
5904
|
this._container.classList.add("maplair-overflow");
|
|
5903
5905
|
this._container.popover = "manual";
|
|
@@ -5970,9 +5972,10 @@
|
|
|
5970
5972
|
/**
|
|
5971
5973
|
* Sets the HTML content of the overlay. A `String` argument is rendered as
|
|
5972
5974
|
* HTML; if it may contain untrusted input, sanitize it (e.g. with DOMPurify)
|
|
5973
|
-
* or pass an `HTMLElement` with safe `textContent` instead.
|
|
5974
|
-
* passed
|
|
5975
|
-
* return a `String
|
|
5975
|
+
* or pass an `HTMLElement` with safe `textContent` instead. A `DocumentFragment`
|
|
5976
|
+
* can be passed as well. If a function is passed the source layer will be passed
|
|
5977
|
+
* to the function. The function should return a `String`, `HTMLElement` or
|
|
5978
|
+
* `DocumentFragment` to be used in the overlay.
|
|
5976
5979
|
* @param {DivOverlayContent} content
|
|
5977
5980
|
* @returns {this}
|
|
5978
5981
|
*/
|
|
@@ -6020,7 +6023,7 @@
|
|
|
6020
6023
|
* @returns {boolean}
|
|
6021
6024
|
*/
|
|
6022
6025
|
isOpen() {
|
|
6023
|
-
return !!this._map
|
|
6026
|
+
return !!this._map?.hasLayer(this);
|
|
6024
6027
|
}
|
|
6025
6028
|
/**
|
|
6026
6029
|
* Brings this overlay in front of other overlays (in the same map pane).
|
|
@@ -6064,25 +6067,21 @@
|
|
|
6064
6067
|
if (!source) return false;
|
|
6065
6068
|
this._source = source;
|
|
6066
6069
|
}
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
else if (source.getLatLng) latlng = source.getLatLng();
|
|
6070
|
-
else if (source.getBounds) latlng = source.getBounds().getCenter();
|
|
6071
|
-
else throw new Error("Unable to get source layer LatLng.");
|
|
6072
|
-
}
|
|
6070
|
+
latlng ??= source.getCenter?.() ?? source.getLatLng?.() ?? source.getBounds?.().getCenter();
|
|
6071
|
+
if (!latlng) throw new Error("Unable to get source layer LatLng.");
|
|
6073
6072
|
this.setLatLng(latlng);
|
|
6074
6073
|
if (this._map) this.update();
|
|
6075
6074
|
return true;
|
|
6076
6075
|
}
|
|
6077
6076
|
_updateContent() {
|
|
6078
|
-
if (
|
|
6077
|
+
if (this._content == null) return;
|
|
6079
6078
|
const node = this._contentNode;
|
|
6080
6079
|
const content = typeof this._content === "function" ? this._content(this._source ?? this) : this._content;
|
|
6081
6080
|
if (typeof content === "string") node.innerHTML = content;
|
|
6082
|
-
else {
|
|
6083
|
-
|
|
6084
|
-
node.
|
|
6085
|
-
}
|
|
6081
|
+
else if (content instanceof DocumentFragment) {
|
|
6082
|
+
if (content.hasChildNodes()) fragmentNodes.set(content, [...content.childNodes]);
|
|
6083
|
+
node.replaceChildren(...fragmentNodes.get(content) ?? []);
|
|
6084
|
+
} else node.replaceChildren(content);
|
|
6086
6085
|
this.fire("contentupdate");
|
|
6087
6086
|
}
|
|
6088
6087
|
_updatePosition() {
|
|
@@ -6233,7 +6232,7 @@
|
|
|
6233
6232
|
* may contain untrusted input, sanitize it (e.g. with DOMPurify) or pass an
|
|
6234
6233
|
* `HTMLElement` with safe `textContent` instead. If a `Function` is passed
|
|
6235
6234
|
* it will receive the layer as the first argument and should return a
|
|
6236
|
-
* `String` or `
|
|
6235
|
+
* `String`, `HTMLElement` or `DocumentFragment`.
|
|
6237
6236
|
* @group Popup methods
|
|
6238
6237
|
* @param {DivOverlayContent|Popup} content
|
|
6239
6238
|
* @param {PopupOptions} [options]
|
|
@@ -6241,6 +6240,7 @@
|
|
|
6241
6240
|
*/
|
|
6242
6241
|
bindPopup(content, options) {
|
|
6243
6242
|
this._popup = this._initOverlay(Popup, this._popup, content, options);
|
|
6243
|
+
this._popup._updateSourceAria(this._popup.isOpen());
|
|
6244
6244
|
this.on({
|
|
6245
6245
|
click: this._openPopup,
|
|
6246
6246
|
remove: this.closePopup,
|
|
@@ -6260,6 +6260,9 @@
|
|
|
6260
6260
|
remove: this.closePopup,
|
|
6261
6261
|
move: this._movePopup
|
|
6262
6262
|
});
|
|
6263
|
+
const el = this.getElement?.();
|
|
6264
|
+
el?.removeAttribute("aria-expanded");
|
|
6265
|
+
el?.removeAttribute("aria-controls");
|
|
6263
6266
|
this._popup = null;
|
|
6264
6267
|
}
|
|
6265
6268
|
return this;
|
|
@@ -6328,9 +6331,8 @@
|
|
|
6328
6331
|
if (!this._popup || !this._map) return;
|
|
6329
6332
|
stopPropagation(e);
|
|
6330
6333
|
const target = e.propagatedFrom ?? e.target;
|
|
6331
|
-
if (this._popup._source === target &&
|
|
6332
|
-
|
|
6333
|
-
else this.openPopup(e.latlng);
|
|
6334
|
+
if (this._popup._source === target && target._togglesPopupOnClick() && this._map.hasLayer(this._popup)) {
|
|
6335
|
+
this.closePopup();
|
|
6334
6336
|
return;
|
|
6335
6337
|
}
|
|
6336
6338
|
this._popup._source = target;
|
|
@@ -6427,9 +6429,11 @@
|
|
|
6427
6429
|
*/
|
|
6428
6430
|
openOn(map) {
|
|
6429
6431
|
map = arguments.length ? map : this._source._map;
|
|
6430
|
-
if (!map.hasLayer(this) && map._popup
|
|
6432
|
+
if (!map.hasLayer(this) && map._popup?.options.autoClose) map.removeLayer(map._popup);
|
|
6431
6433
|
map._popup = this;
|
|
6432
|
-
|
|
6434
|
+
super.openOn(map);
|
|
6435
|
+
this._updateSourceAria(true);
|
|
6436
|
+
return this;
|
|
6433
6437
|
}
|
|
6434
6438
|
/**
|
|
6435
6439
|
* Adds the popup to the map.
|
|
@@ -6444,9 +6448,10 @@
|
|
|
6444
6448
|
(this._closeButton ?? this._container).focus({ preventScroll: true });
|
|
6445
6449
|
}
|
|
6446
6450
|
map.fire("popupopen", { popup: this });
|
|
6451
|
+
this._updateSourceAria(true);
|
|
6447
6452
|
if (this._source) {
|
|
6448
6453
|
this._source.fire("popupopen", { popup: this }, true);
|
|
6449
|
-
if (
|
|
6454
|
+
if (this._source._togglesPopupOnClick()) this._source.on("preclick", stopPropagation);
|
|
6450
6455
|
}
|
|
6451
6456
|
}
|
|
6452
6457
|
/**
|
|
@@ -6454,13 +6459,17 @@
|
|
|
6454
6459
|
* @param {MaplairMap} map
|
|
6455
6460
|
*/
|
|
6456
6461
|
onRemove(map) {
|
|
6457
|
-
if (this._container.contains(document.activeElement)
|
|
6462
|
+
if (this._container.contains(document.activeElement)) {
|
|
6463
|
+
const el = this._source?.getElement?.();
|
|
6464
|
+
(this._returnFocus?.isConnected ? this._returnFocus : el?.tabIndex >= 0 ? el : map._container).focus({ preventScroll: true });
|
|
6465
|
+
}
|
|
6458
6466
|
this._returnFocus = null;
|
|
6459
6467
|
super.onRemove(map);
|
|
6460
6468
|
map.fire("popupclose", { popup: this });
|
|
6469
|
+
this._updateSourceAria(false);
|
|
6461
6470
|
if (this._source) {
|
|
6462
6471
|
this._source.fire("popupclose", { popup: this }, true);
|
|
6463
|
-
if (
|
|
6472
|
+
if (this._source._togglesPopupOnClick()) this._source.off("preclick", stopPropagation);
|
|
6464
6473
|
}
|
|
6465
6474
|
}
|
|
6466
6475
|
/**
|
|
@@ -6473,8 +6482,17 @@
|
|
|
6473
6482
|
if (this.options.keepInView) events.moveend = this._adjustPan;
|
|
6474
6483
|
return events;
|
|
6475
6484
|
}
|
|
6485
|
+
_updateSourceAria(open) {
|
|
6486
|
+
this._ariaSource?.setAttribute("aria-expanded", "false");
|
|
6487
|
+
this._ariaSource?.removeAttribute("aria-controls");
|
|
6488
|
+
const el = this._source?.getElement?.();
|
|
6489
|
+
this._ariaSource = el?.getAttribute("role") === "button" ? el : null;
|
|
6490
|
+
this._ariaSource?.setAttribute("aria-expanded", String(open));
|
|
6491
|
+
if (open) this._ariaSource?.setAttribute("aria-controls", this._container.id);
|
|
6492
|
+
}
|
|
6476
6493
|
_initLayout() {
|
|
6477
6494
|
const prefix = "maplair-popup", container = this._container = create("div", `${prefix} ${this.options.className || ""} maplair-zoom-animated`);
|
|
6495
|
+
container.id = `maplair-popup-${stamp(this)}`;
|
|
6478
6496
|
const wrapper = this._wrapper = create("div", `${prefix}-content-wrapper`, container);
|
|
6479
6497
|
this._contentNode = create("div", `${prefix}-content`, wrapper);
|
|
6480
6498
|
disableClickPropagation(container);
|
|
@@ -6486,7 +6504,7 @@
|
|
|
6486
6504
|
const closeButton = this._closeButton = create("button", `${prefix}-close-button`, container);
|
|
6487
6505
|
closeButton.type = "button";
|
|
6488
6506
|
closeButton.setAttribute("aria-label", I18n.translate("Close popup"));
|
|
6489
|
-
closeButton.
|
|
6507
|
+
closeButton.textContent = "×";
|
|
6490
6508
|
on(closeButton, "click", (ev) => {
|
|
6491
6509
|
ev.preventDefault();
|
|
6492
6510
|
this.close();
|
|
@@ -6554,13 +6572,13 @@
|
|
|
6554
6572
|
}
|
|
6555
6573
|
};
|
|
6556
6574
|
// src/layer/Tooltip.js
|
|
6557
|
-
const directions =
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6575
|
+
const directions = {
|
|
6576
|
+
top: [.5, 1],
|
|
6577
|
+
bottom: [.5, 0],
|
|
6578
|
+
center: [.5, .5],
|
|
6579
|
+
right: [0, .5],
|
|
6580
|
+
left: [1, .5]
|
|
6581
|
+
};
|
|
6564
6582
|
const tipSize = 6;
|
|
6565
6583
|
const autoPadding = 4;
|
|
6566
6584
|
function shiftInto(start, size, min, max) {
|
|
@@ -6653,7 +6671,7 @@
|
|
|
6653
6671
|
* may contain untrusted input, sanitize it (e.g. with DOMPurify) or pass an
|
|
6654
6672
|
* `HTMLElement` with safe `textContent` instead. If a `Function` is passed
|
|
6655
6673
|
* it will receive the layer as the first argument and should return a
|
|
6656
|
-
* `String` or `
|
|
6674
|
+
* `String`, `HTMLElement` or `DocumentFragment`.
|
|
6657
6675
|
* @group Tooltip methods
|
|
6658
6676
|
* @param {DivOverlayContent|Tooltip} content
|
|
6659
6677
|
* @param {TooltipOptions} [options]
|
|
@@ -6664,7 +6682,7 @@
|
|
|
6664
6682
|
if (this._tooltip) this.unbindTooltip();
|
|
6665
6683
|
this._tooltip = this._initOverlay(Tooltip, old, content, options);
|
|
6666
6684
|
this._initTooltipInteractions();
|
|
6667
|
-
if (this._tooltip.options.permanent && this._map
|
|
6685
|
+
if (this._tooltip.options.permanent && this._map?.hasLayer(this)) this.openTooltip();
|
|
6668
6686
|
return this;
|
|
6669
6687
|
},
|
|
6670
6688
|
/**
|
|
@@ -6706,11 +6724,7 @@
|
|
|
6706
6724
|
openTooltip(latlng) {
|
|
6707
6725
|
if (this._tooltip) {
|
|
6708
6726
|
if (!(this instanceof FeatureGroup)) this._tooltip._source = this;
|
|
6709
|
-
if (this._tooltip._prepareOpen(latlng))
|
|
6710
|
-
this._tooltip.openOn(this._map);
|
|
6711
|
-
if (this.getElement) this._setAriaDescribedByOnLayer(this);
|
|
6712
|
-
else if (this.eachLayer) this.eachLayer(this._setAriaDescribedByOnLayer, this);
|
|
6713
|
-
}
|
|
6727
|
+
if (this._tooltip._prepareOpen(latlng)) this._tooltip.openOn(this._map);
|
|
6714
6728
|
}
|
|
6715
6729
|
return this;
|
|
6716
6730
|
},
|
|
@@ -6771,7 +6785,7 @@
|
|
|
6771
6785
|
if (!remove) {
|
|
6772
6786
|
el._maplair_focus_handler && off(el, "focus", el._maplair_focus_handler, this);
|
|
6773
6787
|
el._maplair_focus_handler = () => {
|
|
6774
|
-
if (this._tooltip) {
|
|
6788
|
+
if (this._tooltip && el.matches(":focus-visible")) {
|
|
6775
6789
|
this._tooltip._source = layer;
|
|
6776
6790
|
this.openTooltip();
|
|
6777
6791
|
}
|
|
@@ -6782,9 +6796,6 @@
|
|
|
6782
6796
|
if (remove) delete el._maplair_focus_handler;
|
|
6783
6797
|
}
|
|
6784
6798
|
},
|
|
6785
|
-
_setAriaDescribedByOnLayer(layer) {
|
|
6786
|
-
(typeof layer.getElement === "function" && layer.getElement())?.setAttribute?.("aria-describedby", this._tooltip._container.id);
|
|
6787
|
-
},
|
|
6788
6799
|
_openTooltip(e) {
|
|
6789
6800
|
if (!this._tooltip || !this._map) return;
|
|
6790
6801
|
if (this._map.dragging?.moving()) {
|
|
@@ -6801,13 +6812,7 @@
|
|
|
6801
6812
|
this.openTooltip(this._tooltip.options.sticky ? e.latlng : void 0);
|
|
6802
6813
|
},
|
|
6803
6814
|
_moveTooltip(e) {
|
|
6804
|
-
|
|
6805
|
-
if (this._tooltip.options.sticky && e.originalEvent) {
|
|
6806
|
-
containerPoint = this._map.pointerEventToContainerPoint(e.originalEvent);
|
|
6807
|
-
layerPoint = this._map.containerPointToLayerPoint(containerPoint);
|
|
6808
|
-
latlng = this._map.layerPointToLatLng(layerPoint);
|
|
6809
|
-
}
|
|
6810
|
-
this._tooltip.setLatLng(latlng);
|
|
6815
|
+
this._tooltip.setLatLng(this._tooltip.options.sticky && e.originalEvent ? this._map.pointerEventToLatLng(e.originalEvent) : e.latlng);
|
|
6811
6816
|
}
|
|
6812
6817
|
};
|
|
6813
6818
|
/** @typedef {typeof layerTooltipMethods} LayerTooltipMethods */
|
|
@@ -6896,6 +6901,7 @@
|
|
|
6896
6901
|
map.fire("tooltipopen", { tooltip: this });
|
|
6897
6902
|
if (this._source) {
|
|
6898
6903
|
this.addEventParent(this._source);
|
|
6904
|
+
this._source.getElement?.()?.setAttribute("aria-describedby", this._container.id);
|
|
6899
6905
|
this._source.fire("tooltipopen", { tooltip: this }, true);
|
|
6900
6906
|
}
|
|
6901
6907
|
}
|
|
@@ -6924,7 +6930,7 @@
|
|
|
6924
6930
|
const className = `maplair-tooltip ${this.options.className || ""} maplair-zoom-animated`;
|
|
6925
6931
|
this._contentNode = this._container = create("div", className);
|
|
6926
6932
|
this._container.setAttribute("role", "tooltip");
|
|
6927
|
-
this._container.
|
|
6933
|
+
this._container.id = `maplair-tooltip-${stamp(this)}`;
|
|
6928
6934
|
}
|
|
6929
6935
|
_updateLayout() {}
|
|
6930
6936
|
_adjustPan() {}
|
|
@@ -6939,21 +6945,16 @@
|
|
|
6939
6945
|
_setPosition(pos) {
|
|
6940
6946
|
let direction = this.options.direction, shift = new Point(0, 0);
|
|
6941
6947
|
const container = this._container, tooltipWidth = container.offsetWidth, tooltipHeight = container.offsetHeight, offset = new Point(this.options.offset), anchor = this._getAnchor();
|
|
6942
|
-
if (!
|
|
6948
|
+
if (!(direction in directions)) {
|
|
6943
6949
|
({direction, shift} = this._getAutoPlacement(pos, offset, anchor, tooltipWidth, tooltipHeight));
|
|
6944
6950
|
if (direction === "left") {
|
|
6945
6951
|
offset.x = -offset.x;
|
|
6946
6952
|
anchor.x = -anchor.x;
|
|
6947
6953
|
}
|
|
6948
6954
|
}
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
else if (direction === "right") subX = 0;
|
|
6953
|
-
else if (direction === "left") subX = tooltipWidth;
|
|
6954
|
-
pos = pos.subtract(new Point(subX, subY, true)).add(offset).add(anchor).add(shift);
|
|
6955
|
-
container.classList.remove("maplair-tooltip-right", "maplair-tooltip-left", "maplair-tooltip-top", "maplair-tooltip-bottom");
|
|
6956
|
-
container.classList.add(`maplair-tooltip-${direction}`);
|
|
6955
|
+
const [fx, fy] = directions[direction];
|
|
6956
|
+
pos = pos.subtract(new Point(tooltipWidth * fx, tooltipHeight * fy, true)).add(offset).add(anchor).add(shift);
|
|
6957
|
+
for (const d in directions) container.classList.toggle(`maplair-tooltip-${d}`, d === direction);
|
|
6957
6958
|
const tipShift = direction === "top" || direction === "bottom" ? clampTip(-shift.x, tooltipWidth) : clampTip(-shift.y, tooltipHeight);
|
|
6958
6959
|
if (tipShift) container.style.setProperty("--maplair-tooltip-tip-shift", `${tipShift}px`);
|
|
6959
6960
|
else container.style.removeProperty("--maplair-tooltip-tip-shift");
|
|
@@ -7069,7 +7070,8 @@
|
|
|
7069
7070
|
* @lends MaplairMapOptions
|
|
7070
7071
|
* @property {Renderer} [renderer] The default method for drawing vector layers on the
|
|
7071
7072
|
* map. A new `SVG` renderer by default; pass `new Canvas()` to draw them on a canvas
|
|
7072
|
-
* instead.
|
|
7073
|
+
* instead. Paths in custom panes get their own renderer for that pane, of the same
|
|
7074
|
+
* class and with the same options as this one.
|
|
7073
7075
|
*/
|
|
7074
7076
|
/**
|
|
7075
7077
|
* Registers `getRenderer()` and related methods on the given map class, called by
|
|
@@ -7198,12 +7200,14 @@
|
|
|
7198
7200
|
*/
|
|
7199
7201
|
addHooks() {
|
|
7200
7202
|
on(this._map._container, "pointerdown", this._onPointerDown, this);
|
|
7203
|
+
this._map._container.classList.add("maplair-box-zoom");
|
|
7201
7204
|
}
|
|
7202
7205
|
/**
|
|
7203
7206
|
* Called when the handler is disabled, removes the event hooks.
|
|
7204
7207
|
*/
|
|
7205
7208
|
removeHooks() {
|
|
7206
7209
|
off(this._map._container, "pointerdown", this._onPointerDown, this);
|
|
7210
|
+
this._map._container.classList.remove("maplair-box-zoom");
|
|
7207
7211
|
}
|
|
7208
7212
|
/**
|
|
7209
7213
|
* Returns `true` if a box has been drawn by the current or last interaction.
|
|
@@ -7416,13 +7420,13 @@
|
|
|
7416
7420
|
}
|
|
7417
7421
|
_onDown(e) {
|
|
7418
7422
|
this._moved = false;
|
|
7419
|
-
if (this._element.classList.contains("maplair-zoom-anim")) return;
|
|
7420
7423
|
const pointers = getPointers().length;
|
|
7421
7424
|
if (pointers > 1) {
|
|
7422
7425
|
if (Draggable._dragging === this) this.finishDrag();
|
|
7423
7426
|
return;
|
|
7424
7427
|
}
|
|
7425
|
-
|
|
7428
|
+
const boxZoom = e.shiftKey && this._element.closest(".maplair-container")?.classList.contains("maplair-box-zoom");
|
|
7429
|
+
if (Draggable._dragging || boxZoom || e.button !== 0 && e.pointerType !== "touch") return;
|
|
7426
7430
|
Draggable._dragging = this;
|
|
7427
7431
|
disableImageDrag();
|
|
7428
7432
|
if (this._moving) return;
|
|
@@ -7480,10 +7484,8 @@
|
|
|
7480
7484
|
finishDrag(noInertia) {
|
|
7481
7485
|
this._draggingContainer?.classList.remove("maplair-dragging");
|
|
7482
7486
|
this._draggingContainer = null;
|
|
7483
|
-
|
|
7484
|
-
|
|
7485
|
-
this._lastTarget = null;
|
|
7486
|
-
}
|
|
7487
|
+
this._lastTarget?.classList.remove("maplair-drag-target");
|
|
7488
|
+
this._lastTarget = null;
|
|
7487
7489
|
off(this._dragStartTarget, "pointermove", this._onMove, this);
|
|
7488
7490
|
off(this._dragStartTarget, "pointerup pointercancel lostpointercapture", this._onUp, this);
|
|
7489
7491
|
enableImageDrag();
|
|
@@ -7742,7 +7744,7 @@
|
|
|
7742
7744
|
const container = this._map._container;
|
|
7743
7745
|
if (container.tabIndex <= 0) container.tabIndex = 0;
|
|
7744
7746
|
const shortcuts = this._map.options.ariaKeyShortcuts;
|
|
7745
|
-
if (shortcuts) container.
|
|
7747
|
+
if (shortcuts) container.setAttribute("aria-keyshortcuts", shortcuts === true ? "ArrowLeft ArrowRight ArrowUp ArrowDown = Plus -" : shortcuts);
|
|
7746
7748
|
on(container, {
|
|
7747
7749
|
focus: this._onFocus,
|
|
7748
7750
|
blur: this._onBlur,
|
|
@@ -7798,7 +7800,7 @@
|
|
|
7798
7800
|
return help;
|
|
7799
7801
|
}
|
|
7800
7802
|
_onPointerDown() {
|
|
7801
|
-
if (this._focused) return;
|
|
7803
|
+
if (this._focused || this._map._container.contains(document.activeElement)) return;
|
|
7802
7804
|
this._map._container.focus({
|
|
7803
7805
|
preventScroll: true,
|
|
7804
7806
|
focusVisible: false
|
|
@@ -7816,11 +7818,9 @@
|
|
|
7816
7818
|
}
|
|
7817
7819
|
_onContainerKeyDown(e) {
|
|
7818
7820
|
const map = this._map, popup = map._popup;
|
|
7819
|
-
if (e.key !== "Escape" || e.defaultPrevented || !popup?.options.closeOnEscapeKey || map._controlContainer?.contains(e.target)) return;
|
|
7820
|
-
const inPopup = popup._container.contains(e.target), icon = popup._source?._icon;
|
|
7821
|
+
if (e.key !== "Escape" || e.defaultPrevented || !popup?.isOpen() || !popup.options.closeOnEscapeKey || map._controlContainer?.contains(e.target)) return;
|
|
7821
7822
|
map.closePopup();
|
|
7822
7823
|
e.preventDefault();
|
|
7823
|
-
if (inPopup) (icon?.tabIndex >= 0 ? icon : map._container).focus();
|
|
7824
7824
|
}
|
|
7825
7825
|
_onKeyDown(e) {
|
|
7826
7826
|
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
@@ -7925,8 +7925,8 @@
|
|
|
7925
7925
|
this._moved = false;
|
|
7926
7926
|
this._zooming = true;
|
|
7927
7927
|
map._stop();
|
|
7928
|
-
on(
|
|
7929
|
-
on(
|
|
7928
|
+
on(map._container, "pointermove", this._onPointerMove, this);
|
|
7929
|
+
on(map._container, "pointerup pointercancel", this._onPointerEnd, this);
|
|
7930
7930
|
e.preventDefault();
|
|
7931
7931
|
}
|
|
7932
7932
|
_onPointerMove(e) {
|
|
@@ -7949,10 +7949,7 @@
|
|
|
7949
7949
|
this._moved = true;
|
|
7950
7950
|
}
|
|
7951
7951
|
cancelAnimationFrame(this._animRequest);
|
|
7952
|
-
const moveFn = map._move.bind(map, this._center, this._zoom, {
|
|
7953
|
-
pinch: true,
|
|
7954
|
-
round: false
|
|
7955
|
-
}, void 0);
|
|
7952
|
+
const moveFn = map._move.bind(map, this._center, this._zoom, { pinch: true }, void 0);
|
|
7956
7953
|
this._animRequest = requestAnimationFrame(moveFn.bind(this));
|
|
7957
7954
|
e.preventDefault();
|
|
7958
7955
|
}
|
|
@@ -8105,10 +8102,7 @@
|
|
|
8105
8102
|
const frame = () => {
|
|
8106
8103
|
const pinch = this._pinch, delta = pinch.zoom - pinch.shown;
|
|
8107
8104
|
pinch.shown = eased && Math.abs(delta) > .01 ? pinch.shown + delta * .3 : pinch.zoom;
|
|
8108
|
-
map._move(this._getPinchCenter(pinch.shown), pinch.shown, {
|
|
8109
|
-
pinch: true,
|
|
8110
|
-
round: false
|
|
8111
|
-
});
|
|
8105
|
+
map._move(this._getPinchCenter(pinch.shown), pinch.shown, { pinch: true });
|
|
8112
8106
|
if (pinch.shown !== pinch.zoom) this._pinchFrame = requestAnimationFrame(frame);
|
|
8113
8107
|
};
|
|
8114
8108
|
cancelAnimationFrame(this._pinchFrame);
|
|
@@ -8172,9 +8166,9 @@
|
|
|
8172
8166
|
stop(e);
|
|
8173
8167
|
}
|
|
8174
8168
|
_performZoom() {
|
|
8175
|
-
const map = this._map, zoom = map.getZoom(), snap =
|
|
8169
|
+
const map = this._map, zoom = map.getZoom(), snap = map.options.zoomSnap ?? 0;
|
|
8176
8170
|
map._stop();
|
|
8177
|
-
const d2 = this._delta / (
|
|
8171
|
+
const d2 = this._delta / (map.options.wheelPxPerZoomLevel * 4), d3 = 4 * Math.log(2 / (1 + Math.exp(-Math.abs(d2)))) / Math.LN2, d4 = snap ? Math.ceil(d3 / snap) * snap : d3, d5 = map._prefersReducedMotion() ? Math.min(d4, 1) : d4, delta = map._limitZoom(zoom + (this._delta > 0 ? d5 : -d5)) - zoom;
|
|
8178
8172
|
this._delta = 0;
|
|
8179
8173
|
this._startTime = null;
|
|
8180
8174
|
if (!delta || map._zoomInputBlocked()) return;
|
|
@@ -8239,47 +8233,35 @@
|
|
|
8239
8233
|
removeHooks() {
|
|
8240
8234
|
off(this._map._container, "pointerdown", this._onDown, this);
|
|
8241
8235
|
this._cancel();
|
|
8242
|
-
this._cancelClickPrevent();
|
|
8243
8236
|
this._stopPreventingNative();
|
|
8244
8237
|
}
|
|
8245
8238
|
_onDown(e) {
|
|
8246
8239
|
clearTimeout(this._holdTimeout);
|
|
8247
8240
|
if (getPointers().length !== 1 || e.pointerType === "mouse") return;
|
|
8248
|
-
const el = this._map._container;
|
|
8249
|
-
this._startPos = this._newPos = new Point(e.clientX, e.clientY);
|
|
8241
|
+
const el = this._map._container, start = new Point(e.clientX, e.clientY);
|
|
8250
8242
|
this._holdTimeout = setTimeout((() => {
|
|
8251
8243
|
this._cancel();
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
on(el, "pointerup pointercancel", this._cancelClickPrevent, this);
|
|
8244
|
+
const pointers = getPointers(), p = pointers[0];
|
|
8245
|
+
if (pointers.length !== 1 || start.distanceTo([p.clientX, p.clientY]) > this._map.options.tapTolerance) return;
|
|
8255
8246
|
this._simulateEvent("contextmenu", e);
|
|
8256
8247
|
el.addEventListener("contextmenu", stop, true);
|
|
8248
|
+
el.addEventListener("click", stop, true);
|
|
8257
8249
|
el.addEventListener("pointerdown", this._stopPreventingNative, true);
|
|
8250
|
+
el.addEventListener("keydown", this._stopPreventingNative, true);
|
|
8258
8251
|
}), tapHoldDelay);
|
|
8259
8252
|
on(el, "pointerup pointercancel contextmenu", this._cancel, this);
|
|
8260
|
-
on(el, "pointermove", this._onMove, this);
|
|
8261
|
-
}
|
|
8262
|
-
_cancelClickPrevent() {
|
|
8263
|
-
const el = this._map._container;
|
|
8264
|
-
off(el, "pointerup", preventDefault);
|
|
8265
|
-
off(el, "pointerup pointercancel", this._cancelClickPrevent, this);
|
|
8266
8253
|
}
|
|
8267
8254
|
_stopPreventingNative = () => {
|
|
8268
8255
|
const el = this._map._container;
|
|
8269
8256
|
el.removeEventListener("contextmenu", stop, true);
|
|
8257
|
+
el.removeEventListener("click", stop, true);
|
|
8270
8258
|
el.removeEventListener("pointerdown", this._stopPreventingNative, true);
|
|
8259
|
+
el.removeEventListener("keydown", this._stopPreventingNative, true);
|
|
8271
8260
|
};
|
|
8272
8261
|
_cancel() {
|
|
8273
8262
|
clearTimeout(this._holdTimeout);
|
|
8274
8263
|
const el = this._map._container;
|
|
8275
8264
|
off(el, "pointerup pointercancel contextmenu", this._cancel, this);
|
|
8276
|
-
off(el, "pointermove", this._onMove, this);
|
|
8277
|
-
}
|
|
8278
|
-
_onMove(e) {
|
|
8279
|
-
this._newPos = new Point(e.clientX, e.clientY);
|
|
8280
|
-
}
|
|
8281
|
-
_isTapValid() {
|
|
8282
|
-
return this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance;
|
|
8283
8265
|
}
|
|
8284
8266
|
_simulateEvent(type, e) {
|
|
8285
8267
|
const simulatedEvent = new MouseEvent(type, {
|
|
@@ -8420,10 +8402,7 @@
|
|
|
8420
8402
|
this._moved = true;
|
|
8421
8403
|
}
|
|
8422
8404
|
cancelAnimationFrame(this._animRequest);
|
|
8423
|
-
this._animRequest = requestAnimationFrame(() => map._move(this._center, this._zoom, {
|
|
8424
|
-
pinch: true,
|
|
8425
|
-
round: false
|
|
8426
|
-
}));
|
|
8405
|
+
this._animRequest = requestAnimationFrame(() => map._move(this._center, this._zoom, { pinch: true }));
|
|
8427
8406
|
e.preventDefault();
|
|
8428
8407
|
}
|
|
8429
8408
|
_onUp() {
|
|
@@ -8479,7 +8458,9 @@
|
|
|
8479
8458
|
* user tries to pan outside the view. To set the restriction dynamically, use
|
|
8480
8459
|
* [`setMaxBounds`](#map-setmaxbounds) method.
|
|
8481
8460
|
* @property {Renderer} [renderer] The default method for drawing vector layers on the
|
|
8482
|
-
* map. `SVG`
|
|
8461
|
+
* map. A new `SVG` renderer by default; pass `new Canvas()` to draw them on a canvas
|
|
8462
|
+
* instead. Paths in custom panes get their own renderer for that pane, of the same
|
|
8463
|
+
* class and with the same options as this one.
|
|
8483
8464
|
* @property {boolean} [zoomAnimation=true] Whether the map zoom animation is enabled.
|
|
8484
8465
|
* @property {number} [zoomAnimationThreshold=4] Won't animate zoom if the zoom
|
|
8485
8466
|
* difference exceeds this value (or 1 if the user prefers
|
|
@@ -8563,15 +8544,25 @@
|
|
|
8563
8544
|
/**
|
|
8564
8545
|
* Options of the `MaplairMap` methods which modify the zoom level and the center.
|
|
8565
8546
|
* @typedef {object} ZoomPanOptions
|
|
8547
|
+
* @property {boolean} [animate] Whether to animate the change: like `ZoomOptions.animate`
|
|
8548
|
+
* if the zoom level changes, and like `PanOptions.animate` otherwise. The `zoom` and
|
|
8549
|
+
* `pan` options can set it for each case separately.
|
|
8550
|
+
* @property {boolean} [reset] If `true`, the view is reset without animation.
|
|
8551
|
+
* @property {ZoomOptions} [zoom] Options for the zoom part of the change, taking
|
|
8552
|
+
* precedence over `animate`.
|
|
8553
|
+
* @property {PanOptions} [pan] Options for the pan part of the change, taking
|
|
8554
|
+
* precedence over `animate`.
|
|
8566
8555
|
* @extends ZoomOptions, PanOptions
|
|
8567
8556
|
*/
|
|
8568
8557
|
/**
|
|
8569
8558
|
* Options of `MaplairMap.invalidateSize()`.
|
|
8570
8559
|
* @typedef {object} InvalidateSizeOptions
|
|
8560
|
+
* @property {boolean} [animate=false] If `true`, the map pans to its new center with
|
|
8561
|
+
* animation.
|
|
8571
8562
|
* @property {boolean} [pan=true] If `false`, panning will not occur.
|
|
8572
8563
|
* @property {boolean} [debounceMoveend=false] If `true`, it will delay `moveend` event
|
|
8573
8564
|
* so that it doesn't happen often even if the method is called many times in a row.
|
|
8574
|
-
* @extends
|
|
8565
|
+
* @extends PanOptions
|
|
8575
8566
|
*/
|
|
8576
8567
|
/**
|
|
8577
8568
|
* Padding options of `MaplairMap` methods, e.g. `panInside()`.
|
|
@@ -8619,7 +8610,9 @@
|
|
|
8619
8610
|
* pressing a key or clicking a zoom button) have an `originalEvent` property with the
|
|
8620
8611
|
* DOM event that started the change. It is `undefined` for changes made by code (e.g.
|
|
8621
8612
|
* `setView()`), which allows to tell them apart, e.g. to avoid feedback loops when
|
|
8622
|
-
* synchronizing the view.
|
|
8613
|
+
* synchronizing the view. The `move` and `zoom` events also have `flyTo: true` on each
|
|
8614
|
+
* [`flyTo`](#map-flyto) animation frame, and `pinch: true` while the user pinch-zooms
|
|
8615
|
+
* the map.
|
|
8623
8616
|
*
|
|
8624
8617
|
* @example
|
|
8625
8618
|
* ```js
|
|
@@ -8719,6 +8712,7 @@
|
|
|
8719
8712
|
this._handlers = [];
|
|
8720
8713
|
this._layers = {};
|
|
8721
8714
|
this._zoomBoundLayers = {};
|
|
8715
|
+
this._canvases = [];
|
|
8722
8716
|
this._sizeChanged = true;
|
|
8723
8717
|
this._initContainer(id);
|
|
8724
8718
|
this._initLayout();
|
|
@@ -8749,10 +8743,23 @@
|
|
|
8749
8743
|
* @returns {this}
|
|
8750
8744
|
*/
|
|
8751
8745
|
setView(center, zoom, options) {
|
|
8752
|
-
zoom = zoom === void 0 ? this.
|
|
8746
|
+
zoom = zoom === void 0 ? this._targetZoom() : this._limitZoom(zoom);
|
|
8747
|
+
const targetCenter = center;
|
|
8753
8748
|
center = this._limitCenter(new LatLng(center), zoom, this.options.maxBounds);
|
|
8754
8749
|
options ??= {};
|
|
8755
8750
|
this._stop();
|
|
8751
|
+
this._targetView = {
|
|
8752
|
+
center: targetCenter,
|
|
8753
|
+
zoom
|
|
8754
|
+
};
|
|
8755
|
+
if (this._animatingZoom) {
|
|
8756
|
+
this._pendingView = {
|
|
8757
|
+
center,
|
|
8758
|
+
zoom,
|
|
8759
|
+
options
|
|
8760
|
+
};
|
|
8761
|
+
return this;
|
|
8762
|
+
}
|
|
8756
8763
|
if (this._loaded && !options.reset && options !== true) {
|
|
8757
8764
|
if (options.animate !== void 0) {
|
|
8758
8765
|
options.zoom = {
|
|
@@ -8765,12 +8772,12 @@
|
|
|
8765
8772
|
...options.pan
|
|
8766
8773
|
};
|
|
8767
8774
|
}
|
|
8768
|
-
if (this._zoom !== zoom ? this._tryAnimatedZoom
|
|
8775
|
+
if (this._zoom !== zoom ? this._tryAnimatedZoom?.(center, zoom, options.zoom) : this._tryAnimatedPan(center, options.pan)) {
|
|
8769
8776
|
clearTimeout(this._sizeTimer);
|
|
8770
8777
|
return this;
|
|
8771
8778
|
}
|
|
8772
8779
|
}
|
|
8773
|
-
this._resetView(center, zoom, options.pan?.noMoveStart);
|
|
8780
|
+
this._resetView(this.options.worldCopyJump ? this.wrapLatLng(center) : center, zoom, options.pan?.noMoveStart);
|
|
8774
8781
|
return this;
|
|
8775
8782
|
}
|
|
8776
8783
|
/**
|
|
@@ -8785,7 +8792,7 @@
|
|
|
8785
8792
|
this._zoom = zoom;
|
|
8786
8793
|
return this;
|
|
8787
8794
|
}
|
|
8788
|
-
return this.setView(this.getCenter(), zoom, { zoom: options });
|
|
8795
|
+
return this.setView(this._targetView?.center ?? this.getCenter(), zoom, { zoom: options });
|
|
8789
8796
|
}
|
|
8790
8797
|
/**
|
|
8791
8798
|
* Increases the zoom of the map by `delta` ([`zoomDelta`](#map-zoomdelta) by default).
|
|
@@ -8796,7 +8803,7 @@
|
|
|
8796
8803
|
*/
|
|
8797
8804
|
zoomIn(delta, options) {
|
|
8798
8805
|
delta ??= this.options.zoomDelta;
|
|
8799
|
-
return this.setZoom(this.
|
|
8806
|
+
return this.setZoom(this._targetZoom() + delta, options);
|
|
8800
8807
|
}
|
|
8801
8808
|
/**
|
|
8802
8809
|
* Decreases the zoom of the map by `delta` ([`zoomDelta`](#map-zoomdelta) by default).
|
|
@@ -8807,7 +8814,7 @@
|
|
|
8807
8814
|
*/
|
|
8808
8815
|
zoomOut(delta, options) {
|
|
8809
8816
|
delta ??= this.options.zoomDelta;
|
|
8810
|
-
return this.setZoom(this.
|
|
8817
|
+
return this.setZoom(this._targetZoom() - delta, options);
|
|
8811
8818
|
}
|
|
8812
8819
|
/**
|
|
8813
8820
|
* Zooms the map while keeping a specified geographical point on the map
|
|
@@ -8829,7 +8836,7 @@
|
|
|
8829
8836
|
bounds = bounds.getBounds ? bounds.getBounds() : LatLngBounds.from(bounds);
|
|
8830
8837
|
const paddingTL = Point.from(options.paddingTopLeft || options.padding || [0, 0]), paddingBR = Point.from(options.paddingBottomRight || options.padding || [0, 0]);
|
|
8831
8838
|
let zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR));
|
|
8832
|
-
zoom =
|
|
8839
|
+
zoom = Math.min(options.maxZoom ?? Infinity, zoom);
|
|
8833
8840
|
if (zoom === Infinity) return {
|
|
8834
8841
|
center: bounds.getCenter(),
|
|
8835
8842
|
zoom
|
|
@@ -8872,7 +8879,7 @@
|
|
|
8872
8879
|
* @returns {this}
|
|
8873
8880
|
*/
|
|
8874
8881
|
panTo(center, options) {
|
|
8875
|
-
return this.setView(center,
|
|
8882
|
+
return this.setView(center, void 0, { pan: options });
|
|
8876
8883
|
}
|
|
8877
8884
|
/**
|
|
8878
8885
|
* Pans the map by a given number of pixels (animated unless `animate: false` is passed,
|
|
@@ -8884,24 +8891,18 @@
|
|
|
8884
8891
|
* @returns {this}
|
|
8885
8892
|
*/
|
|
8886
8893
|
panBy(offset, options) {
|
|
8887
|
-
|
|
8894
|
+
const { center = this.getCenter(), zoom = this._zoom } = this._targetView ?? {}, newCenter = this.unproject(this.project(center, zoom).add(Point.from(offset).round()), zoom);
|
|
8895
|
+
return this.setView(newCenter, zoom, { pan: options });
|
|
8896
|
+
}
|
|
8897
|
+
_panBy(offset, options) {
|
|
8888
8898
|
options ??= {};
|
|
8889
|
-
if (!offset.x && !offset.y) return this.
|
|
8890
|
-
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
return this;
|
|
8895
|
-
}
|
|
8896
|
-
if (!this._panAnim) {
|
|
8897
|
-
this._panAnim = new PosAnimation();
|
|
8898
|
-
this._panAnim.on({
|
|
8899
|
-
"step": this._onPanTransitionStep,
|
|
8900
|
-
"end": this._onPanTransitionEnd
|
|
8901
|
-
}, this);
|
|
8902
|
-
}
|
|
8899
|
+
if (!offset.x && !offset.y) return this._moveStart(false, true)._moveEnd(false);
|
|
8900
|
+
if (!this._panAnim) this._panAnim = new PosAnimation().on({
|
|
8901
|
+
step: this._onPanTransitionStep,
|
|
8902
|
+
end: this._onPanTransitionEnd
|
|
8903
|
+
}, this);
|
|
8903
8904
|
if (!options.noMoveStart) this.fire("movestart");
|
|
8904
|
-
const tooFarForReducedMotion = this._prefersReducedMotion() && !
|
|
8905
|
+
const tooFarForReducedMotion = this._prefersReducedMotion() && !this.getSize().divideBy(2).contains(offset);
|
|
8905
8906
|
if (options.animate === true || options.animate !== false && !tooFarForReducedMotion) {
|
|
8906
8907
|
this._mapPane.classList.add("maplair-pan-anim");
|
|
8907
8908
|
const newPos = this._getMapPanePos().subtract(offset).round();
|
|
@@ -8909,7 +8910,7 @@
|
|
|
8909
8910
|
} else {
|
|
8910
8911
|
this._rawPanBy(offset);
|
|
8911
8912
|
this._wrapWorldCopy();
|
|
8912
|
-
this.fire("move").
|
|
8913
|
+
this.fire("move")._moveEnd(false);
|
|
8913
8914
|
}
|
|
8914
8915
|
return this;
|
|
8915
8916
|
}
|
|
@@ -8933,9 +8934,14 @@
|
|
|
8933
8934
|
}
|
|
8934
8935
|
});
|
|
8935
8936
|
if (options.animate !== true && this._prefersReducedMotion()) return this.setView(targetCenter, targetZoom, options);
|
|
8936
|
-
this.
|
|
8937
|
-
|
|
8937
|
+
targetZoom = targetZoom === void 0 ? this._targetZoom() : this._limitZoom(targetZoom);
|
|
8938
|
+
const requestedCenter = targetCenter;
|
|
8938
8939
|
targetCenter = this._limitCenter(new LatLng(targetCenter), targetZoom, this.options.maxBounds);
|
|
8940
|
+
this._stop();
|
|
8941
|
+
this._targetView = {
|
|
8942
|
+
center: requestedCenter,
|
|
8943
|
+
zoom: targetZoom
|
|
8944
|
+
};
|
|
8939
8945
|
const from = this.project(this.getCenter()), to = this.project(targetCenter), size = this.getSize(), startZoom = this._zoom;
|
|
8940
8946
|
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;
|
|
8941
8947
|
function r(i) {
|
|
@@ -8949,7 +8955,7 @@
|
|
|
8949
8955
|
function easeOut(t) {
|
|
8950
8956
|
return 1 - (1 - t) ** 1.5;
|
|
8951
8957
|
}
|
|
8952
|
-
const start = Date.now(), S = (r(1) - r0) / rho, duration =
|
|
8958
|
+
const start = Date.now(), S = (r(1) - r0) / rho, duration = 1e3 * (options.duration || S * .8);
|
|
8953
8959
|
const frame = () => {
|
|
8954
8960
|
const t = (Date.now() - start) / duration, s = easeOut(t) * S;
|
|
8955
8961
|
if (t <= 1) {
|
|
@@ -9101,8 +9107,8 @@
|
|
|
9101
9107
|
}
|
|
9102
9108
|
/**
|
|
9103
9109
|
* Checks if the map container size changed and updates the map if so —
|
|
9104
|
-
* call it after you've changed the map size dynamically, also
|
|
9105
|
-
*
|
|
9110
|
+
* call it after you've changed the map size dynamically, also panning to
|
|
9111
|
+
* keep the center by default. If `options.pan` is `false`, panning will not occur.
|
|
9106
9112
|
* If `options.debounceMoveend` is `true`, it will delay `moveend` event so
|
|
9107
9113
|
* that it doesn't happen often even if the method is called many
|
|
9108
9114
|
* times in a row. Passing `true` instead of options animates the panning.
|
|
@@ -9119,8 +9125,9 @@
|
|
|
9119
9125
|
};
|
|
9120
9126
|
const oldSize = this.getSize();
|
|
9121
9127
|
this._sizeChanged = true;
|
|
9122
|
-
|
|
9123
|
-
|
|
9128
|
+
const newSize = this.getSize();
|
|
9129
|
+
if (!newSize.equals(oldSize)) this._lastCenter = null;
|
|
9130
|
+
const oldCenter = oldSize.divideBy(2).round(), newCenter = newSize.divideBy(2).round(), offset = oldCenter.subtract(newCenter);
|
|
9124
9131
|
if (!offset.x && !offset.y) return this;
|
|
9125
9132
|
if (options.animate && options.pan) this.panBy(offset);
|
|
9126
9133
|
else {
|
|
@@ -9202,7 +9209,7 @@
|
|
|
9202
9209
|
}
|
|
9203
9210
|
_handleGeolocationResponse(pos) {
|
|
9204
9211
|
if (!this._container._maplair_id) return;
|
|
9205
|
-
const
|
|
9212
|
+
const latlng = new LatLng(pos.coords.latitude, pos.coords.longitude), bounds = latlng.toBounds(pos.coords.accuracy * 2), options = this._locateOptions;
|
|
9206
9213
|
if (options.setView) {
|
|
9207
9214
|
const zoom = this.getBoundsZoom(bounds);
|
|
9208
9215
|
this.setView(latlng, options.maxZoom ? Math.min(zoom, options.maxZoom) : zoom);
|
|
@@ -9236,7 +9243,7 @@
|
|
|
9236
9243
|
*/
|
|
9237
9244
|
remove() {
|
|
9238
9245
|
this._initEvents(true);
|
|
9239
|
-
|
|
9246
|
+
this.off("moveend", this._panInsideMaxBounds);
|
|
9240
9247
|
if (this._containerId !== this._container._maplair_id) throw new Error("Map container is being reused by another instance");
|
|
9241
9248
|
delete this._container._maplair_id;
|
|
9242
9249
|
delete this._containerId;
|
|
@@ -9335,7 +9342,7 @@
|
|
|
9335
9342
|
bounds = LatLngBounds.from(bounds);
|
|
9336
9343
|
padding = Point.from(padding ?? [0, 0]);
|
|
9337
9344
|
let zoom = this.getZoom() ?? 0;
|
|
9338
|
-
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);
|
|
9345
|
+
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 = Math.max(size.x, 0) / boundsSize.x, scaley = Math.max(size.y, 0) / boundsSize.y, scale = inside ? Math.max(scalex, scaley) : Math.min(scalex, scaley);
|
|
9339
9346
|
zoom = this.getScaleZoom(scale, zoom);
|
|
9340
9347
|
if (snap) {
|
|
9341
9348
|
zoom = Math.round(zoom / (snap / 100)) * (snap / 100);
|
|
@@ -9745,10 +9752,13 @@
|
|
|
9745
9752
|
return this;
|
|
9746
9753
|
}
|
|
9747
9754
|
_moveEnd(zoomChanged) {
|
|
9755
|
+
if (!this._pendingView) this._targetView = null;
|
|
9748
9756
|
if (zoomChanged) this.fire("zoomend");
|
|
9749
9757
|
return this.fire("moveend");
|
|
9750
9758
|
}
|
|
9751
9759
|
_stop() {
|
|
9760
|
+
this._pendingView = null;
|
|
9761
|
+
this._targetView = null;
|
|
9752
9762
|
cancelAnimationFrame(this._flyToFrame);
|
|
9753
9763
|
cancelAnimationFrame(this._zoomAnimFrame);
|
|
9754
9764
|
this._panAnim?.stop();
|
|
@@ -9805,13 +9815,14 @@
|
|
|
9805
9815
|
_findEventTargets(e, type) {
|
|
9806
9816
|
let targets = [], target, src = e.target, dragging = false;
|
|
9807
9817
|
const isHover = type === "pointerout" || type === "pointerover";
|
|
9818
|
+
const canEndDrag = (type === "click" || type === "preclick") && e.detail > 0;
|
|
9808
9819
|
while (src) {
|
|
9809
9820
|
target = this._targets[stamp(src)];
|
|
9810
|
-
if (target &&
|
|
9821
|
+
if (target && canEndDrag && this._draggableMoved(target)) {
|
|
9811
9822
|
dragging = true;
|
|
9812
9823
|
break;
|
|
9813
9824
|
}
|
|
9814
|
-
if (target
|
|
9825
|
+
if (target?.listens(type, true)) {
|
|
9815
9826
|
if (isHover && !isExternalTarget(src, e)) break;
|
|
9816
9827
|
targets.push(target);
|
|
9817
9828
|
if (isHover) break;
|
|
@@ -9830,8 +9841,23 @@
|
|
|
9830
9841
|
}
|
|
9831
9842
|
_handleDOMEvent(e) {
|
|
9832
9843
|
const el = e.target;
|
|
9833
|
-
if (
|
|
9834
|
-
this.
|
|
9844
|
+
if (e.type === "click") simulateDblclick(e, this._container);
|
|
9845
|
+
if (!this._loaded || e.type === "click" && this._isClickDisabled(el)) return;
|
|
9846
|
+
const type = e.type, move = type === "pointermove", hovered = this._hoveredCanvasLayer, skip = type === "pointerover" || type === "pointerout" || type.startsWith("key") || this._animatingZoom || move && this.dragging?.moving(), layer = skip ? void 0 : this._canvasLayerAt(e, type === "click"), leftMap = type === "pointerout" && !this._container.contains(e.relatedTarget);
|
|
9847
|
+
if (layer !== hovered && (move && !skip || leftMap)) {
|
|
9848
|
+
if (hovered) this._fireDOMEvent(e, "pointerout", [hovered]);
|
|
9849
|
+
this._container.classList.toggle("maplair-interactive", !!layer);
|
|
9850
|
+
this._hoveredCanvasLayer = layer;
|
|
9851
|
+
if (layer) this._fireDOMEvent(e, "pointerover", [layer]);
|
|
9852
|
+
}
|
|
9853
|
+
this._fireDOMEvent(e, type, layer && [layer]);
|
|
9854
|
+
}
|
|
9855
|
+
_canvasLayerAt(e, click) {
|
|
9856
|
+
for (let el = e.target; el !== this._container; el = el.parentNode) if (!el || el === this._controlContainer || this._targets[stamp(el)]) return;
|
|
9857
|
+
for (const renderer of this._canvases) {
|
|
9858
|
+
const layer = renderer._layerAt(e, click);
|
|
9859
|
+
if (layer) return layer;
|
|
9860
|
+
}
|
|
9835
9861
|
}
|
|
9836
9862
|
static _pointerEvents = [
|
|
9837
9863
|
"click",
|
|
@@ -9842,7 +9868,7 @@
|
|
|
9842
9868
|
];
|
|
9843
9869
|
_fireDOMEvent(e, type, canvasTargets) {
|
|
9844
9870
|
if (type === "click") this._fireDOMEvent(e, "preclick", canvasTargets);
|
|
9845
|
-
let targets = this._findEventTargets(e, type);
|
|
9871
|
+
let targets = canvasTargets && (type === "pointerover" || type === "pointerout") ? [] : this._findEventTargets(e, type);
|
|
9846
9872
|
if (canvasTargets) targets = [...canvasTargets.filter((t) => t.listens(type, true)), ...targets];
|
|
9847
9873
|
if (!targets.length) return;
|
|
9848
9874
|
if (type === "contextmenu") e.preventDefault();
|
|
@@ -9930,17 +9956,17 @@
|
|
|
9930
9956
|
_onPanTransitionEnd() {
|
|
9931
9957
|
this._mapPane.classList.remove("maplair-pan-anim");
|
|
9932
9958
|
this._wrapWorldCopy();
|
|
9933
|
-
this.
|
|
9959
|
+
this._moveEnd(false);
|
|
9934
9960
|
}
|
|
9935
9961
|
_tryAnimatedPan(center, options) {
|
|
9936
|
-
const offset = this.
|
|
9962
|
+
const offset = this.latLngToLayerPoint(center)._subtract(this._getCenterLayerPoint())._round();
|
|
9937
9963
|
if (options?.animate !== true && !this.getSize().contains(offset)) return false;
|
|
9938
|
-
this.
|
|
9964
|
+
this._panBy(offset, options);
|
|
9939
9965
|
return true;
|
|
9940
9966
|
}
|
|
9941
9967
|
_createAnimProxy() {
|
|
9942
9968
|
this._proxy = create("div", "maplair-proxy maplair-zoom-animated");
|
|
9943
|
-
this._panes.mapPane.
|
|
9969
|
+
this._panes.mapPane.append(this._proxy);
|
|
9944
9970
|
this.on("zoomanim", this._animateProxyZoom, this);
|
|
9945
9971
|
this.on("load moveend", this._animMoveEnd, this);
|
|
9946
9972
|
on(this._proxy, "transitionend", this._catchTransitionEnd, this);
|
|
@@ -9974,6 +10000,9 @@
|
|
|
9974
10000
|
};
|
|
9975
10001
|
this._flyToFrame = requestAnimationFrame(frame);
|
|
9976
10002
|
}
|
|
10003
|
+
_targetZoom() {
|
|
10004
|
+
return this._targetView?.zoom ?? this._zoom;
|
|
10005
|
+
}
|
|
9977
10006
|
_zoomInputBlocked() {
|
|
9978
10007
|
return this._animatingZoom || Date.now() < this._instantZoomEnd;
|
|
9979
10008
|
}
|
|
@@ -10017,11 +10046,16 @@
|
|
|
10017
10046
|
if (!this._animatingZoom) return;
|
|
10018
10047
|
this._mapPane?.classList.remove("maplair-zoom-anim");
|
|
10019
10048
|
this._animatingZoom = false;
|
|
10020
|
-
this._move(this.
|
|
10049
|
+
this._move(this.getCenter(), this._animateToZoom, void 0, true);
|
|
10021
10050
|
if (this._tempFireZoomEvent) this.fire("zoom");
|
|
10022
10051
|
delete this._tempFireZoomEvent;
|
|
10023
10052
|
this.fire("move");
|
|
10024
10053
|
this._moveEnd(true);
|
|
10054
|
+
const view = this._pendingView;
|
|
10055
|
+
if (view) {
|
|
10056
|
+
this._pendingView = null;
|
|
10057
|
+
this.setView(view.center, view.zoom, view.options);
|
|
10058
|
+
}
|
|
10025
10059
|
}
|
|
10026
10060
|
};
|
|
10027
10061
|
for (const feature of [
|
|
@@ -10141,9 +10175,9 @@
|
|
|
10141
10175
|
closestLayerPoint(p) {
|
|
10142
10176
|
p = Point.from(p);
|
|
10143
10177
|
let minDistance = Infinity, minPoint = null, p1, p2;
|
|
10144
|
-
const closest = _sqClosestPointOnSegment;
|
|
10145
|
-
for (const points of this._parts) for (let i = 1, len = points.length; i < len; i++) {
|
|
10146
|
-
p1 = points[i - 1];
|
|
10178
|
+
const closest = _sqClosestPointOnSegment, closed = this._isClosed();
|
|
10179
|
+
for (const points of this._parts) for (let i = closed ? 0 : 1, len = points.length; i < len; i++) {
|
|
10180
|
+
p1 = points[(i || len) - 1];
|
|
10147
10181
|
p2 = points[i];
|
|
10148
10182
|
const sqDist = closest(p, p1, p2, true);
|
|
10149
10183
|
if (sqDist < minDistance) {
|
|
@@ -10216,7 +10250,7 @@
|
|
|
10216
10250
|
}
|
|
10217
10251
|
_projectLatlngs(latlngs, result, projectedBounds) {
|
|
10218
10252
|
if (latlngs[0] instanceof LatLng) {
|
|
10219
|
-
const ring = latlngs.map((latlng) => this.
|
|
10253
|
+
const ring = latlngs.map((latlng) => this._renderer._latLngToLayerPoint(latlng));
|
|
10220
10254
|
ring.forEach((r) => projectedBounds.extend(r));
|
|
10221
10255
|
result.push(ring);
|
|
10222
10256
|
} else latlngs.forEach((latlng) => this._projectLatlngs(latlng, result, projectedBounds));
|
|
@@ -10224,24 +10258,21 @@
|
|
|
10224
10258
|
_clipPoints() {
|
|
10225
10259
|
const bounds = this._renderer._bounds;
|
|
10226
10260
|
this._parts = [];
|
|
10227
|
-
if (!this._pxBounds
|
|
10261
|
+
if (!this._pxBounds?.intersects(bounds)) return;
|
|
10228
10262
|
if (this.options.noClip) {
|
|
10229
10263
|
this._parts = this._rings;
|
|
10230
10264
|
return;
|
|
10231
10265
|
}
|
|
10232
10266
|
const parts = this._parts;
|
|
10233
|
-
let
|
|
10234
|
-
for (
|
|
10235
|
-
|
|
10236
|
-
|
|
10237
|
-
|
|
10238
|
-
|
|
10239
|
-
|
|
10240
|
-
parts[k].push(segment[
|
|
10241
|
-
|
|
10242
|
-
parts[k].push(segment[1]);
|
|
10243
|
-
k++;
|
|
10244
|
-
}
|
|
10267
|
+
let k = 0;
|
|
10268
|
+
for (const points of this._rings) for (let j = 0, len = points.length; j < len - 1; j++) {
|
|
10269
|
+
const segment = clipSegment(points[j], points[j + 1], bounds, j);
|
|
10270
|
+
if (!segment) continue;
|
|
10271
|
+
parts[k] ??= [];
|
|
10272
|
+
parts[k].push(segment[0]);
|
|
10273
|
+
if (segment[1] !== points[j + 1] || j === len - 2) {
|
|
10274
|
+
parts[k].push(segment[1]);
|
|
10275
|
+
k++;
|
|
10245
10276
|
}
|
|
10246
10277
|
}
|
|
10247
10278
|
}
|
|
@@ -10258,17 +10289,13 @@
|
|
|
10258
10289
|
_updatePath() {
|
|
10259
10290
|
this._renderer._updatePoly(this);
|
|
10260
10291
|
}
|
|
10292
|
+
_isClosed() {
|
|
10293
|
+
return false;
|
|
10294
|
+
}
|
|
10261
10295
|
_containsPoint(p, closed) {
|
|
10262
|
-
let i, j, k, len, len2, part;
|
|
10263
10296
|
const w = this._clickTolerance();
|
|
10264
|
-
if (!this._pxBounds
|
|
10265
|
-
for (
|
|
10266
|
-
part = this._parts[i];
|
|
10267
|
-
for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) {
|
|
10268
|
-
if (!closed && j === 0) continue;
|
|
10269
|
-
if (pointToSegmentDistance(p, part[k], part[j]) <= w) return true;
|
|
10270
|
-
}
|
|
10271
|
-
}
|
|
10297
|
+
if (!this._pxBounds?.contains(p)) return false;
|
|
10298
|
+
for (const part of this._parts) for (let j = closed ? 0 : 1, len = part.length; j < len; j++) if (pointToSegmentDistance(p, part[(j || len) - 1], part[j]) <= w) return true;
|
|
10272
10299
|
return false;
|
|
10273
10300
|
}
|
|
10274
10301
|
/**
|
|
@@ -10465,10 +10492,10 @@
|
|
|
10465
10492
|
}
|
|
10466
10493
|
_clipPoints() {
|
|
10467
10494
|
let bounds = this._renderer._bounds;
|
|
10468
|
-
const w = this.options.weight, p = new Point(w, w);
|
|
10495
|
+
const w = +this.options.weight || 0, p = new Point(w, w);
|
|
10469
10496
|
bounds = new Bounds(bounds.min.subtract(p), bounds.max.add(p));
|
|
10470
10497
|
this._parts = [];
|
|
10471
|
-
if (!this._pxBounds
|
|
10498
|
+
if (!this._pxBounds?.intersects(bounds)) return;
|
|
10472
10499
|
if (this.options.noClip) {
|
|
10473
10500
|
this._parts = this._rings;
|
|
10474
10501
|
return;
|
|
@@ -10481,16 +10508,15 @@
|
|
|
10481
10508
|
_updatePath() {
|
|
10482
10509
|
this._renderer._updatePoly(this, true);
|
|
10483
10510
|
}
|
|
10511
|
+
_isClosed() {
|
|
10512
|
+
return true;
|
|
10513
|
+
}
|
|
10484
10514
|
_containsPoint(p) {
|
|
10485
|
-
let inside = false
|
|
10486
|
-
if (!this._pxBounds
|
|
10487
|
-
for (
|
|
10488
|
-
part =
|
|
10489
|
-
|
|
10490
|
-
p1 = part[j];
|
|
10491
|
-
p2 = part[k];
|
|
10492
|
-
if (p1.y > p.y !== p2.y > p.y && p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x) inside = !inside;
|
|
10493
|
-
}
|
|
10515
|
+
let inside = false;
|
|
10516
|
+
if (!this._pxBounds?.contains(p)) return false;
|
|
10517
|
+
for (const part of this._parts) for (let j = 0, len = part.length, k = len - 1; j < len; k = j++) {
|
|
10518
|
+
const p1 = part[j], p2 = part[k];
|
|
10519
|
+
if (p1.y > p.y !== p2.y > p.y && p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x) inside = !inside;
|
|
10494
10520
|
}
|
|
10495
10521
|
return inside || super._containsPoint(p, true);
|
|
10496
10522
|
}
|
|
@@ -10733,16 +10759,15 @@
|
|
|
10733
10759
|
onAdd(map) {
|
|
10734
10760
|
const className = "maplair-control-scale", container = create("div", className), options = this.options;
|
|
10735
10761
|
this._addScales(options, `${className}-line`, container);
|
|
10736
|
-
map.on(options.updateWhenIdle ? "moveend" : "move", this._update, this);
|
|
10737
10762
|
map.whenReady(this._update, this);
|
|
10738
10763
|
return container;
|
|
10739
10764
|
}
|
|
10740
10765
|
/**
|
|
10741
10766
|
* @internal
|
|
10742
|
-
* @
|
|
10767
|
+
* @returns {Record<string, Function>}
|
|
10743
10768
|
*/
|
|
10744
|
-
|
|
10745
|
-
|
|
10769
|
+
getEvents() {
|
|
10770
|
+
return { [this.options.updateWhenIdle ? "moveend" : "move"]: this._update };
|
|
10746
10771
|
}
|
|
10747
10772
|
_addScales(options, className, container) {
|
|
10748
10773
|
if (options.metric) this._mScale = create("div", className, container);
|
|
@@ -10775,7 +10800,7 @@
|
|
|
10775
10800
|
}
|
|
10776
10801
|
_updateScale(scale, text, ratio) {
|
|
10777
10802
|
scale.style.width = `${Math.round(this.options.maxWidth * ratio)}px`;
|
|
10778
|
-
scale.
|
|
10803
|
+
scale.textContent = text;
|
|
10779
10804
|
}
|
|
10780
10805
|
_getRoundNum(num) {
|
|
10781
10806
|
const pow10 = 10 ** (`${Math.floor(num)}`.length - 1);
|
|
@@ -10882,25 +10907,26 @@
|
|
|
10882
10907
|
const img = this._createImg(src, oldIcon instanceof HTMLImageElement ? oldIcon : null);
|
|
10883
10908
|
this._setIconStyles(img, name);
|
|
10884
10909
|
if (this.options.crossOrigin || this.options.crossOrigin === "") img.crossOrigin = this.options.crossOrigin === true ? "" : this.options.crossOrigin;
|
|
10910
|
+
else img.crossOrigin = null;
|
|
10885
10911
|
return img;
|
|
10886
10912
|
}
|
|
10887
10913
|
_setIconStyles(img, name) {
|
|
10888
10914
|
const options = this.options;
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
const
|
|
10892
|
-
const
|
|
10893
|
-
|
|
10915
|
+
const sizeOption = options[`${name}Size`];
|
|
10916
|
+
const [width, height] = (typeof sizeOption === "number" ? [sizeOption, sizeOption] : Array.isArray(sizeOption) ? sizeOption : [sizeOption?.x, sizeOption?.y]).map(toNumber);
|
|
10917
|
+
const anchorOption = name === "shadow" && options.shadowAnchor || options.iconAnchor;
|
|
10918
|
+
const anchor = Point.validate(anchorOption) ? Point.from(anchorOption) : {
|
|
10919
|
+
x: Math.round(width / 2),
|
|
10920
|
+
y: Math.round(height / 2)
|
|
10921
|
+
};
|
|
10894
10922
|
img.className = `maplair-marker-${name} ${options.className || ""}`;
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
|
|
10898
|
-
}
|
|
10899
|
-
|
|
10900
|
-
if (
|
|
10901
|
-
|
|
10902
|
-
img.style.height = `${size.y}px`;
|
|
10903
|
-
}
|
|
10923
|
+
const { style } = img;
|
|
10924
|
+
style.marginLeft = style.marginTop = style.width = style.height = "";
|
|
10925
|
+
if (!isNaN(anchor.x)) style.marginLeft = `${-anchor.x}px`;
|
|
10926
|
+
if (!isNaN(anchor.y)) style.marginTop = `${-anchor.y}px`;
|
|
10927
|
+
style.transformOrigin = !isNaN(anchor.x) && !isNaN(anchor.y) ? `${anchor.x}px ${anchor.y}px` : "0 0";
|
|
10928
|
+
if (!isNaN(width)) style.width = `${width}px`;
|
|
10929
|
+
if (!isNaN(height)) style.height = `${height}px`;
|
|
10904
10930
|
}
|
|
10905
10931
|
_createImg(src, el) {
|
|
10906
10932
|
el ??= document.createElement("img");
|
|
@@ -11048,10 +11074,10 @@
|
|
|
11048
11074
|
return this._draggable?._moved;
|
|
11049
11075
|
}
|
|
11050
11076
|
_adjustPan(e) {
|
|
11051
|
-
const marker = this._marker, map = marker._map, speed = this._marker.options.autoPanSpeed, padding = this._marker.options.autoPanPadding, iconPos = getPosition(marker._icon), bounds = map.getPixelBounds(), origin = map.getPixelOrigin();
|
|
11052
|
-
|
|
11053
|
-
|
|
11054
|
-
|
|
11077
|
+
const marker = this._marker, map = marker._map, speed = this._marker.options.autoPanSpeed, padding = new Point(this._marker.options.autoPanPadding), iconPos = getPosition(marker._icon), bounds = map.getPixelBounds(), origin = map.getPixelOrigin(), min = bounds.min._subtract(origin)._add(padding), max = bounds.max._subtract(origin)._subtract(padding), dx = Math.max(iconPos.x - max.x, 0) + Math.min(iconPos.x - min.x, 0), dy = Math.max(iconPos.y - max.y, 0) + Math.min(iconPos.y - min.y, 0);
|
|
11078
|
+
if (dx || dy) {
|
|
11079
|
+
const movement = map._limitOffset(new Point(dx / padding.x * speed, dy / padding.y * speed), map.options.maxBounds)._round();
|
|
11080
|
+
if (!movement.x && !movement.y) return;
|
|
11055
11081
|
map.panBy(movement, { animate: false });
|
|
11056
11082
|
this._draggable._newPos._add(movement);
|
|
11057
11083
|
this._draggable._startPos._add(movement);
|
|
@@ -11072,7 +11098,8 @@
|
|
|
11072
11098
|
}
|
|
11073
11099
|
}
|
|
11074
11100
|
_onDrag(e) {
|
|
11075
|
-
const marker = this._marker, iconPos = getPosition(marker._icon), latlng = marker._map.layerPointToLatLng(iconPos);
|
|
11101
|
+
const marker = this._marker, iconPos = getPosition(marker._icon), latlng = marker._map.layerPointToLatLng(iconPos), { alt } = this._oldLatLng;
|
|
11102
|
+
if (alt !== void 0) latlng.alt = alt;
|
|
11076
11103
|
marker._positionElements(iconPos);
|
|
11077
11104
|
marker._latlng = latlng;
|
|
11078
11105
|
e.latlng = latlng;
|
|
@@ -11081,7 +11108,6 @@
|
|
|
11081
11108
|
}
|
|
11082
11109
|
_onDragEnd(e) {
|
|
11083
11110
|
cancelAnimationFrame(this._panRequest);
|
|
11084
|
-
delete this._oldLatLng;
|
|
11085
11111
|
this._marker.fire("moveend").fire("dragend", e);
|
|
11086
11112
|
}
|
|
11087
11113
|
/** @param {KeyboardEvent|FocusEvent} e */
|
|
@@ -11133,7 +11159,8 @@
|
|
|
11133
11159
|
* @property {string} [title=''] Text for the browser tooltip that appear on marker hover
|
|
11134
11160
|
* (no tooltip by default).
|
|
11135
11161
|
* [Useful for accessibility](https://maplair.org/examples/accessibility/#markers-must-be-labelled).
|
|
11136
|
-
* @property {string} [alt
|
|
11162
|
+
* @property {string} [alt] Text for the `alt` attribute of the icon image, the
|
|
11163
|
+
* translation of `'Marker'` by default.
|
|
11137
11164
|
* [Useful for accessibility](https://maplair.org/examples/accessibility/#markers-must-be-labelled).
|
|
11138
11165
|
* @property {number} [zIndexOffset=0] By default, marker images zIndex is set
|
|
11139
11166
|
* automatically based on its latitude. Use this option if you want to put the marker on
|
|
@@ -11145,9 +11172,9 @@
|
|
|
11145
11172
|
* marker, even at 0°, has no shadow, since the shadow of an upright pin looks wrong
|
|
11146
11173
|
* under a tilted one. `null` means no rotation.
|
|
11147
11174
|
* @property {boolean} [riseOnHover=false] If `true`, the marker will get on top of
|
|
11148
|
-
* others
|
|
11149
|
-
* @property {number} [riseOffset=250] The z-index offset used
|
|
11150
|
-
*
|
|
11175
|
+
* others while the pointer is over it. It always does while it has focus.
|
|
11176
|
+
* @property {number} [riseOffset=250] The z-index offset used when the marker gets on
|
|
11177
|
+
* top of others on hover or focus.
|
|
11151
11178
|
* @property {string} [pane='markerPane'] `Map pane` where the markers icon will be added.
|
|
11152
11179
|
* @property {string} [shadowPane='shadowPane'] `Map pane` where the markers shadow will
|
|
11153
11180
|
* be added.
|
|
@@ -11200,7 +11227,7 @@
|
|
|
11200
11227
|
interactive: true,
|
|
11201
11228
|
keyboard: true,
|
|
11202
11229
|
title: "",
|
|
11203
|
-
alt:
|
|
11230
|
+
alt: void 0,
|
|
11204
11231
|
zIndexOffset: 0,
|
|
11205
11232
|
opacity: 1,
|
|
11206
11233
|
rotation: null,
|
|
@@ -11344,7 +11371,7 @@
|
|
|
11344
11371
|
if (this._icon) this._removeIcon();
|
|
11345
11372
|
addIcon = true;
|
|
11346
11373
|
if (options.title) icon.title = options.title;
|
|
11347
|
-
if (icon instanceof HTMLImageElement) icon.alt = options.alt ?? "";
|
|
11374
|
+
if (icon instanceof HTMLImageElement) icon.alt = options.alt ?? I18n.translate("Marker");
|
|
11348
11375
|
}
|
|
11349
11376
|
icon.classList.add(classToAdd);
|
|
11350
11377
|
if (options.keyboard) {
|
|
@@ -11353,10 +11380,9 @@
|
|
|
11353
11380
|
on(icon, "keydown", this._onKeyDown, this);
|
|
11354
11381
|
}
|
|
11355
11382
|
this._icon = icon;
|
|
11356
|
-
if (
|
|
11357
|
-
|
|
11358
|
-
|
|
11359
|
-
});
|
|
11383
|
+
if (this._popup?._source === this) this._popup._updateSourceAria(this._popup.isOpen());
|
|
11384
|
+
on(icon, "focusin focusout", this._updateRise, this);
|
|
11385
|
+
if (options.riseOnHover) on(icon, "pointerover pointerout", this._updateRise, this);
|
|
11360
11386
|
if (this.options.autoPanOnFocus) on(icon, "focus", this._panOnFocus, this);
|
|
11361
11387
|
const newShadow = options.shadow ? options.icon.createShadow?.(this._shadow) ?? null : null;
|
|
11362
11388
|
let addShadow = false;
|
|
@@ -11370,15 +11396,13 @@
|
|
|
11370
11396
|
}
|
|
11371
11397
|
this._shadow = newShadow;
|
|
11372
11398
|
if (options.opacity < 1) this._updateOpacity();
|
|
11373
|
-
if (addIcon) this.getPane().
|
|
11399
|
+
if (addIcon) this.getPane().append(this._icon);
|
|
11374
11400
|
this._initInteraction();
|
|
11375
|
-
if (newShadow && addShadow) this.getPane(options.shadowPane).
|
|
11401
|
+
if (newShadow && addShadow) this.getPane(options.shadowPane).append(this._shadow);
|
|
11376
11402
|
}
|
|
11377
11403
|
_removeIcon() {
|
|
11378
|
-
|
|
11379
|
-
|
|
11380
|
-
pointerout: this._resetZIndex
|
|
11381
|
-
});
|
|
11404
|
+
off(this._icon, "pointerover pointerout focusin focusout", this._updateRise, this);
|
|
11405
|
+
this._hovered = this._focused = false;
|
|
11382
11406
|
if (this.options.autoPanOnFocus) off(this._icon, "focus", this._panOnFocus, this);
|
|
11383
11407
|
off(this._icon, "keydown", this._onKeyDown, this);
|
|
11384
11408
|
this._icon.remove();
|
|
@@ -11391,8 +11415,8 @@
|
|
|
11391
11415
|
if (visible === !this._culled) return;
|
|
11392
11416
|
this._culled = !visible;
|
|
11393
11417
|
if (visible) {
|
|
11394
|
-
this.getPane().
|
|
11395
|
-
if (this._shadow) this.getPane(this.options.shadowPane).
|
|
11418
|
+
this.getPane().append(this._icon);
|
|
11419
|
+
if (this._shadow) this.getPane(this.options.shadowPane).append(this._shadow);
|
|
11396
11420
|
this.update();
|
|
11397
11421
|
} else {
|
|
11398
11422
|
this._icon.remove();
|
|
@@ -11406,7 +11430,7 @@
|
|
|
11406
11430
|
_setPos(pos) {
|
|
11407
11431
|
this._positionElements(pos);
|
|
11408
11432
|
this._zIndex = pos.y + this.options.zIndexOffset;
|
|
11409
|
-
this.
|
|
11433
|
+
this._updateRise();
|
|
11410
11434
|
}
|
|
11411
11435
|
_positionElements(pos) {
|
|
11412
11436
|
const rotation = this.options.rotation;
|
|
@@ -11448,33 +11472,31 @@
|
|
|
11448
11472
|
if (!this.options.interactive) return;
|
|
11449
11473
|
this._icon.classList.add("maplair-interactive");
|
|
11450
11474
|
this.addInteractiveTarget(this._icon);
|
|
11451
|
-
if (
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
return;
|
|
11455
|
-
}
|
|
11456
|
-
let draggable = this.options.draggable;
|
|
11457
|
-
if (this.dragging) {
|
|
11458
|
-
draggable = this.dragging.enabled();
|
|
11459
|
-
this.dragging.disable();
|
|
11460
|
-
}
|
|
11461
|
-
/**
|
|
11462
|
-
* Marker dragging handler, see `Handler`. Only valid when the marker is on the
|
|
11463
|
-
* map (otherwise set [`marker.options.draggable`](#markeroptions-draggable)).
|
|
11464
|
-
*
|
|
11465
|
-
* Interaction handlers are properties of a marker instance that allow you to
|
|
11466
|
-
* control interaction behavior in runtime, enabling or disabling certain
|
|
11467
|
-
* features such as dragging (see `Handler` methods). Example:
|
|
11468
|
-
*
|
|
11469
|
-
* ```js
|
|
11470
|
-
* marker.dragging.disable();
|
|
11471
|
-
* ```
|
|
11472
|
-
* @group Interaction handlers
|
|
11473
|
-
* @type {MarkerDrag}
|
|
11474
|
-
*/
|
|
11475
|
-
this.dragging = new MarkerDrag(this);
|
|
11476
|
-
if (draggable) this.dragging.enable();
|
|
11475
|
+
if (this.dragging?._draggable?._element === this._icon) {
|
|
11476
|
+
this._icon.classList.toggle("maplair-marker-draggable", this.dragging.enabled());
|
|
11477
|
+
return;
|
|
11477
11478
|
}
|
|
11479
|
+
let draggable = this.options.draggable;
|
|
11480
|
+
if (this.dragging) {
|
|
11481
|
+
draggable = this.dragging.enabled();
|
|
11482
|
+
this.dragging.disable();
|
|
11483
|
+
}
|
|
11484
|
+
/**
|
|
11485
|
+
* Marker dragging handler, see `Handler`. Only valid when the marker is on the
|
|
11486
|
+
* map (otherwise set [`marker.options.draggable`](#markeroptions-draggable)).
|
|
11487
|
+
*
|
|
11488
|
+
* Interaction handlers are properties of a marker instance that allow you to
|
|
11489
|
+
* control interaction behavior in runtime, enabling or disabling certain
|
|
11490
|
+
* features such as dragging (see `Handler` methods). Example:
|
|
11491
|
+
*
|
|
11492
|
+
* ```js
|
|
11493
|
+
* marker.dragging.disable();
|
|
11494
|
+
* ```
|
|
11495
|
+
* @group Interaction handlers
|
|
11496
|
+
* @type {MarkerDrag}
|
|
11497
|
+
*/
|
|
11498
|
+
this.dragging = new MarkerDrag(this);
|
|
11499
|
+
if (draggable) this.dragging.enable();
|
|
11478
11500
|
}
|
|
11479
11501
|
/**
|
|
11480
11502
|
* Returns the current [rotation](#markeroptions-rotation) of the marker in degrees.
|
|
@@ -11508,9 +11530,13 @@
|
|
|
11508
11530
|
return this;
|
|
11509
11531
|
}
|
|
11510
11532
|
_updateOpacity() {
|
|
11511
|
-
const opacity = this.options.opacity
|
|
11512
|
-
|
|
11513
|
-
|
|
11533
|
+
for (const el of [this._icon, this._shadow]) if (el) el.style.opacity = `${this.options.opacity}`;
|
|
11534
|
+
}
|
|
11535
|
+
_updateRise(e) {
|
|
11536
|
+
if (e?.type.startsWith("pointer")) this._hovered = e.type === "pointerover";
|
|
11537
|
+
else if (e) this._focused = e.type === "focusin";
|
|
11538
|
+
if (this._hovered || this._focused) this._bringToFront();
|
|
11539
|
+
else this._resetZIndex();
|
|
11514
11540
|
}
|
|
11515
11541
|
_bringToFront() {
|
|
11516
11542
|
this._updateZIndex(this.options.riseOffset);
|
|
@@ -12134,8 +12160,9 @@
|
|
|
12134
12160
|
this.remove();
|
|
12135
12161
|
this._map = map;
|
|
12136
12162
|
this._container = this.onAdd(map);
|
|
12137
|
-
map._container.
|
|
12138
|
-
|
|
12163
|
+
map._container.append(this._container);
|
|
12164
|
+
this._mapEvents = { unload: this.remove };
|
|
12165
|
+
map.on(this._mapEvents, this);
|
|
12139
12166
|
return this;
|
|
12140
12167
|
}
|
|
12141
12168
|
/**
|
|
@@ -13670,6 +13697,7 @@
|
|
|
13670
13697
|
onAdd() {
|
|
13671
13698
|
if (!this._image) {
|
|
13672
13699
|
this._initImage();
|
|
13700
|
+
this._updateZIndex();
|
|
13673
13701
|
if (this.options.opacity < 1) this._updateOpacity();
|
|
13674
13702
|
}
|
|
13675
13703
|
if (this.options.interactive) {
|
|
@@ -13677,7 +13705,7 @@
|
|
|
13677
13705
|
this.addInteractiveTarget(this._image);
|
|
13678
13706
|
}
|
|
13679
13707
|
this._image.classList.toggle("maplair-pixelated", !!this.options.pixelated);
|
|
13680
|
-
this.getPane().
|
|
13708
|
+
this.getPane().append(this._image);
|
|
13681
13709
|
this._reset();
|
|
13682
13710
|
}
|
|
13683
13711
|
/**
|
|
@@ -13710,7 +13738,7 @@
|
|
|
13710
13738
|
* @returns {this}
|
|
13711
13739
|
*/
|
|
13712
13740
|
setStyle(styleOpts) {
|
|
13713
|
-
if (styleOpts.opacity) this.setOpacity(styleOpts.opacity);
|
|
13741
|
+
if (styleOpts.opacity != null) this.setOpacity(styleOpts.opacity);
|
|
13714
13742
|
return this;
|
|
13715
13743
|
}
|
|
13716
13744
|
/**
|
|
@@ -13796,7 +13824,6 @@
|
|
|
13796
13824
|
img.onerror = this._overlayOnError.bind(this);
|
|
13797
13825
|
if (this.options.crossOrigin || this.options.crossOrigin === "") img.crossOrigin = this.options.crossOrigin === true ? "" : this.options.crossOrigin;
|
|
13798
13826
|
img.decoding = this.options.decoding;
|
|
13799
|
-
if (this.options.zIndex) this._updateZIndex();
|
|
13800
13827
|
if (wasElementSupplied) {
|
|
13801
13828
|
this._url = img.src;
|
|
13802
13829
|
return;
|
|
@@ -13818,7 +13845,7 @@
|
|
|
13818
13845
|
this._image.style.opacity = `${this.options.opacity}`;
|
|
13819
13846
|
}
|
|
13820
13847
|
_updateZIndex() {
|
|
13821
|
-
if (this._image && this.options.zIndex
|
|
13848
|
+
if (this._image && this.options.zIndex != null) this._image.style.zIndex = `${this.options.zIndex}`;
|
|
13822
13849
|
}
|
|
13823
13850
|
_overlayOnError() {
|
|
13824
13851
|
this.fire("error");
|
|
@@ -13835,6 +13862,9 @@
|
|
|
13835
13862
|
getCenter() {
|
|
13836
13863
|
return this._bounds.getCenter();
|
|
13837
13864
|
}
|
|
13865
|
+
_togglesPopupOnClick() {
|
|
13866
|
+
return false;
|
|
13867
|
+
}
|
|
13838
13868
|
};
|
|
13839
13869
|
// src/layer/VideoOverlay.js
|
|
13840
13870
|
/** @import {ImageOverlayOptions} from './ImageOverlay.js' */
|
|
@@ -13915,7 +13945,7 @@
|
|
|
13915
13945
|
return;
|
|
13916
13946
|
}
|
|
13917
13947
|
if (!Array.isArray(this._url)) this._url = [this._url];
|
|
13918
|
-
if (!this.options.keepAspectRatio) vid.style
|
|
13948
|
+
if (!this.options.keepAspectRatio) vid.style.objectFit = "fill";
|
|
13919
13949
|
vid.autoplay = !!this.options.autoplay;
|
|
13920
13950
|
vid.controls = !!this.options.controls;
|
|
13921
13951
|
vid.loop = !!this.options.loop;
|
|
@@ -13924,7 +13954,7 @@
|
|
|
13924
13954
|
for (const url of this._url) {
|
|
13925
13955
|
const source = create("source");
|
|
13926
13956
|
source.src = url;
|
|
13927
|
-
vid.
|
|
13957
|
+
vid.append(source);
|
|
13928
13958
|
}
|
|
13929
13959
|
}
|
|
13930
13960
|
};
|
|
@@ -14027,14 +14057,10 @@
|
|
|
14027
14057
|
*/
|
|
14028
14058
|
createIcon(oldIcon) {
|
|
14029
14059
|
const div = oldIcon instanceof HTMLDivElement ? oldIcon : document.createElement("div"), options = this.options;
|
|
14030
|
-
if (options.html instanceof Element)
|
|
14031
|
-
|
|
14032
|
-
|
|
14033
|
-
|
|
14034
|
-
if (options.bgPos) {
|
|
14035
|
-
const bgPos = Point.from(options.bgPos);
|
|
14036
|
-
div.style.backgroundPosition = `${-bgPos.x}px ${-bgPos.y}px`;
|
|
14037
|
-
}
|
|
14060
|
+
if (options.html instanceof Element) div.replaceChildren(options.html);
|
|
14061
|
+
else div.innerHTML = options.html !== false ? options.html : "";
|
|
14062
|
+
const bgPos = options.bgPos && Point.from(options.bgPos);
|
|
14063
|
+
div.style.backgroundPosition = bgPos ? `${-bgPos.x}px ${-bgPos.y}px` : "";
|
|
14038
14064
|
this._setIconStyles(div, "icon");
|
|
14039
14065
|
return div;
|
|
14040
14066
|
}
|
|
@@ -14059,7 +14085,7 @@
|
|
|
14059
14085
|
function svgElement(name, attributes, parent) {
|
|
14060
14086
|
const el = document.createElementNS(svgNS, name);
|
|
14061
14087
|
for (const [key, value] of Object.entries(attributes)) el.setAttribute(key, value);
|
|
14062
|
-
parent?.
|
|
14088
|
+
parent?.append(el);
|
|
14063
14089
|
return el;
|
|
14064
14090
|
}
|
|
14065
14091
|
/**
|
|
@@ -14504,10 +14530,10 @@
|
|
|
14504
14530
|
* @typedef {(error: any, tile: HTMLElement) => void} TileDoneCallback
|
|
14505
14531
|
*/
|
|
14506
14532
|
/**
|
|
14507
|
-
* Generic class for handling a tiled grid of HTML elements
|
|
14508
|
-
*
|
|
14509
|
-
* a tiled grid of
|
|
14510
|
-
*
|
|
14533
|
+
* Generic class for handling a tiled grid of HTML elements, and the base class of all
|
|
14534
|
+
* tile layers. To show map tiles from a URL, use `TileLayer` (or `WMSTileLayer`).
|
|
14535
|
+
* Extend `GridLayer` to create a tiled grid of your own elements like `<canvas>`,
|
|
14536
|
+
* `<img>` or `<div>`; it handles creating and animating them for you.
|
|
14511
14537
|
*
|
|
14512
14538
|
* Layers extending `GridLayer` shall reimplement the [`createTile()`](#gridlayer-createtile)
|
|
14513
14539
|
* method.
|
|
@@ -14703,7 +14729,7 @@
|
|
|
14703
14729
|
redraw() {
|
|
14704
14730
|
if (this._map) {
|
|
14705
14731
|
this._removeAllTiles();
|
|
14706
|
-
const tileZoom = this.
|
|
14732
|
+
const tileZoom = this._getTileZoom(this._map.getZoom());
|
|
14707
14733
|
if (tileZoom !== this._tileZoom) {
|
|
14708
14734
|
this._tileZoom = tileZoom;
|
|
14709
14735
|
this._updateLevels();
|
|
@@ -14754,7 +14780,7 @@
|
|
|
14754
14780
|
return s instanceof Point ? s : new Point(s, s);
|
|
14755
14781
|
}
|
|
14756
14782
|
_updateZIndex() {
|
|
14757
|
-
if (this._container && this.options.zIndex
|
|
14783
|
+
if (this._container && this.options.zIndex != null) this._container.style.zIndex = `${this.options.zIndex}`;
|
|
14758
14784
|
}
|
|
14759
14785
|
_setAutoZIndex(compare) {
|
|
14760
14786
|
const layers = this.getPane().children;
|
|
@@ -14779,7 +14805,7 @@
|
|
|
14779
14805
|
this._container.classList.toggle("maplair-pixelated", !!this.options.pixelated);
|
|
14780
14806
|
this._updateZIndex();
|
|
14781
14807
|
if (this.options.opacity < 1) this._updateOpacity();
|
|
14782
|
-
this.getPane().
|
|
14808
|
+
this.getPane().append(this._container);
|
|
14783
14809
|
}
|
|
14784
14810
|
_keepCurrentTiles() {
|
|
14785
14811
|
const zoom = this._tileZoom, level = this._levels?.[zoom];
|
|
@@ -14853,8 +14879,7 @@
|
|
|
14853
14879
|
_onCreateLevel() {}
|
|
14854
14880
|
_pruneTiles() {
|
|
14855
14881
|
if (!this._map) return;
|
|
14856
|
-
|
|
14857
|
-
if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {
|
|
14882
|
+
if (this._getTileZoom(this._map.getZoom()) === void 0) {
|
|
14858
14883
|
this._removeAllTiles();
|
|
14859
14884
|
return;
|
|
14860
14885
|
}
|
|
@@ -14909,6 +14934,11 @@
|
|
|
14909
14934
|
_animateZoom(e) {
|
|
14910
14935
|
this._setView(e.center, e.zoom, true, e.noUpdate);
|
|
14911
14936
|
}
|
|
14937
|
+
_getTileZoom(zoom) {
|
|
14938
|
+
const { minZoom, maxZoom = Infinity } = this.options;
|
|
14939
|
+
if (zoom < minZoom || zoom > maxZoom) return;
|
|
14940
|
+
return this._clampZoom(Math.round(zoom));
|
|
14941
|
+
}
|
|
14912
14942
|
_clampZoom(zoom) {
|
|
14913
14943
|
const options = this.options;
|
|
14914
14944
|
if (void 0 !== options.minNativeZoom && zoom < options.minNativeZoom) return options.minNativeZoom;
|
|
@@ -14916,13 +14946,11 @@
|
|
|
14916
14946
|
return zoom;
|
|
14917
14947
|
}
|
|
14918
14948
|
_setView(center, zoom, noPrune, noUpdate) {
|
|
14919
|
-
|
|
14920
|
-
if (this.options.maxZoom !== void 0 && tileZoom > this.options.maxZoom || this.options.minZoom !== void 0 && tileZoom < this.options.minZoom) tileZoom = void 0;
|
|
14921
|
-
else tileZoom = this._clampZoom(tileZoom);
|
|
14949
|
+
const tileZoom = this._getTileZoom(zoom);
|
|
14922
14950
|
const tileZoomChanged = this.options.updateWhenZooming && tileZoom !== this._tileZoom;
|
|
14923
14951
|
if (!noUpdate || tileZoomChanged) {
|
|
14924
14952
|
this._tileZoom = tileZoom;
|
|
14925
|
-
|
|
14953
|
+
this._abortLoading?.();
|
|
14926
14954
|
this._updateLevels();
|
|
14927
14955
|
this._resetGrid();
|
|
14928
14956
|
if (tileZoom !== void 0) this._update(center);
|
|
@@ -14991,7 +15019,7 @@
|
|
|
14991
15019
|
else queue.push(coords);
|
|
14992
15020
|
}
|
|
14993
15021
|
queue.sort((a, b) => a.distanceTo(tileCenter) - b.distanceTo(tileCenter));
|
|
14994
|
-
if (queue.length
|
|
15022
|
+
if (queue.length) {
|
|
14995
15023
|
if (!this._loading) {
|
|
14996
15024
|
this._loading = true;
|
|
14997
15025
|
this.fire("loading");
|
|
@@ -14999,7 +15027,7 @@
|
|
|
14999
15027
|
}
|
|
15000
15028
|
const fragment = document.createDocumentFragment();
|
|
15001
15029
|
for (const q of queue) this._addTile(q, fragment);
|
|
15002
|
-
this._level.el.
|
|
15030
|
+
this._level.el.append(fragment);
|
|
15003
15031
|
}
|
|
15004
15032
|
}
|
|
15005
15033
|
_isValidTile(coords) {
|
|
@@ -15053,7 +15081,7 @@
|
|
|
15053
15081
|
coords,
|
|
15054
15082
|
current: true
|
|
15055
15083
|
};
|
|
15056
|
-
container.
|
|
15084
|
+
container.append(tile);
|
|
15057
15085
|
this.fire("tileloadstart", {
|
|
15058
15086
|
tile,
|
|
15059
15087
|
coords
|
|
@@ -15258,13 +15286,13 @@
|
|
|
15258
15286
|
if (!this.options.zoomReverse) {
|
|
15259
15287
|
this.options.zoomOffset++;
|
|
15260
15288
|
this.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom - 1);
|
|
15261
|
-
if (this.options.maxNativeZoom !== void 0) this.options.maxNativeZoom = Math.max(0, this.options.maxNativeZoom - 1);
|
|
15262
|
-
if (this.options.minNativeZoom !== void 0) this.options.minNativeZoom = Math.max(0, this.options.minNativeZoom - 1);
|
|
15263
15289
|
} else {
|
|
15264
15290
|
this.options.zoomOffset--;
|
|
15265
15291
|
this.options.minZoom = Math.min(this.options.maxZoom, this.options.minZoom + 1);
|
|
15266
15292
|
}
|
|
15267
15293
|
this.options.minZoom = Math.max(0, this.options.minZoom);
|
|
15294
|
+
if (this.options.maxNativeZoom !== void 0) this.options.maxNativeZoom = Math.max(0, this.options.maxNativeZoom - 1);
|
|
15295
|
+
if (this.options.minNativeZoom !== void 0) this.options.minNativeZoom = Math.max(0, this.options.minNativeZoom - 1);
|
|
15268
15296
|
} else if (!this.options.zoomReverse) this.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom);
|
|
15269
15297
|
else this.options.minZoom = Math.min(this.options.maxZoom, this.options.minZoom);
|
|
15270
15298
|
}
|
|
@@ -15360,16 +15388,17 @@
|
|
|
15360
15388
|
* @returns {string}
|
|
15361
15389
|
*/
|
|
15362
15390
|
getTileUrl(coords) {
|
|
15363
|
-
const data = Object.create(this.options);
|
|
15391
|
+
const z = coords.z ?? this._tileZoom, data = Object.create(this.options);
|
|
15364
15392
|
Object.assign(data, {
|
|
15365
15393
|
r: window.devicePixelRatio > 1 ? "@2x" : "",
|
|
15366
15394
|
s: this._getSubdomain(coords),
|
|
15367
15395
|
x: coords.x,
|
|
15368
15396
|
y: coords.y,
|
|
15369
|
-
z: this._getZoomForUrl()
|
|
15397
|
+
z: this._getZoomForUrl(z)
|
|
15370
15398
|
});
|
|
15371
|
-
|
|
15372
|
-
|
|
15399
|
+
const worldBounds = this._map?.getPixelWorldBounds(z);
|
|
15400
|
+
if (worldBounds) {
|
|
15401
|
+
const invertedY = this._pxBoundsToTileRange(worldBounds).max.y - coords.y;
|
|
15373
15402
|
if (this.options.tms) data["y"] = invertedY;
|
|
15374
15403
|
data["-y"] = invertedY;
|
|
15375
15404
|
}
|
|
@@ -15384,8 +15413,7 @@
|
|
|
15384
15413
|
if (errorUrl && src !== errorUrl && (src || tile.isConnected)) tile.src = errorUrl;
|
|
15385
15414
|
done(e, tile);
|
|
15386
15415
|
}
|
|
15387
|
-
_getZoomForUrl() {
|
|
15388
|
-
let zoom = this._tileZoom;
|
|
15416
|
+
_getZoomForUrl(zoom) {
|
|
15389
15417
|
const maxZoom = this.options.maxZoom, zoomReverse = this.options.zoomReverse, zoomOffset = this.options.zoomOffset;
|
|
15390
15418
|
if (zoomReverse) zoom = maxZoom - zoom;
|
|
15391
15419
|
return zoom + zoomOffset;
|
|
@@ -15418,7 +15446,7 @@
|
|
|
15418
15446
|
return super._removeTile(key);
|
|
15419
15447
|
}
|
|
15420
15448
|
_tileReady(coords, err, tile) {
|
|
15421
|
-
if (!this._map || tile
|
|
15449
|
+
if (!this._map || tile?.getAttribute("src") === "") return;
|
|
15422
15450
|
return super._tileReady(coords, err, tile);
|
|
15423
15451
|
}
|
|
15424
15452
|
_clampZoom(zoom) {
|
|
@@ -15672,22 +15700,21 @@
|
|
|
15672
15700
|
*/
|
|
15673
15701
|
onAdd(map) {
|
|
15674
15702
|
super.onAdd(map);
|
|
15703
|
+
const z = (r) => +getComputedStyle(r._container.parentNode).zIndex || 0;
|
|
15704
|
+
map._canvases.push(this);
|
|
15705
|
+
map._canvases.sort((a, b) => z(b) - z(a) || (a._container.compareDocumentPosition(b._container) & 2) - 1);
|
|
15675
15706
|
this._draw();
|
|
15676
15707
|
}
|
|
15708
|
+
_initContainer() {
|
|
15709
|
+
const container = this._container = document.createElement("canvas");
|
|
15710
|
+
this._ctx = container.getContext("2d");
|
|
15711
|
+
}
|
|
15677
15712
|
/**
|
|
15678
15713
|
* Removes the canvas from the map.
|
|
15679
15714
|
*/
|
|
15680
15715
|
onRemove() {
|
|
15716
|
+
this._map._canvases = this._map._canvases.filter((r) => r !== this);
|
|
15681
15717
|
super.onRemove();
|
|
15682
|
-
clearTimeout(this._pointerHoverThrottleTimeout);
|
|
15683
|
-
}
|
|
15684
|
-
_initContainer() {
|
|
15685
|
-
const container = this._container = document.createElement("canvas");
|
|
15686
|
-
on(container, "pointermove", this._onPointerMove, this);
|
|
15687
|
-
on(container, "click dblclick pointerdown pointerup contextmenu", this._onClick, this);
|
|
15688
|
-
on(container, "pointerout", this._handlePointerOut, this);
|
|
15689
|
-
container["_maplair_disable_events"] = true;
|
|
15690
|
-
this._ctx = container.getContext("2d");
|
|
15691
15718
|
}
|
|
15692
15719
|
_destroyContainer() {
|
|
15693
15720
|
cancelAnimationFrame(this._redrawRequest);
|
|
@@ -15723,26 +15750,13 @@
|
|
|
15723
15750
|
_initPath(layer) {
|
|
15724
15751
|
this._updateDashArray(layer);
|
|
15725
15752
|
this._layers[stamp(layer)] = layer;
|
|
15726
|
-
|
|
15727
|
-
layer,
|
|
15728
|
-
prev: this._drawLast,
|
|
15729
|
-
next: null
|
|
15730
|
-
};
|
|
15731
|
-
if (this._drawLast) this._drawLast.next = order;
|
|
15732
|
-
this._drawLast = order;
|
|
15733
|
-
this._drawFirst ??= this._drawLast;
|
|
15753
|
+
this._append(layer._order = { layer });
|
|
15734
15754
|
}
|
|
15735
15755
|
_addPath(layer) {
|
|
15736
15756
|
this._requestRedraw(layer);
|
|
15737
15757
|
}
|
|
15738
15758
|
_removePath(layer) {
|
|
15739
|
-
|
|
15740
|
-
const next = order.next;
|
|
15741
|
-
const prev = order.prev;
|
|
15742
|
-
if (next) next.prev = prev;
|
|
15743
|
-
else this._drawLast = prev;
|
|
15744
|
-
if (prev) prev.next = next;
|
|
15745
|
-
else this._drawFirst = next;
|
|
15759
|
+
this._unlink(layer._order);
|
|
15746
15760
|
delete layer._order;
|
|
15747
15761
|
delete this._layers[stamp(layer)];
|
|
15748
15762
|
this._requestRedraw(layer);
|
|
@@ -15768,7 +15782,7 @@
|
|
|
15768
15782
|
}
|
|
15769
15783
|
_extendRedrawBounds(layer) {
|
|
15770
15784
|
if (layer._pxBounds) {
|
|
15771
|
-
const padding = (layer.options.weight
|
|
15785
|
+
const padding = (+layer.options.weight || 0) + 1;
|
|
15772
15786
|
this._redrawBounds ??= new Bounds();
|
|
15773
15787
|
this._redrawBounds.extend(layer._pxBounds.min.subtract([padding, padding]));
|
|
15774
15788
|
this._redrawBounds.extend(layer._pxBounds.max.add([padding, padding]));
|
|
@@ -15810,7 +15824,7 @@
|
|
|
15810
15824
|
this._drawing = true;
|
|
15811
15825
|
for (let order = this._drawFirst; order; order = order.next) {
|
|
15812
15826
|
layer = order.layer;
|
|
15813
|
-
if (!bounds || layer._pxBounds
|
|
15827
|
+
if (!bounds || layer._pxBounds?.intersects(bounds)) layer._updatePath();
|
|
15814
15828
|
}
|
|
15815
15829
|
this._drawing = false;
|
|
15816
15830
|
this._ctx.restore();
|
|
@@ -15855,84 +15869,50 @@
|
|
|
15855
15869
|
}
|
|
15856
15870
|
}
|
|
15857
15871
|
_updateInteractive() {}
|
|
15858
|
-
|
|
15872
|
+
/**
|
|
15873
|
+
* Returns the topmost interactive layer under the pointer.
|
|
15874
|
+
* @param {MouseEvent} e
|
|
15875
|
+
* @param {boolean} [click] Skip layers that were just dragged, so the drag doesn't end with a click.
|
|
15876
|
+
* @returns {Path|undefined}
|
|
15877
|
+
*/
|
|
15878
|
+
_layerAt(e, click) {
|
|
15859
15879
|
const point = this._map.pointerEventToLayerPoint(e);
|
|
15860
|
-
let
|
|
15861
|
-
|
|
15862
|
-
layer
|
|
15863
|
-
if (layer.options.interactive && layer._containsPoint(point)) {
|
|
15864
|
-
if (!(e.type === "click" || e.type === "preclick") || !this._map._draggableMoved(layer)) clickedLayer = layer;
|
|
15865
|
-
}
|
|
15880
|
+
for (let order = this._drawLast; order; order = order.prev) {
|
|
15881
|
+
const layer = order.layer;
|
|
15882
|
+
if (layer.options.interactive && layer._containsPoint(point) && !(click && this._map._draggableMoved(layer))) return layer;
|
|
15866
15883
|
}
|
|
15867
|
-
this._fireEvent(clickedLayer ? [clickedLayer] : false, e);
|
|
15868
15884
|
}
|
|
15869
|
-
|
|
15870
|
-
|
|
15871
|
-
|
|
15872
|
-
|
|
15873
|
-
|
|
15874
|
-
|
|
15875
|
-
const layer = this._hoveredLayer;
|
|
15876
|
-
if (layer) {
|
|
15877
|
-
this._container.classList.remove("maplair-interactive");
|
|
15878
|
-
this._fireEvent([layer], e, "pointerout");
|
|
15879
|
-
this._hoveredLayer = null;
|
|
15880
|
-
this._pointerHoverThrottled = false;
|
|
15885
|
+
_bringToFront(layer) {
|
|
15886
|
+
const order = layer._order;
|
|
15887
|
+
if (order?.next) {
|
|
15888
|
+
this._unlink(order);
|
|
15889
|
+
this._append(order);
|
|
15890
|
+
this._requestRedraw(layer);
|
|
15881
15891
|
}
|
|
15882
15892
|
}
|
|
15883
|
-
|
|
15884
|
-
|
|
15885
|
-
|
|
15886
|
-
|
|
15887
|
-
|
|
15888
|
-
|
|
15889
|
-
|
|
15890
|
-
|
|
15891
|
-
this.
|
|
15892
|
-
if (candidateHoveredLayer) {
|
|
15893
|
-
this._container.classList.add("maplair-interactive");
|
|
15894
|
-
this._fireEvent([candidateHoveredLayer], e, "pointerover");
|
|
15895
|
-
this._hoveredLayer = candidateHoveredLayer;
|
|
15896
|
-
}
|
|
15893
|
+
_bringToBack(layer) {
|
|
15894
|
+
const order = layer._order;
|
|
15895
|
+
if (order?.prev) {
|
|
15896
|
+
this._unlink(order);
|
|
15897
|
+
order.prev = null;
|
|
15898
|
+
order.next = this._drawFirst;
|
|
15899
|
+
this._drawFirst.prev = order;
|
|
15900
|
+
this._drawFirst = order;
|
|
15901
|
+
this._requestRedraw(layer);
|
|
15897
15902
|
}
|
|
15898
|
-
this._fireEvent(this._hoveredLayer ? [this._hoveredLayer] : false, e);
|
|
15899
|
-
this._pointerHoverThrottled = true;
|
|
15900
|
-
this._pointerHoverThrottleTimeout = setTimeout((() => {
|
|
15901
|
-
this._pointerHoverThrottled = false;
|
|
15902
|
-
}), 32);
|
|
15903
|
-
}
|
|
15904
|
-
_fireEvent(layers, e, type) {
|
|
15905
|
-
this._map._fireDOMEvent(e, type || e.type, layers);
|
|
15906
15903
|
}
|
|
15907
|
-
|
|
15908
|
-
const order = layer._order;
|
|
15909
|
-
if (!order) return;
|
|
15910
|
-
const next = order.next;
|
|
15911
|
-
const prev = order.prev;
|
|
15912
|
-
if (next) next.prev = prev;
|
|
15913
|
-
else return;
|
|
15914
|
-
if (prev) prev.next = next;
|
|
15915
|
-
else if (next) this._drawFirst = next;
|
|
15904
|
+
_append(order) {
|
|
15916
15905
|
order.prev = this._drawLast;
|
|
15917
|
-
this._drawLast.next = order;
|
|
15918
15906
|
order.next = null;
|
|
15907
|
+
if (this._drawLast) this._drawLast.next = order;
|
|
15919
15908
|
this._drawLast = order;
|
|
15920
|
-
this.
|
|
15909
|
+
this._drawFirst ??= order;
|
|
15921
15910
|
}
|
|
15922
|
-
|
|
15923
|
-
const order = layer._order;
|
|
15924
|
-
if (!order) return;
|
|
15925
|
-
const next = order.next;
|
|
15926
|
-
const prev = order.prev;
|
|
15927
|
-
if (prev) prev.next = next;
|
|
15928
|
-
else return;
|
|
15911
|
+
_unlink({ prev, next }) {
|
|
15929
15912
|
if (next) next.prev = prev;
|
|
15930
|
-
else
|
|
15931
|
-
|
|
15932
|
-
|
|
15933
|
-
this._drawFirst.prev = order;
|
|
15934
|
-
this._drawFirst = order;
|
|
15935
|
-
this._requestRedraw(layer);
|
|
15913
|
+
else this._drawLast = prev;
|
|
15914
|
+
if (prev) prev.next = next;
|
|
15915
|
+
else this._drawFirst = next;
|
|
15936
15916
|
}
|
|
15937
15917
|
};
|
|
15938
15918
|
// src/layer/vector/Circle.js
|
|
@@ -15980,18 +15960,18 @@
|
|
|
15980
15960
|
return new LatLngBounds(this._map.layerPointToLatLng(this._point.subtract(half)), this._map.layerPointToLatLng(this._point.add(half)));
|
|
15981
15961
|
}
|
|
15982
15962
|
_project() {
|
|
15983
|
-
const lng = this._latlng.lng, lat = this._latlng.lat, map = this._map, crs = map.options.crs;
|
|
15963
|
+
const lng = this._latlng.lng, lat = this._latlng.lat, map = this._map, crs = map.options.crs, renderer = this._renderer, zoom = renderer._pathZoom;
|
|
15984
15964
|
if (crs.distance === EarthCRS.distance) {
|
|
15985
|
-
const d = Math.PI / 180, latR = this._radius / EarthCRS.R / d, top = map.project([lat + latR, lng]), bottom = map.project([lat - latR, lng]), p = top.add(bottom).divideBy(2), lat2 = map.unproject(p).lat;
|
|
15965
|
+
const d = Math.PI / 180, latR = this._radius / EarthCRS.R / d, top = map.project([lat + latR, lng], zoom), bottom = map.project([lat - latR, lng], zoom), p = top.add(bottom).divideBy(2), lat2 = map.unproject(p, zoom).lat;
|
|
15986
15966
|
let lngR = 2 * Math.asin(Math.sqrt((Math.sin(latR * d / 2) ** 2 - Math.sin((lat2 - lat) * d / 2) ** 2) / (Math.cos(lat * d) * Math.cos(lat2 * d)))) / d;
|
|
15987
|
-
if (isNaN(lngR) || lngR === 0) lngR = latR / Math.cos(
|
|
15988
|
-
this._point = p.subtract(
|
|
15989
|
-
this._pxRadius = isNaN(lngR) ? 0 : p.x - map.project([lat2, lng - lngR]).x;
|
|
15967
|
+
if (isNaN(lngR) || lngR === 0) lngR = latR / Math.cos(lat * d);
|
|
15968
|
+
this._point = p.subtract(renderer._pathOrigin);
|
|
15969
|
+
this._pxRadius = isNaN(lngR) ? 0 : p.x - map.project([lat2, lng - lngR], zoom).x;
|
|
15990
15970
|
this._pxRadiusY = p.y - top.y;
|
|
15991
15971
|
} else {
|
|
15992
15972
|
const latlng2 = crs.unproject(crs.project(this._latlng).subtract([this._radius, 0]));
|
|
15993
|
-
this._point =
|
|
15994
|
-
this._pxRadius = Math.abs(this._point.x -
|
|
15973
|
+
this._point = renderer._latLngToLayerPoint(this._latlng);
|
|
15974
|
+
this._pxRadius = Math.abs(this._point.x - renderer._latLngToLayerPoint(latlng2).x);
|
|
15995
15975
|
}
|
|
15996
15976
|
this._updateBounds();
|
|
15997
15977
|
}
|
|
@@ -16422,10 +16402,7 @@
|
|
|
16422
16402
|
other._rawPanBy(offset);
|
|
16423
16403
|
other.fire("move");
|
|
16424
16404
|
}
|
|
16425
|
-
} else other._move(center, zoom, during ? {
|
|
16426
|
-
pinch: true,
|
|
16427
|
-
round: false
|
|
16428
|
-
} : void 0);
|
|
16405
|
+
} else other._move(center, zoom, during ? { pinch: true } : void 0);
|
|
16429
16406
|
}
|
|
16430
16407
|
_syncAll(map) {
|
|
16431
16408
|
for (const other of this._maps.filter((m) => m !== map)) {
|
|
@@ -16557,6 +16534,7 @@
|
|
|
16557
16534
|
* Called when the handler is enabled, adds the event hooks.
|
|
16558
16535
|
*/
|
|
16559
16536
|
addHooks() {
|
|
16537
|
+
this._map._displaceHandler = this;
|
|
16560
16538
|
this._map.on("zoomend", this.schedule, this);
|
|
16561
16539
|
this._map.on("layeradd", this._onLayerAdd, this);
|
|
16562
16540
|
this._map.on("layerremove", this._onLayerRemove, this);
|
|
@@ -16568,6 +16546,7 @@
|
|
|
16568
16546
|
* true positions of the markers.
|
|
16569
16547
|
*/
|
|
16570
16548
|
removeHooks() {
|
|
16549
|
+
if (this._map._displaceHandler === this) delete this._map._displaceHandler;
|
|
16571
16550
|
this._map.off("zoomend", this.schedule, this);
|
|
16572
16551
|
this._map.off("layeradd", this._onLayerAdd, this);
|
|
16573
16552
|
this._map.off("layerremove", this._onLayerRemove, this);
|
|
@@ -16639,6 +16618,7 @@
|
|
|
16639
16618
|
* @param {LatLng} latLng
|
|
16640
16619
|
*/
|
|
16641
16620
|
_moveTo(marker, latLng) {
|
|
16621
|
+
if (marker.getLatLng().equals(latLng)) return;
|
|
16642
16622
|
this._moving = true;
|
|
16643
16623
|
try {
|
|
16644
16624
|
marker.setLatLng(latLng);
|
|
@@ -16658,6 +16638,19 @@
|
|
|
16658
16638
|
if (this._enabled && this._map.hasLayer(event.target)) this.schedule();
|
|
16659
16639
|
}
|
|
16660
16640
|
/**
|
|
16641
|
+
* Called by `CircleMarker#beforeAdd`: puts a marker whose `displaceId` already
|
|
16642
|
+
* has a displaced position at the current zoom (e.g. the same station on
|
|
16643
|
+
* another layer) there before it is drawn, instead of drawing it twice.
|
|
16644
|
+
* @param {CircleMarker} marker
|
|
16645
|
+
*/
|
|
16646
|
+
_beforeMarkerAdd(marker) {
|
|
16647
|
+
if (!displaceable(marker)) return;
|
|
16648
|
+
this._track(marker);
|
|
16649
|
+
const { displaceId } = marker.options;
|
|
16650
|
+
const latLng = displaceId && this._displacedPositions.get(this._map.getZoom())?.get(displaceId);
|
|
16651
|
+
if (latLng) this._moveTo(marker, latLng);
|
|
16652
|
+
}
|
|
16653
|
+
/**
|
|
16661
16654
|
* @param {LayerEvent} event
|
|
16662
16655
|
*/
|
|
16663
16656
|
_onLayerAdd(event) {
|
|
@@ -16694,6 +16687,10 @@
|
|
|
16694
16687
|
}
|
|
16695
16688
|
};
|
|
16696
16689
|
/**
|
|
16690
|
+
* Movement in pixels per pass below which `displace` stops early
|
|
16691
|
+
*/
|
|
16692
|
+
const MIN_MOVE = .01;
|
|
16693
|
+
/**
|
|
16697
16694
|
* Displaces overlapping points in pixel space until they are at least
|
|
16698
16695
|
* `minSeparation` apart. Iterative relaxation: every overlapping pair is pushed
|
|
16699
16696
|
* apart by half of its overlap per pass. Neighbour lookup uses a grid (cell
|
|
@@ -16701,7 +16698,8 @@
|
|
|
16701
16698
|
*
|
|
16702
16699
|
* No point ends up further than `maxDisplacement` away from where it started.
|
|
16703
16700
|
* Points which hit that limit stay overlapping – the limit wins over the
|
|
16704
|
-
* separation.
|
|
16701
|
+
* separation. The relaxation stops early once the points are separated or
|
|
16702
|
+
* no point moves by more than a hundredth of a pixel per pass.
|
|
16705
16703
|
*
|
|
16706
16704
|
* @param {Point[]} points Pixel coordinates (modified in place)
|
|
16707
16705
|
* @param {number} minSeparation Minimum distance between centers, in pixels
|
|
@@ -16721,49 +16719,62 @@
|
|
|
16721
16719
|
for (let iter = 0; iter < iterations; iter++) {
|
|
16722
16720
|
dx.fill(0);
|
|
16723
16721
|
dy.fill(0);
|
|
16724
|
-
/** @type {Map<
|
|
16722
|
+
/** @type {Map<number, Map<number, number[]>>} */
|
|
16725
16723
|
const grid = /* @__PURE__ */ new Map();
|
|
16726
16724
|
for (let i = 0; i < n; i++) {
|
|
16727
|
-
const
|
|
16728
|
-
const
|
|
16725
|
+
const cx = Math.floor(points[i].x / cell);
|
|
16726
|
+
const cy = Math.floor(points[i].y / cell);
|
|
16727
|
+
let column = grid.get(cx);
|
|
16728
|
+
if (!column) {
|
|
16729
|
+
column = /* @__PURE__ */ new Map();
|
|
16730
|
+
grid.set(cx, column);
|
|
16731
|
+
}
|
|
16732
|
+
const bucket = column.get(cy);
|
|
16729
16733
|
if (bucket) bucket.push(i);
|
|
16730
|
-
else
|
|
16734
|
+
else column.set(cy, [i]);
|
|
16731
16735
|
}
|
|
16732
16736
|
let overlaps = 0;
|
|
16733
16737
|
for (let i = 0; i < n; i++) {
|
|
16734
16738
|
const cx = Math.floor(points[i].x / cell);
|
|
16735
16739
|
const cy = Math.floor(points[i].y / cell);
|
|
16736
|
-
for (let gx = cx - 1; gx <= cx + 1; gx++)
|
|
16737
|
-
const
|
|
16738
|
-
if (!
|
|
16739
|
-
for (
|
|
16740
|
-
|
|
16741
|
-
|
|
16742
|
-
|
|
16743
|
-
|
|
16744
|
-
|
|
16745
|
-
|
|
16746
|
-
|
|
16747
|
-
|
|
16748
|
-
|
|
16749
|
-
|
|
16750
|
-
|
|
16751
|
-
|
|
16752
|
-
|
|
16753
|
-
|
|
16754
|
-
|
|
16755
|
-
|
|
16740
|
+
for (let gx = cx - 1; gx <= cx + 1; gx++) {
|
|
16741
|
+
const column = grid.get(gx);
|
|
16742
|
+
if (!column) continue;
|
|
16743
|
+
for (let gy = cy - 1; gy <= cy + 1; gy++) {
|
|
16744
|
+
const bucket = column.get(gy);
|
|
16745
|
+
if (!bucket) continue;
|
|
16746
|
+
for (const j of bucket) {
|
|
16747
|
+
if (j <= i) continue;
|
|
16748
|
+
let vx = points[i].x - points[j].x;
|
|
16749
|
+
let vy = points[i].y - points[j].y;
|
|
16750
|
+
const distSq = vx * vx + vy * vy;
|
|
16751
|
+
if (distSq >= sepSq) continue;
|
|
16752
|
+
overlaps++;
|
|
16753
|
+
let dist;
|
|
16754
|
+
if (distSq === 0) {
|
|
16755
|
+
const angle = i * 2.399963229728653;
|
|
16756
|
+
vx = Math.cos(angle);
|
|
16757
|
+
vy = Math.sin(angle);
|
|
16758
|
+
dist = 1;
|
|
16759
|
+
} else {
|
|
16760
|
+
dist = Math.sqrt(distSq);
|
|
16761
|
+
vx /= dist;
|
|
16762
|
+
vy /= dist;
|
|
16763
|
+
}
|
|
16764
|
+
const push = (sep - dist) / 2;
|
|
16765
|
+
dx[i] += vx * push;
|
|
16766
|
+
dy[i] += vy * push;
|
|
16767
|
+
dx[j] -= vx * push;
|
|
16768
|
+
dy[j] -= vy * push;
|
|
16756
16769
|
}
|
|
16757
|
-
const push = (sep - dist) / 2;
|
|
16758
|
-
dx[i] += vx * push;
|
|
16759
|
-
dy[i] += vy * push;
|
|
16760
|
-
dx[j] -= vx * push;
|
|
16761
|
-
dy[j] -= vy * push;
|
|
16762
16770
|
}
|
|
16763
16771
|
}
|
|
16764
16772
|
}
|
|
16765
16773
|
if (overlaps === 0) break;
|
|
16774
|
+
let maxMoveSq = 0;
|
|
16766
16775
|
for (let i = 0; i < n; i++) {
|
|
16776
|
+
const x = points[i].x;
|
|
16777
|
+
const y = points[i].y;
|
|
16767
16778
|
points[i].x += dx[i];
|
|
16768
16779
|
points[i].y += dy[i];
|
|
16769
16780
|
const ox = points[i].x - ax[i];
|
|
@@ -16774,7 +16785,11 @@
|
|
|
16774
16785
|
points[i].x = ax[i] + ox * scale;
|
|
16775
16786
|
points[i].y = ay[i] + oy * scale;
|
|
16776
16787
|
}
|
|
16788
|
+
const mx = points[i].x - x;
|
|
16789
|
+
const my = points[i].y - y;
|
|
16790
|
+
maxMoveSq = Math.max(maxMoveSq, mx * mx + my * my);
|
|
16777
16791
|
}
|
|
16792
|
+
if (maxMoveSq < MIN_MOVE * MIN_MOVE) break;
|
|
16778
16793
|
}
|
|
16779
16794
|
return points;
|
|
16780
16795
|
}
|
|
@@ -16844,7 +16859,6 @@
|
|
|
16844
16859
|
disableClickPropagation(button);
|
|
16845
16860
|
on(button, "click", stop);
|
|
16846
16861
|
on(button, "click", this._resetNorth, this);
|
|
16847
|
-
on(button, "click", this._refocusOnMap, this);
|
|
16848
16862
|
this._update();
|
|
16849
16863
|
map.on("rotate", this._update, this);
|
|
16850
16864
|
return container;
|
|
@@ -16948,8 +16962,8 @@
|
|
|
16948
16962
|
if (!this._rotatePane) {
|
|
16949
16963
|
const rotatePane = this._rotatePane = create("div", "maplair-rotate-pane");
|
|
16950
16964
|
rotatedMaps.set(rotatePane, this);
|
|
16951
|
-
this.
|
|
16952
|
-
rotatePane.
|
|
16965
|
+
this._mapPane.before(rotatePane);
|
|
16966
|
+
rotatePane.append(this._mapPane);
|
|
16953
16967
|
}
|
|
16954
16968
|
if (bearing === this.getBearing()) return;
|
|
16955
16969
|
this._bearing = bearing;
|
|
@@ -17038,9 +17052,9 @@
|
|
|
17038
17052
|
return panBy.call(this, this._rotateToPane(Point.from(offset)), options);
|
|
17039
17053
|
},
|
|
17040
17054
|
_tryAnimatedPan(center, options) {
|
|
17041
|
-
const offset = this.
|
|
17042
|
-
if (options?.animate !== true && !this.getSize().contains(offset)) return false;
|
|
17043
|
-
this.
|
|
17055
|
+
const offset = this.latLngToLayerPoint(center)._subtract(this._getCenterLayerPoint())._round();
|
|
17056
|
+
if (options?.animate !== true && !this.getSize().contains(this._rotateToContainer(offset))) return false;
|
|
17057
|
+
this._panBy(offset, options);
|
|
17044
17058
|
return true;
|
|
17045
17059
|
},
|
|
17046
17060
|
/**
|
|
@@ -17332,10 +17346,7 @@
|
|
|
17332
17346
|
this._moved = true;
|
|
17333
17347
|
}
|
|
17334
17348
|
cancelAnimationFrame(this._animRequest);
|
|
17335
|
-
const moveFn = map._move.bind(map, this._center, this._zoom, {
|
|
17336
|
-
pinch: true,
|
|
17337
|
-
round: false
|
|
17338
|
-
}, void 0);
|
|
17349
|
+
const moveFn = map._move.bind(map, this._center, this._zoom, { pinch: true }, void 0);
|
|
17339
17350
|
this._animRequest = requestAnimationFrame(moveFn.bind(this));
|
|
17340
17351
|
e.preventDefault();
|
|
17341
17352
|
}
|