maplair 4.4.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/dist/esm/control/AttributionControl.js +20 -3
- package/dist/esm/control/AttributionControl.js.map +1 -1
- package/dist/esm/control/LayersControl.js +35 -20
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/ScaleControl.js +3 -3
- package/dist/esm/control/ScaleControl.js.map +1 -1
- package/dist/esm/control/ZoomControl.js +1 -0
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Util.js +1 -1
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.PointerEvents.js +19 -2
- package/dist/esm/dom/DomEvent.PointerEvents.js.map +1 -1
- package/dist/esm/dom/Draggable.js +6 -2
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/geo/LatLng.js +1 -1
- package/dist/esm/geo/LatLng.js.map +1 -1
- package/dist/esm/geo/LatLngBounds.js +1 -1
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geometry/Bounds.js +1 -1
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/Point.js +4 -2
- package/dist/esm/geometry/Point.js.map +1 -1
- package/dist/esm/geometry/PolyUtil.js +10 -3
- package/dist/esm/geometry/PolyUtil.js.map +1 -1
- package/dist/esm/layer/BlanketOverlay.js +2 -1
- package/dist/esm/layer/BlanketOverlay.js.map +1 -1
- package/dist/esm/layer/DivOverlay.js +3 -3
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/ImageOverlay.js +1 -1
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +1 -1
- package/dist/esm/layer/Layer.js.map +1 -1
- package/dist/esm/layer/Popup.js +3 -4
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/Tooltip.js +31 -22
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/marker/Icon.js +25 -6
- package/dist/esm/layer/marker/Icon.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js +5 -5
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +5 -5
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/tile/GridLayer.js +11 -5
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +10 -6
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/tile/WMSTileLayer.js +7 -3
- package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +2 -2
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +2 -3
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +6 -3
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.ZoomStyles.js +4 -1
- package/dist/esm/layer/vector/Path.ZoomStyles.js.map +1 -1
- package/dist/esm/map/Map.Rotation.js +3 -2
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +58 -26
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/MapSync.js +1 -1
- package/dist/esm/map/MapSync.js.map +1 -1
- package/dist/esm/map/handler/BoxZoomHandler.js +2 -0
- package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DragHandler.js +7 -2
- package/dist/esm/map/handler/DragHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +1 -1
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/TapDragZoomHandler.js +1 -1
- package/dist/esm/map/handler/TapDragZoomHandler.js.map +1 -1
- package/dist/esm/package.js +1 -1
- package/dist/maplair-global-src.js +289 -140
- package/dist/maplair-global-src.js.map +1 -1
- package/dist/maplair-global.js +2 -2
- package/dist/maplair-global.js.map +1 -1
- package/dist/maplair-src.js +289 -140
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.css +1 -1
- package/dist/maplair.js +2 -2
- package/dist/maplair.js.map +1 -1
- package/package.json +1 -1
- package/src/control/AttributionControl.js +29 -3
- package/src/control/LayersControl.js +47 -27
- package/src/control/ScaleControl.js +6 -3
- package/src/control/ZoomControl.js +1 -0
- package/src/core/Util.js +1 -1
- package/src/dom/DomEvent.PointerEvents.js +22 -2
- package/src/dom/Draggable.js +6 -2
- package/src/geo/LatLng.js +2 -1
- package/src/geo/LatLngBounds.js +1 -1
- package/src/geometry/Bounds.js +1 -1
- package/src/geometry/Point.js +4 -2
- package/src/geometry/PolyUtil.js +12 -3
- package/src/layer/BlanketOverlay.js +5 -2
- package/src/layer/DivOverlay.js +3 -3
- package/src/layer/ImageOverlay.js +3 -2
- package/src/layer/Layer.js +1 -1
- package/src/layer/Popup.js +3 -4
- package/src/layer/Tooltip.js +34 -27
- package/src/layer/marker/Icon.js +25 -5
- package/src/layer/marker/Marker.Drag.js +6 -6
- package/src/layer/marker/Marker.js +5 -5
- package/src/layer/tile/GridLayer.js +20 -7
- package/src/layer/tile/TileLayer.js +14 -7
- package/src/layer/tile/WMSTileLayer.js +4 -2
- package/src/layer/vector/Canvas.js +2 -2
- package/src/layer/vector/Circle.js +3 -5
- package/src/layer/vector/CircleMarker.js +5 -2
- package/src/layer/vector/Path.ZoomStyles.js +5 -3
- package/src/map/Map.Rotation.js +6 -3
- package/src/map/Map.js +63 -32
- package/src/map/MapSync.js +1 -1
- package/src/map/handler/BoxZoomHandler.js +3 -0
- package/src/map/handler/DragHandler.js +5 -5
- package/src/map/handler/PinchZoomHandler.js +1 -1
- package/src/map/handler/ScrollWheelZoomHandler.js +1 -1
- package/src/map/handler/TapDragZoomHandler.js +1 -1
- package/src/maplair.css +12 -1
package/dist/maplair-src.js
CHANGED
|
@@ -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
|
|
|
@@ -15,7 +15,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
15
15
|
return target;
|
|
16
16
|
};
|
|
17
17
|
// package.json
|
|
18
|
-
var version$1 = "4.
|
|
18
|
+
var version$1 = "4.5.0";
|
|
19
19
|
// src/core/Util.js
|
|
20
20
|
var Util_exports = /* @__PURE__ */ __exportAll({
|
|
21
21
|
falseFn: () => falseFn,
|
|
@@ -150,7 +150,7 @@ function getDefaultOptions(cls) {
|
|
|
150
150
|
}
|
|
151
151
|
return defaults;
|
|
152
152
|
}
|
|
153
|
-
const templateRe = /\{ *([\w_ -]
|
|
153
|
+
const templateRe = /\{ *([\w_ -]+?) *\}/g;
|
|
154
154
|
/**
|
|
155
155
|
* Simple templating facility, accepts a template string of the form `'Hello {a}, {b}'`
|
|
156
156
|
* and a data object like `{a: 'foo', b: 'bar'}`, returns evaluated string
|
|
@@ -540,19 +540,21 @@ var Point = class Point {
|
|
|
540
540
|
* `scale`. In linear algebra terms, multiply the point by the
|
|
541
541
|
* [scaling matrix](https://en.wikipedia.org/wiki/Scaling_%28geometry%29#Matrix_representation)
|
|
542
542
|
* defined by `scale`.
|
|
543
|
-
* @param {
|
|
543
|
+
* @param {PointExpression} point The scale.
|
|
544
544
|
* @returns {Point}
|
|
545
545
|
*/
|
|
546
546
|
scaleBy(point) {
|
|
547
|
+
point = Point.from(point);
|
|
547
548
|
return new Point(this.x * point.x, this.y * point.y);
|
|
548
549
|
}
|
|
549
550
|
/**
|
|
550
551
|
* Inverse of `scaleBy`. Divide each coordinate of the current point by
|
|
551
552
|
* each coordinate of `scale`.
|
|
552
|
-
* @param {
|
|
553
|
+
* @param {PointExpression} point The scale.
|
|
553
554
|
* @returns {Point}
|
|
554
555
|
*/
|
|
555
556
|
unscaleBy(point) {
|
|
557
|
+
point = Point.from(point);
|
|
556
558
|
return new Point(this.x / point.x, this.y / point.y);
|
|
557
559
|
}
|
|
558
560
|
/**
|
|
@@ -646,6 +648,7 @@ var DomEvent_PointerEvents_exports = /* @__PURE__ */ __exportAll({
|
|
|
646
648
|
disablePointerDetection: () => disablePointerDetection,
|
|
647
649
|
enablePointerDetection: () => enablePointerDetection,
|
|
648
650
|
getPointers: () => getPointers,
|
|
651
|
+
isClickDisabled: () => isClickDisabled,
|
|
649
652
|
simulateDblclick: () => simulateDblclick
|
|
650
653
|
});
|
|
651
654
|
const activePointers = /* @__PURE__ */ new Map();
|
|
@@ -675,10 +678,26 @@ function disablePointerDetection(el) {
|
|
|
675
678
|
el.removeEventListener("pointerup", _onDelete, { capture: true });
|
|
676
679
|
el.removeEventListener("pointercancel", _onDelete, { capture: true });
|
|
677
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* Whether `el` is inside an element that `DomEvent.disableClickPropagation` was called
|
|
683
|
+
* on (before reaching `container`), or detached from the DOM.
|
|
684
|
+
* @internal
|
|
685
|
+
* @param {Node|null} el
|
|
686
|
+
* @param {EventTarget|null} container
|
|
687
|
+
* @returns {boolean}
|
|
688
|
+
*/
|
|
689
|
+
function isClickDisabled(el, container) {
|
|
690
|
+
while (el && el !== container) {
|
|
691
|
+
if (el["_maplair_disable_click"] || !el.parentNode) return true;
|
|
692
|
+
el = el.parentNode;
|
|
693
|
+
}
|
|
694
|
+
return false;
|
|
695
|
+
}
|
|
678
696
|
function _onSet(e) {
|
|
697
|
+
lastPointerType = e.pointerType;
|
|
698
|
+
if (isClickDisabled(e.target, e.currentTarget)) return;
|
|
679
699
|
if (e.isTrusted) e.target.setPointerCapture(e.pointerId);
|
|
680
700
|
activePointers.set(e.pointerId, e);
|
|
681
|
-
lastPointerType = e.pointerType;
|
|
682
701
|
}
|
|
683
702
|
function _onUpdate(e) {
|
|
684
703
|
if (activePointers.has(e.pointerId)) activePointers.set(e.pointerId, e);
|
|
@@ -1345,6 +1364,7 @@ var AttributionControl = class AttributionControl extends Control {
|
|
|
1345
1364
|
this._attributions = {};
|
|
1346
1365
|
this._orders = {};
|
|
1347
1366
|
this._layerAttributions = /* @__PURE__ */ new Map();
|
|
1367
|
+
this._shownLayers = /* @__PURE__ */ new Set();
|
|
1348
1368
|
this.callInitHooks(AttributionControl);
|
|
1349
1369
|
}
|
|
1350
1370
|
/**
|
|
@@ -1367,7 +1387,8 @@ var AttributionControl = class AttributionControl extends Control {
|
|
|
1367
1387
|
getEvents() {
|
|
1368
1388
|
return {
|
|
1369
1389
|
layeradd: this._addLayer,
|
|
1370
|
-
layerremove: this._removeLayer
|
|
1390
|
+
layerremove: this._removeLayer,
|
|
1391
|
+
zoomend: this._onZoomEnd
|
|
1371
1392
|
};
|
|
1372
1393
|
}
|
|
1373
1394
|
/**
|
|
@@ -1380,12 +1401,27 @@ var AttributionControl = class AttributionControl extends Control {
|
|
|
1380
1401
|
const text = layer.getAttribution?.();
|
|
1381
1402
|
if (!text || this._layerAttributions.has(layer)) return;
|
|
1382
1403
|
this._layerAttributions.set(layer, text);
|
|
1383
|
-
this.
|
|
1404
|
+
this._updateLayer(layer);
|
|
1384
1405
|
}
|
|
1385
1406
|
_removeLayer({ layer }) {
|
|
1386
|
-
this.removeAttribution(this._layerAttributions.get(layer));
|
|
1407
|
+
if (this._shownLayers.delete(layer)) this.removeAttribution(this._layerAttributions.get(layer));
|
|
1387
1408
|
this._layerAttributions.delete(layer);
|
|
1388
1409
|
}
|
|
1410
|
+
_onZoomEnd() {
|
|
1411
|
+
for (const layer of this._layerAttributions.keys()) this._updateLayer(layer);
|
|
1412
|
+
}
|
|
1413
|
+
_updateLayer(layer) {
|
|
1414
|
+
const { minZoom = -Infinity, maxZoom = Infinity } = layer.options ?? {}, zoom = this._map.getZoom(), show = zoom >= minZoom && zoom <= maxZoom;
|
|
1415
|
+
if (show === this._shownLayers.has(layer)) return;
|
|
1416
|
+
const text = this._layerAttributions.get(layer);
|
|
1417
|
+
if (show) {
|
|
1418
|
+
this._shownLayers.add(layer);
|
|
1419
|
+
this.addAttribution(text, layer.options?.attributionOrder);
|
|
1420
|
+
} else {
|
|
1421
|
+
this._shownLayers.delete(layer);
|
|
1422
|
+
this.removeAttribution(text);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1389
1425
|
/**
|
|
1390
1426
|
* The HTML text shown before the attributions. Pass `false` to disable.
|
|
1391
1427
|
* @param {string|false} prefix
|
|
@@ -2186,7 +2222,7 @@ const mapLayerMethods = {
|
|
|
2186
2222
|
this._layersMaxZoom = maxZoom === -Infinity ? void 0 : maxZoom;
|
|
2187
2223
|
this._layersMinZoom = minZoom === Infinity ? void 0 : minZoom;
|
|
2188
2224
|
if (oldZoomSpan !== this._getZoomSpan()) this.fire("zoomlevelschange");
|
|
2189
|
-
if (this.options.maxZoom === void 0 && this._layersMaxZoom && this.getZoom() > this._layersMaxZoom) this.setZoom(this._layersMaxZoom);
|
|
2225
|
+
if (this.options.maxZoom === void 0 && this._layersMaxZoom !== void 0 && this.getZoom() > this._layersMaxZoom) this.setZoom(this._layersMaxZoom);
|
|
2190
2226
|
if (this.options.minZoom === void 0 && this._layersMinZoom && this.getZoom() < this._layersMinZoom) this.setZoom(this._layersMinZoom);
|
|
2191
2227
|
}
|
|
2192
2228
|
};
|
|
@@ -2857,6 +2893,7 @@ var LayersControl = class LayersControl extends Control {
|
|
|
2857
2893
|
this._lastZIndex = 0;
|
|
2858
2894
|
this._handlingClick = false;
|
|
2859
2895
|
this._preventClick = false;
|
|
2896
|
+
this._needsUpdate = false;
|
|
2860
2897
|
for (const [name, layer] of Object.entries(baseLayers ?? {})) this._addLayer(layer, name);
|
|
2861
2898
|
for (const [name, layer] of Object.entries(overlays ?? {})) this._addLayer(layer, name, true);
|
|
2862
2899
|
this.callInitHooks(LayersControl);
|
|
@@ -2942,6 +2979,7 @@ var LayersControl = class LayersControl extends Control {
|
|
|
2942
2979
|
* @returns {this}
|
|
2943
2980
|
*/
|
|
2944
2981
|
selectLayer(layer) {
|
|
2982
|
+
if (this._needsUpdate) this._update(true);
|
|
2945
2983
|
const input = this._layerControlInputs.find((input) => input._layer === layer);
|
|
2946
2984
|
if (input && !input.checked) {
|
|
2947
2985
|
input.checked = true;
|
|
@@ -2956,6 +2994,7 @@ var LayersControl = class LayersControl extends Control {
|
|
|
2956
2994
|
expand() {
|
|
2957
2995
|
clearTimeout(this._collapseDelayTimeout);
|
|
2958
2996
|
this._container.classList.add("maplair-control-layers-expanded");
|
|
2997
|
+
if (this._needsUpdate) this._update();
|
|
2959
2998
|
this._section.style.height = "";
|
|
2960
2999
|
const acceptableHeight = this._map.getSize().y - (this._container.offsetTop + 50);
|
|
2961
3000
|
if (acceptableHeight < this._section.clientHeight) {
|
|
@@ -2971,6 +3010,7 @@ var LayersControl = class LayersControl extends Control {
|
|
|
2971
3010
|
*/
|
|
2972
3011
|
collapse() {
|
|
2973
3012
|
if (this.options.inline) return this;
|
|
3013
|
+
clearTimeout(this._collapseDelayTimeout);
|
|
2974
3014
|
if (this.options.collapseDelay > 0) this._collapseDelayTimeout = setTimeout(() => {
|
|
2975
3015
|
this._container.classList.remove("maplair-control-layers-expanded");
|
|
2976
3016
|
}, this.options.collapseDelay);
|
|
@@ -2987,6 +3027,23 @@ var LayersControl = class LayersControl extends Control {
|
|
|
2987
3027
|
disableScrollPropagation(container);
|
|
2988
3028
|
const section = this._section = create("fieldset", `${className}-list`);
|
|
2989
3029
|
section.setAttribute("aria-label", this._getTitle());
|
|
3030
|
+
section.tabIndex = -1;
|
|
3031
|
+
let link;
|
|
3032
|
+
if (!this.options.inline) {
|
|
3033
|
+
link = this._layersLink = create("button", `${className}-toggle`, container);
|
|
3034
|
+
link.type = "button";
|
|
3035
|
+
link.title = this._getTitle();
|
|
3036
|
+
link.setAttribute("aria-label", link.title);
|
|
3037
|
+
const { toggleContent } = this.options;
|
|
3038
|
+
if (typeof toggleContent === "string") link.innerHTML = toggleContent;
|
|
3039
|
+
else if (toggleContent) link.replaceChildren(toggleContent);
|
|
3040
|
+
on(link, "click", (e) => {
|
|
3041
|
+
e.preventDefault();
|
|
3042
|
+
const focused = document.activeElement === link;
|
|
3043
|
+
this._expandSafely();
|
|
3044
|
+
if (focused) section.focus();
|
|
3045
|
+
});
|
|
3046
|
+
}
|
|
2990
3047
|
if (collapsed) {
|
|
2991
3048
|
this._map.on("click", this.collapse, this);
|
|
2992
3049
|
on(container, {
|
|
@@ -2995,26 +3052,15 @@ var LayersControl = class LayersControl extends Control {
|
|
|
2995
3052
|
if (e.pointerType !== "touch") this.collapse();
|
|
2996
3053
|
}
|
|
2997
3054
|
}, this);
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
link.setAttribute("aria-label", link.title);
|
|
3004
|
-
const { toggleContent } = this.options;
|
|
3005
|
-
if (typeof toggleContent === "string") link.innerHTML = toggleContent;
|
|
3006
|
-
else if (toggleContent) link.replaceChildren(toggleContent);
|
|
3007
|
-
on(link, {
|
|
3008
|
-
keydown(e) {
|
|
3009
|
-
if (e.code === "Enter") this._expandSafely();
|
|
3010
|
-
},
|
|
3011
|
-
click(e) {
|
|
3055
|
+
on(section, "keydown", (e) => {
|
|
3056
|
+
if (e.key === "Escape") {
|
|
3057
|
+
clearTimeout(this._collapseDelayTimeout);
|
|
3058
|
+
container.classList.remove(`${className}-expanded`);
|
|
3059
|
+
link.focus();
|
|
3012
3060
|
e.preventDefault();
|
|
3013
|
-
this._expandSafely();
|
|
3014
3061
|
}
|
|
3015
|
-
}
|
|
3016
|
-
}
|
|
3017
|
-
if (!collapsed) this.expand();
|
|
3062
|
+
});
|
|
3063
|
+
} else this.expand();
|
|
3018
3064
|
this._baseLayersList = create("div", `${className}-base`, section);
|
|
3019
3065
|
this._separator = create("div", `${className}-separator`, section);
|
|
3020
3066
|
this._overlaysList = create("div", `${className}-overlays`, section);
|
|
@@ -3034,8 +3080,13 @@ var LayersControl = class LayersControl extends Control {
|
|
|
3034
3080
|
}
|
|
3035
3081
|
this._expandIfNotCollapsed();
|
|
3036
3082
|
}
|
|
3037
|
-
_update() {
|
|
3083
|
+
_update(force) {
|
|
3038
3084
|
if (!this._container) return this;
|
|
3085
|
+
if (!force && !this._container.classList.contains("maplair-control-layers-expanded")) {
|
|
3086
|
+
this._needsUpdate = true;
|
|
3087
|
+
return this;
|
|
3088
|
+
}
|
|
3089
|
+
this._needsUpdate = false;
|
|
3039
3090
|
this._baseLayersList.replaceChildren();
|
|
3040
3091
|
this._overlaysList.replaceChildren();
|
|
3041
3092
|
this._layerControlInputs = [];
|
|
@@ -3052,6 +3103,7 @@ var LayersControl = class LayersControl extends Control {
|
|
|
3052
3103
|
this._baseLayersList.style.display = baseLayersPresent ? "" : "none";
|
|
3053
3104
|
}
|
|
3054
3105
|
this._separator.style.display = overlaysPresent && baseLayersPresent ? "" : "none";
|
|
3106
|
+
this._checkDisabledLayers();
|
|
3055
3107
|
return this;
|
|
3056
3108
|
}
|
|
3057
3109
|
_onLayerChange(e) {
|
|
@@ -3081,7 +3133,6 @@ var LayersControl = class LayersControl extends Control {
|
|
|
3081
3133
|
holder.append(input, name);
|
|
3082
3134
|
const list = obj.overlay ? this._overlaysList : this._baseLayersList;
|
|
3083
3135
|
(group ? this._getGroupContainer(list, group.group) : list).append(label);
|
|
3084
|
-
this._checkDisabledLayers();
|
|
3085
3136
|
return label;
|
|
3086
3137
|
}
|
|
3087
3138
|
/**
|
|
@@ -3346,7 +3397,7 @@ var Bounds = class Bounds {
|
|
|
3346
3397
|
}
|
|
3347
3398
|
};
|
|
3348
3399
|
function isPointExpression(obj) {
|
|
3349
|
-
return obj instanceof Point || (Array.isArray(obj) ? typeof obj[0] !== "object" : "x" in obj);
|
|
3400
|
+
return obj instanceof Point || (Array.isArray(obj) ? obj.length > 0 && typeof obj[0] !== "object" : "x" in obj);
|
|
3350
3401
|
}
|
|
3351
3402
|
// src/layer/BlanketOverlay.js
|
|
3352
3403
|
/** @import {LayerOptions} from './Layer.js' */
|
|
@@ -3443,7 +3494,8 @@ var BlanketOverlay = class BlanketOverlay extends Layer {
|
|
|
3443
3494
|
this._updateTransform(this._map.getCenter(), this._map.getZoom());
|
|
3444
3495
|
}
|
|
3445
3496
|
_updateTransform(center, zoom) {
|
|
3446
|
-
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))
|
|
3497
|
+
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));
|
|
3498
|
+
if (scale === 1) this._map._snapLayerPoint(topLeftOffset);
|
|
3447
3499
|
setTransform(this._container, topLeftOffset, scale);
|
|
3448
3500
|
}
|
|
3449
3501
|
_onMoveEnd(ev) {
|
|
@@ -4116,7 +4168,7 @@ var LatLngBounds = class LatLngBounds {
|
|
|
4116
4168
|
}
|
|
4117
4169
|
};
|
|
4118
4170
|
function isLatLngExpression(obj) {
|
|
4119
|
-
return obj instanceof LatLng || (Array.isArray(obj) ? typeof obj[0] !== "object" : typeof obj === "object" && obj !== null && "lat" in obj);
|
|
4171
|
+
return obj instanceof LatLng || (Array.isArray(obj) ? obj.length > 0 && typeof obj[0] !== "object" : typeof obj === "object" && obj !== null && "lat" in obj);
|
|
4120
4172
|
}
|
|
4121
4173
|
// src/geo/LatLng.js
|
|
4122
4174
|
const coordinate = String.raw`([+-]?\d+(?:\.\d+)?)\s*°?`;
|
|
@@ -4324,7 +4376,7 @@ var LatLng = class LatLng {
|
|
|
4324
4376
|
* @returns {number}
|
|
4325
4377
|
*/
|
|
4326
4378
|
function haversineDistance(latlng1, latlng2, R) {
|
|
4327
|
-
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;
|
|
4379
|
+
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);
|
|
4328
4380
|
return R * (2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)));
|
|
4329
4381
|
}
|
|
4330
4382
|
// src/geometry/LineUtil.js
|
|
@@ -4660,7 +4712,7 @@ var CircleMarker = class CircleMarker extends Path {
|
|
|
4660
4712
|
super();
|
|
4661
4713
|
setOptions(this, options);
|
|
4662
4714
|
this._latlng = new LatLng(latlng);
|
|
4663
|
-
this.
|
|
4715
|
+
this.setRadius(this.options.radius);
|
|
4664
4716
|
this.callInitHooks(CircleMarker);
|
|
4665
4717
|
}
|
|
4666
4718
|
/**
|
|
@@ -4697,7 +4749,10 @@ var CircleMarker = class CircleMarker extends Path {
|
|
|
4697
4749
|
* @returns {this}
|
|
4698
4750
|
*/
|
|
4699
4751
|
setRadius(radius) {
|
|
4700
|
-
|
|
4752
|
+
const r = toNumber(radius);
|
|
4753
|
+
if (isNaN(r)) throw new Error(`Invalid radius: ${radius}`);
|
|
4754
|
+
/** @type {number} */
|
|
4755
|
+
this._radius = this.options.radius = r;
|
|
4701
4756
|
return this.redraw();
|
|
4702
4757
|
}
|
|
4703
4758
|
/**
|
|
@@ -5438,6 +5493,7 @@ var ZoomControl = class ZoomControl extends Control {
|
|
|
5438
5493
|
}
|
|
5439
5494
|
_updateDisabled() {
|
|
5440
5495
|
const map = this._map;
|
|
5496
|
+
if (!map) return;
|
|
5441
5497
|
for (const [button, limit] of [[this._zoomInButton, map.getMaxZoom()], [this._zoomOutButton, map.getMinZoom()]]) {
|
|
5442
5498
|
const disabled = this._disabled || map._zoom === limit;
|
|
5443
5499
|
button.classList.toggle("maplair-disabled", disabled);
|
|
@@ -5968,8 +6024,8 @@ var DivOverlay = class DivOverlay extends Layer {
|
|
|
5968
6024
|
}
|
|
5969
6025
|
/**
|
|
5970
6026
|
* Sets the HTML content of the overlay. A `String` argument is rendered as
|
|
5971
|
-
* HTML; if it may contain untrusted input, sanitize it
|
|
5972
|
-
*
|
|
6027
|
+
* HTML; if it may contain untrusted input, sanitize it or pass an `HTMLElement`
|
|
6028
|
+
* with safe `textContent` instead. A `DocumentFragment`
|
|
5973
6029
|
* can be passed as well. If a function is passed the source layer will be passed
|
|
5974
6030
|
* to the function. The function should return a `String`, `HTMLElement` or
|
|
5975
6031
|
* `DocumentFragment` to be used in the overlay.
|
|
@@ -6083,7 +6139,7 @@ var DivOverlay = class DivOverlay extends Layer {
|
|
|
6083
6139
|
}
|
|
6084
6140
|
_updatePosition() {
|
|
6085
6141
|
if (!this._map) return;
|
|
6086
|
-
const pos = this._map.latLngToLayerPoint(this._latlng)
|
|
6142
|
+
const pos = this._map._snapLayerPoint(this._map.latLngToLayerPoint(this._latlng)), offset = Point.from(this.options.offset);
|
|
6087
6143
|
this._setContainerPosition(pos.add(this._getAnchor()));
|
|
6088
6144
|
const bottom = this._containerBottom = -offset.y, left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x;
|
|
6089
6145
|
if (this.options.overflow) {
|
|
@@ -6226,8 +6282,8 @@ const layerPopupMethods = {
|
|
|
6226
6282
|
/**
|
|
6227
6283
|
* Binds a popup to the layer with the passed `content` and sets up the
|
|
6228
6284
|
* necessary event listeners. A `String` argument is rendered as HTML; if it
|
|
6229
|
-
* may contain untrusted input, sanitize it
|
|
6230
|
-
* `
|
|
6285
|
+
* may contain untrusted input, sanitize it or pass an `HTMLElement` with safe
|
|
6286
|
+
* `textContent` instead. If a `Function` is passed
|
|
6231
6287
|
* it will receive the layer as the first argument and should return a
|
|
6232
6288
|
* `String`, `HTMLElement` or `DocumentFragment`.
|
|
6233
6289
|
* @group Popup methods
|
|
@@ -6369,8 +6425,7 @@ const layerPopupMethods = {
|
|
|
6369
6425
|
*
|
|
6370
6426
|
* **Security note.** Popup string content is rendered as HTML. If your content
|
|
6371
6427
|
* may include untrusted input (e.g. data from users or external APIs), sanitize
|
|
6372
|
-
* it
|
|
6373
|
-
* build a DOM element using `textContent` to render it as plain text:
|
|
6428
|
+
* it first, or build a DOM element using `textContent` to render it as plain text:
|
|
6374
6429
|
*
|
|
6375
6430
|
* ```js
|
|
6376
6431
|
* const el = document.createElement('div');
|
|
@@ -6594,7 +6649,8 @@ function clampTip(tipShift, size) {
|
|
|
6594
6649
|
* Options of `Tooltip`.
|
|
6595
6650
|
* @typedef {object} TooltipOptions
|
|
6596
6651
|
* @property {string} [pane='tooltipPane'] `Map pane` where the tooltip will be added.
|
|
6597
|
-
* @property {PointExpression} [offset=[0, 0]] Optional offset of the tooltip position
|
|
6652
|
+
* @property {PointExpression} [offset=[0, 0]] Optional offset of the tooltip position, in
|
|
6653
|
+
* pixels. Mirrored horizontally when an `auto` tooltip opens to the left.
|
|
6598
6654
|
* @property {'right'|'left'|'top'|'bottom'|'center'|'auto'} [direction='auto']
|
|
6599
6655
|
* Direction where to open the tooltip. Possible values are: `right`, `left`, `top`,
|
|
6600
6656
|
* `bottom`, `center`, `auto`. `auto` chooses the direction with enough space when
|
|
@@ -6665,8 +6721,8 @@ const layerTooltipMethods = {
|
|
|
6665
6721
|
/**
|
|
6666
6722
|
* Binds a tooltip to the layer with the passed `content` and sets up the
|
|
6667
6723
|
* necessary event listeners. A `String` argument is rendered as HTML; if it
|
|
6668
|
-
* may contain untrusted input, sanitize it
|
|
6669
|
-
* `
|
|
6724
|
+
* may contain untrusted input, sanitize it or pass an `HTMLElement` with safe
|
|
6725
|
+
* `textContent` instead. If a `Function` is passed
|
|
6670
6726
|
* it will receive the layer as the first argument and should return a
|
|
6671
6727
|
* `String`, `HTMLElement` or `DocumentFragment`.
|
|
6672
6728
|
* @group Tooltip methods
|
|
@@ -6840,8 +6896,7 @@ const layerTooltipMethods = {
|
|
|
6840
6896
|
*
|
|
6841
6897
|
* **Security note.** Tooltip string content is rendered as HTML. If your content
|
|
6842
6898
|
* may include untrusted input (e.g. data from users or external APIs), sanitize
|
|
6843
|
-
* it
|
|
6844
|
-
* build a DOM element using `textContent` to render it as plain text:
|
|
6899
|
+
* it first, or build a DOM element using `textContent` to render it as plain text:
|
|
6845
6900
|
*
|
|
6846
6901
|
* ```js
|
|
6847
6902
|
* const el = document.createElement('div');
|
|
@@ -6898,7 +6953,8 @@ var Tooltip = class Tooltip extends DivOverlay {
|
|
|
6898
6953
|
map.fire("tooltipopen", { tooltip: this });
|
|
6899
6954
|
if (this._source) {
|
|
6900
6955
|
this.addEventParent(this._source);
|
|
6901
|
-
this._source.getElement?.()
|
|
6956
|
+
this._ariaSource = this._source.getElement?.();
|
|
6957
|
+
this._ariaSource?.setAttribute("aria-describedby", this._container.id);
|
|
6902
6958
|
this._source.fire("tooltipopen", { tooltip: this }, true);
|
|
6903
6959
|
}
|
|
6904
6960
|
}
|
|
@@ -6911,6 +6967,9 @@ var Tooltip = class Tooltip extends DivOverlay {
|
|
|
6911
6967
|
map.fire("tooltipclose", { tooltip: this });
|
|
6912
6968
|
if (this._source) {
|
|
6913
6969
|
this.removeEventParent(this._source);
|
|
6970
|
+
const el = this._ariaSource;
|
|
6971
|
+
if (el?.getAttribute("aria-describedby") === this._container.id) el.removeAttribute("aria-describedby");
|
|
6972
|
+
this._ariaSource = null;
|
|
6914
6973
|
this._source.fire("tooltipclose", { tooltip: this }, true);
|
|
6915
6974
|
}
|
|
6916
6975
|
}
|
|
@@ -6941,14 +7000,12 @@ var Tooltip = class Tooltip extends DivOverlay {
|
|
|
6941
7000
|
}
|
|
6942
7001
|
_setPosition(pos) {
|
|
6943
7002
|
let direction = this.options.direction, shift = new Point(0, 0);
|
|
6944
|
-
const container = this._container, tooltipWidth = container.offsetWidth, tooltipHeight = container.offsetHeight, offset = new Point(this.options.offset)
|
|
7003
|
+
const container = this._container, tooltipWidth = container.offsetWidth, tooltipHeight = container.offsetHeight, offset = new Point(this.options.offset);
|
|
6945
7004
|
if (!(direction in directions)) {
|
|
6946
|
-
({direction, shift} = this._getAutoPlacement(pos, offset,
|
|
6947
|
-
if (direction === "left")
|
|
6948
|
-
offset.x = -offset.x;
|
|
6949
|
-
anchor.x = -anchor.x;
|
|
6950
|
-
}
|
|
7005
|
+
({direction, shift} = this._getAutoPlacement(pos, offset, tooltipWidth, tooltipHeight));
|
|
7006
|
+
if (direction === "left") offset.x = -offset.x;
|
|
6951
7007
|
}
|
|
7008
|
+
const anchor = this._getAnchor(direction);
|
|
6952
7009
|
const [fx, fy] = directions[direction];
|
|
6953
7010
|
pos = pos.subtract(new Point(tooltipWidth * fx, tooltipHeight * fy, true)).add(offset).add(anchor).add(shift);
|
|
6954
7011
|
for (const d in directions) container.classList.toggle(`maplair-tooltip-${d}`, d === direction);
|
|
@@ -6957,12 +7014,19 @@ var Tooltip = class Tooltip extends DivOverlay {
|
|
|
6957
7014
|
else container.style.removeProperty("--maplair-tooltip-tip-shift");
|
|
6958
7015
|
this._setContainerPosition(pos);
|
|
6959
7016
|
}
|
|
6960
|
-
_getAutoPlacement(pos, offset,
|
|
6961
|
-
const area = this._getAutoArea(), point = this._map.layerPointToContainerPoint(pos),
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
|
|
6965
|
-
|
|
7017
|
+
_getAutoPlacement(pos, offset, width, height) {
|
|
7018
|
+
const area = this._getAutoArea(), point = this._map.layerPointToContainerPoint(pos), at = {};
|
|
7019
|
+
for (const d of [
|
|
7020
|
+
"right",
|
|
7021
|
+
"left",
|
|
7022
|
+
"top",
|
|
7023
|
+
"bottom"
|
|
7024
|
+
]) at[d] = point.add(this._getAnchor(d)).add(d === "left" ? [-offset.x, offset.y] : offset);
|
|
7025
|
+
const space = {
|
|
7026
|
+
right: area.max.x - at.right.x - width - tipSize,
|
|
7027
|
+
left: at.left.x - area.min.x - width - tipSize,
|
|
7028
|
+
top: at.top.y - area.min.y - height - tipSize,
|
|
7029
|
+
bottom: area.max.y - at.bottom.y - height - tipSize
|
|
6966
7030
|
};
|
|
6967
7031
|
if (!this._autoDirection) {
|
|
6968
7032
|
const sides = point.x < (area.min.x + area.max.x) / 2 ? ["right", "left"] : ["left", "right"], fallback = space.right >= space.left ? "right" : "left";
|
|
@@ -6972,7 +7036,7 @@ var Tooltip = class Tooltip extends DivOverlay {
|
|
|
6972
7036
|
"bottom"
|
|
6973
7037
|
].find((d) => space[d] >= 0 && (d === "right" || d === "left" || width <= area.max.x - area.min.x)) ?? fallback;
|
|
6974
7038
|
}
|
|
6975
|
-
const direction = this._autoDirection;
|
|
7039
|
+
const direction = this._autoDirection, { x, y } = at[direction];
|
|
6976
7040
|
return {
|
|
6977
7041
|
direction,
|
|
6978
7042
|
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))
|
|
@@ -6993,7 +7057,7 @@ var Tooltip = class Tooltip extends DivOverlay {
|
|
|
6993
7057
|
};
|
|
6994
7058
|
}
|
|
6995
7059
|
_updatePosition() {
|
|
6996
|
-
const pos = this._map.latLngToLayerPoint(this._latlng)
|
|
7060
|
+
const pos = this._map._snapLayerPoint(this._map.latLngToLayerPoint(this._latlng));
|
|
6997
7061
|
this._setPosition(pos);
|
|
6998
7062
|
}
|
|
6999
7063
|
/**
|
|
@@ -7009,8 +7073,8 @@ var Tooltip = class Tooltip extends DivOverlay {
|
|
|
7009
7073
|
const pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center);
|
|
7010
7074
|
this._setPosition(pos);
|
|
7011
7075
|
}
|
|
7012
|
-
_getAnchor() {
|
|
7013
|
-
return new Point(this._source?._getTooltipAnchor && !this.options.sticky ? this._source._getTooltipAnchor() : [0, 0]);
|
|
7076
|
+
_getAnchor(direction) {
|
|
7077
|
+
return new Point(this._source?._getTooltipAnchor && !this.options.sticky ? this._source._getTooltipAnchor(direction) : [0, 0]);
|
|
7014
7078
|
}
|
|
7015
7079
|
/**
|
|
7016
7080
|
* Registers this default feature on the map class, called by `MaplairMap` itself.
|
|
@@ -7205,6 +7269,8 @@ var BoxZoomHandler = class BoxZoomHandler extends Handler {
|
|
|
7205
7269
|
removeHooks() {
|
|
7206
7270
|
off(this._map._container, "pointerdown", this._onPointerDown, this);
|
|
7207
7271
|
this._map._container.classList.remove("maplair-box-zoom");
|
|
7272
|
+
this._finish();
|
|
7273
|
+
this._resetState();
|
|
7208
7274
|
}
|
|
7209
7275
|
/**
|
|
7210
7276
|
* Returns `true` if a box has been drawn by the current or last interaction.
|
|
@@ -7355,9 +7421,13 @@ var DoubleClickZoomHandler = class DoubleClickZoomHandler extends Handler {
|
|
|
7355
7421
|
* pointer drag).
|
|
7356
7422
|
*/
|
|
7357
7423
|
/**
|
|
7358
|
-
* The event object of `dragstart`, `predrag` and `drag` of `Draggable
|
|
7424
|
+
* The event object of `dragstart`, `predrag` and `drag` of `Draggable`, and of
|
|
7425
|
+
* `movestart` and `dragstart` of draggable markers.
|
|
7359
7426
|
* @typedef {object} DraggableEvent
|
|
7360
|
-
* @property {PointerEvent} originalEvent The DOM event of the pointer which
|
|
7427
|
+
* @property {PointerEvent|KeyboardEvent} originalEvent The DOM event of the pointer which
|
|
7428
|
+
* drags: for `dragstart`, the `pointermove` that moved the pointer past `clickTolerance`
|
|
7429
|
+
* (not the `pointerdown`), or the `keydown` of an arrow key that moves a focused
|
|
7430
|
+
* draggable marker.
|
|
7361
7431
|
* @extends MaplairEvent
|
|
7362
7432
|
*/
|
|
7363
7433
|
/**
|
|
@@ -7594,8 +7664,13 @@ var DragHandler = class DragHandler extends Handler {
|
|
|
7594
7664
|
map._stop();
|
|
7595
7665
|
map._setUserEvent(e.originalEvent);
|
|
7596
7666
|
if (this._map.options.maxBounds && this._map.options.maxBoundsViscosity) {
|
|
7597
|
-
const bounds = LatLngBounds.from(this._map.options.maxBounds)
|
|
7598
|
-
|
|
7667
|
+
const bounds = LatLngBounds.from(this._map.options.maxBounds), { min, max } = new Bounds([
|
|
7668
|
+
bounds.getNorthWest(),
|
|
7669
|
+
bounds.getNorthEast(),
|
|
7670
|
+
bounds.getSouthEast(),
|
|
7671
|
+
bounds.getSouthWest()
|
|
7672
|
+
].map((c) => this._map.latLngToContainerPoint(c)));
|
|
7673
|
+
this._offsetLimit = new Bounds(max.multiplyBy(-1), min.multiplyBy(-1).add(this._map.getSize()));
|
|
7599
7674
|
this._viscosity = Math.min(1, Math.max(0, this._map.options.maxBoundsViscosity));
|
|
7600
7675
|
} else this._offsetLimit = null;
|
|
7601
7676
|
map.fire("movestart").fire("dragstart");
|
|
@@ -7962,7 +8037,7 @@ var PinchZoomHandler = class PinchZoomHandler extends Handler {
|
|
|
7962
8037
|
}
|
|
7963
8038
|
this._zooming = false;
|
|
7964
8039
|
cancelAnimationFrame(this._animRequest);
|
|
7965
|
-
if (this._map._zoomAnimated) this._map._animateZoom(this._center, this._map._limitZoom(this._zoom),
|
|
8040
|
+
if (this._map._zoomAnimated) this._map._animateZoom(this._center, this._map._limitZoom(this._zoom), this._map.options.zoomSnap);
|
|
7966
8041
|
else this._map._resetView(this._center, this._map._limitZoom(this._zoom));
|
|
7967
8042
|
}
|
|
7968
8043
|
/**
|
|
@@ -8115,7 +8190,7 @@ var ScrollWheelZoomHandler = class ScrollWheelZoomHandler extends Handler {
|
|
|
8115
8190
|
cancelAnimationFrame(this._pinchFrame);
|
|
8116
8191
|
const map = this._map, zoom = map._limitZoom(this._pinch.zoom), center = this._getPinchCenter(zoom);
|
|
8117
8192
|
this._pinch = null;
|
|
8118
|
-
if (map.options.zoomAnimation && Math.abs(zoom - map.getZoom()) > 1e-9) map._animateZoom(center, zoom,
|
|
8193
|
+
if (map.options.zoomAnimation && Math.abs(zoom - map.getZoom()) > 1e-9) map._animateZoom(center, zoom, map.options.zoomSnap);
|
|
8119
8194
|
else map._move(center, zoom)._moveEnd(true);
|
|
8120
8195
|
}
|
|
8121
8196
|
_panBy(e) {
|
|
@@ -8411,7 +8486,7 @@ var TapDragZoomHandler = class TapDragZoomHandler extends Handler {
|
|
|
8411
8486
|
this._moved = false;
|
|
8412
8487
|
cancelAnimationFrame(this._animRequest);
|
|
8413
8488
|
const map = this._map, zoom = map._limitZoom(this._zoom);
|
|
8414
|
-
if (map.options.zoomAnimation) map._animateZoom(this._center, zoom,
|
|
8489
|
+
if (map.options.zoomAnimation) map._animateZoom(this._center, zoom, map.options.zoomSnap);
|
|
8415
8490
|
else map._move(this._center, zoom)._moveEnd(true);
|
|
8416
8491
|
}
|
|
8417
8492
|
/**
|
|
@@ -8939,6 +9014,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
8939
9014
|
center: requestedCenter,
|
|
8940
9015
|
zoom: targetZoom
|
|
8941
9016
|
};
|
|
9017
|
+
this._subpixelOrigin = true;
|
|
8942
9018
|
const from = this.project(this.getCenter()), to = this.project(targetCenter), size = this.getSize(), startZoom = this._zoom;
|
|
8943
9019
|
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;
|
|
8944
9020
|
function r(i) {
|
|
@@ -8960,6 +9036,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
8960
9036
|
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 });
|
|
8961
9037
|
} else {
|
|
8962
9038
|
const zoomChanged = this._zoom !== targetZoom;
|
|
9039
|
+
this._subpixelOrigin = false;
|
|
8963
9040
|
this._move(targetCenter, targetZoom);
|
|
8964
9041
|
if (!zoomChanged) this.fire("zoom");
|
|
8965
9042
|
this._moveEnd(true);
|
|
@@ -9044,7 +9121,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9044
9121
|
this.options.minZoom = zoom;
|
|
9045
9122
|
if (this._loaded && oldZoom !== zoom) {
|
|
9046
9123
|
this.fire("zoomlevelschange");
|
|
9047
|
-
if (this.
|
|
9124
|
+
if (this._targetZoom() < this.options.minZoom) return this.setZoom(zoom);
|
|
9048
9125
|
}
|
|
9049
9126
|
return this;
|
|
9050
9127
|
}
|
|
@@ -9059,7 +9136,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9059
9136
|
this.options.maxZoom = zoom;
|
|
9060
9137
|
if (this._loaded && oldZoom !== zoom) {
|
|
9061
9138
|
this.fire("zoomlevelschange");
|
|
9062
|
-
if (this.
|
|
9139
|
+
if (this._targetZoom() > this.options.maxZoom) return this.setZoom(zoom);
|
|
9063
9140
|
}
|
|
9064
9141
|
return this;
|
|
9065
9142
|
}
|
|
@@ -9339,7 +9416,12 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9339
9416
|
bounds = LatLngBounds.from(bounds);
|
|
9340
9417
|
padding = Point.from(padding ?? [0, 0]);
|
|
9341
9418
|
let zoom = this.getZoom() ?? 0;
|
|
9342
|
-
const min = this.getMinZoom(), max = this.getMaxZoom(),
|
|
9419
|
+
const min = this.getMinZoom(), max = this.getMaxZoom(), size = this.getSize().subtract(padding), boundsSize = new Bounds([
|
|
9420
|
+
bounds.getNorthWest(),
|
|
9421
|
+
bounds.getNorthEast(),
|
|
9422
|
+
bounds.getSouthEast(),
|
|
9423
|
+
bounds.getSouthWest()
|
|
9424
|
+
].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);
|
|
9343
9425
|
zoom = this.getScaleZoom(scale, zoom);
|
|
9344
9426
|
if (snap) {
|
|
9345
9427
|
zoom = Math.round(zoom / (snap / 100)) * (snap / 100);
|
|
@@ -9578,7 +9660,18 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9578
9660
|
* @returns {Point}
|
|
9579
9661
|
*/
|
|
9580
9662
|
pointerEventToContainerPoint(e) {
|
|
9581
|
-
return getPointerPosition(e, this._container);
|
|
9663
|
+
if (!this._animatingZoom) return getPointerPosition(e, this._container);
|
|
9664
|
+
if (!this._containerRect) {
|
|
9665
|
+
const el = this._container, { x, y, boundingClientRect: r } = getScale(el);
|
|
9666
|
+
this._containerRect = {
|
|
9667
|
+
x,
|
|
9668
|
+
y,
|
|
9669
|
+
left: r.left + el.clientLeft * x,
|
|
9670
|
+
top: r.top + el.clientTop * y
|
|
9671
|
+
};
|
|
9672
|
+
}
|
|
9673
|
+
const c = this._containerRect;
|
|
9674
|
+
return new Point((e.clientX - c.left) / c.x, (e.clientY - c.top) / c.y);
|
|
9582
9675
|
}
|
|
9583
9676
|
/**
|
|
9584
9677
|
* Given a PointerEvent object, returns the pixel coordinate relative to
|
|
@@ -9743,7 +9836,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9743
9836
|
this._lastCenterPanePos = this._getMapPanePos();
|
|
9744
9837
|
this._pixelOrigin = this._getNewPixelOrigin(center);
|
|
9745
9838
|
if (!suppressEvent) {
|
|
9746
|
-
if (zoomChanged || data?.pinch) this.fire("zoom", data);
|
|
9839
|
+
if (zoomChanged || data?.pinch || data?.flyTo) this.fire("zoom", data);
|
|
9747
9840
|
this.fire("move", data);
|
|
9748
9841
|
} else if (data?.pinch) this.fire("zoom", data);
|
|
9749
9842
|
return this;
|
|
@@ -9758,6 +9851,10 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9758
9851
|
this._targetView = null;
|
|
9759
9852
|
cancelAnimationFrame(this._flyToFrame);
|
|
9760
9853
|
cancelAnimationFrame(this._zoomAnimFrame);
|
|
9854
|
+
if (this._subpixelOrigin) {
|
|
9855
|
+
this._subpixelOrigin = false;
|
|
9856
|
+
this._move(this._lastCenter, this._zoom, { flyTo: true });
|
|
9857
|
+
}
|
|
9761
9858
|
this._panAnim?.stop();
|
|
9762
9859
|
return this;
|
|
9763
9860
|
}
|
|
@@ -9830,17 +9927,17 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9830
9927
|
if (!targets.length && !dragging && !isHover && this.listens(type, true)) targets = [this];
|
|
9831
9928
|
return targets;
|
|
9832
9929
|
}
|
|
9833
|
-
_isClickDisabled(el) {
|
|
9834
|
-
while (el && el !== this._container) {
|
|
9835
|
-
if (el["_maplair_disable_click"] || !el.parentNode) return true;
|
|
9836
|
-
el = el.parentNode;
|
|
9837
|
-
}
|
|
9838
|
-
}
|
|
9839
9930
|
_handleDOMEvent(e) {
|
|
9840
9931
|
const el = e.target;
|
|
9841
9932
|
if (e.type === "click") simulateDblclick(e, this._container);
|
|
9842
|
-
if (!this._loaded || e.type === "click" && this.
|
|
9843
|
-
const type = e.type, move = type === "pointermove", hovered = this._hoveredCanvasLayer, skip = type === "pointerover" || type === "pointerout" || type.startsWith("key") || this._animatingZoom || move && this.dragging?.moving(),
|
|
9933
|
+
if (!this._loaded || e.type === "click" && isClickDisabled(el, this._container)) return;
|
|
9934
|
+
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);
|
|
9935
|
+
let layer = skip ? void 0 : this._canvasLayerAt(e, type === "click");
|
|
9936
|
+
if (type === "pointerdown") this._pressedCanvasLayer = skip ? void 0 : layer ?? null;
|
|
9937
|
+
else if (type === "click" && e.detail > 0 && this._pressedCanvasLayer !== void 0) {
|
|
9938
|
+
if (layer !== this._pressedCanvasLayer) layer = void 0;
|
|
9939
|
+
this._pressedCanvasLayer = void 0;
|
|
9940
|
+
}
|
|
9844
9941
|
if (layer !== hovered && (move && !skip || leftMap)) {
|
|
9845
9942
|
if (hovered) this._fireDOMEvent(e, "pointerout", [hovered]);
|
|
9846
9943
|
this._container.classList.toggle("maplair-interactive", !!layer);
|
|
@@ -9909,7 +10006,11 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9909
10006
|
}
|
|
9910
10007
|
_getNewPixelOrigin(center, zoom) {
|
|
9911
10008
|
const viewHalf = this.getSize()._divideBy(2);
|
|
9912
|
-
|
|
10009
|
+
const origin = this.project(center, zoom)._subtract(viewHalf)._add(this._getMapPanePos());
|
|
10010
|
+
return this._subpixelOrigin ? origin : origin._round();
|
|
10011
|
+
}
|
|
10012
|
+
_snapLayerPoint(point) {
|
|
10013
|
+
return this._subpixelOrigin ? point : point._round();
|
|
9913
10014
|
}
|
|
9914
10015
|
_latLngToNewLayerPoint(latlng, zoom, center) {
|
|
9915
10016
|
const topLeft = this._getNewPixelOrigin(center, zoom);
|
|
@@ -9936,7 +10037,12 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9936
10037
|
return offset.add(this._getBoundsOffset(newBounds, bounds));
|
|
9937
10038
|
}
|
|
9938
10039
|
_getBoundsOffset(pxBounds, maxBounds, zoom) {
|
|
9939
|
-
const projectedMaxBounds = new Bounds(
|
|
10040
|
+
const projectedMaxBounds = new Bounds([
|
|
10041
|
+
maxBounds.getNorthWest(),
|
|
10042
|
+
maxBounds.getNorthEast(),
|
|
10043
|
+
maxBounds.getSouthEast(),
|
|
10044
|
+
maxBounds.getSouthWest()
|
|
10045
|
+
].map((c) => this.project(c, zoom))), minOffset = projectedMaxBounds.min.subtract(pxBounds.min), maxOffset = projectedMaxBounds.max.subtract(pxBounds.max);
|
|
9940
10046
|
return new Point(this._rebound(minOffset.x, -maxOffset.x), this._rebound(minOffset.y, -maxOffset.y));
|
|
9941
10047
|
}
|
|
9942
10048
|
_rebound(left, right) {
|
|
@@ -10018,18 +10124,16 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
10018
10124
|
this._zoomAnimFrame = requestAnimationFrame(() => {
|
|
10019
10125
|
this._zoomAnimFrame = null;
|
|
10020
10126
|
if (userEvent) this._setUserEvent(userEvent);
|
|
10021
|
-
this._moveStart(true, options.noMoveStart ?? false)._animateZoom(center, zoom
|
|
10127
|
+
this._moveStart(true, options.noMoveStart ?? false)._animateZoom(center, zoom);
|
|
10022
10128
|
});
|
|
10023
10129
|
return true;
|
|
10024
10130
|
}
|
|
10025
|
-
_animateZoom(center, zoom,
|
|
10131
|
+
_animateZoom(center, zoom, noUpdate) {
|
|
10026
10132
|
if (!this._mapPane) return;
|
|
10027
|
-
|
|
10028
|
-
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
this._mapPane.classList.add("maplair-zoom-anim");
|
|
10032
|
-
}
|
|
10133
|
+
this._animatingZoom = true;
|
|
10134
|
+
this._animateToCenter = center;
|
|
10135
|
+
this._animateToZoom = zoom;
|
|
10136
|
+
this._mapPane.classList.add("maplair-zoom-anim");
|
|
10033
10137
|
this.fire("zoomanim", {
|
|
10034
10138
|
center,
|
|
10035
10139
|
zoom,
|
|
@@ -10037,10 +10141,13 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
10037
10141
|
});
|
|
10038
10142
|
if (!this._tempFireZoomEvent) this._tempFireZoomEvent = this._zoom !== this._animateToZoom;
|
|
10039
10143
|
this._move(this._animateToCenter, this._animateToZoom, void 0, true);
|
|
10040
|
-
this._transitionEndTimer
|
|
10144
|
+
clearTimeout(this._transitionEndTimer);
|
|
10145
|
+
this._transitionEndTimer = setTimeout(this._onZoomTransitionEnd.bind(this), 1e3);
|
|
10041
10146
|
}
|
|
10042
10147
|
_onZoomTransitionEnd() {
|
|
10043
10148
|
if (!this._animatingZoom) return;
|
|
10149
|
+
clearTimeout(this._transitionEndTimer);
|
|
10150
|
+
this._containerRect = null;
|
|
10044
10151
|
this._mapPane?.classList.remove("maplair-zoom-anim");
|
|
10045
10152
|
this._animatingZoom = false;
|
|
10046
10153
|
this._move(this.getCenter(), this._animateToZoom, void 0, true);
|
|
@@ -10319,7 +10426,6 @@ var PolyUtil_exports = /* @__PURE__ */ __exportAll({
|
|
|
10319
10426
|
polygonCenter: () => polygonCenter
|
|
10320
10427
|
});
|
|
10321
10428
|
/** @import {LatLngExpression} from '../geo/LatLng.js' */
|
|
10322
|
-
/** @import {Bounds} from './Bounds.js' */
|
|
10323
10429
|
/** @import {CRS} from '../geo/crs/CRS.js' */
|
|
10324
10430
|
/**
|
|
10325
10431
|
* Clips the polygon geometry defined by the given `points` by the given bounds (using
|
|
@@ -10374,7 +10480,14 @@ function polygonCenter(latlngs, crs) {
|
|
|
10374
10480
|
y += (p1.y + p2.y) * f;
|
|
10375
10481
|
area += f;
|
|
10376
10482
|
}
|
|
10377
|
-
|
|
10483
|
+
if (area !== 0) return crs.unproject(new Point(x / (3 * area), y / (3 * area))._add(origin));
|
|
10484
|
+
const mid = new Bounds(points).getCenter();
|
|
10485
|
+
let center = points[0];
|
|
10486
|
+
for (let i = 0, j = len - 1; i < len; j = i++) {
|
|
10487
|
+
const p = _sqClosestPointOnSegment(mid, points[j], points[i]);
|
|
10488
|
+
if (p.distanceTo(mid) < center.distanceTo(mid)) center = p;
|
|
10489
|
+
}
|
|
10490
|
+
return crs.unproject(center._add(origin));
|
|
10378
10491
|
}
|
|
10379
10492
|
/**
|
|
10380
10493
|
* Returns the 'center of mass' of the passed LatLngs.
|
|
@@ -10800,10 +10913,10 @@ var ScaleControl = class ScaleControl extends Control {
|
|
|
10800
10913
|
scale.textContent = text;
|
|
10801
10914
|
}
|
|
10802
10915
|
_getRoundNum(num) {
|
|
10803
|
-
const
|
|
10804
|
-
let d = num /
|
|
10916
|
+
const exponent = num < 1 ? Math.floor(Math.log10(num)) : `${Math.floor(num)}`.length - 1;
|
|
10917
|
+
let d = num / 10 ** exponent;
|
|
10805
10918
|
d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
|
|
10806
|
-
return
|
|
10919
|
+
return exponent < 0 ? d / 10 ** -exponent : d * 10 ** exponent;
|
|
10807
10920
|
}
|
|
10808
10921
|
};
|
|
10809
10922
|
// src/layer/marker/Icon.js
|
|
@@ -10823,8 +10936,11 @@ var ScaleControl = class ScaleControl extends Control {
|
|
|
10823
10936
|
* can be set in CSS with negative margins.
|
|
10824
10937
|
* @property {PointExpression} [popupAnchor=[0, 0]] The coordinates of the point from
|
|
10825
10938
|
* which popups will "open", relative to the icon anchor.
|
|
10826
|
-
* @property {PointExpression} [tooltipAnchor=[0, 0]]
|
|
10827
|
-
*
|
|
10939
|
+
* @property {PointExpression} [tooltipAnchor=[0, 0]] Where tooltips opening to the side
|
|
10940
|
+
* attach, relative to the icon anchor: `x` is how far to the right (mirrored for tooltips
|
|
10941
|
+
* opening to the left) and `y` how far down. Tooltips opening to the top or bottom attach
|
|
10942
|
+
* to the middle of the icon's top or bottom edge, and `center` ones to the middle of the
|
|
10943
|
+
* icon at the `y` height.
|
|
10828
10944
|
* @property {string} [shadowUrl] The URL to the icon shadow image. If not specified, no
|
|
10829
10945
|
* shadow image will be created.
|
|
10830
10946
|
* @property {string} [shadowRetinaUrl] The URL to a retina sized version of the shadow
|
|
@@ -10907,15 +11023,31 @@ var Icon = class Icon extends Class {
|
|
|
10907
11023
|
else img.crossOrigin = null;
|
|
10908
11024
|
return img;
|
|
10909
11025
|
}
|
|
10910
|
-
|
|
11026
|
+
_getBox(name) {
|
|
10911
11027
|
const options = this.options;
|
|
10912
11028
|
const sizeOption = options[`${name}Size`];
|
|
10913
11029
|
const [width, height] = (typeof sizeOption === "number" ? [sizeOption, sizeOption] : Array.isArray(sizeOption) ? sizeOption : [sizeOption?.x, sizeOption?.y]).map(toNumber);
|
|
10914
11030
|
const anchorOption = name === "shadow" && options.shadowAnchor || options.iconAnchor;
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
|
|
11031
|
+
return {
|
|
11032
|
+
width,
|
|
11033
|
+
height,
|
|
11034
|
+
anchor: Point.validate(anchorOption) ? Point.from(anchorOption) : {
|
|
11035
|
+
x: Math.round(width / 2),
|
|
11036
|
+
y: Math.round(height / 2)
|
|
11037
|
+
}
|
|
10918
11038
|
};
|
|
11039
|
+
}
|
|
11040
|
+
_getTooltipAnchor(direction) {
|
|
11041
|
+
const { x, y } = Point.from(this.options.tooltipAnchor);
|
|
11042
|
+
if (direction === "left") return new Point(-x, y);
|
|
11043
|
+
if (direction === "center") return new Point(0, y);
|
|
11044
|
+
if (direction !== "top" && direction !== "bottom") return new Point(x, y);
|
|
11045
|
+
const { height, anchor } = this._getBox("icon");
|
|
11046
|
+
return new Point(0, (direction === "top" ? -anchor.y : height - anchor.y) || 0);
|
|
11047
|
+
}
|
|
11048
|
+
_setIconStyles(img, name) {
|
|
11049
|
+
const options = this.options;
|
|
11050
|
+
const { width, height, anchor } = this._getBox(name);
|
|
10919
11051
|
img.className = `maplair-marker-${name} ${options.className || ""}`;
|
|
10920
11052
|
const { style } = img;
|
|
10921
11053
|
style.marginLeft = style.marginTop = style.width = style.height = "";
|
|
@@ -11016,8 +11148,8 @@ const arrows = {
|
|
|
11016
11148
|
* The handler of `Marker` which makes the markers draggable, see the
|
|
11017
11149
|
* [`dragging`](#marker-dragging) property of markers and its `draggable` option.
|
|
11018
11150
|
*
|
|
11019
|
-
* @fires Marker#dragstart {
|
|
11020
|
-
* @fires Marker#movestart {
|
|
11151
|
+
* @fires Marker#dragstart {DraggableEvent} Fired when the user starts dragging the marker.
|
|
11152
|
+
* @fires Marker#movestart {DraggableEvent} Fired when the marker starts moving (because of
|
|
11021
11153
|
* dragging).
|
|
11022
11154
|
* @fires Marker#drag {MarkerMoveEvent} Fired repeatedly while the user drags the marker.
|
|
11023
11155
|
* @fires Marker#dragend {DragEndEvent} Fired when the user stops dragging the marker.
|
|
@@ -11083,10 +11215,10 @@ var MarkerDrag = class MarkerDrag extends Handler {
|
|
|
11083
11215
|
this._panRequest = requestAnimationFrame(this._adjustPan.bind(this, e));
|
|
11084
11216
|
}
|
|
11085
11217
|
}
|
|
11086
|
-
_onDragStart() {
|
|
11218
|
+
_onDragStart({ originalEvent }) {
|
|
11087
11219
|
this._oldLatLng = this._marker.getLatLng();
|
|
11088
11220
|
this._marker.closePopup?.();
|
|
11089
|
-
this._marker.fire("movestart").fire("dragstart");
|
|
11221
|
+
this._marker.fire("movestart", { originalEvent }).fire("dragstart", { originalEvent });
|
|
11090
11222
|
}
|
|
11091
11223
|
_onPreDrag(e) {
|
|
11092
11224
|
if (this._marker.options.autoPan) {
|
|
@@ -11123,7 +11255,7 @@ var MarkerDrag = class MarkerDrag extends Handler {
|
|
|
11123
11255
|
draggable._startPos = getPosition(draggable._element);
|
|
11124
11256
|
draggable._moved = draggable._moving = true;
|
|
11125
11257
|
this._keyOffset = new Point(0, 0);
|
|
11126
|
-
draggable.fire("dragstart");
|
|
11258
|
+
draggable.fire("dragstart", { originalEvent: k });
|
|
11127
11259
|
}
|
|
11128
11260
|
const offset = new Point(...dir).multiplyBy(k.shiftKey ? 30 : 10);
|
|
11129
11261
|
this._keyOffset = this._keyOffset.add(map._rotateToPane?.(offset) ?? offset);
|
|
@@ -11355,7 +11487,7 @@ var Marker = class Marker extends Layer {
|
|
|
11355
11487
|
*/
|
|
11356
11488
|
update() {
|
|
11357
11489
|
if (this._icon && this._map && !this._culled) {
|
|
11358
|
-
const pos = this._map.latLngToLayerPoint(this._latlng)
|
|
11490
|
+
const pos = this._map._snapLayerPoint(this._map.latLngToLayerPoint(this._latlng));
|
|
11359
11491
|
this._setPos(pos);
|
|
11360
11492
|
}
|
|
11361
11493
|
return this;
|
|
@@ -11426,7 +11558,7 @@ var Marker = class Marker extends Layer {
|
|
|
11426
11558
|
}
|
|
11427
11559
|
_setPos(pos) {
|
|
11428
11560
|
this._positionElements(pos);
|
|
11429
|
-
this._zIndex = pos.y + this.options.zIndexOffset;
|
|
11561
|
+
this._zIndex = Math.round(pos.y) + this.options.zIndexOffset;
|
|
11430
11562
|
this._updateRise();
|
|
11431
11563
|
}
|
|
11432
11564
|
_positionElements(pos) {
|
|
@@ -11446,7 +11578,7 @@ var Marker = class Marker extends Layer {
|
|
|
11446
11578
|
}
|
|
11447
11579
|
_animateZoom(opt) {
|
|
11448
11580
|
if (this._culled) return;
|
|
11449
|
-
const pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center)
|
|
11581
|
+
const pos = this._map._snapLayerPoint(this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center));
|
|
11450
11582
|
this._setPos(pos);
|
|
11451
11583
|
}
|
|
11452
11584
|
_updateInteractive() {
|
|
@@ -11561,8 +11693,8 @@ var Marker = class Marker extends Layer {
|
|
|
11561
11693
|
_getPopupAnchor() {
|
|
11562
11694
|
return this._rotateAnchor(this.options.icon.options.popupAnchor);
|
|
11563
11695
|
}
|
|
11564
|
-
_getTooltipAnchor() {
|
|
11565
|
-
return this._rotateAnchor(this.options.icon.
|
|
11696
|
+
_getTooltipAnchor(direction) {
|
|
11697
|
+
return this._rotateAnchor(this.options.icon._getTooltipAnchor(direction));
|
|
11566
11698
|
}
|
|
11567
11699
|
_rotateAnchor(anchor) {
|
|
11568
11700
|
const angle = this.options.rotation * Math.PI / 180;
|
|
@@ -13833,7 +13965,7 @@ var ImageOverlay = class ImageOverlay extends Layer {
|
|
|
13833
13965
|
setTransform(this._image, offset, scale);
|
|
13834
13966
|
}
|
|
13835
13967
|
_reset() {
|
|
13836
|
-
const image = this._image, bounds = new Bounds(
|
|
13968
|
+
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();
|
|
13837
13969
|
setPosition(image, bounds.min);
|
|
13838
13970
|
image.style.width = `${size.x}px`;
|
|
13839
13971
|
image.style.height = `${size.y}px`;
|
|
@@ -14798,7 +14930,7 @@ var GridLayer = class GridLayer extends Layer {
|
|
|
14798
14930
|
_onOpaqueTile() {}
|
|
14799
14931
|
_initContainer() {
|
|
14800
14932
|
if (this._container) return;
|
|
14801
|
-
this._container = create("div", `maplair-layer ${this.options.className ?? ""}`);
|
|
14933
|
+
this._container = create("div", `maplair-layer maplair-zoom-animated ${this.options.className ?? ""}`);
|
|
14802
14934
|
this._container.classList.toggle("maplair-pixelated", !!this.options.pixelated);
|
|
14803
14935
|
this._updateZIndex();
|
|
14804
14936
|
if (this.options.opacity < 1) this._updateOpacity();
|
|
@@ -14865,7 +14997,6 @@ var GridLayer = class GridLayer extends Layer {
|
|
|
14865
14997
|
level.origin = map.project(map.unproject(map.getPixelOrigin()), zoom).round();
|
|
14866
14998
|
level.zoom = zoom;
|
|
14867
14999
|
this._setZoomTransform(level, map.getCenter(), map.getZoom());
|
|
14868
|
-
level.el.offsetWidth;
|
|
14869
15000
|
this._onCreateLevel(level);
|
|
14870
15001
|
}
|
|
14871
15002
|
this._level = level;
|
|
@@ -14929,7 +15060,10 @@ var GridLayer = class GridLayer extends Layer {
|
|
|
14929
15060
|
this._setView(this._map.getCenter(), this._map.getZoom(), animating, animating);
|
|
14930
15061
|
}
|
|
14931
15062
|
_animateZoom(e) {
|
|
15063
|
+
const map = this._map, center = map.getCenter(), zoom = map.getZoom(), scale = map.getZoomScale(e.zoom, zoom);
|
|
14932
15064
|
this._setView(e.center, e.zoom, true, e.noUpdate);
|
|
15065
|
+
this._setZoomTransforms(center, zoom);
|
|
15066
|
+
setTransform(this._container, map._getNewPixelOrigin(center, zoom).multiplyBy(scale).subtract(map._getNewPixelOrigin(e.center, e.zoom)), scale);
|
|
14933
15067
|
}
|
|
14934
15068
|
_getTileZoom(zoom) {
|
|
14935
15069
|
const { minZoom, maxZoom = Infinity } = this.options;
|
|
@@ -14957,10 +15091,12 @@ var GridLayer = class GridLayer extends Layer {
|
|
|
14957
15091
|
this._setZoomTransforms(center, zoom);
|
|
14958
15092
|
}
|
|
14959
15093
|
_setZoomTransforms(center, zoom) {
|
|
15094
|
+
if (this._container.style.transform) this._container.style.transform = "";
|
|
14960
15095
|
for (const level of Object.values(this._levels)) this._setZoomTransform(level, center, zoom);
|
|
14961
15096
|
}
|
|
14962
15097
|
_setZoomTransform(level, center, zoom) {
|
|
14963
|
-
const scale = this._map.getZoomScale(zoom, level.zoom), translate = level.origin.multiplyBy(scale).subtract(this._map._getNewPixelOrigin(center, zoom))
|
|
15098
|
+
const scale = this._map.getZoomScale(zoom, level.zoom), translate = level.origin.multiplyBy(scale).subtract(this._map._getNewPixelOrigin(center, zoom));
|
|
15099
|
+
if (scale === 1) this._map._snapLayerPoint(translate);
|
|
14964
15100
|
setTransform(level.el, translate, scale);
|
|
14965
15101
|
}
|
|
14966
15102
|
_resetGrid() {
|
|
@@ -14971,7 +15107,9 @@ var GridLayer = class GridLayer extends Layer {
|
|
|
14971
15107
|
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)];
|
|
14972
15108
|
}
|
|
14973
15109
|
_onMoveEnd() {
|
|
14974
|
-
|
|
15110
|
+
const map = this._map;
|
|
15111
|
+
if (!map || map._animatingZoom) return;
|
|
15112
|
+
if (this._container.style.transform) this._setZoomTransforms(map.getCenter(), map.getZoom());
|
|
14975
15113
|
this._update();
|
|
14976
15114
|
}
|
|
14977
15115
|
_onWorldCopyJump({ worlds }) {
|
|
@@ -15156,6 +15294,10 @@ function isOSMUrl(url) {
|
|
|
15156
15294
|
return osmHosts.some((osmHost) => host === osmHost || host.endsWith(`.${osmHost}`));
|
|
15157
15295
|
}
|
|
15158
15296
|
const upgradeOSMUrl = (url) => isOSMUrl(url) ? url.replace(httpRe, "https:") : url;
|
|
15297
|
+
function retinaLevel() {
|
|
15298
|
+
const dpr = window.devicePixelRatio;
|
|
15299
|
+
return dpr >= 1.5 ? 2 : dpr > 1 ? 1 : 0;
|
|
15300
|
+
}
|
|
15159
15301
|
/**
|
|
15160
15302
|
* Options of `TileLayer`.
|
|
15161
15303
|
* @typedef {object} TileLayerOptions
|
|
@@ -15174,9 +15316,9 @@ const upgradeOSMUrl = (url) => isOSMUrl(url) ? url.replace(httpRe, "https:") : u
|
|
|
15174
15316
|
* this on for [TMS](https://en.wikipedia.org/wiki/Tile_Map_Service) services).
|
|
15175
15317
|
* @property {boolean} [zoomReverse=false] If set to true, the zoom number used in tile
|
|
15176
15318
|
* URLs will be reversed (`maxZoom - zoom` instead of `zoom`).
|
|
15177
|
-
* @property {boolean} [detectRetina=false] If `true` and
|
|
15178
|
-
* will request four tiles of half the specified size and a bigger zoom level
|
|
15179
|
-
* of one to utilize the high resolution.
|
|
15319
|
+
* @property {boolean} [detectRetina=false] If `true` and the device pixel ratio is 1.5 or
|
|
15320
|
+
* higher, it will request four tiles of half the specified size and a bigger zoom level
|
|
15321
|
+
* in place of one to utilize the high resolution.
|
|
15180
15322
|
* @property {boolean|string} [crossOrigin=false] Whether the crossOrigin attribute will
|
|
15181
15323
|
* be added to the tiles. If a String is provided, all tiles will have their crossOrigin
|
|
15182
15324
|
* attribute set to the String provided. This is needed if you want to access tile pixel
|
|
@@ -15276,8 +15418,8 @@ var TileLayer = class TileLayer extends GridLayer {
|
|
|
15276
15418
|
}
|
|
15277
15419
|
_applyRetina() {
|
|
15278
15420
|
Object.assign(this.options, this._nonRetinaOptions);
|
|
15279
|
-
this._retina =
|
|
15280
|
-
if (this.options.detectRetina && this._retina && this.options.maxZoom > 0) {
|
|
15421
|
+
this._retina = retinaLevel();
|
|
15422
|
+
if (this.options.detectRetina && this._retina === 2 && this.options.maxZoom > 0) {
|
|
15281
15423
|
const tileSize = this.options.tileSize;
|
|
15282
15424
|
this.options.tileSize = tileSize instanceof Point ? tileSize.divideBy(2).floor() : Math.floor(tileSize / 2);
|
|
15283
15425
|
if (!this.options.zoomReverse) {
|
|
@@ -15303,7 +15445,7 @@ var TileLayer = class TileLayer extends GridLayer {
|
|
|
15303
15445
|
return events;
|
|
15304
15446
|
}
|
|
15305
15447
|
_onPixelRatioChange() {
|
|
15306
|
-
if (
|
|
15448
|
+
if (retinaLevel() === this._retina) return;
|
|
15307
15449
|
const map = this._map;
|
|
15308
15450
|
this._applyRetina();
|
|
15309
15451
|
if (this.options.detectRetina) {
|
|
@@ -15527,7 +15669,7 @@ var WMSTileLayer = class WMSTileLayer extends TileLayer {
|
|
|
15527
15669
|
this.callInitHooks(WMSTileLayer);
|
|
15528
15670
|
}
|
|
15529
15671
|
_updateWmsSize() {
|
|
15530
|
-
const realRetina = this.options.detectRetina && window.devicePixelRatio
|
|
15672
|
+
const realRetina = this.options.detectRetina && window.devicePixelRatio >= 1.5 ? 2 : 1;
|
|
15531
15673
|
const tileSize = this.getTileSize();
|
|
15532
15674
|
this.wmsParams.width = tileSize.x * realRetina;
|
|
15533
15675
|
this.wmsParams.height = tileSize.y * realRetina;
|
|
@@ -15583,7 +15725,10 @@ var WMSTileLayer = class WMSTileLayer extends TileLayer {
|
|
|
15583
15725
|
for (const [k, v] of Object.entries({
|
|
15584
15726
|
...this.wmsParams,
|
|
15585
15727
|
bbox
|
|
15586
|
-
}))
|
|
15728
|
+
})) {
|
|
15729
|
+
if (v == null) continue;
|
|
15730
|
+
url.searchParams.append(this.options.uppercase ? k.toUpperCase() : k, `${v}`);
|
|
15731
|
+
}
|
|
15587
15732
|
return url.toString();
|
|
15588
15733
|
}
|
|
15589
15734
|
/**
|
|
@@ -15611,7 +15756,8 @@ var WMSTileLayer = class WMSTileLayer extends TileLayer {
|
|
|
15611
15756
|
/**
|
|
15612
15757
|
* Merges an object with the new parameters and re-requests tiles on the current screen
|
|
15613
15758
|
* (unless `noRedraw` was set to true). The current tiles stay visible until the new
|
|
15614
|
-
* tiles have loaded, to avoid flickering.
|
|
15759
|
+
* tiles have loaded, to avoid flickering. Set a parameter to `undefined` or `null` to
|
|
15760
|
+
* leave it out of the requests.
|
|
15615
15761
|
* @param {Record<string, any>} params
|
|
15616
15762
|
* @param {boolean} [noRedraw]
|
|
15617
15763
|
* @returns {this}
|
|
@@ -15699,7 +15845,7 @@ var Canvas = class Canvas extends Renderer {
|
|
|
15699
15845
|
super.onAdd(map);
|
|
15700
15846
|
const z = (r) => +getComputedStyle(r._container.parentNode).zIndex || 0;
|
|
15701
15847
|
map._canvases.push(this);
|
|
15702
|
-
map._canvases.sort((a, b) => z(b) - z(a) || (a._container.compareDocumentPosition(b._container) & 2)
|
|
15848
|
+
map._canvases.sort((a, b) => z(b) - z(a) || 1 - (a._container.compareDocumentPosition(b._container) & 2));
|
|
15703
15849
|
this._draw();
|
|
15704
15850
|
}
|
|
15705
15851
|
_initContainer() {
|
|
@@ -15854,7 +16000,7 @@ var Canvas = class Canvas extends Renderer {
|
|
|
15854
16000
|
ctx.fillStyle = options.fillColor ?? options.color;
|
|
15855
16001
|
ctx.fill(options.fillRule || "evenodd");
|
|
15856
16002
|
}
|
|
15857
|
-
if (options.stroke && options.weight !== 0) {
|
|
16003
|
+
if (options.stroke && +options.weight !== 0) {
|
|
15858
16004
|
ctx.lineDashOffset = Number(options.dashOffset ?? 0);
|
|
15859
16005
|
ctx.setLineDash(layer._dashArray ?? []);
|
|
15860
16006
|
ctx.globalAlpha = options.opacity;
|
|
@@ -15943,7 +16089,6 @@ var Circle = class Circle extends CircleMarker {
|
|
|
15943
16089
|
constructor(latlng, options) {
|
|
15944
16090
|
if (typeof options === "number") throw new Error("Circle: the radius is an option in Maplair. Use new Circle(latlng, {radius}).");
|
|
15945
16091
|
super(latlng, options);
|
|
15946
|
-
if (isNaN(this.options.radius)) throw new Error("Circle radius cannot be NaN");
|
|
15947
16092
|
this.callInitHooks(Circle);
|
|
15948
16093
|
}
|
|
15949
16094
|
/**
|
|
@@ -15963,8 +16108,8 @@ var Circle = class Circle extends CircleMarker {
|
|
|
15963
16108
|
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;
|
|
15964
16109
|
if (isNaN(lngR) || lngR === 0) lngR = latR / Math.cos(lat * d);
|
|
15965
16110
|
this._point = p.subtract(renderer._pathOrigin);
|
|
15966
|
-
this._pxRadius = isNaN(lngR) ? 0 : p.
|
|
15967
|
-
this._pxRadiusY = p.
|
|
16111
|
+
this._pxRadius = isNaN(lngR) ? 0 : p.distanceTo(map.project([lat2, lng - lngR], zoom));
|
|
16112
|
+
this._pxRadiusY = p.distanceTo(top);
|
|
15968
16113
|
} else {
|
|
15969
16114
|
const latlng2 = crs.unproject(crs.project(this._latlng).subtract([this._radius, 0]));
|
|
15970
16115
|
this._point = renderer._latLngToLayerPoint(this._latlng);
|
|
@@ -16369,7 +16514,7 @@ var MapSync = class {
|
|
|
16369
16514
|
if (this._leader !== map) return;
|
|
16370
16515
|
for (const other of this._followers(map)) if (other._zoomAnimated) {
|
|
16371
16516
|
this._animating.add(other);
|
|
16372
|
-
other._animateZoom(e.center, this._zoomFor(other, map, e.zoom),
|
|
16517
|
+
other._animateZoom(e.center, this._zoomFor(other, map, e.zoom), e.noUpdate);
|
|
16373
16518
|
}
|
|
16374
16519
|
}
|
|
16375
16520
|
_onMoveEnd(map) {
|
|
@@ -17109,7 +17254,8 @@ GridLayer.include({ _getTiledPixelBounds(center) {
|
|
|
17109
17254
|
/** @typedef {typeof blanketOverlayRotationMethods} BlanketOverlayMapRotationMethods */
|
|
17110
17255
|
BlanketOverlay.include({
|
|
17111
17256
|
_updateTransform(center, zoom) {
|
|
17112
|
-
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))
|
|
17257
|
+
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));
|
|
17258
|
+
if (scale === 1) this._map._snapLayerPoint(topLeftOffset);
|
|
17113
17259
|
setTransform(this._container, topLeftOffset, scale);
|
|
17114
17260
|
},
|
|
17115
17261
|
_onMoveEnd(ev) {
|
|
@@ -17144,7 +17290,7 @@ DivOverlay.include({
|
|
|
17144
17290
|
},
|
|
17145
17291
|
_updatePosition() {
|
|
17146
17292
|
if (!this._map) return;
|
|
17147
|
-
const map = this._map, pos = map.latLngToLayerPoint(this._latlng)
|
|
17293
|
+
const map = this._map, pos = map._snapLayerPoint(map.latLngToLayerPoint(this._latlng)), anchor = map._rotateToPane(new Point(this._getAnchor()));
|
|
17148
17294
|
let offset = Point.from(this.options.offset);
|
|
17149
17295
|
const transformed = this._zoomAnimated || this.options.overflow || map._bearing;
|
|
17150
17296
|
if (!transformed) offset = offset.add(pos).add(anchor);
|
|
@@ -17911,7 +18057,10 @@ Path.include({
|
|
|
17911
18057
|
});
|
|
17912
18058
|
CircleMarker.include({ setRadius(radius) {
|
|
17913
18059
|
this._takeZoomStyles({ radius });
|
|
17914
|
-
|
|
18060
|
+
if (!this._zoomStyles?.radius) return setRadius.call(this, radius);
|
|
18061
|
+
if (this._map) return setRadius.call(this, evaluate(radius, this._map.getZoom()));
|
|
18062
|
+
this.options.radius = this._radius = radius;
|
|
18063
|
+
return this;
|
|
17915
18064
|
} });
|
|
17916
18065
|
Path.addInitHook(function() {
|
|
17917
18066
|
this._takeZoomStyles(this.options);
|