maplair 4.4.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/dist/esm/control/AttributionControl.js +20 -3
- package/dist/esm/control/AttributionControl.js.map +1 -1
- package/dist/esm/control/LayersControl.js +35 -20
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/ScaleControl.js +3 -3
- package/dist/esm/control/ScaleControl.js.map +1 -1
- package/dist/esm/control/ZoomControl.js +1 -0
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Util.js +1 -1
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.PointerEvents.js +19 -2
- package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
- package/dist/esm/dom/Draggable.js +6 -2
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/geo/LatLng.js +1 -1
- package/dist/esm/geo/LatLng.js.map +1 -1
- package/dist/esm/geo/LatLngBounds.js +1 -1
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geometry/Bounds.js +1 -1
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/Point.js +4 -2
- package/dist/esm/geometry/Point.js.map +1 -1
- package/dist/esm/geometry/PolyUtil.js +10 -3
- package/dist/esm/geometry/PolyUtil.js.map +1 -1
- package/dist/esm/layer/BlanketOverlay.js +2 -1
- package/dist/esm/layer/BlanketOverlay.js.map +1 -1
- package/dist/esm/layer/DivOverlay.js +3 -3
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/ImageOverlay.js +1 -1
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +1 -1
- package/dist/esm/layer/Layer.js.map +1 -1
- package/dist/esm/layer/Popup.js +3 -4
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/Tooltip.js +31 -22
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/marker/Icon.js +25 -6
- package/dist/esm/layer/marker/Icon.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js +5 -5
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +5 -5
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/tile/GridLayer.js +11 -5
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +10 -6
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/tile/WMSTileLayer.js +7 -3
- package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +2 -2
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +2 -3
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +6 -3
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.ZoomStyles.js +4 -1
- package/dist/esm/layer/vector/Path.ZoomStyles.js.map +1 -1
- package/dist/esm/map/Map.Rotation.js +3 -2
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +58 -26
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/MapSync.js +1 -1
- package/dist/esm/map/MapSync.js.map +1 -1
- package/dist/esm/map/handler/BoxZoomHandler.js +2 -0
- package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DragHandler.js +7 -2
- package/dist/esm/map/handler/DragHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +1 -1
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/TapDragZoomHandler.js +1 -1
- package/dist/esm/map/handler/TapDragZoomHandler.js.map +1 -1
- package/dist/esm/package.js +1 -1
- package/dist/maplair-global-src.js +289 -140
- package/dist/maplair-global-src.js.map +1 -1
- package/dist/maplair-global.js +2 -2
- package/dist/maplair-global.js.map +1 -1
- package/dist/maplair-src.js +289 -140
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.css +1 -1
- package/dist/maplair.js +2 -2
- package/dist/maplair.js.map +1 -1
- package/package.json +1 -1
- package/src/control/AttributionControl.js +29 -3
- package/src/control/LayersControl.js +47 -27
- package/src/control/ScaleControl.js +6 -3
- package/src/control/ZoomControl.js +1 -0
- package/src/core/Util.js +1 -1
- package/src/dom/DomEvent.PointerEvents.js +22 -2
- package/src/dom/Draggable.js +6 -2
- package/src/geo/LatLng.js +2 -1
- package/src/geo/LatLngBounds.js +1 -1
- package/src/geometry/Bounds.js +1 -1
- package/src/geometry/Point.js +4 -2
- package/src/geometry/PolyUtil.js +12 -3
- package/src/layer/BlanketOverlay.js +5 -2
- package/src/layer/DivOverlay.js +3 -3
- package/src/layer/ImageOverlay.js +3 -2
- package/src/layer/Layer.js +1 -1
- package/src/layer/Popup.js +3 -4
- package/src/layer/Tooltip.js +34 -27
- package/src/layer/marker/Icon.js +25 -5
- package/src/layer/marker/Marker.Drag.js +6 -6
- package/src/layer/marker/Marker.js +5 -5
- package/src/layer/tile/GridLayer.js +20 -7
- package/src/layer/tile/TileLayer.js +14 -7
- package/src/layer/tile/WMSTileLayer.js +4 -2
- package/src/layer/vector/Canvas.js +2 -2
- package/src/layer/vector/Circle.js +3 -5
- package/src/layer/vector/CircleMarker.js +5 -2
- package/src/layer/vector/Path.ZoomStyles.js +5 -3
- package/src/map/Map.Rotation.js +6 -3
- package/src/map/Map.js +63 -32
- package/src/map/MapSync.js +1 -1
- package/src/map/handler/BoxZoomHandler.js +3 -0
- package/src/map/handler/DragHandler.js +5 -5
- package/src/map/handler/PinchZoomHandler.js +1 -1
- package/src/map/handler/ScrollWheelZoomHandler.js +1 -1
- package/src/map/handler/TapDragZoomHandler.js +1 -1
- package/src/maplair.css +12 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* Maplair 4.
|
|
2
|
+
* Maplair 4.5.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.5.0";
|
|
22
22
|
// src/core/Util.js
|
|
23
23
|
var Util_exports = /* @__PURE__ */ __exportAll({
|
|
24
24
|
falseFn: () => falseFn,
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
}
|
|
154
154
|
return defaults;
|
|
155
155
|
}
|
|
156
|
-
const templateRe = /\{ *([\w_ -]
|
|
156
|
+
const templateRe = /\{ *([\w_ -]+?) *\}/g;
|
|
157
157
|
/**
|
|
158
158
|
* Simple templating facility, accepts a template string of the form `'Hello {a}, {b}'`
|
|
159
159
|
* and a data object like `{a: 'foo', b: 'bar'}`, returns evaluated string
|
|
@@ -543,19 +543,21 @@
|
|
|
543
543
|
* `scale`. In linear algebra terms, multiply the point by the
|
|
544
544
|
* [scaling matrix](https://en.wikipedia.org/wiki/Scaling_%28geometry%29#Matrix_representation)
|
|
545
545
|
* defined by `scale`.
|
|
546
|
-
* @param {
|
|
546
|
+
* @param {PointExpression} point The scale.
|
|
547
547
|
* @returns {Point}
|
|
548
548
|
*/
|
|
549
549
|
scaleBy(point) {
|
|
550
|
+
point = Point.from(point);
|
|
550
551
|
return new Point(this.x * point.x, this.y * point.y);
|
|
551
552
|
}
|
|
552
553
|
/**
|
|
553
554
|
* Inverse of `scaleBy`. Divide each coordinate of the current point by
|
|
554
555
|
* each coordinate of `scale`.
|
|
555
|
-
* @param {
|
|
556
|
+
* @param {PointExpression} point The scale.
|
|
556
557
|
* @returns {Point}
|
|
557
558
|
*/
|
|
558
559
|
unscaleBy(point) {
|
|
560
|
+
point = Point.from(point);
|
|
559
561
|
return new Point(this.x / point.x, this.y / point.y);
|
|
560
562
|
}
|
|
561
563
|
/**
|
|
@@ -649,6 +651,7 @@
|
|
|
649
651
|
disablePointerDetection: () => disablePointerDetection,
|
|
650
652
|
enablePointerDetection: () => enablePointerDetection,
|
|
651
653
|
getPointers: () => getPointers,
|
|
654
|
+
isClickDisabled: () => isClickDisabled,
|
|
652
655
|
simulateDblclick: () => simulateDblclick
|
|
653
656
|
});
|
|
654
657
|
const activePointers = /* @__PURE__ */ new Map();
|
|
@@ -678,10 +681,26 @@
|
|
|
678
681
|
el.removeEventListener("pointerup", _onDelete, { capture: true });
|
|
679
682
|
el.removeEventListener("pointercancel", _onDelete, { capture: true });
|
|
680
683
|
}
|
|
684
|
+
/**
|
|
685
|
+
* Whether `el` is inside an element that `DomEvent.disableClickPropagation` was called
|
|
686
|
+
* on (before reaching `container`), or detached from the DOM.
|
|
687
|
+
* @internal
|
|
688
|
+
* @param {Node|null} el
|
|
689
|
+
* @param {EventTarget|null} container
|
|
690
|
+
* @returns {boolean}
|
|
691
|
+
*/
|
|
692
|
+
function isClickDisabled(el, container) {
|
|
693
|
+
while (el && el !== container) {
|
|
694
|
+
if (el["_maplair_disable_click"] || !el.parentNode) return true;
|
|
695
|
+
el = el.parentNode;
|
|
696
|
+
}
|
|
697
|
+
return false;
|
|
698
|
+
}
|
|
681
699
|
function _onSet(e) {
|
|
700
|
+
lastPointerType = e.pointerType;
|
|
701
|
+
if (isClickDisabled(e.target, e.currentTarget)) return;
|
|
682
702
|
if (e.isTrusted) e.target.setPointerCapture(e.pointerId);
|
|
683
703
|
activePointers.set(e.pointerId, e);
|
|
684
|
-
lastPointerType = e.pointerType;
|
|
685
704
|
}
|
|
686
705
|
function _onUpdate(e) {
|
|
687
706
|
if (activePointers.has(e.pointerId)) activePointers.set(e.pointerId, e);
|
|
@@ -1348,6 +1367,7 @@
|
|
|
1348
1367
|
this._attributions = {};
|
|
1349
1368
|
this._orders = {};
|
|
1350
1369
|
this._layerAttributions = /* @__PURE__ */ new Map();
|
|
1370
|
+
this._shownLayers = /* @__PURE__ */ new Set();
|
|
1351
1371
|
this.callInitHooks(AttributionControl);
|
|
1352
1372
|
}
|
|
1353
1373
|
/**
|
|
@@ -1370,7 +1390,8 @@
|
|
|
1370
1390
|
getEvents() {
|
|
1371
1391
|
return {
|
|
1372
1392
|
layeradd: this._addLayer,
|
|
1373
|
-
layerremove: this._removeLayer
|
|
1393
|
+
layerremove: this._removeLayer,
|
|
1394
|
+
zoomend: this._onZoomEnd
|
|
1374
1395
|
};
|
|
1375
1396
|
}
|
|
1376
1397
|
/**
|
|
@@ -1383,12 +1404,27 @@
|
|
|
1383
1404
|
const text = layer.getAttribution?.();
|
|
1384
1405
|
if (!text || this._layerAttributions.has(layer)) return;
|
|
1385
1406
|
this._layerAttributions.set(layer, text);
|
|
1386
|
-
this.
|
|
1407
|
+
this._updateLayer(layer);
|
|
1387
1408
|
}
|
|
1388
1409
|
_removeLayer({ layer }) {
|
|
1389
|
-
this.removeAttribution(this._layerAttributions.get(layer));
|
|
1410
|
+
if (this._shownLayers.delete(layer)) this.removeAttribution(this._layerAttributions.get(layer));
|
|
1390
1411
|
this._layerAttributions.delete(layer);
|
|
1391
1412
|
}
|
|
1413
|
+
_onZoomEnd() {
|
|
1414
|
+
for (const layer of this._layerAttributions.keys()) this._updateLayer(layer);
|
|
1415
|
+
}
|
|
1416
|
+
_updateLayer(layer) {
|
|
1417
|
+
const { minZoom = -Infinity, maxZoom = Infinity } = layer.options ?? {}, zoom = this._map.getZoom(), show = zoom >= minZoom && zoom <= maxZoom;
|
|
1418
|
+
if (show === this._shownLayers.has(layer)) return;
|
|
1419
|
+
const text = this._layerAttributions.get(layer);
|
|
1420
|
+
if (show) {
|
|
1421
|
+
this._shownLayers.add(layer);
|
|
1422
|
+
this.addAttribution(text, layer.options?.attributionOrder);
|
|
1423
|
+
} else {
|
|
1424
|
+
this._shownLayers.delete(layer);
|
|
1425
|
+
this.removeAttribution(text);
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1392
1428
|
/**
|
|
1393
1429
|
* The HTML text shown before the attributions. Pass `false` to disable.
|
|
1394
1430
|
* @param {string|false} prefix
|
|
@@ -2189,7 +2225,7 @@
|
|
|
2189
2225
|
this._layersMaxZoom = maxZoom === -Infinity ? void 0 : maxZoom;
|
|
2190
2226
|
this._layersMinZoom = minZoom === Infinity ? void 0 : minZoom;
|
|
2191
2227
|
if (oldZoomSpan !== this._getZoomSpan()) this.fire("zoomlevelschange");
|
|
2192
|
-
if (this.options.maxZoom === void 0 && this._layersMaxZoom && this.getZoom() > this._layersMaxZoom) this.setZoom(this._layersMaxZoom);
|
|
2228
|
+
if (this.options.maxZoom === void 0 && this._layersMaxZoom !== void 0 && this.getZoom() > this._layersMaxZoom) this.setZoom(this._layersMaxZoom);
|
|
2193
2229
|
if (this.options.minZoom === void 0 && this._layersMinZoom && this.getZoom() < this._layersMinZoom) this.setZoom(this._layersMinZoom);
|
|
2194
2230
|
}
|
|
2195
2231
|
};
|
|
@@ -2860,6 +2896,7 @@
|
|
|
2860
2896
|
this._lastZIndex = 0;
|
|
2861
2897
|
this._handlingClick = false;
|
|
2862
2898
|
this._preventClick = false;
|
|
2899
|
+
this._needsUpdate = false;
|
|
2863
2900
|
for (const [name, layer] of Object.entries(baseLayers ?? {})) this._addLayer(layer, name);
|
|
2864
2901
|
for (const [name, layer] of Object.entries(overlays ?? {})) this._addLayer(layer, name, true);
|
|
2865
2902
|
this.callInitHooks(LayersControl);
|
|
@@ -2945,6 +2982,7 @@
|
|
|
2945
2982
|
* @returns {this}
|
|
2946
2983
|
*/
|
|
2947
2984
|
selectLayer(layer) {
|
|
2985
|
+
if (this._needsUpdate) this._update(true);
|
|
2948
2986
|
const input = this._layerControlInputs.find((input) => input._layer === layer);
|
|
2949
2987
|
if (input && !input.checked) {
|
|
2950
2988
|
input.checked = true;
|
|
@@ -2959,6 +2997,7 @@
|
|
|
2959
2997
|
expand() {
|
|
2960
2998
|
clearTimeout(this._collapseDelayTimeout);
|
|
2961
2999
|
this._container.classList.add("maplair-control-layers-expanded");
|
|
3000
|
+
if (this._needsUpdate) this._update();
|
|
2962
3001
|
this._section.style.height = "";
|
|
2963
3002
|
const acceptableHeight = this._map.getSize().y - (this._container.offsetTop + 50);
|
|
2964
3003
|
if (acceptableHeight < this._section.clientHeight) {
|
|
@@ -2974,6 +3013,7 @@
|
|
|
2974
3013
|
*/
|
|
2975
3014
|
collapse() {
|
|
2976
3015
|
if (this.options.inline) return this;
|
|
3016
|
+
clearTimeout(this._collapseDelayTimeout);
|
|
2977
3017
|
if (this.options.collapseDelay > 0) this._collapseDelayTimeout = setTimeout(() => {
|
|
2978
3018
|
this._container.classList.remove("maplair-control-layers-expanded");
|
|
2979
3019
|
}, this.options.collapseDelay);
|
|
@@ -2990,6 +3030,23 @@
|
|
|
2990
3030
|
disableScrollPropagation(container);
|
|
2991
3031
|
const section = this._section = create("fieldset", `${className}-list`);
|
|
2992
3032
|
section.setAttribute("aria-label", this._getTitle());
|
|
3033
|
+
section.tabIndex = -1;
|
|
3034
|
+
let link;
|
|
3035
|
+
if (!this.options.inline) {
|
|
3036
|
+
link = this._layersLink = create("button", `${className}-toggle`, container);
|
|
3037
|
+
link.type = "button";
|
|
3038
|
+
link.title = this._getTitle();
|
|
3039
|
+
link.setAttribute("aria-label", link.title);
|
|
3040
|
+
const { toggleContent } = this.options;
|
|
3041
|
+
if (typeof toggleContent === "string") link.innerHTML = toggleContent;
|
|
3042
|
+
else if (toggleContent) link.replaceChildren(toggleContent);
|
|
3043
|
+
on(link, "click", (e) => {
|
|
3044
|
+
e.preventDefault();
|
|
3045
|
+
const focused = document.activeElement === link;
|
|
3046
|
+
this._expandSafely();
|
|
3047
|
+
if (focused) section.focus();
|
|
3048
|
+
});
|
|
3049
|
+
}
|
|
2993
3050
|
if (collapsed) {
|
|
2994
3051
|
this._map.on("click", this.collapse, this);
|
|
2995
3052
|
on(container, {
|
|
@@ -2998,26 +3055,15 @@
|
|
|
2998
3055
|
if (e.pointerType !== "touch") this.collapse();
|
|
2999
3056
|
}
|
|
3000
3057
|
}, this);
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
link.setAttribute("aria-label", link.title);
|
|
3007
|
-
const { toggleContent } = this.options;
|
|
3008
|
-
if (typeof toggleContent === "string") link.innerHTML = toggleContent;
|
|
3009
|
-
else if (toggleContent) link.replaceChildren(toggleContent);
|
|
3010
|
-
on(link, {
|
|
3011
|
-
keydown(e) {
|
|
3012
|
-
if (e.code === "Enter") this._expandSafely();
|
|
3013
|
-
},
|
|
3014
|
-
click(e) {
|
|
3058
|
+
on(section, "keydown", (e) => {
|
|
3059
|
+
if (e.key === "Escape") {
|
|
3060
|
+
clearTimeout(this._collapseDelayTimeout);
|
|
3061
|
+
container.classList.remove(`${className}-expanded`);
|
|
3062
|
+
link.focus();
|
|
3015
3063
|
e.preventDefault();
|
|
3016
|
-
this._expandSafely();
|
|
3017
3064
|
}
|
|
3018
|
-
}
|
|
3019
|
-
}
|
|
3020
|
-
if (!collapsed) this.expand();
|
|
3065
|
+
});
|
|
3066
|
+
} else this.expand();
|
|
3021
3067
|
this._baseLayersList = create("div", `${className}-base`, section);
|
|
3022
3068
|
this._separator = create("div", `${className}-separator`, section);
|
|
3023
3069
|
this._overlaysList = create("div", `${className}-overlays`, section);
|
|
@@ -3037,8 +3083,13 @@
|
|
|
3037
3083
|
}
|
|
3038
3084
|
this._expandIfNotCollapsed();
|
|
3039
3085
|
}
|
|
3040
|
-
_update() {
|
|
3086
|
+
_update(force) {
|
|
3041
3087
|
if (!this._container) return this;
|
|
3088
|
+
if (!force && !this._container.classList.contains("maplair-control-layers-expanded")) {
|
|
3089
|
+
this._needsUpdate = true;
|
|
3090
|
+
return this;
|
|
3091
|
+
}
|
|
3092
|
+
this._needsUpdate = false;
|
|
3042
3093
|
this._baseLayersList.replaceChildren();
|
|
3043
3094
|
this._overlaysList.replaceChildren();
|
|
3044
3095
|
this._layerControlInputs = [];
|
|
@@ -3055,6 +3106,7 @@
|
|
|
3055
3106
|
this._baseLayersList.style.display = baseLayersPresent ? "" : "none";
|
|
3056
3107
|
}
|
|
3057
3108
|
this._separator.style.display = overlaysPresent && baseLayersPresent ? "" : "none";
|
|
3109
|
+
this._checkDisabledLayers();
|
|
3058
3110
|
return this;
|
|
3059
3111
|
}
|
|
3060
3112
|
_onLayerChange(e) {
|
|
@@ -3084,7 +3136,6 @@
|
|
|
3084
3136
|
holder.append(input, name);
|
|
3085
3137
|
const list = obj.overlay ? this._overlaysList : this._baseLayersList;
|
|
3086
3138
|
(group ? this._getGroupContainer(list, group.group) : list).append(label);
|
|
3087
|
-
this._checkDisabledLayers();
|
|
3088
3139
|
return label;
|
|
3089
3140
|
}
|
|
3090
3141
|
/**
|
|
@@ -3349,7 +3400,7 @@
|
|
|
3349
3400
|
}
|
|
3350
3401
|
};
|
|
3351
3402
|
function isPointExpression(obj) {
|
|
3352
|
-
return obj instanceof Point || (Array.isArray(obj) ? typeof obj[0] !== "object" : "x" in obj);
|
|
3403
|
+
return obj instanceof Point || (Array.isArray(obj) ? obj.length > 0 && typeof obj[0] !== "object" : "x" in obj);
|
|
3353
3404
|
}
|
|
3354
3405
|
// src/layer/BlanketOverlay.js
|
|
3355
3406
|
/** @import {LayerOptions} from './Layer.js' */
|
|
@@ -3446,7 +3497,8 @@
|
|
|
3446
3497
|
this._updateTransform(this._map.getCenter(), this._map.getZoom());
|
|
3447
3498
|
}
|
|
3448
3499
|
_updateTransform(center, zoom) {
|
|
3449
|
-
const scale = this._map.getZoomScale(zoom, this._zoom), viewHalf = this._map.getSize().multiplyBy(.5 + this.options.padding), currentCenterPoint = this._map.project(this._center, zoom), topLeftOffset = viewHalf.multiplyBy(-scale)._add(currentCenterPoint)._subtract(this._map._getNewPixelOrigin(center, zoom))
|
|
3500
|
+
const scale = this._map.getZoomScale(zoom, this._zoom), viewHalf = this._map.getSize().multiplyBy(.5 + this.options.padding), currentCenterPoint = this._map.project(this._center, zoom), topLeftOffset = viewHalf.multiplyBy(-scale)._add(currentCenterPoint)._subtract(this._map._getNewPixelOrigin(center, zoom));
|
|
3501
|
+
if (scale === 1) this._map._snapLayerPoint(topLeftOffset);
|
|
3450
3502
|
setTransform(this._container, topLeftOffset, scale);
|
|
3451
3503
|
}
|
|
3452
3504
|
_onMoveEnd(ev) {
|
|
@@ -4119,7 +4171,7 @@
|
|
|
4119
4171
|
}
|
|
4120
4172
|
};
|
|
4121
4173
|
function isLatLngExpression(obj) {
|
|
4122
|
-
return obj instanceof LatLng || (Array.isArray(obj) ? typeof obj[0] !== "object" : typeof obj === "object" && obj !== null && "lat" in obj);
|
|
4174
|
+
return obj instanceof LatLng || (Array.isArray(obj) ? obj.length > 0 && typeof obj[0] !== "object" : typeof obj === "object" && obj !== null && "lat" in obj);
|
|
4123
4175
|
}
|
|
4124
4176
|
// src/geo/LatLng.js
|
|
4125
4177
|
const coordinate = String.raw`([+-]?\d+(?:\.\d+)?)\s*°?`;
|
|
@@ -4327,7 +4379,7 @@
|
|
|
4327
4379
|
* @returns {number}
|
|
4328
4380
|
*/
|
|
4329
4381
|
function haversineDistance(latlng1, latlng2, R) {
|
|
4330
|
-
const rad = Math.PI / 180, lat1 = latlng1.lat * rad, lat2 = latlng2.lat * rad, sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2), sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2), a = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon;
|
|
4382
|
+
const rad = Math.PI / 180, lat1 = latlng1.lat * rad, lat2 = latlng2.lat * rad, sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2), sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2), a = Math.min(sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon, 1);
|
|
4331
4383
|
return R * (2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)));
|
|
4332
4384
|
}
|
|
4333
4385
|
// src/geometry/LineUtil.js
|
|
@@ -4663,7 +4715,7 @@
|
|
|
4663
4715
|
super();
|
|
4664
4716
|
setOptions(this, options);
|
|
4665
4717
|
this._latlng = new LatLng(latlng);
|
|
4666
|
-
this.
|
|
4718
|
+
this.setRadius(this.options.radius);
|
|
4667
4719
|
this.callInitHooks(CircleMarker);
|
|
4668
4720
|
}
|
|
4669
4721
|
/**
|
|
@@ -4700,7 +4752,10 @@
|
|
|
4700
4752
|
* @returns {this}
|
|
4701
4753
|
*/
|
|
4702
4754
|
setRadius(radius) {
|
|
4703
|
-
|
|
4755
|
+
const r = toNumber(radius);
|
|
4756
|
+
if (isNaN(r)) throw new Error(`Invalid radius: ${radius}`);
|
|
4757
|
+
/** @type {number} */
|
|
4758
|
+
this._radius = this.options.radius = r;
|
|
4704
4759
|
return this.redraw();
|
|
4705
4760
|
}
|
|
4706
4761
|
/**
|
|
@@ -5441,6 +5496,7 @@
|
|
|
5441
5496
|
}
|
|
5442
5497
|
_updateDisabled() {
|
|
5443
5498
|
const map = this._map;
|
|
5499
|
+
if (!map) return;
|
|
5444
5500
|
for (const [button, limit] of [[this._zoomInButton, map.getMaxZoom()], [this._zoomOutButton, map.getMinZoom()]]) {
|
|
5445
5501
|
const disabled = this._disabled || map._zoom === limit;
|
|
5446
5502
|
button.classList.toggle("maplair-disabled", disabled);
|
|
@@ -5971,8 +6027,8 @@
|
|
|
5971
6027
|
}
|
|
5972
6028
|
/**
|
|
5973
6029
|
* Sets the HTML content of the overlay. A `String` argument is rendered as
|
|
5974
|
-
* HTML; if it may contain untrusted input, sanitize it
|
|
5975
|
-
*
|
|
6030
|
+
* HTML; if it may contain untrusted input, sanitize it or pass an `HTMLElement`
|
|
6031
|
+
* with safe `textContent` instead. A `DocumentFragment`
|
|
5976
6032
|
* can be passed as well. If a function is passed the source layer will be passed
|
|
5977
6033
|
* to the function. The function should return a `String`, `HTMLElement` or
|
|
5978
6034
|
* `DocumentFragment` to be used in the overlay.
|
|
@@ -6086,7 +6142,7 @@
|
|
|
6086
6142
|
}
|
|
6087
6143
|
_updatePosition() {
|
|
6088
6144
|
if (!this._map) return;
|
|
6089
|
-
const pos = this._map.latLngToLayerPoint(this._latlng)
|
|
6145
|
+
const pos = this._map._snapLayerPoint(this._map.latLngToLayerPoint(this._latlng)), offset = Point.from(this.options.offset);
|
|
6090
6146
|
this._setContainerPosition(pos.add(this._getAnchor()));
|
|
6091
6147
|
const bottom = this._containerBottom = -offset.y, left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x;
|
|
6092
6148
|
if (this.options.overflow) {
|
|
@@ -6229,8 +6285,8 @@
|
|
|
6229
6285
|
/**
|
|
6230
6286
|
* Binds a popup to the layer with the passed `content` and sets up the
|
|
6231
6287
|
* necessary event listeners. A `String` argument is rendered as HTML; if it
|
|
6232
|
-
* may contain untrusted input, sanitize it
|
|
6233
|
-
* `
|
|
6288
|
+
* may contain untrusted input, sanitize it or pass an `HTMLElement` with safe
|
|
6289
|
+
* `textContent` instead. If a `Function` is passed
|
|
6234
6290
|
* it will receive the layer as the first argument and should return a
|
|
6235
6291
|
* `String`, `HTMLElement` or `DocumentFragment`.
|
|
6236
6292
|
* @group Popup methods
|
|
@@ -6372,8 +6428,7 @@
|
|
|
6372
6428
|
*
|
|
6373
6429
|
* **Security note.** Popup string content is rendered as HTML. If your content
|
|
6374
6430
|
* may include untrusted input (e.g. data from users or external APIs), sanitize
|
|
6375
|
-
* it
|
|
6376
|
-
* build a DOM element using `textContent` to render it as plain text:
|
|
6431
|
+
* it first, or build a DOM element using `textContent` to render it as plain text:
|
|
6377
6432
|
*
|
|
6378
6433
|
* ```js
|
|
6379
6434
|
* const el = document.createElement('div');
|
|
@@ -6597,7 +6652,8 @@
|
|
|
6597
6652
|
* Options of `Tooltip`.
|
|
6598
6653
|
* @typedef {object} TooltipOptions
|
|
6599
6654
|
* @property {string} [pane='tooltipPane'] `Map pane` where the tooltip will be added.
|
|
6600
|
-
* @property {PointExpression} [offset=[0, 0]] Optional offset of the tooltip position
|
|
6655
|
+
* @property {PointExpression} [offset=[0, 0]] Optional offset of the tooltip position, in
|
|
6656
|
+
* pixels. Mirrored horizontally when an `auto` tooltip opens to the left.
|
|
6601
6657
|
* @property {'right'|'left'|'top'|'bottom'|'center'|'auto'} [direction='auto']
|
|
6602
6658
|
* Direction where to open the tooltip. Possible values are: `right`, `left`, `top`,
|
|
6603
6659
|
* `bottom`, `center`, `auto`. `auto` chooses the direction with enough space when
|
|
@@ -6668,8 +6724,8 @@
|
|
|
6668
6724
|
/**
|
|
6669
6725
|
* Binds a tooltip to the layer with the passed `content` and sets up the
|
|
6670
6726
|
* necessary event listeners. A `String` argument is rendered as HTML; if it
|
|
6671
|
-
* may contain untrusted input, sanitize it
|
|
6672
|
-
* `
|
|
6727
|
+
* may contain untrusted input, sanitize it or pass an `HTMLElement` with safe
|
|
6728
|
+
* `textContent` instead. If a `Function` is passed
|
|
6673
6729
|
* it will receive the layer as the first argument and should return a
|
|
6674
6730
|
* `String`, `HTMLElement` or `DocumentFragment`.
|
|
6675
6731
|
* @group Tooltip methods
|
|
@@ -6843,8 +6899,7 @@
|
|
|
6843
6899
|
*
|
|
6844
6900
|
* **Security note.** Tooltip string content is rendered as HTML. If your content
|
|
6845
6901
|
* may include untrusted input (e.g. data from users or external APIs), sanitize
|
|
6846
|
-
* it
|
|
6847
|
-
* build a DOM element using `textContent` to render it as plain text:
|
|
6902
|
+
* it first, or build a DOM element using `textContent` to render it as plain text:
|
|
6848
6903
|
*
|
|
6849
6904
|
* ```js
|
|
6850
6905
|
* const el = document.createElement('div');
|
|
@@ -6901,7 +6956,8 @@
|
|
|
6901
6956
|
map.fire("tooltipopen", { tooltip: this });
|
|
6902
6957
|
if (this._source) {
|
|
6903
6958
|
this.addEventParent(this._source);
|
|
6904
|
-
this._source.getElement?.()
|
|
6959
|
+
this._ariaSource = this._source.getElement?.();
|
|
6960
|
+
this._ariaSource?.setAttribute("aria-describedby", this._container.id);
|
|
6905
6961
|
this._source.fire("tooltipopen", { tooltip: this }, true);
|
|
6906
6962
|
}
|
|
6907
6963
|
}
|
|
@@ -6914,6 +6970,9 @@
|
|
|
6914
6970
|
map.fire("tooltipclose", { tooltip: this });
|
|
6915
6971
|
if (this._source) {
|
|
6916
6972
|
this.removeEventParent(this._source);
|
|
6973
|
+
const el = this._ariaSource;
|
|
6974
|
+
if (el?.getAttribute("aria-describedby") === this._container.id) el.removeAttribute("aria-describedby");
|
|
6975
|
+
this._ariaSource = null;
|
|
6917
6976
|
this._source.fire("tooltipclose", { tooltip: this }, true);
|
|
6918
6977
|
}
|
|
6919
6978
|
}
|
|
@@ -6944,14 +7003,12 @@
|
|
|
6944
7003
|
}
|
|
6945
7004
|
_setPosition(pos) {
|
|
6946
7005
|
let direction = this.options.direction, shift = new Point(0, 0);
|
|
6947
|
-
const container = this._container, tooltipWidth = container.offsetWidth, tooltipHeight = container.offsetHeight, offset = new Point(this.options.offset)
|
|
7006
|
+
const container = this._container, tooltipWidth = container.offsetWidth, tooltipHeight = container.offsetHeight, offset = new Point(this.options.offset);
|
|
6948
7007
|
if (!(direction in directions)) {
|
|
6949
|
-
({direction, shift} = this._getAutoPlacement(pos, offset,
|
|
6950
|
-
if (direction === "left")
|
|
6951
|
-
offset.x = -offset.x;
|
|
6952
|
-
anchor.x = -anchor.x;
|
|
6953
|
-
}
|
|
7008
|
+
({direction, shift} = this._getAutoPlacement(pos, offset, tooltipWidth, tooltipHeight));
|
|
7009
|
+
if (direction === "left") offset.x = -offset.x;
|
|
6954
7010
|
}
|
|
7011
|
+
const anchor = this._getAnchor(direction);
|
|
6955
7012
|
const [fx, fy] = directions[direction];
|
|
6956
7013
|
pos = pos.subtract(new Point(tooltipWidth * fx, tooltipHeight * fy, true)).add(offset).add(anchor).add(shift);
|
|
6957
7014
|
for (const d in directions) container.classList.toggle(`maplair-tooltip-${d}`, d === direction);
|
|
@@ -6960,12 +7017,19 @@
|
|
|
6960
7017
|
else container.style.removeProperty("--maplair-tooltip-tip-shift");
|
|
6961
7018
|
this._setContainerPosition(pos);
|
|
6962
7019
|
}
|
|
6963
|
-
_getAutoPlacement(pos, offset,
|
|
6964
|
-
const area = this._getAutoArea(), point = this._map.layerPointToContainerPoint(pos),
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
7020
|
+
_getAutoPlacement(pos, offset, width, height) {
|
|
7021
|
+
const area = this._getAutoArea(), point = this._map.layerPointToContainerPoint(pos), at = {};
|
|
7022
|
+
for (const d of [
|
|
7023
|
+
"right",
|
|
7024
|
+
"left",
|
|
7025
|
+
"top",
|
|
7026
|
+
"bottom"
|
|
7027
|
+
]) at[d] = point.add(this._getAnchor(d)).add(d === "left" ? [-offset.x, offset.y] : offset);
|
|
7028
|
+
const space = {
|
|
7029
|
+
right: area.max.x - at.right.x - width - tipSize,
|
|
7030
|
+
left: at.left.x - area.min.x - width - tipSize,
|
|
7031
|
+
top: at.top.y - area.min.y - height - tipSize,
|
|
7032
|
+
bottom: area.max.y - at.bottom.y - height - tipSize
|
|
6969
7033
|
};
|
|
6970
7034
|
if (!this._autoDirection) {
|
|
6971
7035
|
const sides = point.x < (area.min.x + area.max.x) / 2 ? ["right", "left"] : ["left", "right"], fallback = space.right >= space.left ? "right" : "left";
|
|
@@ -6975,7 +7039,7 @@
|
|
|
6975
7039
|
"bottom"
|
|
6976
7040
|
].find((d) => space[d] >= 0 && (d === "right" || d === "left" || width <= area.max.x - area.min.x)) ?? fallback;
|
|
6977
7041
|
}
|
|
6978
|
-
const direction = this._autoDirection;
|
|
7042
|
+
const direction = this._autoDirection, { x, y } = at[direction];
|
|
6979
7043
|
return {
|
|
6980
7044
|
direction,
|
|
6981
7045
|
shift: direction === "top" || direction === "bottom" ? new Point(shiftInto(x - width / 2, width, area.min.x, area.max.x), 0) : new Point(0, shiftInto(y - height / 2, height, area.min.y, area.max.y))
|
|
@@ -6996,7 +7060,7 @@
|
|
|
6996
7060
|
};
|
|
6997
7061
|
}
|
|
6998
7062
|
_updatePosition() {
|
|
6999
|
-
const pos = this._map.latLngToLayerPoint(this._latlng)
|
|
7063
|
+
const pos = this._map._snapLayerPoint(this._map.latLngToLayerPoint(this._latlng));
|
|
7000
7064
|
this._setPosition(pos);
|
|
7001
7065
|
}
|
|
7002
7066
|
/**
|
|
@@ -7012,8 +7076,8 @@
|
|
|
7012
7076
|
const pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center);
|
|
7013
7077
|
this._setPosition(pos);
|
|
7014
7078
|
}
|
|
7015
|
-
_getAnchor() {
|
|
7016
|
-
return new Point(this._source?._getTooltipAnchor && !this.options.sticky ? this._source._getTooltipAnchor() : [0, 0]);
|
|
7079
|
+
_getAnchor(direction) {
|
|
7080
|
+
return new Point(this._source?._getTooltipAnchor && !this.options.sticky ? this._source._getTooltipAnchor(direction) : [0, 0]);
|
|
7017
7081
|
}
|
|
7018
7082
|
/**
|
|
7019
7083
|
* Registers this default feature on the map class, called by `MaplairMap` itself.
|
|
@@ -7208,6 +7272,8 @@
|
|
|
7208
7272
|
removeHooks() {
|
|
7209
7273
|
off(this._map._container, "pointerdown", this._onPointerDown, this);
|
|
7210
7274
|
this._map._container.classList.remove("maplair-box-zoom");
|
|
7275
|
+
this._finish();
|
|
7276
|
+
this._resetState();
|
|
7211
7277
|
}
|
|
7212
7278
|
/**
|
|
7213
7279
|
* Returns `true` if a box has been drawn by the current or last interaction.
|
|
@@ -7358,9 +7424,13 @@
|
|
|
7358
7424
|
* pointer drag).
|
|
7359
7425
|
*/
|
|
7360
7426
|
/**
|
|
7361
|
-
* The event object of `dragstart`, `predrag` and `drag` of `Draggable
|
|
7427
|
+
* The event object of `dragstart`, `predrag` and `drag` of `Draggable`, and of
|
|
7428
|
+
* `movestart` and `dragstart` of draggable markers.
|
|
7362
7429
|
* @typedef {object} DraggableEvent
|
|
7363
|
-
* @property {PointerEvent} originalEvent The DOM event of the pointer which
|
|
7430
|
+
* @property {PointerEvent|KeyboardEvent} originalEvent The DOM event of the pointer which
|
|
7431
|
+
* drags: for `dragstart`, the `pointermove` that moved the pointer past `clickTolerance`
|
|
7432
|
+
* (not the `pointerdown`), or the `keydown` of an arrow key that moves a focused
|
|
7433
|
+
* draggable marker.
|
|
7364
7434
|
* @extends MaplairEvent
|
|
7365
7435
|
*/
|
|
7366
7436
|
/**
|
|
@@ -7597,8 +7667,13 @@
|
|
|
7597
7667
|
map._stop();
|
|
7598
7668
|
map._setUserEvent(e.originalEvent);
|
|
7599
7669
|
if (this._map.options.maxBounds && this._map.options.maxBoundsViscosity) {
|
|
7600
|
-
const bounds = LatLngBounds.from(this._map.options.maxBounds)
|
|
7601
|
-
|
|
7670
|
+
const bounds = LatLngBounds.from(this._map.options.maxBounds), { min, max } = new Bounds([
|
|
7671
|
+
bounds.getNorthWest(),
|
|
7672
|
+
bounds.getNorthEast(),
|
|
7673
|
+
bounds.getSouthEast(),
|
|
7674
|
+
bounds.getSouthWest()
|
|
7675
|
+
].map((c) => this._map.latLngToContainerPoint(c)));
|
|
7676
|
+
this._offsetLimit = new Bounds(max.multiplyBy(-1), min.multiplyBy(-1).add(this._map.getSize()));
|
|
7602
7677
|
this._viscosity = Math.min(1, Math.max(0, this._map.options.maxBoundsViscosity));
|
|
7603
7678
|
} else this._offsetLimit = null;
|
|
7604
7679
|
map.fire("movestart").fire("dragstart");
|
|
@@ -7965,7 +8040,7 @@
|
|
|
7965
8040
|
}
|
|
7966
8041
|
this._zooming = false;
|
|
7967
8042
|
cancelAnimationFrame(this._animRequest);
|
|
7968
|
-
if (this._map._zoomAnimated) this._map._animateZoom(this._center, this._map._limitZoom(this._zoom),
|
|
8043
|
+
if (this._map._zoomAnimated) this._map._animateZoom(this._center, this._map._limitZoom(this._zoom), this._map.options.zoomSnap);
|
|
7969
8044
|
else this._map._resetView(this._center, this._map._limitZoom(this._zoom));
|
|
7970
8045
|
}
|
|
7971
8046
|
/**
|
|
@@ -8118,7 +8193,7 @@
|
|
|
8118
8193
|
cancelAnimationFrame(this._pinchFrame);
|
|
8119
8194
|
const map = this._map, zoom = map._limitZoom(this._pinch.zoom), center = this._getPinchCenter(zoom);
|
|
8120
8195
|
this._pinch = null;
|
|
8121
|
-
if (map.options.zoomAnimation && Math.abs(zoom - map.getZoom()) > 1e-9) map._animateZoom(center, zoom,
|
|
8196
|
+
if (map.options.zoomAnimation && Math.abs(zoom - map.getZoom()) > 1e-9) map._animateZoom(center, zoom, map.options.zoomSnap);
|
|
8122
8197
|
else map._move(center, zoom)._moveEnd(true);
|
|
8123
8198
|
}
|
|
8124
8199
|
_panBy(e) {
|
|
@@ -8414,7 +8489,7 @@
|
|
|
8414
8489
|
this._moved = false;
|
|
8415
8490
|
cancelAnimationFrame(this._animRequest);
|
|
8416
8491
|
const map = this._map, zoom = map._limitZoom(this._zoom);
|
|
8417
|
-
if (map.options.zoomAnimation) map._animateZoom(this._center, zoom,
|
|
8492
|
+
if (map.options.zoomAnimation) map._animateZoom(this._center, zoom, map.options.zoomSnap);
|
|
8418
8493
|
else map._move(this._center, zoom)._moveEnd(true);
|
|
8419
8494
|
}
|
|
8420
8495
|
/**
|
|
@@ -8942,6 +9017,7 @@
|
|
|
8942
9017
|
center: requestedCenter,
|
|
8943
9018
|
zoom: targetZoom
|
|
8944
9019
|
};
|
|
9020
|
+
this._subpixelOrigin = true;
|
|
8945
9021
|
const from = this.project(this.getCenter()), to = this.project(targetCenter), size = this.getSize(), startZoom = this._zoom;
|
|
8946
9022
|
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;
|
|
8947
9023
|
function r(i) {
|
|
@@ -8963,6 +9039,7 @@
|
|
|
8963
9039
|
this._move(this.unproject(from.add(to.subtract(from).multiplyBy(u(s) / u1)), startZoom), this.getScaleZoom(Math.cosh(r0 + rho * s) / Math.cosh(r0), startZoom), { flyTo: true });
|
|
8964
9040
|
} else {
|
|
8965
9041
|
const zoomChanged = this._zoom !== targetZoom;
|
|
9042
|
+
this._subpixelOrigin = false;
|
|
8966
9043
|
this._move(targetCenter, targetZoom);
|
|
8967
9044
|
if (!zoomChanged) this.fire("zoom");
|
|
8968
9045
|
this._moveEnd(true);
|
|
@@ -9047,7 +9124,7 @@
|
|
|
9047
9124
|
this.options.minZoom = zoom;
|
|
9048
9125
|
if (this._loaded && oldZoom !== zoom) {
|
|
9049
9126
|
this.fire("zoomlevelschange");
|
|
9050
|
-
if (this.
|
|
9127
|
+
if (this._targetZoom() < this.options.minZoom) return this.setZoom(zoom);
|
|
9051
9128
|
}
|
|
9052
9129
|
return this;
|
|
9053
9130
|
}
|
|
@@ -9062,7 +9139,7 @@
|
|
|
9062
9139
|
this.options.maxZoom = zoom;
|
|
9063
9140
|
if (this._loaded && oldZoom !== zoom) {
|
|
9064
9141
|
this.fire("zoomlevelschange");
|
|
9065
|
-
if (this.
|
|
9142
|
+
if (this._targetZoom() > this.options.maxZoom) return this.setZoom(zoom);
|
|
9066
9143
|
}
|
|
9067
9144
|
return this;
|
|
9068
9145
|
}
|
|
@@ -9342,7 +9419,12 @@
|
|
|
9342
9419
|
bounds = LatLngBounds.from(bounds);
|
|
9343
9420
|
padding = Point.from(padding ?? [0, 0]);
|
|
9344
9421
|
let zoom = this.getZoom() ?? 0;
|
|
9345
|
-
const min = this.getMinZoom(), max = this.getMaxZoom(),
|
|
9422
|
+
const min = this.getMinZoom(), max = this.getMaxZoom(), size = this.getSize().subtract(padding), boundsSize = new Bounds([
|
|
9423
|
+
bounds.getNorthWest(),
|
|
9424
|
+
bounds.getNorthEast(),
|
|
9425
|
+
bounds.getSouthEast(),
|
|
9426
|
+
bounds.getSouthWest()
|
|
9427
|
+
].map((c) => this.project(c, 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);
|
|
9346
9428
|
zoom = this.getScaleZoom(scale, zoom);
|
|
9347
9429
|
if (snap) {
|
|
9348
9430
|
zoom = Math.round(zoom / (snap / 100)) * (snap / 100);
|
|
@@ -9581,7 +9663,18 @@
|
|
|
9581
9663
|
* @returns {Point}
|
|
9582
9664
|
*/
|
|
9583
9665
|
pointerEventToContainerPoint(e) {
|
|
9584
|
-
return getPointerPosition(e, this._container);
|
|
9666
|
+
if (!this._animatingZoom) return getPointerPosition(e, this._container);
|
|
9667
|
+
if (!this._containerRect) {
|
|
9668
|
+
const el = this._container, { x, y, boundingClientRect: r } = getScale(el);
|
|
9669
|
+
this._containerRect = {
|
|
9670
|
+
x,
|
|
9671
|
+
y,
|
|
9672
|
+
left: r.left + el.clientLeft * x,
|
|
9673
|
+
top: r.top + el.clientTop * y
|
|
9674
|
+
};
|
|
9675
|
+
}
|
|
9676
|
+
const c = this._containerRect;
|
|
9677
|
+
return new Point((e.clientX - c.left) / c.x, (e.clientY - c.top) / c.y);
|
|
9585
9678
|
}
|
|
9586
9679
|
/**
|
|
9587
9680
|
* Given a PointerEvent object, returns the pixel coordinate relative to
|
|
@@ -9746,7 +9839,7 @@
|
|
|
9746
9839
|
this._lastCenterPanePos = this._getMapPanePos();
|
|
9747
9840
|
this._pixelOrigin = this._getNewPixelOrigin(center);
|
|
9748
9841
|
if (!suppressEvent) {
|
|
9749
|
-
if (zoomChanged || data?.pinch) this.fire("zoom", data);
|
|
9842
|
+
if (zoomChanged || data?.pinch || data?.flyTo) this.fire("zoom", data);
|
|
9750
9843
|
this.fire("move", data);
|
|
9751
9844
|
} else if (data?.pinch) this.fire("zoom", data);
|
|
9752
9845
|
return this;
|
|
@@ -9761,6 +9854,10 @@
|
|
|
9761
9854
|
this._targetView = null;
|
|
9762
9855
|
cancelAnimationFrame(this._flyToFrame);
|
|
9763
9856
|
cancelAnimationFrame(this._zoomAnimFrame);
|
|
9857
|
+
if (this._subpixelOrigin) {
|
|
9858
|
+
this._subpixelOrigin = false;
|
|
9859
|
+
this._move(this._lastCenter, this._zoom, { flyTo: true });
|
|
9860
|
+
}
|
|
9764
9861
|
this._panAnim?.stop();
|
|
9765
9862
|
return this;
|
|
9766
9863
|
}
|
|
@@ -9833,17 +9930,17 @@
|
|
|
9833
9930
|
if (!targets.length && !dragging && !isHover && this.listens(type, true)) targets = [this];
|
|
9834
9931
|
return targets;
|
|
9835
9932
|
}
|
|
9836
|
-
_isClickDisabled(el) {
|
|
9837
|
-
while (el && el !== this._container) {
|
|
9838
|
-
if (el["_maplair_disable_click"] || !el.parentNode) return true;
|
|
9839
|
-
el = el.parentNode;
|
|
9840
|
-
}
|
|
9841
|
-
}
|
|
9842
9933
|
_handleDOMEvent(e) {
|
|
9843
9934
|
const el = e.target;
|
|
9844
9935
|
if (e.type === "click") simulateDblclick(e, this._container);
|
|
9845
|
-
if (!this._loaded || e.type === "click" && this.
|
|
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(),
|
|
9936
|
+
if (!this._loaded || e.type === "click" && isClickDisabled(el, this._container)) return;
|
|
9937
|
+
const type = e.type, move = type === "pointermove", hovered = this._hoveredCanvasLayer, skip = type === "pointerover" || type === "pointerout" || type.startsWith("key") || this._animatingZoom || move && this.dragging?.moving(), leftMap = type === "pointerout" && !this._container.contains(e.relatedTarget);
|
|
9938
|
+
let layer = skip ? void 0 : this._canvasLayerAt(e, type === "click");
|
|
9939
|
+
if (type === "pointerdown") this._pressedCanvasLayer = skip ? void 0 : layer ?? null;
|
|
9940
|
+
else if (type === "click" && e.detail > 0 && this._pressedCanvasLayer !== void 0) {
|
|
9941
|
+
if (layer !== this._pressedCanvasLayer) layer = void 0;
|
|
9942
|
+
this._pressedCanvasLayer = void 0;
|
|
9943
|
+
}
|
|
9847
9944
|
if (layer !== hovered && (move && !skip || leftMap)) {
|
|
9848
9945
|
if (hovered) this._fireDOMEvent(e, "pointerout", [hovered]);
|
|
9849
9946
|
this._container.classList.toggle("maplair-interactive", !!layer);
|
|
@@ -9912,7 +10009,11 @@
|
|
|
9912
10009
|
}
|
|
9913
10010
|
_getNewPixelOrigin(center, zoom) {
|
|
9914
10011
|
const viewHalf = this.getSize()._divideBy(2);
|
|
9915
|
-
|
|
10012
|
+
const origin = this.project(center, zoom)._subtract(viewHalf)._add(this._getMapPanePos());
|
|
10013
|
+
return this._subpixelOrigin ? origin : origin._round();
|
|
10014
|
+
}
|
|
10015
|
+
_snapLayerPoint(point) {
|
|
10016
|
+
return this._subpixelOrigin ? point : point._round();
|
|
9916
10017
|
}
|
|
9917
10018
|
_latLngToNewLayerPoint(latlng, zoom, center) {
|
|
9918
10019
|
const topLeft = this._getNewPixelOrigin(center, zoom);
|
|
@@ -9939,7 +10040,12 @@
|
|
|
9939
10040
|
return offset.add(this._getBoundsOffset(newBounds, bounds));
|
|
9940
10041
|
}
|
|
9941
10042
|
_getBoundsOffset(pxBounds, maxBounds, zoom) {
|
|
9942
|
-
const projectedMaxBounds = new Bounds(
|
|
10043
|
+
const projectedMaxBounds = new Bounds([
|
|
10044
|
+
maxBounds.getNorthWest(),
|
|
10045
|
+
maxBounds.getNorthEast(),
|
|
10046
|
+
maxBounds.getSouthEast(),
|
|
10047
|
+
maxBounds.getSouthWest()
|
|
10048
|
+
].map((c) => this.project(c, zoom))), minOffset = projectedMaxBounds.min.subtract(pxBounds.min), maxOffset = projectedMaxBounds.max.subtract(pxBounds.max);
|
|
9943
10049
|
return new Point(this._rebound(minOffset.x, -maxOffset.x), this._rebound(minOffset.y, -maxOffset.y));
|
|
9944
10050
|
}
|
|
9945
10051
|
_rebound(left, right) {
|
|
@@ -10021,18 +10127,16 @@
|
|
|
10021
10127
|
this._zoomAnimFrame = requestAnimationFrame(() => {
|
|
10022
10128
|
this._zoomAnimFrame = null;
|
|
10023
10129
|
if (userEvent) this._setUserEvent(userEvent);
|
|
10024
|
-
this._moveStart(true, options.noMoveStart ?? false)._animateZoom(center, zoom
|
|
10130
|
+
this._moveStart(true, options.noMoveStart ?? false)._animateZoom(center, zoom);
|
|
10025
10131
|
});
|
|
10026
10132
|
return true;
|
|
10027
10133
|
}
|
|
10028
|
-
_animateZoom(center, zoom,
|
|
10134
|
+
_animateZoom(center, zoom, noUpdate) {
|
|
10029
10135
|
if (!this._mapPane) return;
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
this._mapPane.classList.add("maplair-zoom-anim");
|
|
10035
|
-
}
|
|
10136
|
+
this._animatingZoom = true;
|
|
10137
|
+
this._animateToCenter = center;
|
|
10138
|
+
this._animateToZoom = zoom;
|
|
10139
|
+
this._mapPane.classList.add("maplair-zoom-anim");
|
|
10036
10140
|
this.fire("zoomanim", {
|
|
10037
10141
|
center,
|
|
10038
10142
|
zoom,
|
|
@@ -10040,10 +10144,13 @@
|
|
|
10040
10144
|
});
|
|
10041
10145
|
if (!this._tempFireZoomEvent) this._tempFireZoomEvent = this._zoom !== this._animateToZoom;
|
|
10042
10146
|
this._move(this._animateToCenter, this._animateToZoom, void 0, true);
|
|
10043
|
-
this._transitionEndTimer
|
|
10147
|
+
clearTimeout(this._transitionEndTimer);
|
|
10148
|
+
this._transitionEndTimer = setTimeout(this._onZoomTransitionEnd.bind(this), 1e3);
|
|
10044
10149
|
}
|
|
10045
10150
|
_onZoomTransitionEnd() {
|
|
10046
10151
|
if (!this._animatingZoom) return;
|
|
10152
|
+
clearTimeout(this._transitionEndTimer);
|
|
10153
|
+
this._containerRect = null;
|
|
10047
10154
|
this._mapPane?.classList.remove("maplair-zoom-anim");
|
|
10048
10155
|
this._animatingZoom = false;
|
|
10049
10156
|
this._move(this.getCenter(), this._animateToZoom, void 0, true);
|
|
@@ -10322,7 +10429,6 @@
|
|
|
10322
10429
|
polygonCenter: () => polygonCenter
|
|
10323
10430
|
});
|
|
10324
10431
|
/** @import {LatLngExpression} from '../geo/LatLng.js' */
|
|
10325
|
-
/** @import {Bounds} from './Bounds.js' */
|
|
10326
10432
|
/** @import {CRS} from '../geo/crs/CRS.js' */
|
|
10327
10433
|
/**
|
|
10328
10434
|
* Clips the polygon geometry defined by the given `points` by the given bounds (using
|
|
@@ -10377,7 +10483,14 @@
|
|
|
10377
10483
|
y += (p1.y + p2.y) * f;
|
|
10378
10484
|
area += f;
|
|
10379
10485
|
}
|
|
10380
|
-
|
|
10486
|
+
if (area !== 0) return crs.unproject(new Point(x / (3 * area), y / (3 * area))._add(origin));
|
|
10487
|
+
const mid = new Bounds(points).getCenter();
|
|
10488
|
+
let center = points[0];
|
|
10489
|
+
for (let i = 0, j = len - 1; i < len; j = i++) {
|
|
10490
|
+
const p = _sqClosestPointOnSegment(mid, points[j], points[i]);
|
|
10491
|
+
if (p.distanceTo(mid) < center.distanceTo(mid)) center = p;
|
|
10492
|
+
}
|
|
10493
|
+
return crs.unproject(center._add(origin));
|
|
10381
10494
|
}
|
|
10382
10495
|
/**
|
|
10383
10496
|
* Returns the 'center of mass' of the passed LatLngs.
|
|
@@ -10803,10 +10916,10 @@
|
|
|
10803
10916
|
scale.textContent = text;
|
|
10804
10917
|
}
|
|
10805
10918
|
_getRoundNum(num) {
|
|
10806
|
-
const
|
|
10807
|
-
let d = num /
|
|
10919
|
+
const exponent = num < 1 ? Math.floor(Math.log10(num)) : `${Math.floor(num)}`.length - 1;
|
|
10920
|
+
let d = num / 10 ** exponent;
|
|
10808
10921
|
d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
|
|
10809
|
-
return
|
|
10922
|
+
return exponent < 0 ? d / 10 ** -exponent : d * 10 ** exponent;
|
|
10810
10923
|
}
|
|
10811
10924
|
};
|
|
10812
10925
|
// src/layer/marker/Icon.js
|
|
@@ -10826,8 +10939,11 @@
|
|
|
10826
10939
|
* can be set in CSS with negative margins.
|
|
10827
10940
|
* @property {PointExpression} [popupAnchor=[0, 0]] The coordinates of the point from
|
|
10828
10941
|
* which popups will "open", relative to the icon anchor.
|
|
10829
|
-
* @property {PointExpression} [tooltipAnchor=[0, 0]]
|
|
10830
|
-
*
|
|
10942
|
+
* @property {PointExpression} [tooltipAnchor=[0, 0]] Where tooltips opening to the side
|
|
10943
|
+
* attach, relative to the icon anchor: `x` is how far to the right (mirrored for tooltips
|
|
10944
|
+
* opening to the left) and `y` how far down. Tooltips opening to the top or bottom attach
|
|
10945
|
+
* to the middle of the icon's top or bottom edge, and `center` ones to the middle of the
|
|
10946
|
+
* icon at the `y` height.
|
|
10831
10947
|
* @property {string} [shadowUrl] The URL to the icon shadow image. If not specified, no
|
|
10832
10948
|
* shadow image will be created.
|
|
10833
10949
|
* @property {string} [shadowRetinaUrl] The URL to a retina sized version of the shadow
|
|
@@ -10910,15 +11026,31 @@
|
|
|
10910
11026
|
else img.crossOrigin = null;
|
|
10911
11027
|
return img;
|
|
10912
11028
|
}
|
|
10913
|
-
|
|
11029
|
+
_getBox(name) {
|
|
10914
11030
|
const options = this.options;
|
|
10915
11031
|
const sizeOption = options[`${name}Size`];
|
|
10916
11032
|
const [width, height] = (typeof sizeOption === "number" ? [sizeOption, sizeOption] : Array.isArray(sizeOption) ? sizeOption : [sizeOption?.x, sizeOption?.y]).map(toNumber);
|
|
10917
11033
|
const anchorOption = name === "shadow" && options.shadowAnchor || options.iconAnchor;
|
|
10918
|
-
|
|
10919
|
-
|
|
10920
|
-
|
|
11034
|
+
return {
|
|
11035
|
+
width,
|
|
11036
|
+
height,
|
|
11037
|
+
anchor: Point.validate(anchorOption) ? Point.from(anchorOption) : {
|
|
11038
|
+
x: Math.round(width / 2),
|
|
11039
|
+
y: Math.round(height / 2)
|
|
11040
|
+
}
|
|
10921
11041
|
};
|
|
11042
|
+
}
|
|
11043
|
+
_getTooltipAnchor(direction) {
|
|
11044
|
+
const { x, y } = Point.from(this.options.tooltipAnchor);
|
|
11045
|
+
if (direction === "left") return new Point(-x, y);
|
|
11046
|
+
if (direction === "center") return new Point(0, y);
|
|
11047
|
+
if (direction !== "top" && direction !== "bottom") return new Point(x, y);
|
|
11048
|
+
const { height, anchor } = this._getBox("icon");
|
|
11049
|
+
return new Point(0, (direction === "top" ? -anchor.y : height - anchor.y) || 0);
|
|
11050
|
+
}
|
|
11051
|
+
_setIconStyles(img, name) {
|
|
11052
|
+
const options = this.options;
|
|
11053
|
+
const { width, height, anchor } = this._getBox(name);
|
|
10922
11054
|
img.className = `maplair-marker-${name} ${options.className || ""}`;
|
|
10923
11055
|
const { style } = img;
|
|
10924
11056
|
style.marginLeft = style.marginTop = style.width = style.height = "";
|
|
@@ -11019,8 +11151,8 @@
|
|
|
11019
11151
|
* The handler of `Marker` which makes the markers draggable, see the
|
|
11020
11152
|
* [`dragging`](#marker-dragging) property of markers and its `draggable` option.
|
|
11021
11153
|
*
|
|
11022
|
-
* @fires Marker#dragstart {
|
|
11023
|
-
* @fires Marker#movestart {
|
|
11154
|
+
* @fires Marker#dragstart {DraggableEvent} Fired when the user starts dragging the marker.
|
|
11155
|
+
* @fires Marker#movestart {DraggableEvent} Fired when the marker starts moving (because of
|
|
11024
11156
|
* dragging).
|
|
11025
11157
|
* @fires Marker#drag {MarkerMoveEvent} Fired repeatedly while the user drags the marker.
|
|
11026
11158
|
* @fires Marker#dragend {DragEndEvent} Fired when the user stops dragging the marker.
|
|
@@ -11086,10 +11218,10 @@
|
|
|
11086
11218
|
this._panRequest = requestAnimationFrame(this._adjustPan.bind(this, e));
|
|
11087
11219
|
}
|
|
11088
11220
|
}
|
|
11089
|
-
_onDragStart() {
|
|
11221
|
+
_onDragStart({ originalEvent }) {
|
|
11090
11222
|
this._oldLatLng = this._marker.getLatLng();
|
|
11091
11223
|
this._marker.closePopup?.();
|
|
11092
|
-
this._marker.fire("movestart").fire("dragstart");
|
|
11224
|
+
this._marker.fire("movestart", { originalEvent }).fire("dragstart", { originalEvent });
|
|
11093
11225
|
}
|
|
11094
11226
|
_onPreDrag(e) {
|
|
11095
11227
|
if (this._marker.options.autoPan) {
|
|
@@ -11126,7 +11258,7 @@
|
|
|
11126
11258
|
draggable._startPos = getPosition(draggable._element);
|
|
11127
11259
|
draggable._moved = draggable._moving = true;
|
|
11128
11260
|
this._keyOffset = new Point(0, 0);
|
|
11129
|
-
draggable.fire("dragstart");
|
|
11261
|
+
draggable.fire("dragstart", { originalEvent: k });
|
|
11130
11262
|
}
|
|
11131
11263
|
const offset = new Point(...dir).multiplyBy(k.shiftKey ? 30 : 10);
|
|
11132
11264
|
this._keyOffset = this._keyOffset.add(map._rotateToPane?.(offset) ?? offset);
|
|
@@ -11358,7 +11490,7 @@
|
|
|
11358
11490
|
*/
|
|
11359
11491
|
update() {
|
|
11360
11492
|
if (this._icon && this._map && !this._culled) {
|
|
11361
|
-
const pos = this._map.latLngToLayerPoint(this._latlng)
|
|
11493
|
+
const pos = this._map._snapLayerPoint(this._map.latLngToLayerPoint(this._latlng));
|
|
11362
11494
|
this._setPos(pos);
|
|
11363
11495
|
}
|
|
11364
11496
|
return this;
|
|
@@ -11429,7 +11561,7 @@
|
|
|
11429
11561
|
}
|
|
11430
11562
|
_setPos(pos) {
|
|
11431
11563
|
this._positionElements(pos);
|
|
11432
|
-
this._zIndex = pos.y + this.options.zIndexOffset;
|
|
11564
|
+
this._zIndex = Math.round(pos.y) + this.options.zIndexOffset;
|
|
11433
11565
|
this._updateRise();
|
|
11434
11566
|
}
|
|
11435
11567
|
_positionElements(pos) {
|
|
@@ -11449,7 +11581,7 @@
|
|
|
11449
11581
|
}
|
|
11450
11582
|
_animateZoom(opt) {
|
|
11451
11583
|
if (this._culled) return;
|
|
11452
|
-
const pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center)
|
|
11584
|
+
const pos = this._map._snapLayerPoint(this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center));
|
|
11453
11585
|
this._setPos(pos);
|
|
11454
11586
|
}
|
|
11455
11587
|
_updateInteractive() {
|
|
@@ -11564,8 +11696,8 @@
|
|
|
11564
11696
|
_getPopupAnchor() {
|
|
11565
11697
|
return this._rotateAnchor(this.options.icon.options.popupAnchor);
|
|
11566
11698
|
}
|
|
11567
|
-
_getTooltipAnchor() {
|
|
11568
|
-
return this._rotateAnchor(this.options.icon.
|
|
11699
|
+
_getTooltipAnchor(direction) {
|
|
11700
|
+
return this._rotateAnchor(this.options.icon._getTooltipAnchor(direction));
|
|
11569
11701
|
}
|
|
11570
11702
|
_rotateAnchor(anchor) {
|
|
11571
11703
|
const angle = this.options.rotation * Math.PI / 180;
|
|
@@ -13836,7 +13968,7 @@
|
|
|
13836
13968
|
setTransform(this._image, offset, scale);
|
|
13837
13969
|
}
|
|
13838
13970
|
_reset() {
|
|
13839
|
-
const image = this._image, bounds = new Bounds(
|
|
13971
|
+
const image = this._image, map = this._map, bounds = new Bounds(map._snapLayerPoint(map.latLngToLayerPoint(this._bounds.getNorthWest())), map._snapLayerPoint(map.latLngToLayerPoint(this._bounds.getSouthEast()))), size = bounds.getSize();
|
|
13840
13972
|
setPosition(image, bounds.min);
|
|
13841
13973
|
image.style.width = `${size.x}px`;
|
|
13842
13974
|
image.style.height = `${size.y}px`;
|
|
@@ -14801,7 +14933,7 @@
|
|
|
14801
14933
|
_onOpaqueTile() {}
|
|
14802
14934
|
_initContainer() {
|
|
14803
14935
|
if (this._container) return;
|
|
14804
|
-
this._container = create("div", `maplair-layer ${this.options.className ?? ""}`);
|
|
14936
|
+
this._container = create("div", `maplair-layer maplair-zoom-animated ${this.options.className ?? ""}`);
|
|
14805
14937
|
this._container.classList.toggle("maplair-pixelated", !!this.options.pixelated);
|
|
14806
14938
|
this._updateZIndex();
|
|
14807
14939
|
if (this.options.opacity < 1) this._updateOpacity();
|
|
@@ -14868,7 +15000,6 @@
|
|
|
14868
15000
|
level.origin = map.project(map.unproject(map.getPixelOrigin()), zoom).round();
|
|
14869
15001
|
level.zoom = zoom;
|
|
14870
15002
|
this._setZoomTransform(level, map.getCenter(), map.getZoom());
|
|
14871
|
-
level.el.offsetWidth;
|
|
14872
15003
|
this._onCreateLevel(level);
|
|
14873
15004
|
}
|
|
14874
15005
|
this._level = level;
|
|
@@ -14932,7 +15063,10 @@
|
|
|
14932
15063
|
this._setView(this._map.getCenter(), this._map.getZoom(), animating, animating);
|
|
14933
15064
|
}
|
|
14934
15065
|
_animateZoom(e) {
|
|
15066
|
+
const map = this._map, center = map.getCenter(), zoom = map.getZoom(), scale = map.getZoomScale(e.zoom, zoom);
|
|
14935
15067
|
this._setView(e.center, e.zoom, true, e.noUpdate);
|
|
15068
|
+
this._setZoomTransforms(center, zoom);
|
|
15069
|
+
setTransform(this._container, map._getNewPixelOrigin(center, zoom).multiplyBy(scale).subtract(map._getNewPixelOrigin(e.center, e.zoom)), scale);
|
|
14936
15070
|
}
|
|
14937
15071
|
_getTileZoom(zoom) {
|
|
14938
15072
|
const { minZoom, maxZoom = Infinity } = this.options;
|
|
@@ -14960,10 +15094,12 @@
|
|
|
14960
15094
|
this._setZoomTransforms(center, zoom);
|
|
14961
15095
|
}
|
|
14962
15096
|
_setZoomTransforms(center, zoom) {
|
|
15097
|
+
if (this._container.style.transform) this._container.style.transform = "";
|
|
14963
15098
|
for (const level of Object.values(this._levels)) this._setZoomTransform(level, center, zoom);
|
|
14964
15099
|
}
|
|
14965
15100
|
_setZoomTransform(level, center, zoom) {
|
|
14966
|
-
const scale = this._map.getZoomScale(zoom, level.zoom), translate = level.origin.multiplyBy(scale).subtract(this._map._getNewPixelOrigin(center, zoom))
|
|
15101
|
+
const scale = this._map.getZoomScale(zoom, level.zoom), translate = level.origin.multiplyBy(scale).subtract(this._map._getNewPixelOrigin(center, zoom));
|
|
15102
|
+
if (scale === 1) this._map._snapLayerPoint(translate);
|
|
14967
15103
|
setTransform(level.el, translate, scale);
|
|
14968
15104
|
}
|
|
14969
15105
|
_resetGrid() {
|
|
@@ -14974,7 +15110,9 @@
|
|
|
14974
15110
|
this._wrapY = crs.wrapLat && !this.options.noWrap && [Math.floor(map.project([crs.wrapLat[0], 0], tileZoom).y / tileSize.y), Math.ceil(map.project([crs.wrapLat[1], 0], tileZoom).y / tileSize.y)];
|
|
14975
15111
|
}
|
|
14976
15112
|
_onMoveEnd() {
|
|
14977
|
-
|
|
15113
|
+
const map = this._map;
|
|
15114
|
+
if (!map || map._animatingZoom) return;
|
|
15115
|
+
if (this._container.style.transform) this._setZoomTransforms(map.getCenter(), map.getZoom());
|
|
14978
15116
|
this._update();
|
|
14979
15117
|
}
|
|
14980
15118
|
_onWorldCopyJump({ worlds }) {
|
|
@@ -15159,6 +15297,10 @@
|
|
|
15159
15297
|
return osmHosts.some((osmHost) => host === osmHost || host.endsWith(`.${osmHost}`));
|
|
15160
15298
|
}
|
|
15161
15299
|
const upgradeOSMUrl = (url) => isOSMUrl(url) ? url.replace(httpRe, "https:") : url;
|
|
15300
|
+
function retinaLevel() {
|
|
15301
|
+
const dpr = window.devicePixelRatio;
|
|
15302
|
+
return dpr >= 1.5 ? 2 : dpr > 1 ? 1 : 0;
|
|
15303
|
+
}
|
|
15162
15304
|
/**
|
|
15163
15305
|
* Options of `TileLayer`.
|
|
15164
15306
|
* @typedef {object} TileLayerOptions
|
|
@@ -15177,9 +15319,9 @@
|
|
|
15177
15319
|
* this on for [TMS](https://en.wikipedia.org/wiki/Tile_Map_Service) services).
|
|
15178
15320
|
* @property {boolean} [zoomReverse=false] If set to true, the zoom number used in tile
|
|
15179
15321
|
* URLs will be reversed (`maxZoom - zoom` instead of `zoom`).
|
|
15180
|
-
* @property {boolean} [detectRetina=false] If `true` and
|
|
15181
|
-
* will request four tiles of half the specified size and a bigger zoom level
|
|
15182
|
-
* of one to utilize the high resolution.
|
|
15322
|
+
* @property {boolean} [detectRetina=false] If `true` and the device pixel ratio is 1.5 or
|
|
15323
|
+
* higher, it will request four tiles of half the specified size and a bigger zoom level
|
|
15324
|
+
* in place of one to utilize the high resolution.
|
|
15183
15325
|
* @property {boolean|string} [crossOrigin=false] Whether the crossOrigin attribute will
|
|
15184
15326
|
* be added to the tiles. If a String is provided, all tiles will have their crossOrigin
|
|
15185
15327
|
* attribute set to the String provided. This is needed if you want to access tile pixel
|
|
@@ -15279,8 +15421,8 @@
|
|
|
15279
15421
|
}
|
|
15280
15422
|
_applyRetina() {
|
|
15281
15423
|
Object.assign(this.options, this._nonRetinaOptions);
|
|
15282
|
-
this._retina =
|
|
15283
|
-
if (this.options.detectRetina && this._retina && this.options.maxZoom > 0) {
|
|
15424
|
+
this._retina = retinaLevel();
|
|
15425
|
+
if (this.options.detectRetina && this._retina === 2 && this.options.maxZoom > 0) {
|
|
15284
15426
|
const tileSize = this.options.tileSize;
|
|
15285
15427
|
this.options.tileSize = tileSize instanceof Point ? tileSize.divideBy(2).floor() : Math.floor(tileSize / 2);
|
|
15286
15428
|
if (!this.options.zoomReverse) {
|
|
@@ -15306,7 +15448,7 @@
|
|
|
15306
15448
|
return events;
|
|
15307
15449
|
}
|
|
15308
15450
|
_onPixelRatioChange() {
|
|
15309
|
-
if (
|
|
15451
|
+
if (retinaLevel() === this._retina) return;
|
|
15310
15452
|
const map = this._map;
|
|
15311
15453
|
this._applyRetina();
|
|
15312
15454
|
if (this.options.detectRetina) {
|
|
@@ -15530,7 +15672,7 @@
|
|
|
15530
15672
|
this.callInitHooks(WMSTileLayer);
|
|
15531
15673
|
}
|
|
15532
15674
|
_updateWmsSize() {
|
|
15533
|
-
const realRetina = this.options.detectRetina && window.devicePixelRatio
|
|
15675
|
+
const realRetina = this.options.detectRetina && window.devicePixelRatio >= 1.5 ? 2 : 1;
|
|
15534
15676
|
const tileSize = this.getTileSize();
|
|
15535
15677
|
this.wmsParams.width = tileSize.x * realRetina;
|
|
15536
15678
|
this.wmsParams.height = tileSize.y * realRetina;
|
|
@@ -15586,7 +15728,10 @@
|
|
|
15586
15728
|
for (const [k, v] of Object.entries({
|
|
15587
15729
|
...this.wmsParams,
|
|
15588
15730
|
bbox
|
|
15589
|
-
}))
|
|
15731
|
+
})) {
|
|
15732
|
+
if (v == null) continue;
|
|
15733
|
+
url.searchParams.append(this.options.uppercase ? k.toUpperCase() : k, `${v}`);
|
|
15734
|
+
}
|
|
15590
15735
|
return url.toString();
|
|
15591
15736
|
}
|
|
15592
15737
|
/**
|
|
@@ -15614,7 +15759,8 @@
|
|
|
15614
15759
|
/**
|
|
15615
15760
|
* Merges an object with the new parameters and re-requests tiles on the current screen
|
|
15616
15761
|
* (unless `noRedraw` was set to true). The current tiles stay visible until the new
|
|
15617
|
-
* tiles have loaded, to avoid flickering.
|
|
15762
|
+
* tiles have loaded, to avoid flickering. Set a parameter to `undefined` or `null` to
|
|
15763
|
+
* leave it out of the requests.
|
|
15618
15764
|
* @param {Record<string, any>} params
|
|
15619
15765
|
* @param {boolean} [noRedraw]
|
|
15620
15766
|
* @returns {this}
|
|
@@ -15702,7 +15848,7 @@
|
|
|
15702
15848
|
super.onAdd(map);
|
|
15703
15849
|
const z = (r) => +getComputedStyle(r._container.parentNode).zIndex || 0;
|
|
15704
15850
|
map._canvases.push(this);
|
|
15705
|
-
map._canvases.sort((a, b) => z(b) - z(a) || (a._container.compareDocumentPosition(b._container) & 2)
|
|
15851
|
+
map._canvases.sort((a, b) => z(b) - z(a) || 1 - (a._container.compareDocumentPosition(b._container) & 2));
|
|
15706
15852
|
this._draw();
|
|
15707
15853
|
}
|
|
15708
15854
|
_initContainer() {
|
|
@@ -15857,7 +16003,7 @@
|
|
|
15857
16003
|
ctx.fillStyle = options.fillColor ?? options.color;
|
|
15858
16004
|
ctx.fill(options.fillRule || "evenodd");
|
|
15859
16005
|
}
|
|
15860
|
-
if (options.stroke && options.weight !== 0) {
|
|
16006
|
+
if (options.stroke && +options.weight !== 0) {
|
|
15861
16007
|
ctx.lineDashOffset = Number(options.dashOffset ?? 0);
|
|
15862
16008
|
ctx.setLineDash(layer._dashArray ?? []);
|
|
15863
16009
|
ctx.globalAlpha = options.opacity;
|
|
@@ -15946,7 +16092,6 @@
|
|
|
15946
16092
|
constructor(latlng, options) {
|
|
15947
16093
|
if (typeof options === "number") throw new Error("Circle: the radius is an option in Maplair. Use new Circle(latlng, {radius}).");
|
|
15948
16094
|
super(latlng, options);
|
|
15949
|
-
if (isNaN(this.options.radius)) throw new Error("Circle radius cannot be NaN");
|
|
15950
16095
|
this.callInitHooks(Circle);
|
|
15951
16096
|
}
|
|
15952
16097
|
/**
|
|
@@ -15966,8 +16111,8 @@
|
|
|
15966
16111
|
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;
|
|
15967
16112
|
if (isNaN(lngR) || lngR === 0) lngR = latR / Math.cos(lat * d);
|
|
15968
16113
|
this._point = p.subtract(renderer._pathOrigin);
|
|
15969
|
-
this._pxRadius = isNaN(lngR) ? 0 : p.
|
|
15970
|
-
this._pxRadiusY = p.
|
|
16114
|
+
this._pxRadius = isNaN(lngR) ? 0 : p.distanceTo(map.project([lat2, lng - lngR], zoom));
|
|
16115
|
+
this._pxRadiusY = p.distanceTo(top);
|
|
15971
16116
|
} else {
|
|
15972
16117
|
const latlng2 = crs.unproject(crs.project(this._latlng).subtract([this._radius, 0]));
|
|
15973
16118
|
this._point = renderer._latLngToLayerPoint(this._latlng);
|
|
@@ -16372,7 +16517,7 @@
|
|
|
16372
16517
|
if (this._leader !== map) return;
|
|
16373
16518
|
for (const other of this._followers(map)) if (other._zoomAnimated) {
|
|
16374
16519
|
this._animating.add(other);
|
|
16375
|
-
other._animateZoom(e.center, this._zoomFor(other, map, e.zoom),
|
|
16520
|
+
other._animateZoom(e.center, this._zoomFor(other, map, e.zoom), e.noUpdate);
|
|
16376
16521
|
}
|
|
16377
16522
|
}
|
|
16378
16523
|
_onMoveEnd(map) {
|
|
@@ -17112,7 +17257,8 @@
|
|
|
17112
17257
|
/** @typedef {typeof blanketOverlayRotationMethods} BlanketOverlayMapRotationMethods */
|
|
17113
17258
|
BlanketOverlay.include({
|
|
17114
17259
|
_updateTransform(center, zoom) {
|
|
17115
|
-
const scale = this._map.getZoomScale(zoom, this._zoom), viewHalf = this._map._getViewSize().multiplyBy(.5 + this.options.padding), currentCenterPoint = this._map.project(this._center, zoom), topLeftOffset = viewHalf.multiplyBy(-scale)._add(currentCenterPoint)._subtract(this._map._getNewPixelOrigin(center, zoom))
|
|
17260
|
+
const scale = this._map.getZoomScale(zoom, this._zoom), viewHalf = this._map._getViewSize().multiplyBy(.5 + this.options.padding), currentCenterPoint = this._map.project(this._center, zoom), topLeftOffset = viewHalf.multiplyBy(-scale)._add(currentCenterPoint)._subtract(this._map._getNewPixelOrigin(center, zoom));
|
|
17261
|
+
if (scale === 1) this._map._snapLayerPoint(topLeftOffset);
|
|
17116
17262
|
setTransform(this._container, topLeftOffset, scale);
|
|
17117
17263
|
},
|
|
17118
17264
|
_onMoveEnd(ev) {
|
|
@@ -17147,7 +17293,7 @@
|
|
|
17147
17293
|
},
|
|
17148
17294
|
_updatePosition() {
|
|
17149
17295
|
if (!this._map) return;
|
|
17150
|
-
const map = this._map, pos = map.latLngToLayerPoint(this._latlng)
|
|
17296
|
+
const map = this._map, pos = map._snapLayerPoint(map.latLngToLayerPoint(this._latlng)), anchor = map._rotateToPane(new Point(this._getAnchor()));
|
|
17151
17297
|
let offset = Point.from(this.options.offset);
|
|
17152
17298
|
const transformed = this._zoomAnimated || this.options.overflow || map._bearing;
|
|
17153
17299
|
if (!transformed) offset = offset.add(pos).add(anchor);
|
|
@@ -17914,7 +18060,10 @@ load(source, fetchOptions = this.options.fetchOptions) {
|
|
|
17914
18060
|
});
|
|
17915
18061
|
CircleMarker.include({ setRadius(radius) {
|
|
17916
18062
|
this._takeZoomStyles({ radius });
|
|
17917
|
-
|
|
18063
|
+
if (!this._zoomStyles?.radius) return setRadius.call(this, radius);
|
|
18064
|
+
if (this._map) return setRadius.call(this, evaluate(radius, this._map.getZoom()));
|
|
18065
|
+
this.options.radius = this._radius = radius;
|
|
18066
|
+
return this;
|
|
17918
18067
|
} });
|
|
17919
18068
|
Path.addInitHook(function() {
|
|
17920
18069
|
this._takeZoomStyles(this.options);
|