maplair 4.1.0 → 4.2.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 +60 -0
- package/dist/esm/Maplair.js +5 -4
- package/dist/esm/Maplair.js.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.js +1 -2
- package/dist/esm/control/AttributionControl.js +1 -2
- package/dist/esm/control/ButtonControl.js +1 -2
- package/dist/esm/control/ContextMenu.js +1 -2
- package/dist/esm/control/Control.js +1 -2
- package/dist/esm/control/FullscreenControl.js +1 -2
- package/dist/esm/control/LayersControl.js +27 -31
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/LegendControl.js +1 -2
- package/dist/esm/control/MiniMapControl.js +1 -2
- package/dist/esm/control/RotateControl.js +1 -2
- package/dist/esm/control/ScaleControl.js +1 -2
- package/dist/esm/control/SearchControl.js +1 -2
- package/dist/esm/control/SideBySideControl.js +1 -2
- package/dist/esm/control/TextControl.js +1 -2
- package/dist/esm/control/TimeControl.js +1 -2
- package/dist/esm/control/ZoomControl.js +18 -29
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Class.js +2 -9
- package/dist/esm/core/Class.js.map +1 -1
- package/dist/esm/core/Events.js +1 -2
- package/dist/esm/core/Handler.js +10 -3
- package/dist/esm/core/Handler.js.map +1 -1
- package/dist/esm/core/I18n.js +1 -2
- package/dist/esm/core/Util.js +2 -3
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.DoubleTap.js +1 -2
- package/dist/esm/dom/DomEvent.PointerEvents.js +1 -2
- package/dist/esm/dom/DomEvent.js +10 -18
- package/dist/esm/dom/DomEvent.js.map +1 -1
- package/dist/esm/dom/DomUtil.js +1 -2
- package/dist/esm/dom/Draggable.js +4 -3
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/dom/PosAnimation.js +1 -2
- package/dist/esm/geo/LatLng.js +1 -2
- package/dist/esm/geo/LatLngBounds.js +9 -15
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geo/crs/CRS.js +1 -2
- package/dist/esm/geo/crs/EPSG3395.js +4 -5
- package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
- package/dist/esm/geo/crs/EPSG3857.js +4 -5
- package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
- package/dist/esm/geo/crs/EPSG4326.js +3 -4
- package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
- package/dist/esm/geo/crs/EarthCRS.js +1 -2
- package/dist/esm/geo/crs/SimpleCRS.js +3 -4
- package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
- package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +4 -5
- package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +3 -4
- package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +4 -5
- package/dist/esm/geo/projection/SphericalMercatorProjection.js.map +1 -0
- package/dist/esm/geometry/Bounds.js +10 -14
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/LineUtil.js +2 -3
- package/dist/esm/geometry/LineUtil.js.map +1 -1
- package/dist/esm/geometry/Point.js +1 -2
- package/dist/esm/geometry/PolyUtil.js +17 -25
- package/dist/esm/geometry/PolyUtil.js.map +1 -1
- package/dist/esm/geometry/Transformation.js +1 -2
- package/dist/esm/layer/BlanketOverlay.js +1 -2
- package/dist/esm/layer/Classification.js +1 -2
- package/dist/esm/layer/DivOverlay.js +2 -3
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/FeatureGroup.js +5 -4
- package/dist/esm/layer/FeatureGroup.js.map +1 -1
- package/dist/esm/layer/GeoJSON.Load.js +1 -2
- package/dist/esm/layer/GeoJSON.js +8 -10
- package/dist/esm/layer/GeoJSON.js.map +1 -1
- package/dist/esm/layer/GeoJSONUtil.js +1 -2
- package/dist/esm/layer/HeatLayer.js +2 -3
- package/dist/esm/layer/HeatLayer.js.map +1 -1
- package/dist/esm/layer/ImageOverlay.js +2 -3
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +1 -2
- package/dist/esm/layer/LayerGroup.js +2 -3
- package/dist/esm/layer/LayerGroup.js.map +1 -1
- package/dist/esm/layer/Popup.js +9 -16
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/SVGOverlay.js +1 -2
- package/dist/esm/layer/Tooltip.js +16 -17
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/VideoOverlay.js +1 -2
- package/dist/esm/layer/marker/DefaultIcon.js +29 -7
- package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
- package/dist/esm/layer/marker/DivIcon.js +1 -2
- package/dist/esm/layer/marker/Icon.js +2 -2
- package/dist/esm/layer/marker/Icon.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js +43 -4
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Move.js +4 -6
- package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +54 -14
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/marker/MarkerClusterGroup.js +1 -2
- package/dist/esm/layer/marker/SvgIcon.js +1 -2
- package/dist/esm/layer/tile/GridLayer.js +4 -4
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +8 -8
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/tile/WMSTileLayer.js +5 -4
- package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +7 -14
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +4 -3
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +2 -3
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.DashAnimation.js +1 -2
- package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
- package/dist/esm/layer/vector/Path.js +1 -2
- package/dist/esm/layer/vector/Polygon.js +2 -3
- package/dist/esm/layer/vector/Polygon.js.map +1 -1
- package/dist/esm/layer/vector/Polyline.Decorations.js +1 -2
- package/dist/esm/layer/vector/Polyline.js +2 -3
- package/dist/esm/layer/vector/Polyline.js.map +1 -1
- package/dist/esm/layer/vector/Rectangle.js +1 -2
- package/dist/esm/layer/vector/Renderer.getRenderer.js +4 -5
- package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
- package/dist/esm/layer/vector/Renderer.js +1 -2
- package/dist/esm/layer/vector/SVG.js +7 -4
- package/dist/esm/layer/vector/SVG.js.map +1 -1
- package/dist/esm/map/Hash.js +1 -2
- package/dist/esm/map/Map.Rotation.js +31 -16
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +10 -17
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/MapSync.js +1 -2
- package/dist/esm/map/handler/BoxZoomHandler.js +20 -40
- package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DisplaceHandler.js +1 -2
- package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
- package/dist/esm/map/handler/DragHandler.js +1 -2
- package/dist/esm/map/handler/KeyboardHandler.js +23 -43
- package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +1 -2
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +1 -2
- package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
- package/dist/esm/map/handler/TapHoldHandler.js +1 -2
- package/dist/esm/package.js +2 -3
- package/dist/maplair-global-src.js +487 -613
- 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 +483 -609
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.css +1 -1263
- package/dist/maplair.js +2 -2
- package/dist/maplair.js.map +1 -1
- package/package.json +3 -8
- package/src/Maplair.all.js +0 -1
- package/src/control/LayersControl.js +39 -52
- package/src/control/ZoomControl.js +17 -31
- package/src/core/Class.js +5 -14
- package/src/core/Handler.js +11 -1
- package/src/core/Util.js +1 -1
- package/src/dom/DomEvent.js +9 -19
- package/src/dom/Draggable.js +5 -1
- package/src/geo/LatLngBounds.js +8 -15
- package/src/geo/crs/EPSG3395.js +3 -3
- package/src/geo/crs/EPSG3857.js +3 -3
- package/src/geo/crs/EPSG4326.js +2 -2
- package/src/geo/crs/SimpleCRS.js +2 -2
- package/src/geo/index.js +1 -2
- package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +1 -1
- package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +1 -1
- package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +1 -1
- package/src/geo/projection/index.js +5 -5
- package/src/geometry/Bounds.js +12 -17
- package/src/geometry/LineUtil.js +1 -1
- package/src/geometry/PolyUtil.js +23 -31
- package/src/layer/DivOverlay.js +1 -1
- package/src/layer/FeatureGroup.js +8 -2
- package/src/layer/GeoJSON.js +10 -13
- package/src/layer/HeatLayer.js +1 -1
- package/src/layer/ImageOverlay.js +2 -2
- package/src/layer/LayerGroup.js +1 -1
- package/src/layer/Popup.js +9 -19
- package/src/layer/Tooltip.js +19 -17
- package/src/layer/marker/DefaultIcon.js +33 -5
- package/src/layer/marker/Icon.js +2 -0
- package/src/layer/marker/Marker.Drag.js +53 -5
- package/src/layer/marker/Marker.Move.js +3 -4
- package/src/layer/marker/Marker.js +64 -13
- package/src/layer/tile/GridLayer.js +5 -2
- package/src/layer/tile/TileLayer.js +9 -6
- package/src/layer/tile/WMSTileLayer.js +5 -2
- package/src/layer/vector/Canvas.js +10 -14
- package/src/layer/vector/Circle.js +4 -1
- package/src/layer/vector/CircleMarker.js +2 -1
- package/src/layer/vector/Polygon.js +1 -1
- package/src/layer/vector/Polyline.js +1 -1
- package/src/layer/vector/Renderer.getRenderer.js +4 -3
- package/src/layer/vector/SVG.js +12 -2
- package/src/map/Map.Rotation.js +28 -4
- package/src/map/Map.js +17 -21
- package/src/map/handler/BoxZoomHandler.js +21 -42
- package/src/map/handler/KeyboardHandler.js +34 -53
- package/src/maplair.css +5 -0
- package/dist/esm/geo/projection/Projection.LonLat.js.map +0 -1
- package/dist/esm/geo/projection/Projection.Mercator.js.map +0 -1
- package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +0 -1
- package/dist/esm/geo/projection/index.js +0 -14
- package/dist/esm/geo/projection/index.js.map +0 -1
- package/dist/esm/layer/marker/Marker.Rotation.js +0 -70
- package/dist/esm/layer/marker/Marker.Rotation.js.map +0 -1
- package/src/layer/marker/Marker.Rotation.js +0 -103
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* Maplair 4.
|
|
2
|
+
* Maplair 4.2.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) {
|
|
6
6
|
(function(global, factory) {
|
|
7
7
|
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define([], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.L = factory());
|
|
8
8
|
})(this, function() {
|
|
9
|
-
|
|
9
|
+
// \0rolldown/runtime.js
|
|
10
10
|
var __defProp = Object.defineProperty;
|
|
11
11
|
var __exportAll = (all, no_symbols) => {
|
|
12
12
|
let target = {};
|
|
@@ -17,11 +17,9 @@
|
|
|
17
17
|
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
18
|
return target;
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/core/Util.js
|
|
20
|
+
// package.json
|
|
21
|
+
var version$1 = "4.2.0";
|
|
22
|
+
// src/core/Util.js
|
|
25
23
|
var Util_exports = /* @__PURE__ */ __exportAll({
|
|
26
24
|
falseFn: () => falseFn,
|
|
27
25
|
formatNum: () => formatNum,
|
|
@@ -79,7 +77,7 @@
|
|
|
79
77
|
}
|
|
80
78
|
/**
|
|
81
79
|
* Returns the number `x` modulo `range` in such a way so it lies within
|
|
82
|
-
* `range[0]` and `range[1]`. The returned value will be
|
|
80
|
+
* `range[0]` and `range[1]`. The returned value will always be smaller than
|
|
83
81
|
* `range[1]` unless `includeMax` is set to `true`.
|
|
84
82
|
* @param {number} x
|
|
85
83
|
* @param {[number, number]} range
|
|
@@ -161,8 +159,7 @@
|
|
|
161
159
|
return value;
|
|
162
160
|
});
|
|
163
161
|
}
|
|
164
|
-
|
|
165
|
-
//#region src/core/Class.js
|
|
162
|
+
// src/core/Class.js
|
|
166
163
|
/**
|
|
167
164
|
* Class powers the OOP facilities of Maplair and is used to create almost all of the
|
|
168
165
|
* Maplair classes documented here.
|
|
@@ -320,15 +317,9 @@
|
|
|
320
317
|
* @returns {T}
|
|
321
318
|
*/
|
|
322
319
|
static include(props) {
|
|
323
|
-
for (const k of
|
|
320
|
+
for (let obj = props; obj && obj !== Object.prototype; obj = Object.getPrototypeOf(obj)) for (const k of Object.getOwnPropertyNames(obj)) if (k !== "constructor" && k !== "options") this.prototype[k] = props[k];
|
|
324
321
|
if (props.options) this.mergeOptions(props.options);
|
|
325
322
|
return this;
|
|
326
|
-
function* getAllMethodNames(obj) {
|
|
327
|
-
do {
|
|
328
|
-
if (obj === Object || obj === Object.prototype) break;
|
|
329
|
-
for (const k of Object.getOwnPropertyNames(obj)) yield k;
|
|
330
|
-
} while ((obj = Object.getPrototypeOf(obj)) !== null);
|
|
331
|
-
}
|
|
332
323
|
}
|
|
333
324
|
/**
|
|
334
325
|
* [Merges `options`](#class-options) into the `defaultOptions` of the class.
|
|
@@ -393,8 +384,7 @@
|
|
|
393
384
|
return this;
|
|
394
385
|
}
|
|
395
386
|
};
|
|
396
|
-
|
|
397
|
-
//#region src/geometry/Point.js
|
|
387
|
+
// src/geometry/Point.js
|
|
398
388
|
/**
|
|
399
389
|
* A point in pixels: a `Point`, an array of the form `[x, y]`, or a plain object of
|
|
400
390
|
* the form `{x, y}`. Accepted by all Maplair methods and options which accept `Point`
|
|
@@ -647,8 +637,7 @@
|
|
|
647
637
|
return `Point(${formatNum(this.x)}, ${formatNum(this.y)})`;
|
|
648
638
|
}
|
|
649
639
|
};
|
|
650
|
-
|
|
651
|
-
//#region src/dom/DomEvent.DoubleTap.js
|
|
640
|
+
// src/dom/DomEvent.DoubleTap.js
|
|
652
641
|
function makeDblclick(ev) {
|
|
653
642
|
const init = {
|
|
654
643
|
bubbles: ev.bubbles,
|
|
@@ -735,8 +724,7 @@
|
|
|
735
724
|
obj.removeEventListener("pointerdown", handlers.onPointerDown, true);
|
|
736
725
|
obj.removeEventListener("click", handlers.simDblclick);
|
|
737
726
|
}
|
|
738
|
-
|
|
739
|
-
//#region src/dom/DomEvent.PointerEvents.js
|
|
727
|
+
// src/dom/DomEvent.PointerEvents.js
|
|
740
728
|
var DomEvent_PointerEvents_exports = /* @__PURE__ */ __exportAll({
|
|
741
729
|
disablePointerDetection: () => disablePointerDetection,
|
|
742
730
|
enablePointerDetection: () => enablePointerDetection,
|
|
@@ -787,8 +775,7 @@
|
|
|
787
775
|
function getPointers() {
|
|
788
776
|
return [...activePointers.values()];
|
|
789
777
|
}
|
|
790
|
-
|
|
791
|
-
//#region src/dom/DomEvent.js
|
|
778
|
+
// src/dom/DomEvent.js
|
|
792
779
|
var DomEvent_exports = /* @__PURE__ */ __exportAll({
|
|
793
780
|
PointerEvents: () => DomEvent_PointerEvents_exports,
|
|
794
781
|
disableClickPropagation: () => disableClickPropagation,
|
|
@@ -814,12 +801,11 @@
|
|
|
814
801
|
* @param {string|Record<string, (ev: any) => void>} types
|
|
815
802
|
* @param {((ev: any) => void)|object} [fn]
|
|
816
803
|
* @param {object} [context]
|
|
817
|
-
* @returns {
|
|
804
|
+
* @returns {void}
|
|
818
805
|
*/
|
|
819
806
|
function on(obj, types, fn, context) {
|
|
820
807
|
if (types && typeof types === "object") for (const [type, listener] of Object.entries(types)) addOne(obj, type, listener, fn);
|
|
821
808
|
else for (const type of splitWords(types)) addOne(obj, type, fn, context);
|
|
822
|
-
return this;
|
|
823
809
|
}
|
|
824
810
|
const eventsKey = "_maplair_events";
|
|
825
811
|
/**
|
|
@@ -833,7 +819,7 @@
|
|
|
833
819
|
* @param {string|Record<string, (ev: any) => void>} [types]
|
|
834
820
|
* @param {((ev: any) => void)|object} [fn]
|
|
835
821
|
* @param {object} [context]
|
|
836
|
-
* @returns {
|
|
822
|
+
* @returns {void}
|
|
837
823
|
*/
|
|
838
824
|
function off(obj, types, fn, context) {
|
|
839
825
|
if (arguments.length === 1) {
|
|
@@ -845,7 +831,6 @@
|
|
|
845
831
|
if (arguments.length === 2) batchRemove(obj, (type) => types.includes(type));
|
|
846
832
|
else for (const type of types) removeOne(obj, type, fn, context);
|
|
847
833
|
}
|
|
848
|
-
return this;
|
|
849
834
|
}
|
|
850
835
|
const DIGIT_RE = /\d/;
|
|
851
836
|
function batchRemove(obj, filterFn) {
|
|
@@ -856,7 +841,7 @@
|
|
|
856
841
|
}
|
|
857
842
|
function addOne(obj, type, fn, context) {
|
|
858
843
|
const id = type + stamp(fn) + (context ? `_${stamp(context)}` : "");
|
|
859
|
-
if (obj[eventsKey] && obj[eventsKey][id]) return
|
|
844
|
+
if (obj[eventsKey] && obj[eventsKey][id]) return;
|
|
860
845
|
let handler = function(e) {
|
|
861
846
|
return fn.call(context || obj, e);
|
|
862
847
|
};
|
|
@@ -868,7 +853,7 @@
|
|
|
868
853
|
function removeOne(obj, type, fn, context, id) {
|
|
869
854
|
id ??= type + stamp(fn) + (context ? `_${stamp(context)}` : "");
|
|
870
855
|
const handler = obj[eventsKey] && obj[eventsKey][id];
|
|
871
|
-
if (!handler) return
|
|
856
|
+
if (!handler) return;
|
|
872
857
|
if (type === "dblclick") removeDoubleTapListener(obj, handler);
|
|
873
858
|
else obj.removeEventListener(type, handler, false);
|
|
874
859
|
obj[eventsKey][id] = null;
|
|
@@ -881,22 +866,20 @@
|
|
|
881
866
|
* ```
|
|
882
867
|
* Also accepts a Maplair event with an `originalEvent`.
|
|
883
868
|
* @param {Event|{originalEvent: Event}} e
|
|
884
|
-
* @returns {
|
|
869
|
+
* @returns {void}
|
|
885
870
|
*/
|
|
886
871
|
function stopPropagation(e) {
|
|
887
872
|
if (e.stopPropagation) e.stopPropagation();
|
|
888
873
|
else if (e.originalEvent) e.originalEvent._stopped = true;
|
|
889
874
|
else console.debug("Unsupported event", e);
|
|
890
|
-
return this;
|
|
891
875
|
}
|
|
892
876
|
/**
|
|
893
877
|
* Adds `stopPropagation` to the element's `'wheel'` events (plus browser variants).
|
|
894
878
|
* @param {HTMLElement} el
|
|
895
|
-
* @returns {
|
|
879
|
+
* @returns {void}
|
|
896
880
|
*/
|
|
897
881
|
function disableScrollPropagation(el) {
|
|
898
882
|
addOne(el, "wheel", stopPropagation);
|
|
899
|
-
return this;
|
|
900
883
|
}
|
|
901
884
|
/**
|
|
902
885
|
* Adds `stopPropagation` to the element's `'dblclick'`, `'contextmenu'`
|
|
@@ -904,12 +887,11 @@
|
|
|
904
887
|
* For `'click'` events, prevents the map from handling the click
|
|
905
888
|
* while still allowing the native DOM click event to propagate normally.
|
|
906
889
|
* @param {HTMLElement} el
|
|
907
|
-
* @returns {
|
|
890
|
+
* @returns {void}
|
|
908
891
|
*/
|
|
909
892
|
function disableClickPropagation(el) {
|
|
910
893
|
on(el, "pointerdown dblclick contextmenu", stopPropagation);
|
|
911
894
|
el["_maplair_disable_click"] = true;
|
|
912
|
-
return this;
|
|
913
895
|
}
|
|
914
896
|
/**
|
|
915
897
|
* Prevents the default action of the DOM Event `e` from happening (such as
|
|
@@ -917,21 +899,19 @@
|
|
|
917
899
|
* with page reload when a `<form>` is submitted).
|
|
918
900
|
* Use it inside listener functions.
|
|
919
901
|
* @param {Event} e
|
|
920
|
-
* @returns {
|
|
902
|
+
* @returns {void}
|
|
921
903
|
*/
|
|
922
904
|
function preventDefault(e) {
|
|
923
905
|
e.preventDefault?.();
|
|
924
|
-
return this;
|
|
925
906
|
}
|
|
926
907
|
/**
|
|
927
908
|
* Does `stopPropagation` and `preventDefault` at the same time.
|
|
928
909
|
* @param {Event} e
|
|
929
|
-
* @returns {
|
|
910
|
+
* @returns {void}
|
|
930
911
|
*/
|
|
931
912
|
function stop(e) {
|
|
932
913
|
preventDefault(e);
|
|
933
914
|
stopPropagation(e);
|
|
934
|
-
return this;
|
|
935
915
|
}
|
|
936
916
|
/**
|
|
937
917
|
* Gets normalized pointer position from a DOM event relative to the
|
|
@@ -974,8 +954,7 @@
|
|
|
974
954
|
function isExternalTarget(el, e) {
|
|
975
955
|
return !el.contains(e.relatedTarget);
|
|
976
956
|
}
|
|
977
|
-
|
|
978
|
-
//#region src/dom/DomUtil.js
|
|
957
|
+
// src/dom/DomUtil.js
|
|
979
958
|
var DomUtil_exports = /* @__PURE__ */ __exportAll({
|
|
980
959
|
create: () => create,
|
|
981
960
|
disableImageDrag: () => disableImageDrag,
|
|
@@ -1115,8 +1094,7 @@
|
|
|
1115
1094
|
boundingClientRect: rect
|
|
1116
1095
|
};
|
|
1117
1096
|
}
|
|
1118
|
-
|
|
1119
|
-
//#region src/control/Control.js
|
|
1097
|
+
// src/control/Control.js
|
|
1120
1098
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
1121
1099
|
/**
|
|
1122
1100
|
* Options of `Control`, inherited by all controls.
|
|
@@ -1271,8 +1249,7 @@
|
|
|
1271
1249
|
MaplairMap.include(mapControlMethods);
|
|
1272
1250
|
}
|
|
1273
1251
|
};
|
|
1274
|
-
|
|
1275
|
-
//#region src/core/I18n.js
|
|
1252
|
+
// src/core/I18n.js
|
|
1276
1253
|
/**
|
|
1277
1254
|
* Utility functions to deal with translations.
|
|
1278
1255
|
*
|
|
@@ -1341,8 +1318,7 @@
|
|
|
1341
1318
|
}
|
|
1342
1319
|
}
|
|
1343
1320
|
};
|
|
1344
|
-
|
|
1345
|
-
//#region src/control/AttributionControl.js
|
|
1321
|
+
// src/control/AttributionControl.js
|
|
1346
1322
|
/** @import {ControlOptions} from './Control.js' */
|
|
1347
1323
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
1348
1324
|
const mapleLeaf = "<span aria-hidden=\"true\" class=\"maplair-attribution-leaf\">🍁</span>";
|
|
@@ -1495,8 +1471,7 @@
|
|
|
1495
1471
|
});
|
|
1496
1472
|
}
|
|
1497
1473
|
};
|
|
1498
|
-
|
|
1499
|
-
//#region src/control/ButtonControl.js
|
|
1474
|
+
// src/control/ButtonControl.js
|
|
1500
1475
|
/** @import {ControlOptions} from './Control.js' */
|
|
1501
1476
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
1502
1477
|
/**
|
|
@@ -1708,8 +1683,7 @@
|
|
|
1708
1683
|
return this._buttons;
|
|
1709
1684
|
}
|
|
1710
1685
|
};
|
|
1711
|
-
|
|
1712
|
-
//#region src/core/Events.js
|
|
1686
|
+
// src/core/Events.js
|
|
1713
1687
|
const warnedEvents = /* @__PURE__ */ new Set();
|
|
1714
1688
|
/** @import {LatLng} from '../geo/LatLng.js' */
|
|
1715
1689
|
/** @import {LatLngBounds} from '../geo/LatLngBounds.js' */
|
|
@@ -2096,8 +2070,7 @@
|
|
|
2096
2070
|
}, true);
|
|
2097
2071
|
}
|
|
2098
2072
|
};
|
|
2099
|
-
|
|
2100
|
-
//#region src/layer/Layer.js
|
|
2073
|
+
// src/layer/Layer.js
|
|
2101
2074
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
2102
2075
|
/** @import {LayerGroup} from './LayerGroup.js' */
|
|
2103
2076
|
/** @import {EventListener, MaplairEvent, MaplairPointerEvent, LayerEvent} from '../core/Events.js' */
|
|
@@ -2418,8 +2391,7 @@
|
|
|
2418
2391
|
MaplairMap.include(mapLayerMethods);
|
|
2419
2392
|
}
|
|
2420
2393
|
};
|
|
2421
|
-
|
|
2422
|
-
//#region src/control/ContextMenu.js
|
|
2394
|
+
// src/control/ContextMenu.js
|
|
2423
2395
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
2424
2396
|
/** @import {LatLng} from '../geo/LatLng.js' */
|
|
2425
2397
|
/** @import {Point} from '../geometry/Point.js' */
|
|
@@ -2581,8 +2553,7 @@
|
|
|
2581
2553
|
buttons.at(next % buttons.length)?.focus();
|
|
2582
2554
|
}
|
|
2583
2555
|
};
|
|
2584
|
-
|
|
2585
|
-
//#region src/control/FullscreenControl.js
|
|
2556
|
+
// src/control/FullscreenControl.js
|
|
2586
2557
|
/** @import {ControlOptions} from './Control.js' */
|
|
2587
2558
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
2588
2559
|
/** @import {MaplairEvent} from '../core/Events.js' */
|
|
@@ -2758,8 +2729,7 @@
|
|
|
2758
2729
|
});
|
|
2759
2730
|
}
|
|
2760
2731
|
};
|
|
2761
|
-
|
|
2762
|
-
//#region src/control/LayersControl.js
|
|
2732
|
+
// src/control/LayersControl.js
|
|
2763
2733
|
/** @import {ControlOptions} from './Control.js' */
|
|
2764
2734
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
2765
2735
|
/** @import {Layer} from '../layer/Layer.js' */
|
|
@@ -2938,6 +2908,7 @@
|
|
|
2938
2908
|
this._map.off("zoomend", this._checkDisabledLayers, this);
|
|
2939
2909
|
for (const layer of this._layers) layer.layer.off("add remove", this._onLayerChange, this);
|
|
2940
2910
|
this._map.off("resize", this._expandIfNotCollapsed, this);
|
|
2911
|
+
this._map.off("click", this.collapse, this);
|
|
2941
2912
|
}
|
|
2942
2913
|
/**
|
|
2943
2914
|
* Adds a base layer (radio button entry) with the given name to the control.
|
|
@@ -2966,8 +2937,7 @@
|
|
|
2966
2937
|
*/
|
|
2967
2938
|
removeLayer(layer) {
|
|
2968
2939
|
layer.off("add remove", this._onLayerChange, this);
|
|
2969
|
-
|
|
2970
|
-
if (obj) this._layers.splice(this._layers.indexOf(obj), 1);
|
|
2940
|
+
this._layers = this._layers.filter((o) => o.layer !== layer);
|
|
2971
2941
|
return this._map ? this._update() : this;
|
|
2972
2942
|
}
|
|
2973
2943
|
/**
|
|
@@ -2991,7 +2961,7 @@
|
|
|
2991
2961
|
* @returns {this}
|
|
2992
2962
|
*/
|
|
2993
2963
|
selectLayer(layer) {
|
|
2994
|
-
const input = this._layerControlInputs.find((input) => input.
|
|
2964
|
+
const input = this._layerControlInputs.find((input) => input._layer === layer);
|
|
2995
2965
|
if (input && !input.checked) {
|
|
2996
2966
|
input.checked = true;
|
|
2997
2967
|
this._onInputClick();
|
|
@@ -3016,21 +2986,14 @@
|
|
|
3016
2986
|
}
|
|
3017
2987
|
/**
|
|
3018
2988
|
* Collapse the control container if expanded.
|
|
3019
|
-
* @param {Event} [ev] The event causing the collapse, if any (collapsing is skipped
|
|
3020
|
-
* for `pointerleave` and `pointerout` of touch).
|
|
3021
2989
|
* @returns {this}
|
|
3022
2990
|
*/
|
|
3023
|
-
collapse(
|
|
2991
|
+
collapse() {
|
|
3024
2992
|
if (this.options.inline) return this;
|
|
3025
|
-
if (
|
|
3026
|
-
if (this.options.collapseDelay > 0) {
|
|
3027
|
-
this._collapseDelayTimeout = setTimeout(() => {
|
|
3028
|
-
this._container.classList.remove("maplair-control-layers-expanded");
|
|
3029
|
-
}, this.options.collapseDelay);
|
|
3030
|
-
return this;
|
|
3031
|
-
}
|
|
2993
|
+
if (this.options.collapseDelay > 0) this._collapseDelayTimeout = setTimeout(() => {
|
|
3032
2994
|
this._container.classList.remove("maplair-control-layers-expanded");
|
|
3033
|
-
}
|
|
2995
|
+
}, this.options.collapseDelay);
|
|
2996
|
+
else this._container.classList.remove("maplair-control-layers-expanded");
|
|
3034
2997
|
return this;
|
|
3035
2998
|
}
|
|
3036
2999
|
_initLayout() {
|
|
@@ -3044,7 +3007,9 @@
|
|
|
3044
3007
|
this._map.on("click", this.collapse, this);
|
|
3045
3008
|
on(container, {
|
|
3046
3009
|
pointerenter: this._expandSafely,
|
|
3047
|
-
pointerleave
|
|
3010
|
+
pointerleave(e) {
|
|
3011
|
+
if (e.pointerType !== "touch") this.collapse();
|
|
3012
|
+
}
|
|
3048
3013
|
}, this);
|
|
3049
3014
|
}
|
|
3050
3015
|
if (!this.options.inline) {
|
|
@@ -3071,9 +3036,6 @@
|
|
|
3071
3036
|
this._overlaysList = create("div", `${className}-overlays`, section);
|
|
3072
3037
|
container.appendChild(section);
|
|
3073
3038
|
}
|
|
3074
|
-
_getLayer(id) {
|
|
3075
|
-
for (const layer of this._layers) if (layer && stamp(layer.layer) === id) return layer;
|
|
3076
|
-
}
|
|
3077
3039
|
_addLayer(layer, name, overlay) {
|
|
3078
3040
|
if (this._map) layer.on("add remove", this._onLayerChange, this);
|
|
3079
3041
|
this._layers.push({
|
|
@@ -3110,7 +3072,7 @@
|
|
|
3110
3072
|
}
|
|
3111
3073
|
_onLayerChange(e) {
|
|
3112
3074
|
if (!this._handlingClick) this._update();
|
|
3113
|
-
const obj = this.
|
|
3075
|
+
const obj = this._layers.find((o) => o.layer === e.target);
|
|
3114
3076
|
const type = obj.overlay ? e.type === "add" ? "overlayadd" : "overlayremove" : e.type === "add" ? "baselayerchange" : null;
|
|
3115
3077
|
if (type) this._map.fire(type, this._clickEvent ? {
|
|
3116
3078
|
...obj,
|
|
@@ -3125,7 +3087,7 @@
|
|
|
3125
3087
|
input.defaultChecked = checked;
|
|
3126
3088
|
if (!obj.overlay) input.name = `maplair-base-layers_${stamp(this)}`;
|
|
3127
3089
|
this._layerControlInputs.push(input);
|
|
3128
|
-
input.
|
|
3090
|
+
input._layer = obj.layer;
|
|
3129
3091
|
on(input, "click", this._onInputClick, this);
|
|
3130
3092
|
const group = this.options.groupBy?.(obj.name, obj.layer, obj.overlay);
|
|
3131
3093
|
const name = document.createElement("span");
|
|
@@ -3159,24 +3121,29 @@
|
|
|
3159
3121
|
}
|
|
3160
3122
|
_onInputClick(e) {
|
|
3161
3123
|
if (this._preventClick) return;
|
|
3162
|
-
const
|
|
3124
|
+
const checked = /* @__PURE__ */ new Map();
|
|
3125
|
+
for (const input of this._layerControlInputs) {
|
|
3126
|
+
const layer = input._layer;
|
|
3127
|
+
checked.set(layer, checked.get(layer) || input.checked);
|
|
3128
|
+
}
|
|
3129
|
+
const addedLayers = [], removedLayers = [];
|
|
3130
|
+
for (const [layer, on] of checked) if (on !== this._map.hasLayer(layer)) (on ? addedLayers : removedLayers).push(layer);
|
|
3163
3131
|
this._handlingClick = true;
|
|
3164
3132
|
this._clickEvent = e;
|
|
3165
|
-
for (const
|
|
3166
|
-
|
|
3167
|
-
if (input.checked) addedLayers.push(layer);
|
|
3168
|
-
else if (!input.checked) removedLayers.push(layer);
|
|
3169
|
-
}
|
|
3170
|
-
for (const layer of removedLayers) if (this._map.hasLayer(layer)) this._map.removeLayer(layer);
|
|
3171
|
-
for (const layer of addedLayers) if (!this._map.hasLayer(layer)) this._map.addLayer(layer);
|
|
3133
|
+
for (const layer of removedLayers) this._map.removeLayer(layer);
|
|
3134
|
+
for (const layer of addedLayers) this._map.addLayer(layer);
|
|
3172
3135
|
this._handlingClick = false;
|
|
3173
3136
|
this._clickEvent = void 0;
|
|
3137
|
+
for (const [layer, on] of checked) if (on !== this._map.hasLayer(layer)) {
|
|
3138
|
+
this._update();
|
|
3139
|
+
break;
|
|
3140
|
+
}
|
|
3174
3141
|
this._refocusOnMap(e);
|
|
3175
3142
|
}
|
|
3176
3143
|
_checkDisabledLayers() {
|
|
3177
3144
|
const inputs = this._layerControlInputs, zoom = this._map.getZoom();
|
|
3178
3145
|
for (const input of inputs) {
|
|
3179
|
-
const layer =
|
|
3146
|
+
const layer = input._layer;
|
|
3180
3147
|
input.disabled = layer.options.minZoom !== void 0 && zoom < layer.options.minZoom || layer.options.maxZoom !== void 0 && zoom > layer.options.maxZoom;
|
|
3181
3148
|
}
|
|
3182
3149
|
}
|
|
@@ -3198,8 +3165,7 @@
|
|
|
3198
3165
|
});
|
|
3199
3166
|
}
|
|
3200
3167
|
};
|
|
3201
|
-
|
|
3202
|
-
//#region src/geometry/Bounds.js
|
|
3168
|
+
// src/geometry/Bounds.js
|
|
3203
3169
|
/** @import {PointExpression} from './Point.js' */
|
|
3204
3170
|
/**
|
|
3205
3171
|
* A rectangular area in pixel coordinates: a `Bounds`, or an array of points (usually
|
|
@@ -3276,14 +3242,12 @@
|
|
|
3276
3242
|
extend(obj) {
|
|
3277
3243
|
let min2, max2;
|
|
3278
3244
|
if (!obj) return this;
|
|
3279
|
-
if (obj
|
|
3245
|
+
if (isPointExpression(obj)) min2 = max2 = Point.from(obj);
|
|
3280
3246
|
else {
|
|
3281
|
-
|
|
3282
|
-
min2
|
|
3283
|
-
max2 = obj.max;
|
|
3284
|
-
if (!min2 || !max2) return this;
|
|
3247
|
+
({min: min2, max: max2} = Bounds.from(obj));
|
|
3248
|
+
if (!min2) return this;
|
|
3285
3249
|
}
|
|
3286
|
-
if (!this.min
|
|
3250
|
+
if (!this.min) {
|
|
3287
3251
|
this.min = new Point(min2);
|
|
3288
3252
|
this.max = new Point(max2);
|
|
3289
3253
|
} else {
|
|
@@ -3344,12 +3308,8 @@
|
|
|
3344
3308
|
*/
|
|
3345
3309
|
contains(obj) {
|
|
3346
3310
|
let min, max;
|
|
3347
|
-
if (
|
|
3348
|
-
else
|
|
3349
|
-
if (obj instanceof Bounds) {
|
|
3350
|
-
min = obj.min;
|
|
3351
|
-
max = obj.max;
|
|
3352
|
-
} else min = max = obj;
|
|
3311
|
+
if (isPointExpression(obj)) min = max = Point.from(obj);
|
|
3312
|
+
else ({min, max} = Bounds.from(obj));
|
|
3353
3313
|
return min.x >= this.min.x && max.x <= this.max.x && min.y >= this.min.y && max.y <= this.max.y;
|
|
3354
3314
|
}
|
|
3355
3315
|
/**
|
|
@@ -3403,8 +3363,10 @@
|
|
|
3403
3363
|
return this.min.equals(bounds.getTopLeft()) && this.max.equals(bounds.getBottomRight());
|
|
3404
3364
|
}
|
|
3405
3365
|
};
|
|
3406
|
-
|
|
3407
|
-
|
|
3366
|
+
function isPointExpression(obj) {
|
|
3367
|
+
return obj instanceof Point || (Array.isArray(obj) ? typeof obj[0] === "number" : "x" in obj);
|
|
3368
|
+
}
|
|
3369
|
+
// src/layer/BlanketOverlay.js
|
|
3408
3370
|
/** @import {LayerOptions} from './Layer.js' */
|
|
3409
3371
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
3410
3372
|
/** @import {EventListener} from '../core/Events.js' */
|
|
@@ -3533,8 +3495,7 @@
|
|
|
3533
3495
|
_onViewReset() {}
|
|
3534
3496
|
_onSettled() {}
|
|
3535
3497
|
};
|
|
3536
|
-
|
|
3537
|
-
//#region src/layer/vector/Renderer.js
|
|
3498
|
+
// src/layer/vector/Renderer.js
|
|
3538
3499
|
/** @import {BlanketOverlayOptions} from '../BlanketOverlay.js' */
|
|
3539
3500
|
/** @import {MaplairEvent} from '../../core/Events.js' */
|
|
3540
3501
|
/** @import {MaplairMap} from '../../map/Map.js' */
|
|
@@ -3603,8 +3564,7 @@
|
|
|
3603
3564
|
}
|
|
3604
3565
|
_update() {}
|
|
3605
3566
|
};
|
|
3606
|
-
|
|
3607
|
-
//#region src/layer/vector/SVG.js
|
|
3567
|
+
// src/layer/vector/SVG.js
|
|
3608
3568
|
/** @import {Point} from '../../geometry/Point.js' */
|
|
3609
3569
|
/** @import {RendererOptions} from './Renderer.js' */
|
|
3610
3570
|
/**
|
|
@@ -3728,7 +3688,7 @@
|
|
|
3728
3688
|
}
|
|
3729
3689
|
_updateCircle(layer) {
|
|
3730
3690
|
const p = layer._point, r = Math.max(Math.round(layer._pxRadius), 1), arc = `a${r},${Math.max(Math.round(layer._pxRadiusY), 1) || r} 0 1,0 `;
|
|
3731
|
-
const d = layer._empty() ? "M0 0" : `M${p.x - r},${p.y}${arc}${r * 2},0 ${arc}${-r * 2},0 `;
|
|
3691
|
+
const d = layer._empty() ? "M0 0" : `M${num(p.x - r)},${num(p.y)}${arc}${r * 2},0 ${arc}${-r * 2},0 `;
|
|
3732
3692
|
this._setPath(layer, d);
|
|
3733
3693
|
}
|
|
3734
3694
|
_setPath(layer, path) {
|
|
@@ -3758,11 +3718,14 @@
|
|
|
3758
3718
|
* @returns {string}
|
|
3759
3719
|
*/
|
|
3760
3720
|
static pointsToPath(rings, closed) {
|
|
3761
|
-
return rings.flatMap((points) => [...points.map((p, j) => `${(j ? "L" : "M") + p.x} ${p.y}`), closed ? "z" : ""]).join("") || "M0 0";
|
|
3721
|
+
return rings.flatMap((points) => [...points.map((p, j) => `${(j ? "L" : "M") + num(p.x)} ${num(p.y)}`), closed ? "z" : ""]).join("") || "M0 0";
|
|
3762
3722
|
}
|
|
3763
3723
|
};
|
|
3764
|
-
|
|
3765
|
-
|
|
3724
|
+
function num(v) {
|
|
3725
|
+
const n = Math.round(v * 10), a = n < 0 ? -n : n, i = Math.floor(a / 10), d = a - i * 10;
|
|
3726
|
+
return (n < 0 ? "-" : "") + (d ? `${i}.${d}` : i);
|
|
3727
|
+
}
|
|
3728
|
+
// src/layer/vector/Path.js
|
|
3766
3729
|
/** @import {InteractiveLayerOptions} from '../Layer.js' */
|
|
3767
3730
|
/** @import {MaplairMap} from '../../map/Map.js' */
|
|
3768
3731
|
/** @import {Renderer} from './Renderer.js' */
|
|
@@ -3904,8 +3867,7 @@
|
|
|
3904
3867
|
return (this.options.stroke ? this.options.weight / 2 : 0) + (this._renderer.options.tolerance || 0);
|
|
3905
3868
|
}
|
|
3906
3869
|
};
|
|
3907
|
-
|
|
3908
|
-
//#region src/geo/LatLngBounds.js
|
|
3870
|
+
// src/geo/LatLngBounds.js
|
|
3909
3871
|
/** @import {LatLngExpression} from './LatLng.js' */
|
|
3910
3872
|
/**
|
|
3911
3873
|
* A geographical area: a `LatLngBounds`, or an array of geographical points (usually
|
|
@@ -3985,19 +3947,14 @@
|
|
|
3985
3947
|
extend(obj) {
|
|
3986
3948
|
const sw = this._southWest, ne = this._northEast;
|
|
3987
3949
|
let sw2, ne2;
|
|
3988
|
-
if (obj instanceof LatLng)
|
|
3989
|
-
|
|
3990
|
-
ne2 = obj;
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
if (!obj) return this;
|
|
3997
|
-
if (LatLng.validate(obj)) return this.extend(LatLng.from(obj));
|
|
3998
|
-
return this.extend(LatLngBounds.from(obj));
|
|
3999
|
-
}
|
|
4000
|
-
if (!sw && !ne) {
|
|
3950
|
+
if (obj instanceof LatLng) sw2 = ne2 = obj;
|
|
3951
|
+
else if (obj instanceof LatLngBounds) {
|
|
3952
|
+
({_southWest: sw2, _northEast: ne2} = obj);
|
|
3953
|
+
if (!sw2) return this;
|
|
3954
|
+
} else if (!obj) return this;
|
|
3955
|
+
else if (LatLng.validate(obj)) sw2 = ne2 = LatLng.from(obj);
|
|
3956
|
+
else return this.extend(LatLngBounds.from(obj));
|
|
3957
|
+
if (!sw) {
|
|
4001
3958
|
this._southWest = new LatLng(sw2.lat, sw2.lng);
|
|
4002
3959
|
this._northEast = new LatLng(ne2.lat, ne2.lng);
|
|
4003
3960
|
} else {
|
|
@@ -4155,8 +4112,7 @@
|
|
|
4155
4112
|
return !!(this._southWest && this._northEast);
|
|
4156
4113
|
}
|
|
4157
4114
|
};
|
|
4158
|
-
|
|
4159
|
-
//#region src/geo/LatLng.js
|
|
4115
|
+
// src/geo/LatLng.js
|
|
4160
4116
|
const coordinate = String.raw`([+-]?\d+(?:\.\d+)?)\s*°?`;
|
|
4161
4117
|
const separator = String.raw`(?:\s*[,;]\s*|\s+)`;
|
|
4162
4118
|
const plainRe = new RegExp(`^${coordinate}${separator}${coordinate}$`);
|
|
@@ -4376,8 +4332,7 @@
|
|
|
4376
4332
|
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;
|
|
4377
4333
|
return R * (2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)));
|
|
4378
4334
|
}
|
|
4379
|
-
|
|
4380
|
-
//#region src/geometry/LineUtil.js
|
|
4335
|
+
// src/geometry/LineUtil.js
|
|
4381
4336
|
var LineUtil_exports = /* @__PURE__ */ __exportAll({
|
|
4382
4337
|
_getBitCode: () => _getBitCode,
|
|
4383
4338
|
_getEdgeIntersection: () => _getEdgeIntersection,
|
|
@@ -4596,12 +4551,11 @@
|
|
|
4596
4551
|
if (!latlngs || latlngs.length === 0) throw new Error("latlngs not passed");
|
|
4597
4552
|
if (!isFlat(latlngs)) {
|
|
4598
4553
|
console.warn("latlngs are not flat! Only the first ring will be used");
|
|
4599
|
-
|
|
4554
|
+
return _projectRing(latlngs[0], crs);
|
|
4600
4555
|
}
|
|
4601
4556
|
return latlngs.map((latlng) => crs.project(LatLng.from(latlng)));
|
|
4602
4557
|
}
|
|
4603
|
-
|
|
4604
|
-
//#region src/layer/GeoJSONUtil.js
|
|
4558
|
+
// src/layer/GeoJSONUtil.js
|
|
4605
4559
|
/** @import {Feature, FeatureCollection, GeoJsonObject, Geometry} from 'geojson' */
|
|
4606
4560
|
/** @import {Layer} from './Layer.js' */
|
|
4607
4561
|
/** @import {LatLngExpression} from '../geo/LatLng.js' */
|
|
@@ -4669,8 +4623,7 @@
|
|
|
4669
4623
|
coordinates: latLngToCoords(layer.getLatLng(), precision)
|
|
4670
4624
|
});
|
|
4671
4625
|
}
|
|
4672
|
-
|
|
4673
|
-
//#region src/layer/vector/CircleMarker.js
|
|
4626
|
+
// src/layer/vector/CircleMarker.js
|
|
4674
4627
|
/** @import {Feature} from 'geojson' */
|
|
4675
4628
|
/** @import {LatLngExpression} from '../../geo/LatLng.js' */
|
|
4676
4629
|
/** @import {MaplairEvent} from '../../core/Events.js' */
|
|
@@ -4762,7 +4715,7 @@
|
|
|
4762
4715
|
return this;
|
|
4763
4716
|
}
|
|
4764
4717
|
_project() {
|
|
4765
|
-
this._point = this._map.latLngToLayerPoint(this._latlng);
|
|
4718
|
+
this._point = this._map.latLngToLayerPoint(this._latlng)._round();
|
|
4766
4719
|
this._pxRadius = this._radius;
|
|
4767
4720
|
this._updateBounds();
|
|
4768
4721
|
}
|
|
@@ -4793,8 +4746,7 @@
|
|
|
4793
4746
|
return pointToGeoJSON(this, precision);
|
|
4794
4747
|
}
|
|
4795
4748
|
};
|
|
4796
|
-
|
|
4797
|
-
//#region src/control/LegendControl.js
|
|
4749
|
+
// src/control/LegendControl.js
|
|
4798
4750
|
/** @import {ControlOptions} from './Control.js' */
|
|
4799
4751
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
4800
4752
|
/** @import {FeatureGroup} from '../layer/FeatureGroup.js' */
|
|
@@ -5013,8 +4965,7 @@
|
|
|
5013
4965
|
for (const [key, value] of Object.entries(attributes)) el.setAttribute(key, value);
|
|
5014
4966
|
return el;
|
|
5015
4967
|
}
|
|
5016
|
-
|
|
5017
|
-
//#region src/geo/crs/CRS.js
|
|
4968
|
+
// src/geo/crs/CRS.js
|
|
5018
4969
|
/** @import {LatLngExpression} from '../LatLng.js' */
|
|
5019
4970
|
/** @import {LatLngBoundsExpression} from '../LatLngBounds.js' */
|
|
5020
4971
|
/** @import {Point} from '../../geometry/Point.js' */
|
|
@@ -5158,8 +5109,7 @@
|
|
|
5158
5109
|
return new LatLngBounds(new LatLng(sw.lat - latShift, sw.lng - lngShift), new LatLng(ne.lat - latShift, ne.lng - lngShift));
|
|
5159
5110
|
}
|
|
5160
5111
|
};
|
|
5161
|
-
|
|
5162
|
-
//#region src/geo/crs/EarthCRS.js
|
|
5112
|
+
// src/geo/crs/EarthCRS.js
|
|
5163
5113
|
/** @import {LatLng} from '../LatLng.js' */
|
|
5164
5114
|
/**
|
|
5165
5115
|
* Serves as the base for CRS that are global such that they cover the earth.
|
|
@@ -5191,8 +5141,7 @@
|
|
|
5191
5141
|
return haversineDistance(latlng1, latlng2, this.R);
|
|
5192
5142
|
}
|
|
5193
5143
|
};
|
|
5194
|
-
|
|
5195
|
-
//#region src/geo/projection/Projection.SphericalMercator.js
|
|
5144
|
+
// src/geo/projection/SphericalMercatorProjection.js
|
|
5196
5145
|
/** @import {Projection} from './index.js' */
|
|
5197
5146
|
const earthRadius$1 = 6378137;
|
|
5198
5147
|
/**
|
|
@@ -5201,7 +5150,7 @@
|
|
|
5201
5150
|
* a sphere. Used by the `EPSG:3857` CRS.
|
|
5202
5151
|
* @type {Projection & {R: number, MAX_LATITUDE: number}}
|
|
5203
5152
|
*/
|
|
5204
|
-
const
|
|
5153
|
+
const SphericalMercatorProjection = {
|
|
5205
5154
|
R: earthRadius$1,
|
|
5206
5155
|
MAX_LATITUDE: 85.0511287798,
|
|
5207
5156
|
project(latlng) {
|
|
@@ -5219,8 +5168,7 @@
|
|
|
5219
5168
|
return new Bounds([-d, -d], [d, d]);
|
|
5220
5169
|
})()
|
|
5221
5170
|
};
|
|
5222
|
-
|
|
5223
|
-
//#region src/geometry/Transformation.js
|
|
5171
|
+
// src/geometry/Transformation.js
|
|
5224
5172
|
/**
|
|
5225
5173
|
* Represents an affine transformation: a set of coefficients `a`, `b`, `c`, `d`
|
|
5226
5174
|
* for transforming a point of a form `(x, y)` into `(a*x + b, c*y + d)` and doing
|
|
@@ -5284,8 +5232,7 @@
|
|
|
5284
5232
|
return new Point((point.x / scale - this._b) / this._a, (point.y / scale - this._d) / this._c);
|
|
5285
5233
|
}
|
|
5286
5234
|
};
|
|
5287
|
-
|
|
5288
|
-
//#region src/geo/crs/EPSG3857.js
|
|
5235
|
+
// src/geo/crs/EPSG3857.js
|
|
5289
5236
|
/** @import {Projection} from '../projection/index.js' */
|
|
5290
5237
|
/**
|
|
5291
5238
|
* The most common CRS for online maps, used by almost all free and commercial
|
|
@@ -5296,10 +5243,10 @@
|
|
|
5296
5243
|
/** @type {string} */
|
|
5297
5244
|
static code = "EPSG:3857";
|
|
5298
5245
|
/** @type {Projection} */
|
|
5299
|
-
static projection =
|
|
5246
|
+
static projection = SphericalMercatorProjection;
|
|
5300
5247
|
/** @type {Transformation} */
|
|
5301
5248
|
static transformation = /* @__PURE__ */ (() => {
|
|
5302
|
-
const scale = .5 / (Math.PI *
|
|
5249
|
+
const scale = .5 / (Math.PI * SphericalMercatorProjection.R);
|
|
5303
5250
|
return new Transformation(scale, .5, -scale, .5);
|
|
5304
5251
|
})();
|
|
5305
5252
|
};
|
|
@@ -5310,8 +5257,7 @@
|
|
|
5310
5257
|
/** @type {string} */
|
|
5311
5258
|
static code = "EPSG:900913";
|
|
5312
5259
|
};
|
|
5313
|
-
|
|
5314
|
-
//#region src/dom/PosAnimation.js
|
|
5260
|
+
// src/dom/PosAnimation.js
|
|
5315
5261
|
/** @import {Point} from '../geometry/Point.js' */
|
|
5316
5262
|
/** @import {MaplairEvent} from '../core/Events.js' */
|
|
5317
5263
|
/**
|
|
@@ -5387,8 +5333,7 @@
|
|
|
5387
5333
|
return 1 - (1 - t) ** this._easeOutPower;
|
|
5388
5334
|
}
|
|
5389
5335
|
};
|
|
5390
|
-
|
|
5391
|
-
//#region src/control/ZoomControl.js
|
|
5336
|
+
// src/control/ZoomControl.js
|
|
5392
5337
|
/** @import {ControlOptions} from './Control.js' */
|
|
5393
5338
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
5394
5339
|
/**
|
|
@@ -5442,8 +5387,8 @@
|
|
|
5442
5387
|
*/
|
|
5443
5388
|
onAdd(map) {
|
|
5444
5389
|
const zoomName = "maplair-control-zoom", container = create("div", `${zoomName} maplair-bar`), options = this.options;
|
|
5445
|
-
this._zoomInButton = this._createButton(options.zoomInText, I18n.translate("Zoom in"), `${zoomName}-in`, container, this.
|
|
5446
|
-
this._zoomOutButton = this._createButton(options.zoomOutText, I18n.translate("Zoom out"), `${zoomName}-out`, container, this.
|
|
5390
|
+
this._zoomInButton = this._createButton(options.zoomInText, I18n.translate("Zoom in"), `${zoomName}-in`, container, (e) => this._zoom(e, 1));
|
|
5391
|
+
this._zoomOutButton = this._createButton(options.zoomOutText, I18n.translate("Zoom out"), `${zoomName}-out`, container, (e) => this._zoom(e, -1));
|
|
5447
5392
|
this._updateDisabled();
|
|
5448
5393
|
map.on("zoomend zoomlevelschange", this._updateDisabled, this);
|
|
5449
5394
|
return container;
|
|
@@ -5473,16 +5418,11 @@
|
|
|
5473
5418
|
this._updateDisabled();
|
|
5474
5419
|
return this;
|
|
5475
5420
|
}
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
}
|
|
5482
|
-
_zoomOut(e) {
|
|
5483
|
-
if (!this._disabled && this._map._zoom > this._map.getMinZoom()) {
|
|
5484
|
-
this._map._setUserEvent(e);
|
|
5485
|
-
this._map.zoomOut(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1));
|
|
5421
|
+
_zoom(e, dir) {
|
|
5422
|
+
const map = this._map;
|
|
5423
|
+
if (!this._disabled && (dir > 0 ? map._zoom < map.getMaxZoom() : map._zoom > map.getMinZoom())) {
|
|
5424
|
+
map._setUserEvent(e);
|
|
5425
|
+
map.zoomIn(dir * map.options.zoomDelta * (e.shiftKey ? 3 : 1));
|
|
5486
5426
|
}
|
|
5487
5427
|
}
|
|
5488
5428
|
_createButton(html, title, className, container, fn) {
|
|
@@ -5492,24 +5432,19 @@
|
|
|
5492
5432
|
link.title = title;
|
|
5493
5433
|
link.setAttribute("aria-label", title);
|
|
5494
5434
|
disableClickPropagation(link);
|
|
5495
|
-
on(link, "click",
|
|
5496
|
-
|
|
5497
|
-
|
|
5435
|
+
on(link, "click", (e) => {
|
|
5436
|
+
stop(e);
|
|
5437
|
+
fn.call(this, e);
|
|
5438
|
+
this._refocusOnMap(e);
|
|
5439
|
+
});
|
|
5498
5440
|
return link;
|
|
5499
5441
|
}
|
|
5500
5442
|
_updateDisabled() {
|
|
5501
|
-
const map = this._map
|
|
5502
|
-
this._zoomInButton.
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
if (this._disabled || map._zoom === map.getMinZoom()) {
|
|
5507
|
-
this._zoomOutButton.classList.add(className);
|
|
5508
|
-
this._zoomOutButton.setAttribute("aria-disabled", "true");
|
|
5509
|
-
}
|
|
5510
|
-
if (this._disabled || map._zoom === map.getMaxZoom()) {
|
|
5511
|
-
this._zoomInButton.classList.add(className);
|
|
5512
|
-
this._zoomInButton.setAttribute("aria-disabled", "true");
|
|
5443
|
+
const map = this._map;
|
|
5444
|
+
for (const [button, limit] of [[this._zoomInButton, map.getMaxZoom()], [this._zoomOutButton, map.getMinZoom()]]) {
|
|
5445
|
+
const disabled = this._disabled || map._zoom === limit;
|
|
5446
|
+
button.classList.toggle("maplair-disabled", disabled);
|
|
5447
|
+
button.setAttribute("aria-disabled", `${disabled}`);
|
|
5513
5448
|
}
|
|
5514
5449
|
}
|
|
5515
5450
|
/**
|
|
@@ -5527,8 +5462,7 @@
|
|
|
5527
5462
|
});
|
|
5528
5463
|
}
|
|
5529
5464
|
};
|
|
5530
|
-
|
|
5531
|
-
//#region src/layer/LayerGroup.js
|
|
5465
|
+
// src/layer/LayerGroup.js
|
|
5532
5466
|
/** @import {Feature, FeatureCollection} from 'geojson' */
|
|
5533
5467
|
/** @import {InteractiveLayerOptions} from './Layer.js' */
|
|
5534
5468
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
@@ -5575,7 +5509,7 @@
|
|
|
5575
5509
|
* @returns {this}
|
|
5576
5510
|
*/
|
|
5577
5511
|
removeLayer(layer) {
|
|
5578
|
-
const id = layer
|
|
5512
|
+
const id = typeof layer === "number" ? layer : this.getLayerId(layer);
|
|
5579
5513
|
if (this._map && this._layers[id]) this._map.removeLayer(this._layers[id]);
|
|
5580
5514
|
delete this._layers[id];
|
|
5581
5515
|
return this;
|
|
@@ -5707,8 +5641,7 @@
|
|
|
5707
5641
|
};
|
|
5708
5642
|
}
|
|
5709
5643
|
};
|
|
5710
|
-
|
|
5711
|
-
//#region src/layer/FeatureGroup.js
|
|
5644
|
+
// src/layer/FeatureGroup.js
|
|
5712
5645
|
/** @import {Layer, InteractiveLayerOptions} from './Layer.js' */
|
|
5713
5646
|
/** @import {LayerEvent} from '../core/Events.js' */
|
|
5714
5647
|
/** @import {PathOptions} from './vector/Path.js' */
|
|
@@ -5803,17 +5736,18 @@
|
|
|
5803
5736
|
}
|
|
5804
5737
|
/**
|
|
5805
5738
|
* Returns the `LatLngBounds` of the feature group (created from bounds and
|
|
5806
|
-
* coordinates of its children).
|
|
5739
|
+
* coordinates of its children, including the layers of nested layer groups).
|
|
5807
5740
|
* @returns {LatLngBounds}
|
|
5808
5741
|
*/
|
|
5809
5742
|
getBounds() {
|
|
5810
5743
|
const bounds = new LatLngBounds();
|
|
5811
|
-
for (const layer of Object.values(this._layers))
|
|
5744
|
+
for (const layer of Object.values(this._layers)) if (layer.getBounds) bounds.extend(layer.getBounds());
|
|
5745
|
+
else if (layer.getLatLng) bounds.extend(layer.getLatLng());
|
|
5746
|
+
else if (layer instanceof LayerGroup) bounds.extend(FeatureGroup.prototype.getBounds.call(layer));
|
|
5812
5747
|
return bounds;
|
|
5813
5748
|
}
|
|
5814
5749
|
};
|
|
5815
|
-
|
|
5816
|
-
//#region src/layer/DivOverlay.js
|
|
5750
|
+
// src/layer/DivOverlay.js
|
|
5817
5751
|
/** @import {InteractiveLayerOptions} from './Layer.js' */
|
|
5818
5752
|
/** @import {LatLngExpression} from '../geo/LatLng.js' */
|
|
5819
5753
|
/** @import {PointExpression} from '../geometry/Point.js' */
|
|
@@ -6152,7 +6086,7 @@
|
|
|
6152
6086
|
}
|
|
6153
6087
|
_updatePosition() {
|
|
6154
6088
|
if (!this._map) return;
|
|
6155
|
-
const pos = this._map.latLngToLayerPoint(this._latlng), offset = Point.from(this.options.offset);
|
|
6089
|
+
const pos = this._map.latLngToLayerPoint(this._latlng)._round(), offset = Point.from(this.options.offset);
|
|
6156
6090
|
this._setContainerPosition(pos.add(this._getAnchor()));
|
|
6157
6091
|
const bottom = this._containerBottom = -offset.y, left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x;
|
|
6158
6092
|
if (this.options.overflow) {
|
|
@@ -6185,8 +6119,7 @@
|
|
|
6185
6119
|
Layer.include(layerDivOverlayMethods);
|
|
6186
6120
|
}
|
|
6187
6121
|
};
|
|
6188
|
-
|
|
6189
|
-
//#region src/layer/Popup.js
|
|
6122
|
+
// src/layer/Popup.js
|
|
6190
6123
|
/** @import {DivOverlayOptions, DivOverlayContent} from './DivOverlay.js' */
|
|
6191
6124
|
/** @import {LatLngExpression} from '../geo/LatLng.js' */
|
|
6192
6125
|
/** @import {PointExpression} from '../geometry/Point.js' */
|
|
@@ -6392,7 +6325,7 @@
|
|
|
6392
6325
|
},
|
|
6393
6326
|
_openPopup(e) {
|
|
6394
6327
|
if (!this._popup || !this._map) return;
|
|
6395
|
-
|
|
6328
|
+
stopPropagation(e);
|
|
6396
6329
|
const target = e.propagatedFrom ?? e.target;
|
|
6397
6330
|
if (this._popup._source === target && !(target instanceof Path)) {
|
|
6398
6331
|
if (this._map.hasLayer(this._popup)) this.closePopup();
|
|
@@ -6544,9 +6477,6 @@
|
|
|
6544
6477
|
const wrapper = this._wrapper = create("div", `${prefix}-content-wrapper`, container);
|
|
6545
6478
|
this._contentNode = create("div", `${prefix}-content`, wrapper);
|
|
6546
6479
|
disableClickPropagation(container);
|
|
6547
|
-
on(container, "keydown", (e) => {
|
|
6548
|
-
if (e.key === "Escape" && this.options.closeOnEscapeKey) this.close();
|
|
6549
|
-
});
|
|
6550
6480
|
disableScrollPropagation(this._contentNode);
|
|
6551
6481
|
on(container, "contextmenu", stopPropagation);
|
|
6552
6482
|
this._tipContainer = create("div", `${prefix}-tip-container`, container);
|
|
@@ -6562,14 +6492,12 @@
|
|
|
6562
6492
|
});
|
|
6563
6493
|
}
|
|
6564
6494
|
if (this.options.trackResize) {
|
|
6565
|
-
this._resizeObserver = new ResizeObserver((
|
|
6495
|
+
this._resizeObserver = new ResizeObserver(() => {
|
|
6566
6496
|
if (!this._map) return;
|
|
6567
|
-
this._containerWidth = entries[0]?.contentRect?.width;
|
|
6568
|
-
this._containerHeight = entries[0]?.contentRect?.height;
|
|
6569
6497
|
this._updateLayout();
|
|
6570
6498
|
this._updatePosition();
|
|
6571
6499
|
this._adjustPan();
|
|
6572
|
-
})
|
|
6500
|
+
});
|
|
6573
6501
|
this._resizeObserver.observe(this._contentNode);
|
|
6574
6502
|
}
|
|
6575
6503
|
}
|
|
@@ -6577,11 +6505,10 @@
|
|
|
6577
6505
|
const container = this._contentNode, style = container.style;
|
|
6578
6506
|
style.maxWidth = `${this.options.maxWidth}px`;
|
|
6579
6507
|
style.minWidth = `${this.options.minWidth}px`;
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
} else container.classList.remove(scrolledClass);
|
|
6508
|
+
style.height = "";
|
|
6509
|
+
const maxHeight = this.options.maxHeight, scrolled = !!maxHeight && container.offsetHeight > maxHeight;
|
|
6510
|
+
if (scrolled) style.height = `${maxHeight}px`;
|
|
6511
|
+
container.classList.toggle("maplair-popup-scrolled", scrolled);
|
|
6585
6512
|
this._containerWidth = this._container.offsetWidth;
|
|
6586
6513
|
this._containerHeight = this._container.offsetHeight;
|
|
6587
6514
|
this._containerMarginBottom = parseInt(getComputedStyle(this._container).marginBottom, 10) || 0;
|
|
@@ -6625,8 +6552,7 @@
|
|
|
6625
6552
|
Layer.include(layerPopupMethods);
|
|
6626
6553
|
}
|
|
6627
6554
|
};
|
|
6628
|
-
|
|
6629
|
-
//#region src/layer/Tooltip.js
|
|
6555
|
+
// src/layer/Tooltip.js
|
|
6630
6556
|
const directions = [
|
|
6631
6557
|
"top",
|
|
6632
6558
|
"bottom",
|
|
@@ -6733,8 +6659,9 @@
|
|
|
6733
6659
|
* @returns {this}
|
|
6734
6660
|
*/
|
|
6735
6661
|
bindTooltip(content, options) {
|
|
6736
|
-
|
|
6737
|
-
this._tooltip
|
|
6662
|
+
const old = this.isTooltipOpen() ? null : this._tooltip;
|
|
6663
|
+
if (this._tooltip) this.unbindTooltip();
|
|
6664
|
+
this._tooltip = this._initOverlay(Tooltip, old, content, options);
|
|
6738
6665
|
this._initTooltipInteractions();
|
|
6739
6666
|
if (this._tooltip.options.permanent && this._map && this._map.hasLayer(this)) this.openTooltip();
|
|
6740
6667
|
return this;
|
|
@@ -6753,21 +6680,20 @@
|
|
|
6753
6680
|
return this;
|
|
6754
6681
|
},
|
|
6755
6682
|
_initTooltipInteractions(remove) {
|
|
6756
|
-
|
|
6757
|
-
const onOff = remove ? "off" : "on", events = {
|
|
6683
|
+
const { permanent, sticky } = this._tooltip.options, events = {
|
|
6758
6684
|
remove: this.closeTooltip,
|
|
6759
6685
|
move: this._moveTooltip
|
|
6760
6686
|
};
|
|
6761
|
-
if (
|
|
6687
|
+
if (permanent) events.add = this._openTooltip;
|
|
6688
|
+
else {
|
|
6762
6689
|
events.pointerover = this._openTooltip;
|
|
6763
6690
|
events.pointerout = this.closeTooltip;
|
|
6764
6691
|
events.click = this._openTooltip;
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
}
|
|
6768
|
-
if (
|
|
6769
|
-
this[
|
|
6770
|
-
this._tooltipHandlersAdded = !remove;
|
|
6692
|
+
events.add = this._toggleFocusListeners;
|
|
6693
|
+
if (this._map) this._toggleFocusListeners(!remove);
|
|
6694
|
+
}
|
|
6695
|
+
if (sticky) events.pointermove = this._moveTooltip;
|
|
6696
|
+
this[remove ? "off" : "on"](events);
|
|
6771
6697
|
},
|
|
6772
6698
|
/**
|
|
6773
6699
|
* Opens the bound tooltip at the specified `latlng` or at the default tooltip
|
|
@@ -6833,9 +6759,9 @@
|
|
|
6833
6759
|
getTooltip() {
|
|
6834
6760
|
return this._tooltip;
|
|
6835
6761
|
},
|
|
6836
|
-
|
|
6837
|
-
if (this.getElement) this._addFocusListenersOnLayer(this,
|
|
6838
|
-
else if (this.eachLayer) this.eachLayer((layer) => this._addFocusListenersOnLayer(layer,
|
|
6762
|
+
_toggleFocusListeners(add) {
|
|
6763
|
+
if (this.getElement) this._addFocusListenersOnLayer(this, !add);
|
|
6764
|
+
else if (this.eachLayer) this.eachLayer((layer) => this._addFocusListenersOnLayer(layer, !add), this);
|
|
6839
6765
|
},
|
|
6840
6766
|
_addFocusListenersOnLayer(layer, remove) {
|
|
6841
6767
|
const el = typeof layer.getElement === "function" && layer.getElement();
|
|
@@ -7068,7 +6994,7 @@
|
|
|
7068
6994
|
};
|
|
7069
6995
|
}
|
|
7070
6996
|
_updatePosition() {
|
|
7071
|
-
const pos = this._map.latLngToLayerPoint(this._latlng);
|
|
6997
|
+
const pos = this._map.latLngToLayerPoint(this._latlng)._round();
|
|
7072
6998
|
this._setPosition(pos);
|
|
7073
6999
|
}
|
|
7074
7000
|
/**
|
|
@@ -7097,8 +7023,7 @@
|
|
|
7097
7023
|
Layer.include(layerTooltipMethods);
|
|
7098
7024
|
}
|
|
7099
7025
|
};
|
|
7100
|
-
|
|
7101
|
-
//#region src/layer/vector/Renderer.getRenderer.js
|
|
7026
|
+
// src/layer/vector/Renderer.getRenderer.js
|
|
7102
7027
|
var Renderer_getRenderer_exports = /* @__PURE__ */ __exportAll({ register: () => register });
|
|
7103
7028
|
/** @import {MaplairMap} from '../../map/Map.js' */
|
|
7104
7029
|
/** @import {Path} from './Path.js' */
|
|
@@ -7114,11 +7039,11 @@
|
|
|
7114
7039
|
* are respected, and that the renderers do exist on the map.
|
|
7115
7040
|
* @internal
|
|
7116
7041
|
* @param {Path} layer
|
|
7117
|
-
* @returns {Renderer}
|
|
7042
|
+
* @returns {Renderer|undefined}
|
|
7118
7043
|
*/
|
|
7119
7044
|
getRenderer(layer) {
|
|
7120
|
-
const renderer = layer.options.renderer ?? this._getPaneRenderer(layer) ?? this.options.renderer ?? (this._renderer ??= layer._createRenderer());
|
|
7121
|
-
if (!this.hasLayer(renderer)) this.addLayer(renderer);
|
|
7045
|
+
const renderer = layer.options.renderer ?? this._getPaneRenderer(layer) ?? this.options.renderer ?? (this._renderer ??= layer._createRenderer?.());
|
|
7046
|
+
if (renderer && !this.hasLayer(renderer)) this.addLayer(renderer);
|
|
7122
7047
|
return renderer;
|
|
7123
7048
|
},
|
|
7124
7049
|
_getPaneRenderer(layer) {
|
|
@@ -7157,15 +7082,14 @@
|
|
|
7157
7082
|
if (this.options.preferCanvas !== void 0) console.error("MaplairMap: preferCanvas option has been removed. Use renderer: new Canvas() instead.");
|
|
7158
7083
|
});
|
|
7159
7084
|
}
|
|
7160
|
-
|
|
7161
|
-
//#region src/core/Handler.js
|
|
7085
|
+
// src/core/Handler.js
|
|
7162
7086
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
7163
7087
|
/**
|
|
7164
7088
|
* Abstract class for map interaction handlers, the base class of the handlers that
|
|
7165
7089
|
* are used internally to inject interaction features like dragging to classes like
|
|
7166
7090
|
* `MaplairMap` and `Marker`.
|
|
7167
7091
|
*
|
|
7168
|
-
* Classes inheriting from `Handler`
|
|
7092
|
+
* Classes inheriting from `Handler` implement the two following extension methods:
|
|
7169
7093
|
*
|
|
7170
7094
|
* * `addHooks()` is called when the handler is enabled, should add event hooks.
|
|
7171
7095
|
* * `removeHooks()` is called when the handler is disabled, should remove the event
|
|
@@ -7208,6 +7132,14 @@
|
|
|
7208
7132
|
return !!this._enabled;
|
|
7209
7133
|
}
|
|
7210
7134
|
/**
|
|
7135
|
+
* Called when the handler is enabled, should add event hooks.
|
|
7136
|
+
*/
|
|
7137
|
+
addHooks() {}
|
|
7138
|
+
/**
|
|
7139
|
+
* Called when the handler is disabled, should remove the event hooks added previously.
|
|
7140
|
+
*/
|
|
7141
|
+
removeHooks() {}
|
|
7142
|
+
/**
|
|
7211
7143
|
* Adds a new handler of this class to the given map with the given name, which is
|
|
7212
7144
|
* then available as the property of the map with this name.
|
|
7213
7145
|
* @template {typeof Handler} T
|
|
@@ -7221,8 +7153,7 @@
|
|
|
7221
7153
|
return this;
|
|
7222
7154
|
}
|
|
7223
7155
|
};
|
|
7224
|
-
|
|
7225
|
-
//#region src/map/handler/BoxZoomHandler.js
|
|
7156
|
+
// src/map/handler/BoxZoomHandler.js
|
|
7226
7157
|
/** @import {MaplairMap} from '../Map.js' */
|
|
7227
7158
|
/** @import {MaplairEvent} from '../../core/Events.js' */
|
|
7228
7159
|
/**
|
|
@@ -7259,23 +7190,19 @@
|
|
|
7259
7190
|
*/
|
|
7260
7191
|
constructor(map) {
|
|
7261
7192
|
super(map);
|
|
7262
|
-
this._container = map._container;
|
|
7263
|
-
this._pane = map._panes.overlayPane;
|
|
7264
|
-
this._resetStateTimeout = 0;
|
|
7265
|
-
map.on("unload", this._destroy, this);
|
|
7266
7193
|
this.callInitHooks(BoxZoomHandler);
|
|
7267
7194
|
}
|
|
7268
7195
|
/**
|
|
7269
7196
|
* Called when the handler is enabled, adds the event hooks.
|
|
7270
7197
|
*/
|
|
7271
7198
|
addHooks() {
|
|
7272
|
-
on(this._container, "pointerdown", this._onPointerDown, this);
|
|
7199
|
+
on(this._map._container, "pointerdown", this._onPointerDown, this);
|
|
7273
7200
|
}
|
|
7274
7201
|
/**
|
|
7275
7202
|
* Called when the handler is disabled, removes the event hooks.
|
|
7276
7203
|
*/
|
|
7277
7204
|
removeHooks() {
|
|
7278
|
-
off(this._container, "pointerdown", this._onPointerDown, this);
|
|
7205
|
+
off(this._map._container, "pointerdown", this._onPointerDown, this);
|
|
7279
7206
|
}
|
|
7280
7207
|
/**
|
|
7281
7208
|
* Returns `true` if a box has been drawn by the current or last interaction.
|
|
@@ -7284,42 +7211,34 @@
|
|
|
7284
7211
|
moved() {
|
|
7285
7212
|
return this._moved;
|
|
7286
7213
|
}
|
|
7287
|
-
_destroy() {
|
|
7288
|
-
this._pane.remove();
|
|
7289
|
-
delete this._pane;
|
|
7290
|
-
}
|
|
7291
7214
|
_resetState() {
|
|
7292
|
-
this._resetStateTimeout
|
|
7215
|
+
clearTimeout(this._resetStateTimeout);
|
|
7293
7216
|
this._moved = false;
|
|
7294
7217
|
}
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
this.
|
|
7299
|
-
|
|
7218
|
+
_toggleListeners(onOff) {
|
|
7219
|
+
onOff(this._map._container, {
|
|
7220
|
+
contextmenu: stop,
|
|
7221
|
+
pointermove: this._onPointerMove,
|
|
7222
|
+
pointerup: this._onPointerUp
|
|
7223
|
+
}, this);
|
|
7224
|
+
onOff(document, "keydown", this._onKeyDown, this);
|
|
7300
7225
|
}
|
|
7301
7226
|
_onPointerDown(e) {
|
|
7302
7227
|
if (!e.shiftKey || e.button !== 0) return false;
|
|
7303
|
-
this._clearDeferredResetState();
|
|
7304
7228
|
this._resetState();
|
|
7305
7229
|
preventDefault(e);
|
|
7306
7230
|
this._startPoint = this._map.pointerEventToContainerPoint(e);
|
|
7307
|
-
|
|
7308
|
-
contextmenu: stop,
|
|
7309
|
-
pointermove: this._onPointerMove,
|
|
7310
|
-
pointerup: this._onPointerUp,
|
|
7311
|
-
keydown: this._onKeyDown
|
|
7312
|
-
}, this);
|
|
7313
|
-
on(document, "keydown", this._onKeyDown, this);
|
|
7231
|
+
this._toggleListeners(on);
|
|
7314
7232
|
}
|
|
7315
7233
|
_onPointerMove(e) {
|
|
7234
|
+
const map = this._map;
|
|
7316
7235
|
if (!this._moved) {
|
|
7317
7236
|
this._moved = true;
|
|
7318
|
-
this._box = create("div", "maplair-zoom-box",
|
|
7319
|
-
|
|
7320
|
-
|
|
7237
|
+
this._box = create("div", "maplair-zoom-box", map._container);
|
|
7238
|
+
map._container.classList.add("maplair-crosshair");
|
|
7239
|
+
map.fire("boxzoomstart");
|
|
7321
7240
|
}
|
|
7322
|
-
this._point =
|
|
7241
|
+
this._point = map.pointerEventToContainerPoint(e);
|
|
7323
7242
|
const bounds = new Bounds(this._point, this._startPoint), size = bounds.getSize();
|
|
7324
7243
|
setPosition(this._box, bounds.min);
|
|
7325
7244
|
this._box.style.width = `${size.x}px`;
|
|
@@ -7328,21 +7247,15 @@
|
|
|
7328
7247
|
_finish() {
|
|
7329
7248
|
if (this._moved) {
|
|
7330
7249
|
this._box.remove();
|
|
7331
|
-
this._container.classList.remove("maplair-crosshair");
|
|
7250
|
+
this._map._container.classList.remove("maplair-crosshair");
|
|
7332
7251
|
}
|
|
7333
|
-
|
|
7334
|
-
contextmenu: stop,
|
|
7335
|
-
pointermove: this._onPointerMove,
|
|
7336
|
-
pointerup: this._onPointerUp
|
|
7337
|
-
}, this);
|
|
7338
|
-
off(document, "keydown", this._onKeyDown, this);
|
|
7252
|
+
this._toggleListeners(off);
|
|
7339
7253
|
}
|
|
7340
7254
|
_onPointerUp(e) {
|
|
7341
7255
|
if (e.button !== 0) return;
|
|
7342
7256
|
this._finish();
|
|
7343
7257
|
if (!this._moved) return;
|
|
7344
|
-
this.
|
|
7345
|
-
this._resetStateTimeout = setTimeout(this._resetState.bind(this), 0);
|
|
7258
|
+
this._resetStateTimeout = setTimeout(() => this._resetState(), 0);
|
|
7346
7259
|
const bounds = new LatLngBounds(this._map.containerPointToLatLng(this._startPoint), this._map.containerPointToLatLng(this._point));
|
|
7347
7260
|
this._map._setUserEvent(e);
|
|
7348
7261
|
if (this._map.getBoundsZoom(bounds) !== Infinity) this._map.fitBounds(bounds);
|
|
@@ -7351,7 +7264,6 @@
|
|
|
7351
7264
|
_onKeyDown(e) {
|
|
7352
7265
|
if (e.code === "Escape") {
|
|
7353
7266
|
this._finish();
|
|
7354
|
-
this._clearDeferredResetState();
|
|
7355
7267
|
this._resetState();
|
|
7356
7268
|
}
|
|
7357
7269
|
}
|
|
@@ -7365,8 +7277,7 @@
|
|
|
7365
7277
|
MaplairMap.addInitHook("addHandler", "boxZoom", BoxZoomHandler);
|
|
7366
7278
|
}
|
|
7367
7279
|
};
|
|
7368
|
-
|
|
7369
|
-
//#region src/map/handler/DoubleClickZoomHandler.js
|
|
7280
|
+
// src/map/handler/DoubleClickZoomHandler.js
|
|
7370
7281
|
/** @import {MaplairMap} from '../Map.js' */
|
|
7371
7282
|
/**
|
|
7372
7283
|
* Map options of `DoubleClickZoomHandler`.
|
|
@@ -7432,8 +7343,7 @@
|
|
|
7432
7343
|
MaplairMap.addInitHook("addHandler", "doubleClickZoom", DoubleClickZoomHandler);
|
|
7433
7344
|
}
|
|
7434
7345
|
};
|
|
7435
|
-
|
|
7436
|
-
//#region src/dom/Draggable.js
|
|
7346
|
+
// src/dom/Draggable.js
|
|
7437
7347
|
/** @import {MaplairEvent, DragEndEvent} from '../core/Events.js' */
|
|
7438
7348
|
/**
|
|
7439
7349
|
* Options of `Draggable`.
|
|
@@ -7506,7 +7416,8 @@
|
|
|
7506
7416
|
_onDown(e) {
|
|
7507
7417
|
this._moved = false;
|
|
7508
7418
|
if (this._element.classList.contains("maplair-zoom-anim")) return;
|
|
7509
|
-
|
|
7419
|
+
const pointers = getPointers().length;
|
|
7420
|
+
if (pointers > 1) {
|
|
7510
7421
|
if (Draggable._dragging === this) this.finishDrag();
|
|
7511
7422
|
return;
|
|
7512
7423
|
}
|
|
@@ -7514,6 +7425,7 @@
|
|
|
7514
7425
|
Draggable._dragging = this;
|
|
7515
7426
|
disableImageDrag();
|
|
7516
7427
|
if (this._moving) return;
|
|
7428
|
+
if (!pointers && e.isTrusted) e.target.setPointerCapture(e.pointerId);
|
|
7517
7429
|
this.fire("down");
|
|
7518
7430
|
const sizedParent = getSizedParentNode(this._element);
|
|
7519
7431
|
this._startPoint = new Point(e.clientX, e.clientY);
|
|
@@ -7583,8 +7495,7 @@
|
|
|
7583
7495
|
});
|
|
7584
7496
|
}
|
|
7585
7497
|
};
|
|
7586
|
-
|
|
7587
|
-
//#region src/map/handler/DragHandler.js
|
|
7498
|
+
// src/map/handler/DragHandler.js
|
|
7588
7499
|
/** @import {MaplairMap} from '../Map.js' */
|
|
7589
7500
|
/** @import {MaplairEvent, DragEndEvent} from '../../core/Events.js' */
|
|
7590
7501
|
/**
|
|
@@ -7771,8 +7682,7 @@
|
|
|
7771
7682
|
MaplairMap.addInitHook("addHandler", "dragging", DragHandler);
|
|
7772
7683
|
}
|
|
7773
7684
|
};
|
|
7774
|
-
|
|
7775
|
-
//#region src/map/handler/KeyboardHandler.js
|
|
7685
|
+
// src/map/handler/KeyboardHandler.js
|
|
7776
7686
|
/** @import {MaplairMap} from '../Map.js' */
|
|
7777
7687
|
/** @import {MaplairEvent} from '../../core/Events.js' */
|
|
7778
7688
|
/**
|
|
@@ -7822,8 +7732,6 @@
|
|
|
7822
7732
|
*/
|
|
7823
7733
|
constructor(map) {
|
|
7824
7734
|
super(map);
|
|
7825
|
-
this._setPanDelta(map.options.keyboardPanDelta);
|
|
7826
|
-
this._setZoomDelta(map.options.zoomDelta);
|
|
7827
7735
|
this.callInitHooks(KeyboardHandler);
|
|
7828
7736
|
}
|
|
7829
7737
|
/**
|
|
@@ -7837,27 +7745,21 @@
|
|
|
7837
7745
|
on(container, {
|
|
7838
7746
|
focus: this._onFocus,
|
|
7839
7747
|
blur: this._onBlur,
|
|
7840
|
-
pointerdown: this._onPointerDown
|
|
7841
|
-
|
|
7842
|
-
this._map.on({
|
|
7843
|
-
focus: this._addHooks,
|
|
7844
|
-
blur: this._removeHooks
|
|
7748
|
+
pointerdown: this._onPointerDown,
|
|
7749
|
+
keydown: this._onContainerKeyDown
|
|
7845
7750
|
}, this);
|
|
7846
7751
|
}
|
|
7847
7752
|
/**
|
|
7848
7753
|
* Called when the handler is disabled, removes the event hooks.
|
|
7849
7754
|
*/
|
|
7850
7755
|
removeHooks() {
|
|
7851
|
-
this.
|
|
7756
|
+
off(document, "keydown", this._onKeyDown, this);
|
|
7852
7757
|
if (this._map.options.ariaKeyShortcuts) this._map._container.removeAttribute("aria-keyshortcuts");
|
|
7853
7758
|
off(this._map._container, {
|
|
7854
7759
|
focus: this._onFocus,
|
|
7855
7760
|
blur: this._onBlur,
|
|
7856
|
-
pointerdown: this._onPointerDown
|
|
7857
|
-
|
|
7858
|
-
this._map.off({
|
|
7859
|
-
focus: this._addHooks,
|
|
7860
|
-
blur: this._removeHooks
|
|
7761
|
+
pointerdown: this._onPointerDown,
|
|
7762
|
+
keydown: this._onContainerKeyDown
|
|
7861
7763
|
}, this);
|
|
7862
7764
|
this._help?.remove();
|
|
7863
7765
|
this._help = null;
|
|
@@ -7903,29 +7805,21 @@
|
|
|
7903
7805
|
}
|
|
7904
7806
|
_onFocus() {
|
|
7905
7807
|
this._focused = true;
|
|
7808
|
+
on(document, "keydown", this._onKeyDown, this);
|
|
7906
7809
|
this._map.fire("focus");
|
|
7907
7810
|
}
|
|
7908
7811
|
_onBlur() {
|
|
7909
7812
|
this._focused = false;
|
|
7813
|
+
off(document, "keydown", this._onKeyDown, this);
|
|
7910
7814
|
this._map.fire("blur");
|
|
7911
7815
|
}
|
|
7912
|
-
|
|
7913
|
-
const
|
|
7914
|
-
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
_setZoomDelta(zoomDelta) {
|
|
7920
|
-
const zoomKeys = this._zoomKeys = {}, { zoomIn, zoomOut } = KeyboardHandler.keys;
|
|
7921
|
-
for (const key of zoomIn) zoomKeys[key] = zoomDelta;
|
|
7922
|
-
for (const key of zoomOut) zoomKeys[key] = -zoomDelta;
|
|
7923
|
-
}
|
|
7924
|
-
_addHooks() {
|
|
7925
|
-
on(document, "keydown", this._onKeyDown, this);
|
|
7926
|
-
}
|
|
7927
|
-
_removeHooks() {
|
|
7928
|
-
off(document, "keydown", this._onKeyDown, this);
|
|
7816
|
+
_onContainerKeyDown(e) {
|
|
7817
|
+
const map = this._map, popup = map._popup;
|
|
7818
|
+
if (e.key !== "Escape" || e.defaultPrevented || !popup?.options.closeOnEscapeKey || map._controlContainer?.contains(e.target)) return;
|
|
7819
|
+
const inPopup = popup._container.contains(e.target), icon = popup._source?._icon;
|
|
7820
|
+
map.closePopup();
|
|
7821
|
+
e.preventDefault();
|
|
7822
|
+
if (inPopup) (icon?.tabIndex >= 0 ? icon : map._container).focus();
|
|
7929
7823
|
}
|
|
7930
7824
|
_onKeyDown(e) {
|
|
7931
7825
|
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
@@ -7934,23 +7828,20 @@
|
|
|
7934
7828
|
stop(e);
|
|
7935
7829
|
return;
|
|
7936
7830
|
}
|
|
7937
|
-
const key = e.key, map = this._map;
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
offset =
|
|
7942
|
-
if (e.shiftKey) offset = Point.from(offset).multiplyBy(3);
|
|
7943
|
-
if (map.options.maxBounds) offset = map._limitOffset(Point.from(offset), map.options.maxBounds);
|
|
7831
|
+
const key = e.key, map = this._map, { left, right, down, up, zoomIn, zoomOut } = KeyboardHandler.keys, x = +right.includes(key) - +left.includes(key), y = +down.includes(key) - +up.includes(key), dz = +zoomIn.includes(key) - +zoomOut.includes(key), k = e.shiftKey ? 3 : 1;
|
|
7832
|
+
if (x || y) {
|
|
7833
|
+
if (!map._panAnim?._inProgress) {
|
|
7834
|
+
let offset = new Point(x, y).multiplyBy(k * map.options.keyboardPanDelta);
|
|
7835
|
+
if (map.options.maxBounds) offset = map._limitOffset(offset, map.options.maxBounds);
|
|
7944
7836
|
map._setUserEvent(e);
|
|
7945
7837
|
map.panBy(offset);
|
|
7946
7838
|
}
|
|
7947
|
-
} else if (
|
|
7839
|
+
} else if (dz) {
|
|
7948
7840
|
if (!map._zoomInputBlocked()) {
|
|
7949
7841
|
map._setUserEvent(e);
|
|
7950
|
-
map.setZoom(map.getZoom() +
|
|
7842
|
+
map.setZoom(map.getZoom() + k * dz * map.options.zoomDelta);
|
|
7951
7843
|
}
|
|
7952
|
-
} else
|
|
7953
|
-
else return;
|
|
7844
|
+
} else return;
|
|
7954
7845
|
stop(e);
|
|
7955
7846
|
}
|
|
7956
7847
|
/**
|
|
@@ -7967,8 +7858,7 @@
|
|
|
7967
7858
|
MaplairMap.addInitHook("addHandler", "keyboard", KeyboardHandler);
|
|
7968
7859
|
}
|
|
7969
7860
|
};
|
|
7970
|
-
|
|
7971
|
-
//#region src/map/handler/PinchZoomHandler.js
|
|
7861
|
+
// src/map/handler/PinchZoomHandler.js
|
|
7972
7862
|
/** @import {MaplairMap} from '../Map.js' */
|
|
7973
7863
|
/**
|
|
7974
7864
|
* Map options of `PinchZoomHandler`, touch interaction options.
|
|
@@ -8103,8 +7993,7 @@
|
|
|
8103
7993
|
});
|
|
8104
7994
|
}
|
|
8105
7995
|
};
|
|
8106
|
-
|
|
8107
|
-
//#region src/map/handler/ScrollWheelZoomHandler.js
|
|
7996
|
+
// src/map/handler/ScrollWheelZoomHandler.js
|
|
8108
7997
|
/** @import {MaplairMap} from '../Map.js' */
|
|
8109
7998
|
const pinchPxPerZoomLevel = 100;
|
|
8110
7999
|
const gestureEndDelay$1 = 150;
|
|
@@ -8306,8 +8195,7 @@
|
|
|
8306
8195
|
MaplairMap.addInitHook("addHandler", "scrollWheelZoom", ScrollWheelZoomHandler);
|
|
8307
8196
|
}
|
|
8308
8197
|
};
|
|
8309
|
-
|
|
8310
|
-
//#region src/map/handler/TapHoldHandler.js
|
|
8198
|
+
// src/map/handler/TapHoldHandler.js
|
|
8311
8199
|
/** @import {MaplairMap} from '../Map.js' */
|
|
8312
8200
|
const tapHoldDelay = 600;
|
|
8313
8201
|
/**
|
|
@@ -8418,8 +8306,7 @@
|
|
|
8418
8306
|
MaplairMap.addInitHook("addHandler", "tapHold", TapHoldHandler);
|
|
8419
8307
|
}
|
|
8420
8308
|
};
|
|
8421
|
-
|
|
8422
|
-
//#region src/map/handler/TapDragZoomHandler.js
|
|
8309
|
+
// src/map/handler/TapDragZoomHandler.js
|
|
8423
8310
|
/** @import {MaplairMap} from '../Map.js' */
|
|
8424
8311
|
const maxTapInterval = 500;
|
|
8425
8312
|
const maxTapDistance = 30;
|
|
@@ -8560,8 +8447,7 @@
|
|
|
8560
8447
|
MaplairMap.addInitHook("addHandler", "tapDragZoom", TapDragZoomHandler);
|
|
8561
8448
|
}
|
|
8562
8449
|
};
|
|
8563
|
-
|
|
8564
|
-
//#region src/map/Map.js
|
|
8450
|
+
// src/map/Map.js
|
|
8565
8451
|
/** @import {LatLngExpression} from '../geo/LatLng.js' */
|
|
8566
8452
|
/** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */
|
|
8567
8453
|
/** @import {PointExpression} from '../geometry/Point.js' */
|
|
@@ -8934,7 +8820,7 @@
|
|
|
8934
8820
|
* @returns {this}
|
|
8935
8821
|
*/
|
|
8936
8822
|
setZoomAround(latlng, zoom, options) {
|
|
8937
|
-
const
|
|
8823
|
+
const center = this.project(this.getCenter()), offset = latlng instanceof Point ? this.containerPointToLayerPoint(latlng).subtract(this.containerPointToLayerPoint(this.getSize().divideBy(2))) : this.project(latlng).subtract(center), newCenter = this.unproject(center.add(offset.multiplyBy(1 - 1 / this.getZoomScale(zoom))));
|
|
8938
8824
|
return this.setView(newCenter, zoom, { zoom: options });
|
|
8939
8825
|
}
|
|
8940
8826
|
_getBoundsCenterZoom(bounds, options) {
|
|
@@ -9056,9 +8942,6 @@
|
|
|
9056
8942
|
return -Math.asinh(t1 / b1);
|
|
9057
8943
|
}
|
|
9058
8944
|
const r0 = r(0);
|
|
9059
|
-
function w(s) {
|
|
9060
|
-
return w0 * (Math.cosh(r0) / Math.cosh(r0 + rho * s));
|
|
9061
|
-
}
|
|
9062
8945
|
function u(s) {
|
|
9063
8946
|
return w0 * (Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2;
|
|
9064
8947
|
}
|
|
@@ -9070,7 +8953,7 @@
|
|
|
9070
8953
|
const t = (Date.now() - start) / duration, s = easeOut(t) * S;
|
|
9071
8954
|
if (t <= 1) {
|
|
9072
8955
|
this._flyToFrame = requestAnimationFrame(frame);
|
|
9073
|
-
this._move(this.unproject(from.add(to.subtract(from).multiplyBy(u(s) / u1)), startZoom), this.getScaleZoom(
|
|
8956
|
+
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 });
|
|
9074
8957
|
} else {
|
|
9075
8958
|
const zoomChanged = this._zoom !== targetZoom;
|
|
9076
8959
|
this._move(targetCenter, targetZoom);
|
|
@@ -9398,7 +9281,7 @@
|
|
|
9398
9281
|
*/
|
|
9399
9282
|
getCenter() {
|
|
9400
9283
|
this._checkIfLoaded();
|
|
9401
|
-
if (this._lastCenter &&
|
|
9284
|
+
if (this._lastCenter && this._getMapPanePos().equals(this._lastCenterPanePos)) return new LatLng(this._lastCenter);
|
|
9402
9285
|
return this.layerPointToLatLng(this._getCenterLayerPoint());
|
|
9403
9286
|
}
|
|
9404
9287
|
/**
|
|
@@ -9602,7 +9485,7 @@
|
|
|
9602
9485
|
* @returns {Point}
|
|
9603
9486
|
*/
|
|
9604
9487
|
latLngToLayerPoint(latlng) {
|
|
9605
|
-
return this.project(LatLng.from(latlng)).
|
|
9488
|
+
return this.project(LatLng.from(latlng))._subtract(this.getPixelOrigin());
|
|
9606
9489
|
}
|
|
9607
9490
|
/**
|
|
9608
9491
|
* Returns a `LatLng` where `lat` and `lng` has been wrapped according to the
|
|
@@ -9852,6 +9735,7 @@
|
|
|
9852
9735
|
const zoomChanged = this._zoom !== zoom;
|
|
9853
9736
|
this._zoom = zoom;
|
|
9854
9737
|
this._lastCenter = center;
|
|
9738
|
+
this._lastCenterPanePos = this._getMapPanePos();
|
|
9855
9739
|
this._pixelOrigin = this._getNewPixelOrigin(center);
|
|
9856
9740
|
if (!suppressEvent) {
|
|
9857
9741
|
if (zoomChanged || data?.pinch) this.fire("zoom", data);
|
|
@@ -9964,10 +9848,10 @@
|
|
|
9964
9848
|
const target = targets[0];
|
|
9965
9849
|
const data = { originalEvent: e };
|
|
9966
9850
|
if (e.type !== "keydown" && e.type !== "keyup") {
|
|
9967
|
-
const
|
|
9968
|
-
data.containerPoint =
|
|
9851
|
+
const latlng = (!target._pxRadius || target._pxRadius <= 10) && target.getLatLng?.();
|
|
9852
|
+
data.containerPoint = latlng ? this.latLngToContainerPoint(latlng) : this.pointerEventToContainerPoint(e);
|
|
9969
9853
|
data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
|
|
9970
|
-
data.latlng =
|
|
9854
|
+
data.latlng = latlng || this.layerPointToLatLng(data.layerPoint);
|
|
9971
9855
|
}
|
|
9972
9856
|
for (const t of targets) {
|
|
9973
9857
|
t.fire(type, data, true);
|
|
@@ -9996,10 +9880,6 @@
|
|
|
9996
9880
|
_getMapPanePos() {
|
|
9997
9881
|
return getPosition(this._mapPane);
|
|
9998
9882
|
}
|
|
9999
|
-
_moved() {
|
|
10000
|
-
const pos = this._getMapPanePos();
|
|
10001
|
-
return pos && !pos.equals([0, 0]);
|
|
10002
|
-
}
|
|
10003
9883
|
_getTopLeftPoint(center, zoom) {
|
|
10004
9884
|
return (center && zoom !== void 0 ? this._getNewPixelOrigin(center, zoom) : this.getPixelOrigin()).subtract(this._getMapPanePos());
|
|
10005
9885
|
}
|
|
@@ -10015,7 +9895,7 @@
|
|
|
10015
9895
|
return this.containerPointToLayerPoint(this.getSize()._divideBy(2));
|
|
10016
9896
|
}
|
|
10017
9897
|
_getCenterOffset(latlng) {
|
|
10018
|
-
return this.latLngToLayerPoint(latlng).
|
|
9898
|
+
return this.latLngToLayerPoint(latlng)._round()._subtract(this._getCenterLayerPoint());
|
|
10019
9899
|
}
|
|
10020
9900
|
_limitCenter(center, zoom, bounds) {
|
|
10021
9901
|
if (!bounds) return center;
|
|
@@ -10162,8 +10042,7 @@
|
|
|
10162
10042
|
ZoomControl,
|
|
10163
10043
|
FullscreenControl
|
|
10164
10044
|
]) feature.register(MaplairMap);
|
|
10165
|
-
|
|
10166
|
-
//#region src/layer/vector/Polyline.js
|
|
10045
|
+
// src/layer/vector/Polyline.js
|
|
10167
10046
|
/** @import {Feature} from 'geojson' */
|
|
10168
10047
|
/** @import {LatLngExpression} from '../../geo/LatLng.js' */
|
|
10169
10048
|
/** @import {PointExpression} from '../../geometry/Point.js' */
|
|
@@ -10354,7 +10233,7 @@
|
|
|
10354
10233
|
for (i = 0, k = 0, len = this._rings.length; i < len; i++) {
|
|
10355
10234
|
points = this._rings[i];
|
|
10356
10235
|
for (j = 0, len2 = points.length; j < len2 - 1; j++) {
|
|
10357
|
-
segment = clipSegment(points[j], points[j + 1], bounds, j
|
|
10236
|
+
segment = clipSegment(points[j], points[j + 1], bounds, j);
|
|
10358
10237
|
if (!segment) continue;
|
|
10359
10238
|
parts[k] ??= [];
|
|
10360
10239
|
parts[k].push(segment[0]);
|
|
@@ -10408,8 +10287,7 @@
|
|
|
10408
10287
|
});
|
|
10409
10288
|
}
|
|
10410
10289
|
};
|
|
10411
|
-
|
|
10412
|
-
//#region src/geometry/PolyUtil.js
|
|
10290
|
+
// src/geometry/PolyUtil.js
|
|
10413
10291
|
var PolyUtil_exports = /* @__PURE__ */ __exportAll({
|
|
10414
10292
|
centroid: () => centroid,
|
|
10415
10293
|
clipPolygon: () => clipPolygon,
|
|
@@ -10430,37 +10308,30 @@
|
|
|
10430
10308
|
* @returns {Point[]}
|
|
10431
10309
|
*/
|
|
10432
10310
|
function clipPolygon(points, bounds, round) {
|
|
10433
|
-
|
|
10434
|
-
const edges = [
|
|
10311
|
+
for (const edge of [
|
|
10435
10312
|
1,
|
|
10436
10313
|
4,
|
|
10437
10314
|
2,
|
|
10438
10315
|
8
|
|
10439
|
-
]
|
|
10440
|
-
|
|
10441
|
-
|
|
10442
|
-
|
|
10443
|
-
|
|
10444
|
-
for (
|
|
10445
|
-
|
|
10446
|
-
b
|
|
10447
|
-
if (!(a
|
|
10448
|
-
|
|
10449
|
-
|
|
10450
|
-
p._code = _getBitCode(p, bounds);
|
|
10451
|
-
clippedPoints.push(p);
|
|
10452
|
-
}
|
|
10453
|
-
clippedPoints.push(a);
|
|
10454
|
-
} else if (!(b._code & edge)) {
|
|
10455
|
-
p = _getEdgeIntersection(b, a, edge, bounds, round);
|
|
10456
|
-
p._code = _getBitCode(p, bounds);
|
|
10457
|
-
clippedPoints.push(p);
|
|
10458
|
-
}
|
|
10316
|
+
]) {
|
|
10317
|
+
if (!points.length) break;
|
|
10318
|
+
/** @type {Point[]} */
|
|
10319
|
+
const clippedPoints = [];
|
|
10320
|
+
let b = points[points.length - 1], bOut = isOutside(b, edge, bounds);
|
|
10321
|
+
for (const a of points) {
|
|
10322
|
+
const aOut = isOutside(a, edge, bounds);
|
|
10323
|
+
if (aOut !== bOut) clippedPoints.push(_getEdgeIntersection(b, a, edge, bounds, round));
|
|
10324
|
+
if (!aOut) clippedPoints.push(a);
|
|
10325
|
+
b = a;
|
|
10326
|
+
bOut = aOut;
|
|
10459
10327
|
}
|
|
10460
10328
|
points = clippedPoints;
|
|
10461
10329
|
}
|
|
10462
10330
|
return points;
|
|
10463
10331
|
}
|
|
10332
|
+
function isOutside(p, edge, bounds) {
|
|
10333
|
+
return edge === 1 ? p.x < bounds.min.x : edge === 2 ? p.x > bounds.max.x : edge === 4 ? p.y < bounds.min.y : p.y > bounds.max.y;
|
|
10334
|
+
}
|
|
10464
10335
|
/**
|
|
10465
10336
|
* Returns the center ([centroid](http://en.wikipedia.org/wiki/Centroid)) of the passed
|
|
10466
10337
|
* LatLngs (first ring) from a polygon.
|
|
@@ -10497,8 +10368,7 @@
|
|
|
10497
10368
|
}
|
|
10498
10369
|
return new LatLng([latSum / len, lngSum / len]);
|
|
10499
10370
|
}
|
|
10500
|
-
|
|
10501
|
-
//#region src/layer/vector/Polygon.js
|
|
10371
|
+
// src/layer/vector/Polygon.js
|
|
10502
10372
|
/** @import {Feature} from 'geojson' */
|
|
10503
10373
|
/** @import {LatLngExpression} from '../../geo/LatLng.js' */
|
|
10504
10374
|
/** @import {PolylineOptions} from './Polyline.js' */
|
|
@@ -10603,7 +10473,7 @@
|
|
|
10603
10473
|
return;
|
|
10604
10474
|
}
|
|
10605
10475
|
for (const ring of this._rings) {
|
|
10606
|
-
const clipped = clipPolygon(ring, bounds
|
|
10476
|
+
const clipped = clipPolygon(ring, bounds);
|
|
10607
10477
|
if (clipped.length) this._parts.push(clipped);
|
|
10608
10478
|
}
|
|
10609
10479
|
}
|
|
@@ -10640,8 +10510,7 @@
|
|
|
10640
10510
|
});
|
|
10641
10511
|
}
|
|
10642
10512
|
};
|
|
10643
|
-
|
|
10644
|
-
//#region src/control/MiniMapControl.js
|
|
10513
|
+
// src/control/MiniMapControl.js
|
|
10645
10514
|
/** @import {ControlOptions} from './Control.js' */
|
|
10646
10515
|
/** @import {MaplairMapOptions} from '../map/Map.js' */
|
|
10647
10516
|
/** @import {Layer} from '../layer/Layer.js' */
|
|
@@ -10811,8 +10680,7 @@
|
|
|
10811
10680
|
if (!this._miniMap.dragging?.moved()) this._map.panTo(e.latlng);
|
|
10812
10681
|
}
|
|
10813
10682
|
};
|
|
10814
|
-
|
|
10815
|
-
//#region src/control/ScaleControl.js
|
|
10683
|
+
// src/control/ScaleControl.js
|
|
10816
10684
|
/** @import {ControlOptions} from './Control.js' */
|
|
10817
10685
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
10818
10686
|
/**
|
|
@@ -10915,8 +10783,7 @@
|
|
|
10915
10783
|
return pow10 * d;
|
|
10916
10784
|
}
|
|
10917
10785
|
};
|
|
10918
|
-
|
|
10919
|
-
//#region src/layer/marker/Icon.js
|
|
10786
|
+
// src/layer/marker/Icon.js
|
|
10920
10787
|
/** @import {PointExpression} from '../../geometry/Point.js' */
|
|
10921
10788
|
/**
|
|
10922
10789
|
* Options of `Icon`.
|
|
@@ -11028,6 +10895,7 @@
|
|
|
11028
10895
|
img.style.marginLeft = `${-anchor.x}px`;
|
|
11029
10896
|
img.style.marginTop = `${-anchor.y}px`;
|
|
11030
10897
|
}
|
|
10898
|
+
img.style.transformOrigin = anchor ? `${anchor.x}px ${anchor.y}px` : "0 0";
|
|
11031
10899
|
if (size) {
|
|
11032
10900
|
img.style.width = `${size.x}px`;
|
|
11033
10901
|
img.style.height = `${size.y}px`;
|
|
@@ -11042,14 +10910,25 @@
|
|
|
11042
10910
|
return window.devicePixelRatio > 1 && this.options[`${name}RetinaUrl`] || this.options[`${name}Url`];
|
|
11043
10911
|
}
|
|
11044
10912
|
};
|
|
11045
|
-
|
|
11046
|
-
//#region src/layer/marker/DefaultIcon.js
|
|
10913
|
+
// src/layer/marker/DefaultIcon.js
|
|
11047
10914
|
/** @import {IconOptions} from './Icon.js' */
|
|
11048
10915
|
/** @import {PointExpression} from '../../geometry/Point.js' */
|
|
11049
10916
|
/**
|
|
10917
|
+
* @param {string} fill
|
|
10918
|
+
* @param {string} fillTop
|
|
10919
|
+
* @param {number} fillTopOpacity
|
|
10920
|
+
* @param {string} stroke
|
|
10921
|
+
* @param {string} strokeTop
|
|
10922
|
+
* @param {string} [outline]
|
|
10923
|
+
* @returns {string}
|
|
10924
|
+
*/
|
|
10925
|
+
const marker = (fill, fillTop, fillTopOpacity, stroke, strokeTop, outline = "") => `data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round" viewBox="0 0 500 820"><defs><linearGradient id="a" x1="0" x2="1" y1="0" y2="0" gradientTransform="rotate(-90 478.727 62.272)scale(37.566)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="${fill}"/><stop offset="1" stop-color="${fillTop}" stop-opacity="${fillTopOpacity}"/></linearGradient><linearGradient id="b" x1="0" x2="1" y1="0" y2="0" gradientTransform="rotate(-90 468.484 54.002)scale(19.053)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="${stroke}"/><stop offset="1" stop-color="${strokeTop}"/></linearGradient></defs><g fill="%23FFF"><path id="p" d="M416.500 542.096L420.919 533.569L422.024 531.437L424.460 529.996L424.233 527.174L426.670 525.732L426.382 522.881L428.720 521.213L428.075 518.393L429.979 516.125L428.342 513.639L429.080 510.777L426.581 509.207L426.168 506.292L423.266 505.773L421.781 503.221L418.898 503.859L416.511 502.112L414.131 503.870L411.248 503.241L409.766 505.793L406.865 506.302L406.439 509.216L403.933 510.775L404.661 513.641L403.023 516.136L404.935 518.393L404.271 521.204L406.590 522.896L406.299 525.752L408.738 527.189L408.516 530.011L410.956 531.448L412.065 533.578Z" transform="translate(-7889.1 -9807.44)scale(19.5417)"/></g><use href="%23p" fill="url(%23a)" stroke="url(%23b)" stroke-width="1.1" stroke-linejoin="miter" stroke-miterlimit="10"/>${outline}<path fill="%23FFF" d="m-90 2030 45-863a95 95 0 0 0-111-98l-859 151 116-320a65 65 0 0 0-20-73l-941-762 212-99a65 65 0 0 0 34-79l-186-572 542 115a65 65 0 0 0 73-38l105-247 423 454a65 65 0 0 0 111-57l-204-1052 327 189a65 65 0 0 0 91-27l332-652 332 652a65 65 0 0 0 91 27l327-189-204 1052a65 65 0 0 0 111 57l423-454 105 247a65 65 0 0 0 73 38l542-115-186 572a65 65 0 0 0 34 79l212 99-941 762a65 65 0 0 0-20 73l116 320-859-151a95 95 0 0 0-111 98l45 863z" transform="translate(250 258)scale(.068)"/></svg>`;
|
|
10926
|
+
/**
|
|
11050
10927
|
* Options of `DefaultIcon`.
|
|
11051
10928
|
* @typedef {object} DefaultIconOptions
|
|
11052
10929
|
* @property {string} [iconUrl] The maple leaf marker, inlined as an SVG data URI.
|
|
10930
|
+
* @property {string|null} [color=null] Paints the pin in the given CSS color instead of
|
|
10931
|
+
* the default red, overriding `iconUrl`, e.g. `new DefaultIcon({color: 'teal'})`.
|
|
11053
10932
|
* @property {string} [shadowUrl] Its shadow, inlined as an SVG data URI.
|
|
11054
10933
|
* @property {PointExpression|number} [iconSize=[25, 41]]
|
|
11055
10934
|
* @property {PointExpression} [iconAnchor=[12, 41]]
|
|
@@ -11059,9 +10938,9 @@
|
|
|
11059
10938
|
* @extends IconOptions
|
|
11060
10939
|
*/
|
|
11061
10940
|
/**
|
|
11062
|
-
* A
|
|
11063
|
-
*
|
|
11064
|
-
* URIs, so they work with any bundler and need no image files.
|
|
10941
|
+
* A subclass of `Icon`, represents the icon to use in `Marker`s when no icon is
|
|
10942
|
+
* specified, optionally in another `color`. The maple leaf marker and its shadow are
|
|
10943
|
+
* inlined as SVG data URIs, so they work with any bundler and need no image files.
|
|
11065
10944
|
*
|
|
11066
10945
|
* In order to customize the default icon, just change the properties of
|
|
11067
10946
|
* `DefaultIcon.defaultOptions` (which is a set of `Icon options`).
|
|
@@ -11071,13 +10950,14 @@
|
|
|
11071
10950
|
*/
|
|
11072
10951
|
var DefaultIcon = class DefaultIcon extends Icon {
|
|
11073
10952
|
static defaultOptions = {
|
|
11074
|
-
iconUrl:
|
|
10953
|
+
iconUrl: /* @__PURE__ */ marker("%23C2331B", "%23E2603F", 1, "%238F2D20", "%23B23A27"),
|
|
11075
10954
|
shadowUrl: "data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" xml:space=\"preserve\" viewBox=\"0 0 817.2 820\"><radialGradient id=\"a\" cx=\"526.6\" cy=\"486.836\" r=\"478.154\" fx=\"275.876\" fy=\"893.983\" gradientUnits=\"userSpaceOnUse\"><stop offset=\"0\" style=\"stop-color:%235c5c5c;stop-opacity:.9477\"/><stop offset=\".112\" style=\"stop-color:%23474747;stop-opacity:.7805\"/><stop offset=\".34\" style=\"stop-color:%23202020;stop-opacity:.4413\"/><stop offset=\".523\" style=\"stop-color:%23090909;stop-opacity:.1692\"/><stop offset=\".637\" style=\"stop-color:%23000;stop-opacity:0\"/></radialGradient><path d=\"M254.7 820.0L430.1 664.9L473.9 626.1L541.3 599.9L561.5 548.6L629.0 522.4L648.1 470.5L715.4 440.2L726.3 388.9L789.2 347.6L774.9 302.4L817.1 250.3L775.4 221.8L792.3 168.8L732.1 159.3L721.8 112.9L651.7 124.5L614.0 92.7L545.0 124.7L486.2 113.3L430.2 159.7L360.8 169.0L325.1 222.0L255.1 250.3L245.6 302.4L186.6 347.8L209.1 388.9L169.0 440.0L205.6 470.8L173.5 522.7L215.1 548.9L184.8 600.2L226.4 626.3L232.1 665.1Z\" style=\"fill-rule:evenodd;clip-rule:evenodd;fill:url(%23a);fill-opacity:.7;filter:blur(15px)\"/></svg>",
|
|
11076
10955
|
iconSize: [25, 41],
|
|
11077
10956
|
iconAnchor: [12, 41],
|
|
11078
10957
|
popupAnchor: [1, -34],
|
|
11079
10958
|
tooltipAnchor: [16, -28],
|
|
11080
|
-
shadowSize: [41, 41]
|
|
10959
|
+
shadowSize: [41, 41],
|
|
10960
|
+
color: null
|
|
11081
10961
|
};
|
|
11082
10962
|
/**
|
|
11083
10963
|
* Creates the default icon, optionally with changed options.
|
|
@@ -11087,11 +10967,27 @@
|
|
|
11087
10967
|
super(...args);
|
|
11088
10968
|
this.callInitHooks(DefaultIcon);
|
|
11089
10969
|
}
|
|
10970
|
+
/**
|
|
10971
|
+
* @param {'icon'|'shadow'} name
|
|
10972
|
+
* @returns {string|undefined}
|
|
10973
|
+
*/
|
|
10974
|
+
_getIconUrl(name) {
|
|
10975
|
+
const { color } = this.options;
|
|
10976
|
+
if (!color || name !== "icon") return super._getIconUrl(name);
|
|
10977
|
+
const c = encodeURIComponent(color);
|
|
10978
|
+
return marker(c, c, .75, c, c, "<use href=\"%23p\" fill=\"none\" stroke=\"%23666\" stroke-opacity=\".4\"/>");
|
|
10979
|
+
}
|
|
11090
10980
|
};
|
|
11091
|
-
|
|
11092
|
-
//#region src/layer/marker/Marker.Drag.js
|
|
10981
|
+
// src/layer/marker/Marker.Drag.js
|
|
11093
10982
|
/** @import {Marker, MarkerMoveEvent} from './Marker.js' */
|
|
11094
10983
|
/** @import {MaplairEvent, DragEndEvent} from '../../core/Events.js' */
|
|
10984
|
+
/** @type {Record<string, [number, number]>} */
|
|
10985
|
+
const arrows = {
|
|
10986
|
+
ArrowLeft: [-1, 0],
|
|
10987
|
+
ArrowRight: [1, 0],
|
|
10988
|
+
ArrowUp: [0, -1],
|
|
10989
|
+
ArrowDown: [0, 1]
|
|
10990
|
+
};
|
|
11095
10991
|
/**
|
|
11096
10992
|
* The handler of `Marker` which makes the markers draggable, see the
|
|
11097
10993
|
* [`dragging`](#marker-dragging) property of markers and its `draggable` option.
|
|
@@ -11126,18 +11022,21 @@
|
|
|
11126
11022
|
drag: this._onDrag,
|
|
11127
11023
|
dragend: this._onDragEnd
|
|
11128
11024
|
}, this).enable();
|
|
11025
|
+
on(icon, "keydown keyup blur", this._onKey, this);
|
|
11129
11026
|
icon.classList.add("maplair-marker-draggable");
|
|
11130
11027
|
}
|
|
11131
11028
|
/**
|
|
11132
11029
|
* Makes the icon of the marker undraggable, called by `disable()`.
|
|
11133
11030
|
*/
|
|
11134
11031
|
removeHooks() {
|
|
11032
|
+
this._keyOffset = null;
|
|
11135
11033
|
this._draggable.off({
|
|
11136
11034
|
dragstart: this._onDragStart,
|
|
11137
11035
|
predrag: this._onPreDrag,
|
|
11138
11036
|
drag: this._onDrag,
|
|
11139
11037
|
dragend: this._onDragEnd
|
|
11140
11038
|
}, this).disable();
|
|
11039
|
+
off(this._draggable._element, "keydown keyup blur", this._onKey, this);
|
|
11141
11040
|
this._marker._icon?.classList.remove("maplair-marker-draggable");
|
|
11142
11041
|
}
|
|
11143
11042
|
/**
|
|
@@ -11172,8 +11071,8 @@
|
|
|
11172
11071
|
}
|
|
11173
11072
|
}
|
|
11174
11073
|
_onDrag(e) {
|
|
11175
|
-
const marker = this._marker,
|
|
11176
|
-
|
|
11074
|
+
const marker = this._marker, iconPos = getPosition(marker._icon), latlng = marker._map.layerPointToLatLng(iconPos);
|
|
11075
|
+
marker._positionElements(iconPos);
|
|
11177
11076
|
marker._latlng = latlng;
|
|
11178
11077
|
e.latlng = latlng;
|
|
11179
11078
|
e.oldLatLng = this._oldLatLng;
|
|
@@ -11184,9 +11083,37 @@
|
|
|
11184
11083
|
delete this._oldLatLng;
|
|
11185
11084
|
this._marker.fire("moveend").fire("dragend", e);
|
|
11186
11085
|
}
|
|
11086
|
+
/** @param {KeyboardEvent|FocusEvent} e */
|
|
11087
|
+
_onKey(e) {
|
|
11088
|
+
const k = e, dir = arrows[k.key], draggable = this._draggable, { options, _map: map } = this._marker;
|
|
11089
|
+
if (e.type !== "keydown") {
|
|
11090
|
+
if (this._keyOffset) {
|
|
11091
|
+
this._keyOffset = null;
|
|
11092
|
+
draggable.finishDrag();
|
|
11093
|
+
}
|
|
11094
|
+
} else if (dir && k.target === draggable._element && !(k.altKey || k.ctrlKey || k.metaKey)) {
|
|
11095
|
+
e.preventDefault();
|
|
11096
|
+
if (!this._keyOffset) {
|
|
11097
|
+
if (Draggable._dragging) return;
|
|
11098
|
+
Draggable._dragging = draggable;
|
|
11099
|
+
draggable._startPos = getPosition(draggable._element);
|
|
11100
|
+
draggable._moved = draggable._moving = true;
|
|
11101
|
+
this._keyOffset = new Point(0, 0);
|
|
11102
|
+
draggable.fire("dragstart");
|
|
11103
|
+
}
|
|
11104
|
+
const offset = new Point(...dir).multiplyBy(k.shiftKey ? 30 : 10);
|
|
11105
|
+
this._keyOffset = this._keyOffset.add(map._rotateToPane?.(offset) ?? offset);
|
|
11106
|
+
draggable._newPos = draggable._startPos.add(this._keyOffset);
|
|
11107
|
+
setPosition(draggable._element, draggable._newPos);
|
|
11108
|
+
draggable.fire("drag", { originalEvent: k });
|
|
11109
|
+
if (options.autoPan) map.panInside(this._marker._latlng, {
|
|
11110
|
+
padding: options.autoPanPadding,
|
|
11111
|
+
animate: false
|
|
11112
|
+
});
|
|
11113
|
+
}
|
|
11114
|
+
}
|
|
11187
11115
|
};
|
|
11188
|
-
|
|
11189
|
-
//#region src/layer/marker/Marker.js
|
|
11116
|
+
// src/layer/marker/Marker.js
|
|
11190
11117
|
/** @import {Feature} from 'geojson' */
|
|
11191
11118
|
/** @import {Icon} from './Icon.js' */
|
|
11192
11119
|
/** @import {LatLngExpression} from '../../geo/LatLng.js' */
|
|
@@ -11212,6 +11139,10 @@
|
|
|
11212
11139
|
* top of all others (or below), specifying a high value like `1000` (or high negative
|
|
11213
11140
|
* value, respectively).
|
|
11214
11141
|
* @property {number} [opacity=1] The opacity of the marker.
|
|
11142
|
+
* @property {number|null} [rotation=null] Rotation of the marker icon in degrees,
|
|
11143
|
+
* clockwise, around the icon anchor, e.g. for the heading of a vehicle. A rotated
|
|
11144
|
+
* marker, even at 0°, has no shadow, since the shadow of an upright pin looks wrong
|
|
11145
|
+
* under a tilted one. `null` means no rotation.
|
|
11215
11146
|
* @property {boolean} [riseOnHover=false] If `true`, the marker will get on top of
|
|
11216
11147
|
* others when you hover the pointer over it.
|
|
11217
11148
|
* @property {number} [riseOffset=250] The z-index offset used for the `riseOnHover`
|
|
@@ -11231,7 +11162,8 @@
|
|
|
11231
11162
|
* marker is focused (via e.g. pressing `tab` on the keyboard) to ensure the marker is
|
|
11232
11163
|
* visible within the map's bounds.
|
|
11233
11164
|
* @property {boolean} [draggable=false] Whether the marker is draggable with pointer or
|
|
11234
|
-
* not.
|
|
11165
|
+
* not. A focused draggable marker can also be moved with the arrow keys, by 10 pixels
|
|
11166
|
+
* or 30 with Shift.
|
|
11235
11167
|
* @property {boolean} [autoPan=false] Whether to pan the map when dragging this marker
|
|
11236
11168
|
* near its edge or not.
|
|
11237
11169
|
* @property {PointExpression} [autoPanPadding=[50, 50]] Distance (in pixels to the
|
|
@@ -11270,6 +11202,7 @@
|
|
|
11270
11202
|
alt: "Marker",
|
|
11271
11203
|
zIndexOffset: 0,
|
|
11272
11204
|
opacity: 1,
|
|
11205
|
+
rotation: null,
|
|
11273
11206
|
riseOnHover: false,
|
|
11274
11207
|
riseOffset: 250,
|
|
11275
11208
|
pane: "markerPane",
|
|
@@ -11397,7 +11330,7 @@
|
|
|
11397
11330
|
*/
|
|
11398
11331
|
update() {
|
|
11399
11332
|
if (this._icon && this._map && !this._culled) {
|
|
11400
|
-
const pos = this._map.latLngToLayerPoint(this._latlng).
|
|
11333
|
+
const pos = this._map.latLngToLayerPoint(this._latlng)._round();
|
|
11401
11334
|
this._setPos(pos);
|
|
11402
11335
|
}
|
|
11403
11336
|
return this;
|
|
@@ -11424,7 +11357,7 @@
|
|
|
11424
11357
|
pointerout: this._resetZIndex
|
|
11425
11358
|
});
|
|
11426
11359
|
if (this.options.autoPanOnFocus) on(icon, "focus", this._panOnFocus, this);
|
|
11427
|
-
const newShadow = options.shadow ? options.icon.createShadow(this._shadow) : null;
|
|
11360
|
+
const newShadow = options.shadow ? options.icon.createShadow?.(this._shadow) ?? null : null;
|
|
11428
11361
|
let addShadow = false;
|
|
11429
11362
|
if (newShadow !== this._shadow) {
|
|
11430
11363
|
this._removeShadow();
|
|
@@ -11470,18 +11403,28 @@
|
|
|
11470
11403
|
this._shadow = null;
|
|
11471
11404
|
}
|
|
11472
11405
|
_setPos(pos) {
|
|
11473
|
-
|
|
11474
|
-
if (this._shadow) setPosition(this._shadow, pos);
|
|
11406
|
+
this._positionElements(pos);
|
|
11475
11407
|
this._zIndex = pos.y + this.options.zIndexOffset;
|
|
11476
11408
|
this._resetZIndex();
|
|
11477
11409
|
}
|
|
11410
|
+
_positionElements(pos) {
|
|
11411
|
+
const rotation = this.options.rotation;
|
|
11412
|
+
if (this._icon) {
|
|
11413
|
+
setPosition(this._icon, pos);
|
|
11414
|
+
if (rotation != null) this._icon.style.transform += ` rotate(${rotation}deg)`;
|
|
11415
|
+
}
|
|
11416
|
+
if (this._shadow) {
|
|
11417
|
+
setPosition(this._shadow, pos);
|
|
11418
|
+
this._shadow.style.display = rotation == null ? "" : "none";
|
|
11419
|
+
}
|
|
11420
|
+
}
|
|
11478
11421
|
_updateZIndex(offset) {
|
|
11479
11422
|
const zIndex = String(this._zIndex + offset);
|
|
11480
11423
|
if (this._icon && this._icon.style.zIndex !== zIndex) this._icon.style.zIndex = zIndex;
|
|
11481
11424
|
}
|
|
11482
11425
|
_animateZoom(opt) {
|
|
11483
11426
|
if (this._culled) return;
|
|
11484
|
-
const pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).
|
|
11427
|
+
const pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center)._round();
|
|
11485
11428
|
this._setPos(pos);
|
|
11486
11429
|
}
|
|
11487
11430
|
_updateInteractive() {
|
|
@@ -11533,6 +11476,27 @@
|
|
|
11533
11476
|
}
|
|
11534
11477
|
}
|
|
11535
11478
|
/**
|
|
11479
|
+
* Returns the current [rotation](#markeroptions-rotation) of the marker in degrees.
|
|
11480
|
+
* @returns {number|null}
|
|
11481
|
+
*/
|
|
11482
|
+
getRotation() {
|
|
11483
|
+
return this.options.rotation;
|
|
11484
|
+
}
|
|
11485
|
+
/**
|
|
11486
|
+
* Changes the [rotation](#markeroptions-rotation) of the marker; `null` removes it.
|
|
11487
|
+
* @param {number|null} rotation
|
|
11488
|
+
* @returns {this}
|
|
11489
|
+
*/
|
|
11490
|
+
setRotation(rotation) {
|
|
11491
|
+
this.options.rotation = rotation;
|
|
11492
|
+
if (this._icon && !this._map._animatingZoom) {
|
|
11493
|
+
this._positionElements(getPosition(this._icon));
|
|
11494
|
+
this._popup?._updatePosition();
|
|
11495
|
+
this._tooltip?._updatePosition();
|
|
11496
|
+
}
|
|
11497
|
+
return this;
|
|
11498
|
+
}
|
|
11499
|
+
/**
|
|
11536
11500
|
* Changes the opacity of the marker.
|
|
11537
11501
|
* @param {number} opacity
|
|
11538
11502
|
* @returns {this}
|
|
@@ -11564,19 +11528,23 @@
|
|
|
11564
11528
|
_panOnFocus() {
|
|
11565
11529
|
const map = this._map;
|
|
11566
11530
|
if (!map) return;
|
|
11567
|
-
const
|
|
11568
|
-
const size = iconOpts.iconSize ? Point.from(iconOpts.iconSize) : new Point(0, 0);
|
|
11569
|
-
const anchor = iconOpts.iconAnchor ? Point.from(iconOpts.iconAnchor) : new Point(0, 0);
|
|
11531
|
+
const icon = this._icon, style = getComputedStyle(icon), anchor = new Point(-parseFloat(style.marginLeft) || 0, -parseFloat(style.marginTop) || 0), size = new Point(icon.offsetWidth, icon.offsetHeight);
|
|
11570
11532
|
map.panInside(this._latlng, {
|
|
11571
11533
|
paddingTopLeft: anchor,
|
|
11572
11534
|
paddingBottomRight: size.subtract(anchor)
|
|
11573
11535
|
});
|
|
11574
11536
|
}
|
|
11575
11537
|
_getPopupAnchor() {
|
|
11576
|
-
return this.options.icon.options.popupAnchor;
|
|
11538
|
+
return this._rotateAnchor(this.options.icon.options.popupAnchor);
|
|
11577
11539
|
}
|
|
11578
11540
|
_getTooltipAnchor() {
|
|
11579
|
-
return this.options.icon.options.tooltipAnchor;
|
|
11541
|
+
return this._rotateAnchor(this.options.icon.options.tooltipAnchor);
|
|
11542
|
+
}
|
|
11543
|
+
_rotateAnchor(anchor) {
|
|
11544
|
+
const angle = this.options.rotation * Math.PI / 180;
|
|
11545
|
+
if (!angle || !anchor) return anchor;
|
|
11546
|
+
const { x, y } = Point.from(anchor), cos = Math.cos(angle), sin = Math.sin(angle);
|
|
11547
|
+
return new Point(x * cos - y * sin, x * sin + y * cos);
|
|
11580
11548
|
}
|
|
11581
11549
|
/**
|
|
11582
11550
|
* Coordinates values are rounded with [`formatNum`](#util-formatnum) to the
|
|
@@ -11590,8 +11558,7 @@
|
|
|
11590
11558
|
return pointToGeoJSON(this, precision);
|
|
11591
11559
|
}
|
|
11592
11560
|
};
|
|
11593
|
-
|
|
11594
|
-
//#region src/control/SearchControl.js
|
|
11561
|
+
// src/control/SearchControl.js
|
|
11595
11562
|
/** @import {ControlOptions} from './Control.js' */
|
|
11596
11563
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
11597
11564
|
/** @import {MaplairEvent} from '../core/Events.js' */
|
|
@@ -12103,8 +12070,7 @@
|
|
|
12103
12070
|
else this.collapse();
|
|
12104
12071
|
}
|
|
12105
12072
|
};
|
|
12106
|
-
|
|
12107
|
-
//#region src/control/SideBySideControl.js
|
|
12073
|
+
// src/control/SideBySideControl.js
|
|
12108
12074
|
/** @import {ControlOptions} from './Control.js' */
|
|
12109
12075
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
12110
12076
|
/** @import {Layer} from '../layer/Layer.js' */
|
|
@@ -12302,8 +12268,7 @@
|
|
|
12302
12268
|
function getElement(layer) {
|
|
12303
12269
|
return layer.getContainer?.() ?? layer.getElement?.();
|
|
12304
12270
|
}
|
|
12305
|
-
|
|
12306
|
-
//#region src/control/TextControl.js
|
|
12271
|
+
// src/control/TextControl.js
|
|
12307
12272
|
/** @import {ControlOptions} from './Control.js' */
|
|
12308
12273
|
/**
|
|
12309
12274
|
* Options of `TextControl`.
|
|
@@ -12377,8 +12342,7 @@
|
|
|
12377
12342
|
container.hidden = !content;
|
|
12378
12343
|
}
|
|
12379
12344
|
};
|
|
12380
|
-
|
|
12381
|
-
//#region src/control/TimeControl.js
|
|
12345
|
+
// src/control/TimeControl.js
|
|
12382
12346
|
/** @import {ControlOptions} from './Control.js' */
|
|
12383
12347
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
12384
12348
|
/** @import {Layer} from '../layer/Layer.js' */
|
|
@@ -12777,8 +12741,7 @@
|
|
|
12777
12741
|
return this;
|
|
12778
12742
|
}
|
|
12779
12743
|
};
|
|
12780
|
-
|
|
12781
|
-
//#region src/geo/projection/Projection.LonLat.js
|
|
12744
|
+
// src/geo/projection/LonLatProjection.js
|
|
12782
12745
|
/** @import {Projection} from './index.js' */
|
|
12783
12746
|
/**
|
|
12784
12747
|
* Equirectangular, or Plate Carree projection — the most simple projection,
|
|
@@ -12787,7 +12750,7 @@
|
|
|
12787
12750
|
* `EPSG4326` and `SimpleCRS` CRS.
|
|
12788
12751
|
* @type {Projection}
|
|
12789
12752
|
*/
|
|
12790
|
-
const
|
|
12753
|
+
const LonLatProjection = {
|
|
12791
12754
|
project(latlng) {
|
|
12792
12755
|
latlng = LatLng.from(latlng);
|
|
12793
12756
|
return new Point(latlng.lng, latlng.lat);
|
|
@@ -12803,7 +12766,7 @@
|
|
|
12803
12766
|
* Earth is an ellipsoid. Used by the EPSG:3395 CRS.
|
|
12804
12767
|
* @type {Projection & {R: number, R_MINOR: number}}
|
|
12805
12768
|
*/
|
|
12806
|
-
const
|
|
12769
|
+
const MercatorProjection = {
|
|
12807
12770
|
R: 6378137,
|
|
12808
12771
|
R_MINOR: 6356752.314245179,
|
|
12809
12772
|
bounds: /* @__PURE__ */ new Bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),
|
|
@@ -12829,15 +12792,7 @@
|
|
|
12829
12792
|
return new LatLng(phi * d, point.x * d / r);
|
|
12830
12793
|
}
|
|
12831
12794
|
};
|
|
12832
|
-
|
|
12833
|
-
//#region src/geo/projection/index.js
|
|
12834
|
-
var projection_exports = /* @__PURE__ */ __exportAll({
|
|
12835
|
-
LonLat: () => LonLat,
|
|
12836
|
-
Mercator: () => Mercator,
|
|
12837
|
-
SphericalMercator: () => SphericalMercator
|
|
12838
|
-
});
|
|
12839
|
-
//#endregion
|
|
12840
|
-
//#region src/geo/crs/EPSG3395.js
|
|
12795
|
+
// src/geo/crs/EPSG3395.js
|
|
12841
12796
|
/** @import {Projection} from '../projection/index.js' */
|
|
12842
12797
|
/**
|
|
12843
12798
|
* Rarely used by some commercial tile providers. Uses Elliptical Mercator projection.
|
|
@@ -12846,15 +12801,14 @@
|
|
|
12846
12801
|
/** @type {string} */
|
|
12847
12802
|
static code = "EPSG:3395";
|
|
12848
12803
|
/** @type {Projection} */
|
|
12849
|
-
static projection =
|
|
12804
|
+
static projection = MercatorProjection;
|
|
12850
12805
|
/** @type {Transformation} */
|
|
12851
12806
|
static transformation = /* @__PURE__ */ (() => {
|
|
12852
|
-
const scale = .5 / (Math.PI *
|
|
12807
|
+
const scale = .5 / (Math.PI * MercatorProjection.R);
|
|
12853
12808
|
return new Transformation(scale, .5, -scale, .5);
|
|
12854
12809
|
})();
|
|
12855
12810
|
};
|
|
12856
|
-
|
|
12857
|
-
//#region src/geo/crs/EPSG4326.js
|
|
12811
|
+
// src/geo/crs/EPSG4326.js
|
|
12858
12812
|
/** @import {Projection} from '../projection/index.js' */
|
|
12859
12813
|
/**
|
|
12860
12814
|
* A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.
|
|
@@ -12870,12 +12824,11 @@
|
|
|
12870
12824
|
/** @type {string} */
|
|
12871
12825
|
static code = "EPSG:4326";
|
|
12872
12826
|
/** @type {Projection} */
|
|
12873
|
-
static projection =
|
|
12827
|
+
static projection = LonLatProjection;
|
|
12874
12828
|
/** @type {Transformation} */
|
|
12875
12829
|
static transformation = /* @__PURE__ */ new Transformation(1 / 180, 1, -1 / 180, .5);
|
|
12876
12830
|
};
|
|
12877
|
-
|
|
12878
|
-
//#region src/geo/crs/SimpleCRS.js
|
|
12831
|
+
// src/geo/crs/SimpleCRS.js
|
|
12879
12832
|
/** @import {LatLng} from '../LatLng.js' */
|
|
12880
12833
|
/** @import {Projection} from '../projection/index.js' */
|
|
12881
12834
|
/**
|
|
@@ -12886,7 +12839,7 @@
|
|
|
12886
12839
|
*/
|
|
12887
12840
|
var SimpleCRS = class extends CRS {
|
|
12888
12841
|
/** @type {Projection} */
|
|
12889
|
-
static projection =
|
|
12842
|
+
static projection = LonLatProjection;
|
|
12890
12843
|
/** @type {Transformation} */
|
|
12891
12844
|
static transformation = /* @__PURE__ */ new Transformation(1, 0, -1, 0);
|
|
12892
12845
|
/**
|
|
@@ -12918,8 +12871,7 @@
|
|
|
12918
12871
|
/** @type {boolean} */
|
|
12919
12872
|
static infinite = true;
|
|
12920
12873
|
};
|
|
12921
|
-
|
|
12922
|
-
//#region src/layer/GeoJSON.js
|
|
12874
|
+
// src/layer/GeoJSON.js
|
|
12923
12875
|
/** @import {Feature, FeatureCollection, GeoJSON as GeoJSONData, GeoJsonObject, Geometry} from 'geojson' */
|
|
12924
12876
|
/** @import {Layer, InteractiveLayerOptions} from './Layer.js' */
|
|
12925
12877
|
/** @import {LatLngExpression} from '../geo/LatLng.js' */
|
|
@@ -13015,19 +12967,18 @@
|
|
|
13015
12967
|
* @returns {this}
|
|
13016
12968
|
*/
|
|
13017
12969
|
addData(geojson) {
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
for (const feature of features) if (feature.geometries || feature.geometry || feature.features || feature.coordinates) this.addData(feature);
|
|
12970
|
+
if (Array.isArray(geojson) || "features" in geojson) {
|
|
12971
|
+
for (const data of Array.isArray(geojson) ? geojson : geojson.features) this.addData(data);
|
|
13021
12972
|
return this;
|
|
13022
12973
|
}
|
|
13023
|
-
const options = this.options;
|
|
13024
|
-
if (options.filter && !options.filter(
|
|
13025
|
-
const layer = GeoJSON.geometryToLayer(
|
|
12974
|
+
const options = this.options, feature = GeoJSON.asFeature(geojson);
|
|
12975
|
+
if (!feature.geometry || options.filter && !options.filter(feature)) return this;
|
|
12976
|
+
const layer = GeoJSON.geometryToLayer(feature, options);
|
|
13026
12977
|
if (!layer) return this;
|
|
13027
|
-
layer.feature =
|
|
12978
|
+
layer.feature = feature;
|
|
13028
12979
|
layer.defaultOptions = layer.options;
|
|
13029
12980
|
this.resetStyle(layer);
|
|
13030
|
-
if (options.onEachFeature) options.onEachFeature(
|
|
12981
|
+
if (options.onEachFeature) options.onEachFeature(feature, layer);
|
|
13031
12982
|
return this.addLayer(layer);
|
|
13032
12983
|
}
|
|
13033
12984
|
/**
|
|
@@ -13176,8 +13127,7 @@
|
|
|
13176
13127
|
return asFeature(geojson);
|
|
13177
13128
|
}
|
|
13178
13129
|
};
|
|
13179
|
-
|
|
13180
|
-
//#region src/layer/Classification.js
|
|
13130
|
+
// src/layer/Classification.js
|
|
13181
13131
|
/** @import {PathOptions} from './vector/Path.js' */
|
|
13182
13132
|
/**
|
|
13183
13133
|
* A class of a `Classification`, given by value or by range.
|
|
@@ -13445,8 +13395,7 @@
|
|
|
13445
13395
|
return range;
|
|
13446
13396
|
});
|
|
13447
13397
|
}
|
|
13448
|
-
|
|
13449
|
-
//#region src/layer/HeatLayer.js
|
|
13398
|
+
// src/layer/HeatLayer.js
|
|
13450
13399
|
/** @import {BlanketOverlayOptions} from './BlanketOverlay.js' */
|
|
13451
13400
|
/** @import {LatLngExpression} from '../geo/LatLng.js' */
|
|
13452
13401
|
/**
|
|
@@ -13602,7 +13551,7 @@
|
|
|
13602
13551
|
if (!map || !this._bounds) return;
|
|
13603
13552
|
const ctx = this._ctx, { width, height } = this._container, offset = this._bounds.min, { radius, blur, max, minOpacity } = this.options, r = radius + blur, maxZoom = this.options.maxZoom ?? map.getMaxZoom(), zoomFactor = 1 / 2 ** Math.max(0, Math.min(maxZoom - map.getZoom(), 12)), cellSize = radius / 2, grid = /* @__PURE__ */ new Map();
|
|
13604
13553
|
for (const latlng of this._latlngs) {
|
|
13605
|
-
const point = map.latLngToLayerPoint(latlng).
|
|
13554
|
+
const point = map.latLngToLayerPoint(latlng)._round()._subtract(offset);
|
|
13606
13555
|
if (point.x < -r || point.y < -r || point.x > width + r || point.y > height + r) continue;
|
|
13607
13556
|
const intensity = (latlng.alt ?? latlng[2] ?? 1) * zoomFactor, key = `${Math.floor(point.x / cellSize)}:${Math.floor(point.y / cellSize)}`, cell = grid.get(key);
|
|
13608
13557
|
if (cell) {
|
|
@@ -13636,8 +13585,7 @@
|
|
|
13636
13585
|
ctx.putImageData(image, 0, 0);
|
|
13637
13586
|
}
|
|
13638
13587
|
};
|
|
13639
|
-
|
|
13640
|
-
//#region src/layer/ImageOverlay.js
|
|
13588
|
+
// src/layer/ImageOverlay.js
|
|
13641
13589
|
/** @import {InteractiveLayerOptions} from './Layer.js' */
|
|
13642
13590
|
/** @import {LatLng} from '../geo/LatLng.js' */
|
|
13643
13591
|
/** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */
|
|
@@ -13860,7 +13808,7 @@
|
|
|
13860
13808
|
setTransform(this._image, offset, scale);
|
|
13861
13809
|
}
|
|
13862
13810
|
_reset() {
|
|
13863
|
-
const image = this._image, bounds = new Bounds(this._map.latLngToLayerPoint(this._bounds.getNorthWest()), this._map.latLngToLayerPoint(this._bounds.getSouthEast())), size = bounds.getSize();
|
|
13811
|
+
const image = this._image, bounds = new Bounds(this._map.latLngToLayerPoint(this._bounds.getNorthWest())._round(), this._map.latLngToLayerPoint(this._bounds.getSouthEast())._round()), size = bounds.getSize();
|
|
13864
13812
|
setPosition(image, bounds.min);
|
|
13865
13813
|
image.style.width = `${size.x}px`;
|
|
13866
13814
|
image.style.height = `${size.y}px`;
|
|
@@ -13887,8 +13835,7 @@
|
|
|
13887
13835
|
return this._bounds.getCenter();
|
|
13888
13836
|
}
|
|
13889
13837
|
};
|
|
13890
|
-
|
|
13891
|
-
//#region src/layer/VideoOverlay.js
|
|
13838
|
+
// src/layer/VideoOverlay.js
|
|
13892
13839
|
/** @import {ImageOverlayOptions} from './ImageOverlay.js' */
|
|
13893
13840
|
/** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */
|
|
13894
13841
|
/** @import {MaplairEvent} from '../core/Events.js' */
|
|
@@ -13980,8 +13927,7 @@
|
|
|
13980
13927
|
}
|
|
13981
13928
|
}
|
|
13982
13929
|
};
|
|
13983
|
-
|
|
13984
|
-
//#region src/layer/SVGOverlay.js
|
|
13930
|
+
// src/layer/SVGOverlay.js
|
|
13985
13931
|
/** @import {ImageOverlayOptions} from './ImageOverlay.js' */
|
|
13986
13932
|
/** @import {LatLngBoundsExpression} from '../geo/LatLngBounds.js' */
|
|
13987
13933
|
/**
|
|
@@ -14026,8 +13972,7 @@
|
|
|
14026
13972
|
if (this.options.className) el.classList.add(...splitWords(this.options.className));
|
|
14027
13973
|
}
|
|
14028
13974
|
};
|
|
14029
|
-
|
|
14030
|
-
//#region src/layer/marker/DivIcon.js
|
|
13975
|
+
// src/layer/marker/DivIcon.js
|
|
14031
13976
|
/** @import {IconOptions} from './Icon.js' */
|
|
14032
13977
|
/** @import {PointExpression} from '../../geometry/Point.js' */
|
|
14033
13978
|
/**
|
|
@@ -14100,8 +14045,7 @@
|
|
|
14100
14045
|
return null;
|
|
14101
14046
|
}
|
|
14102
14047
|
};
|
|
14103
|
-
|
|
14104
|
-
//#region src/layer/marker/SvgIcon.js
|
|
14048
|
+
// src/layer/marker/SvgIcon.js
|
|
14105
14049
|
/** @import {DefaultIconOptions} from './DefaultIcon.js' */
|
|
14106
14050
|
const svgNS = "http://www.w3.org/2000/svg";
|
|
14107
14051
|
const markerPath = "M416.500 542.096L420.919 533.569L422.024 531.437L424.460 529.996L424.233 527.174L426.670 525.732L426.382 522.881L428.720 521.213L428.075 518.393L429.979 516.125L428.342 513.639L429.080 510.777L426.581 509.207L426.168 506.292L423.266 505.773L421.781 503.221L418.898 503.859L416.511 502.112L414.131 503.870L411.248 503.241L409.766 505.793L406.865 506.302L406.439 509.216L403.933 510.775L404.661 513.641L403.023 516.136L404.935 518.393L404.271 521.204L406.590 522.896L406.299 525.752L408.738 527.189L408.516 530.011L410.956 531.448L412.065 533.578Z";
|
|
@@ -14210,8 +14154,7 @@
|
|
|
14210
14154
|
return div;
|
|
14211
14155
|
}
|
|
14212
14156
|
};
|
|
14213
|
-
|
|
14214
|
-
//#region src/layer/marker/MarkerClusterGroup.js
|
|
14157
|
+
// src/layer/marker/MarkerClusterGroup.js
|
|
14215
14158
|
/** @import {Layer, LayerOptions} from '../Layer.js' */
|
|
14216
14159
|
/** @import {MaplairEvent} from '../../core/Events.js' */
|
|
14217
14160
|
/**
|
|
@@ -14501,8 +14444,7 @@
|
|
|
14501
14444
|
if (map && this._shown.has(spider.clusterMarker)) map.addLayer(spider.clusterMarker);
|
|
14502
14445
|
}
|
|
14503
14446
|
};
|
|
14504
|
-
|
|
14505
|
-
//#region src/layer/tile/GridLayer.js
|
|
14447
|
+
// src/layer/tile/GridLayer.js
|
|
14506
14448
|
/** @import {LatLngBoundsExpression} from '../../geo/LatLngBounds.js' */
|
|
14507
14449
|
/** @import {MaplairMap} from '../../map/Map.js' */
|
|
14508
14450
|
/** @import {MaplairEvent, TileEvent, TileErrorEvent} from '../../core/Events.js' */
|
|
@@ -14751,7 +14693,7 @@
|
|
|
14751
14693
|
* @returns {boolean}
|
|
14752
14694
|
*/
|
|
14753
14695
|
isLoading() {
|
|
14754
|
-
return this._loading;
|
|
14696
|
+
return !!this._loading;
|
|
14755
14697
|
}
|
|
14756
14698
|
/**
|
|
14757
14699
|
* Causes the layer to clear all the tiles and request them again.
|
|
@@ -15141,9 +15083,10 @@
|
|
|
15141
15083
|
coords
|
|
15142
15084
|
});
|
|
15143
15085
|
}
|
|
15144
|
-
if (this._noTilesToLoad()) {
|
|
15086
|
+
if (this._map && this._noTilesToLoad()) {
|
|
15145
15087
|
this._loading = false;
|
|
15146
15088
|
this.fire("load");
|
|
15089
|
+
if (!this._map) return;
|
|
15147
15090
|
this._map._scheduleIdleCheck();
|
|
15148
15091
|
if (!this._map._fadeAnimated) requestAnimationFrame(this._pruneTiles.bind(this));
|
|
15149
15092
|
else this._pruneTimeout = setTimeout(this._pruneTiles.bind(this), 250);
|
|
@@ -15176,9 +15119,7 @@
|
|
|
15176
15119
|
return Object.values(this._tiles).every((t) => t.loaded);
|
|
15177
15120
|
}
|
|
15178
15121
|
};
|
|
15179
|
-
|
|
15180
|
-
//#region src/layer/tile/TileLayer.js
|
|
15181
|
-
/** @import {Point} from '../../geometry/Point.js' */
|
|
15122
|
+
// src/layer/tile/TileLayer.js
|
|
15182
15123
|
/** @import {GridLayerOptions, TileDoneCallback} from './GridLayer.js' */
|
|
15183
15124
|
/** @import {TileEvent} from '../../core/Events.js' */
|
|
15184
15125
|
const osmHosts = ["tile.openstreetmap.org", "tile.osm.org"];
|
|
@@ -15311,7 +15252,8 @@
|
|
|
15311
15252
|
Object.assign(this.options, this._nonRetinaOptions);
|
|
15312
15253
|
this._retina = window.devicePixelRatio > 1;
|
|
15313
15254
|
if (this.options.detectRetina && this._retina && this.options.maxZoom > 0) {
|
|
15314
|
-
|
|
15255
|
+
const tileSize = this.options.tileSize;
|
|
15256
|
+
this.options.tileSize = tileSize instanceof Point ? tileSize.divideBy(2).floor() : Math.floor(tileSize / 2);
|
|
15315
15257
|
if (!this.options.zoomReverse) {
|
|
15316
15258
|
this.options.zoomOffset++;
|
|
15317
15259
|
this.options.maxZoom = Math.max(this.options.minZoom, this.options.maxZoom - 1);
|
|
@@ -15437,8 +15379,8 @@
|
|
|
15437
15379
|
done(null, tile);
|
|
15438
15380
|
}
|
|
15439
15381
|
_tileOnError(done, tile, e) {
|
|
15440
|
-
const errorUrl = this.options.errorTileUrl;
|
|
15441
|
-
if (errorUrl &&
|
|
15382
|
+
const errorUrl = this.options.errorTileUrl, src = tile.getAttribute("src");
|
|
15383
|
+
if (errorUrl && src !== errorUrl && (src || tile.isConnected)) tile.src = errorUrl;
|
|
15442
15384
|
done(e, tile);
|
|
15443
15385
|
}
|
|
15444
15386
|
_getZoomForUrl() {
|
|
@@ -15448,8 +15390,8 @@
|
|
|
15448
15390
|
return zoom + zoomOffset;
|
|
15449
15391
|
}
|
|
15450
15392
|
_getSubdomain(tilePoint) {
|
|
15451
|
-
const
|
|
15452
|
-
return
|
|
15393
|
+
const { subdomains } = this.options;
|
|
15394
|
+
return subdomains?.[Math.abs(tilePoint.x + tilePoint.y) % subdomains.length];
|
|
15453
15395
|
}
|
|
15454
15396
|
_abortLoading() {
|
|
15455
15397
|
let i, tile;
|
|
@@ -15482,8 +15424,7 @@
|
|
|
15482
15424
|
return Math.round(super._clampZoom(zoom));
|
|
15483
15425
|
}
|
|
15484
15426
|
};
|
|
15485
|
-
|
|
15486
|
-
//#region src/layer/tile/WMSTileLayer.js
|
|
15427
|
+
// src/layer/tile/WMSTileLayer.js
|
|
15487
15428
|
/** @import {CRS} from '../../geo/crs/CRS.js' */
|
|
15488
15429
|
/** @import {Point} from '../../geometry/Point.js' */
|
|
15489
15430
|
/** @import {MaplairMap} from '../../map/Map.js' */
|
|
@@ -15580,8 +15521,9 @@
|
|
|
15580
15521
|
_updateCrs() {
|
|
15581
15522
|
this._crs = this.options.crs ?? this._map.options.crs;
|
|
15582
15523
|
this._wmsVersion = parseFloat(this.wmsParams.version);
|
|
15583
|
-
|
|
15584
|
-
this.wmsParams
|
|
15524
|
+
delete this.wmsParams.srs;
|
|
15525
|
+
delete this.wmsParams.crs;
|
|
15526
|
+
this.wmsParams[this._wmsVersion >= 1.3 ? "crs" : "srs"] = this._crs.code;
|
|
15585
15527
|
}
|
|
15586
15528
|
/**
|
|
15587
15529
|
* Returns the map events the layer listens to, see `Layer`.
|
|
@@ -15650,6 +15592,7 @@
|
|
|
15650
15592
|
*/
|
|
15651
15593
|
setParams(params, noRedraw) {
|
|
15652
15594
|
Object.assign(this.wmsParams, params);
|
|
15595
|
+
if (this._map) this._updateCrs();
|
|
15653
15596
|
if (!noRedraw) {
|
|
15654
15597
|
this._keepCurrentTiles();
|
|
15655
15598
|
this.redraw();
|
|
@@ -15657,8 +15600,7 @@
|
|
|
15657
15600
|
return this;
|
|
15658
15601
|
}
|
|
15659
15602
|
};
|
|
15660
|
-
|
|
15661
|
-
//#region src/layer/vector/Canvas.js
|
|
15603
|
+
// src/layer/vector/Canvas.js
|
|
15662
15604
|
/** @import {MaplairMap} from '../../map/Map.js' */
|
|
15663
15605
|
/** @import {EventListener} from '../../core/Events.js' */
|
|
15664
15606
|
/** @import {RendererOptions} from './Renderer.js' */
|
|
@@ -15815,10 +15757,8 @@
|
|
|
15815
15757
|
this._requestRedraw(layer);
|
|
15816
15758
|
}
|
|
15817
15759
|
_updateDashArray(layer) {
|
|
15818
|
-
if (typeof layer.options.dashArray === "string")
|
|
15819
|
-
|
|
15820
|
-
layer.options._dashArray = parts.map((n) => Number(n)).filter((n) => !isNaN(n));
|
|
15821
|
-
} else layer.options._dashArray = layer.options.dashArray;
|
|
15760
|
+
if (typeof layer.options.dashArray === "string") layer._dashArray = layer.options.dashArray.split(DASH_SEPARATOR_RE$1).map((n) => Number(n)).filter((n) => !isNaN(n));
|
|
15761
|
+
else layer._dashArray = layer.options.dashArray;
|
|
15822
15762
|
}
|
|
15823
15763
|
_requestRedraw(layer) {
|
|
15824
15764
|
if (!this._map) return;
|
|
@@ -15889,14 +15829,10 @@
|
|
|
15889
15829
|
}
|
|
15890
15830
|
_updateCircle(layer) {
|
|
15891
15831
|
if (!this._drawing || layer._empty()) return;
|
|
15892
|
-
const
|
|
15893
|
-
if (s !== 1) {
|
|
15894
|
-
ctx.save();
|
|
15895
|
-
ctx.scale(1, s);
|
|
15896
|
-
}
|
|
15832
|
+
const { x, y } = layer._point, ctx = this._ctx, r = Math.max(Math.round(layer._pxRadius), 1), ry = Math.max(Math.round(layer._pxRadiusY), 1) || r;
|
|
15897
15833
|
ctx.beginPath();
|
|
15898
|
-
ctx.arc(
|
|
15899
|
-
|
|
15834
|
+
if (ry === r) ctx.arc(x, y, r, 0, Math.PI * 2);
|
|
15835
|
+
else ctx.ellipse(x, y, r, ry, 0, 0, Math.PI * 2);
|
|
15900
15836
|
this._fillStroke(ctx, layer);
|
|
15901
15837
|
}
|
|
15902
15838
|
_fillStroke(ctx, layer) {
|
|
@@ -15908,7 +15844,7 @@
|
|
|
15908
15844
|
}
|
|
15909
15845
|
if (options.stroke && options.weight !== 0) {
|
|
15910
15846
|
ctx.lineDashOffset = Number(options.dashOffset ?? 0);
|
|
15911
|
-
ctx.setLineDash(
|
|
15847
|
+
ctx.setLineDash(layer._dashArray ?? []);
|
|
15912
15848
|
ctx.globalAlpha = options.opacity;
|
|
15913
15849
|
ctx.lineWidth = options.weight;
|
|
15914
15850
|
ctx.strokeStyle = options.color;
|
|
@@ -15998,8 +15934,7 @@
|
|
|
15998
15934
|
this._requestRedraw(layer);
|
|
15999
15935
|
}
|
|
16000
15936
|
};
|
|
16001
|
-
|
|
16002
|
-
//#region src/layer/vector/Circle.js
|
|
15937
|
+
// src/layer/vector/Circle.js
|
|
16003
15938
|
/** @import {LatLngExpression} from '../../geo/LatLng.js' */
|
|
16004
15939
|
/** @import {CircleMarkerOptions} from './CircleMarker.js' */
|
|
16005
15940
|
/**
|
|
@@ -16033,10 +15968,12 @@
|
|
|
16033
15968
|
this.callInitHooks(Circle);
|
|
16034
15969
|
}
|
|
16035
15970
|
/**
|
|
16036
|
-
* Returns the `LatLngBounds` of the path.
|
|
15971
|
+
* Returns the `LatLngBounds` of the path. When the circle isn't on a map, they're
|
|
15972
|
+
* approximated on a sphere.
|
|
16037
15973
|
* @returns {LatLngBounds}
|
|
16038
15974
|
*/
|
|
16039
15975
|
getBounds() {
|
|
15976
|
+
if (!this._map) return this._latlng.toBounds(this._radius * 2);
|
|
16040
15977
|
const half = [this._pxRadius, this._pxRadiusY ?? this._pxRadius];
|
|
16041
15978
|
return new LatLngBounds(this._map.layerPointToLatLng(this._point.subtract(half)), this._map.layerPointToLatLng(this._point.add(half)));
|
|
16042
15979
|
}
|
|
@@ -16057,8 +15994,7 @@
|
|
|
16057
15994
|
this._updateBounds();
|
|
16058
15995
|
}
|
|
16059
15996
|
};
|
|
16060
|
-
|
|
16061
|
-
//#region src/layer/vector/Rectangle.js
|
|
15997
|
+
// src/layer/vector/Rectangle.js
|
|
16062
15998
|
/** @import {LatLngBoundsExpression} from '../../geo/LatLngBounds.js' */
|
|
16063
15999
|
/** @import {PolygonOptions} from './Polygon.js' */
|
|
16064
16000
|
/**
|
|
@@ -16105,8 +16041,7 @@
|
|
|
16105
16041
|
];
|
|
16106
16042
|
}
|
|
16107
16043
|
};
|
|
16108
|
-
|
|
16109
|
-
//#region src/map/Hash.js
|
|
16044
|
+
// src/map/Hash.js
|
|
16110
16045
|
/** @import {MaplairMap} from './Map.js' */
|
|
16111
16046
|
/** @import {Layer} from '../layer/Layer.js' */
|
|
16112
16047
|
const leadingHashRe = /^#/;
|
|
@@ -16338,8 +16273,7 @@
|
|
|
16338
16273
|
].filter(Boolean).join("&")}`;
|
|
16339
16274
|
}
|
|
16340
16275
|
};
|
|
16341
|
-
|
|
16342
|
-
//#region src/map/MapSync.js
|
|
16276
|
+
// src/map/MapSync.js
|
|
16343
16277
|
/** @import {MaplairMap} from './Map.js' */
|
|
16344
16278
|
/**
|
|
16345
16279
|
* Options of `MapSync`.
|
|
@@ -16503,8 +16437,7 @@
|
|
|
16503
16437
|
}
|
|
16504
16438
|
}
|
|
16505
16439
|
};
|
|
16506
|
-
|
|
16507
|
-
//#region src/map/handler/DisplaceHandler.js
|
|
16440
|
+
// src/map/handler/DisplaceHandler.js
|
|
16508
16441
|
/** @import {MaplairMap} from '../Map.js' */
|
|
16509
16442
|
/** @import {Layer} from '../../layer/Layer.js' */
|
|
16510
16443
|
/** @import {LayerEvent} from '../../core/Events.js' */
|
|
@@ -16843,81 +16776,13 @@
|
|
|
16843
16776
|
}
|
|
16844
16777
|
return points;
|
|
16845
16778
|
}
|
|
16846
|
-
|
|
16847
|
-
//#region src/Maplair.js
|
|
16779
|
+
// src/Maplair.js
|
|
16848
16780
|
/**
|
|
16849
16781
|
* A constant that represents the Maplair version in use.
|
|
16850
16782
|
* @type {string}
|
|
16851
16783
|
*/
|
|
16852
16784
|
const version = version$1;
|
|
16853
|
-
|
|
16854
|
-
//#region src/layer/marker/Marker.Rotation.js
|
|
16855
|
-
const { _setPos: setPos } = Marker.prototype, { _onDrag: onDrag } = MarkerDrag.prototype;
|
|
16856
|
-
/**
|
|
16857
|
-
* Options of `Marker` for the rotation of marker icons, see the
|
|
16858
|
-
* [marker rotation](#marker-setrotationangle).
|
|
16859
|
-
* @typedef {object} MarkerRotationOptions
|
|
16860
|
-
* @lends MarkerOptions
|
|
16861
|
-
* @property {number} [rotationAngle=0] Rotation of the icon in degrees, clockwise, e.g.
|
|
16862
|
-
* for the heading of a vehicle. On a rotated map, the angle is relative to the screen,
|
|
16863
|
-
* or to north with `rotateWithView`. The shadow is not rotated.
|
|
16864
|
-
* @property {string} [rotationOrigin] The CSS
|
|
16865
|
-
* [`transform-origin`](https://developer.mozilla.org/docs/Web/CSS/transform-origin) to
|
|
16866
|
-
* rotate the icon around, e.g. `'center'`. By default the anchor of the icon.
|
|
16867
|
-
* @property {boolean} [rotateWithView=false] On a rotated map (see
|
|
16868
|
-
* `MaplairMap.setBearing()`), whether the icon rotates with the map (e.g. for arrows
|
|
16869
|
-
* pointing in a geographic direction) instead of staying upright.
|
|
16870
|
-
*/
|
|
16871
|
-
Marker.include({ options: {
|
|
16872
|
-
rotationAngle: 0,
|
|
16873
|
-
rotationOrigin: void 0,
|
|
16874
|
-
rotateWithView: false
|
|
16875
|
-
} });
|
|
16876
|
-
/** @typedef {typeof markerRotationMethods} MarkerRotationMethods */
|
|
16877
|
-
Marker.include({
|
|
16878
|
-
/**
|
|
16879
|
-
* Changes the [`rotationAngle`](#markeroptions-rotationangle) of the icon.
|
|
16880
|
-
* @group Marker rotation
|
|
16881
|
-
* @param {number} angle
|
|
16882
|
-
* @returns {this}
|
|
16883
|
-
*/
|
|
16884
|
-
setRotationAngle(angle) {
|
|
16885
|
-
this.options.rotationAngle = angle;
|
|
16886
|
-
return this.update();
|
|
16887
|
-
},
|
|
16888
|
-
/**
|
|
16889
|
-
* Changes the [`rotationOrigin`](#markeroptions-rotationorigin) of the icon.
|
|
16890
|
-
* @group Marker rotation
|
|
16891
|
-
* @param {string} origin
|
|
16892
|
-
* @returns {this}
|
|
16893
|
-
*/
|
|
16894
|
-
setRotationOrigin(origin) {
|
|
16895
|
-
this.options.rotationOrigin = origin;
|
|
16896
|
-
return this.update();
|
|
16897
|
-
},
|
|
16898
|
-
_setPos(pos) {
|
|
16899
|
-
setPos.call(this, pos);
|
|
16900
|
-
this._rotateIcon();
|
|
16901
|
-
},
|
|
16902
|
-
_rotateIcon() {
|
|
16903
|
-
const bearing = this.options.rotateWithView ? 0 : this._map?.getBearing?.() ?? 0;
|
|
16904
|
-
this._rotateElement(this._icon, bearing + (this.options.rotationAngle || 0), this.options.rotationOrigin);
|
|
16905
|
-
this._rotateElement(this._shadow, bearing);
|
|
16906
|
-
},
|
|
16907
|
-
_rotateElement(el, angle, origin) {
|
|
16908
|
-
if (!el) return;
|
|
16909
|
-
if (angle % 360) {
|
|
16910
|
-
el.style.transform += ` rotate(${angle}deg)`;
|
|
16911
|
-
el.style.transformOrigin = origin ?? `${-parseFloat(el.style.marginLeft) || 0}px ${-parseFloat(el.style.marginTop) || 0}px`;
|
|
16912
|
-
} else if (el.style.transformOrigin) el.style.transformOrigin = "";
|
|
16913
|
-
}
|
|
16914
|
-
});
|
|
16915
|
-
MarkerDrag.include({ _onDrag(e) {
|
|
16916
|
-
onDrag.call(this, e);
|
|
16917
|
-
this._marker._rotateIcon();
|
|
16918
|
-
} });
|
|
16919
|
-
//#endregion
|
|
16920
|
-
//#region src/control/RotateControl.js
|
|
16785
|
+
// src/control/RotateControl.js
|
|
16921
16786
|
/** @import {ControlOptions} from './Control.js' */
|
|
16922
16787
|
/** @import {MaplairMap} from '../map/Map.js' */
|
|
16923
16788
|
const compass = "<svg aria-hidden=\"true\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\"><path d=\"M8 1 11 8H5z\" fill=\"#d22\"/><path d=\"M8 15 5 8h6z\" fill=\"#999\"/></svg>";
|
|
@@ -17011,8 +16876,7 @@
|
|
|
17011
16876
|
});
|
|
17012
16877
|
}
|
|
17013
16878
|
};
|
|
17014
|
-
|
|
17015
|
-
//#region src/map/Map.Rotation.js
|
|
16879
|
+
// src/map/Map.Rotation.js
|
|
17016
16880
|
function normalizeBearing(bearing) {
|
|
17017
16881
|
return (Number(bearing) % 360 + 360) % 360;
|
|
17018
16882
|
}
|
|
@@ -17021,7 +16885,7 @@
|
|
|
17021
16885
|
return new Point(point.x * cos - point.y * sin, point.x * sin + point.y * cos);
|
|
17022
16886
|
}
|
|
17023
16887
|
const rotatedMaps = /* @__PURE__ */ new WeakMap();
|
|
17024
|
-
const { panBy } = MaplairMap.prototype, { getEvents: getDivOverlayEvents } = DivOverlay.prototype, { _setPosition: setTooltipPosition } = Tooltip.prototype, { getEvents: getMarkerEvents } = Marker.prototype, { _onDown: onDraggableDown, _updatePosition: updateDraggablePosition } = Draggable.prototype, { _onPointerStart: onPinchStart } = PinchZoomHandler.prototype, { _onDown: onTapDragDown } = TapDragZoomHandler.prototype, { _pinchTo: pinchTo } = ScrollWheelZoomHandler.prototype;
|
|
16888
|
+
const { panBy } = MaplairMap.prototype, { getEvents: getDivOverlayEvents } = DivOverlay.prototype, { _setPosition: setTooltipPosition } = Tooltip.prototype, { getEvents: getMarkerEvents, _positionElements: positionMarkerElements } = Marker.prototype, { _onDown: onDraggableDown, _updatePosition: updateDraggablePosition } = Draggable.prototype, { _onPointerStart: onPinchStart } = PinchZoomHandler.prototype, { _onDown: onTapDragDown } = TapDragZoomHandler.prototype, { _pinchTo: pinchTo } = ScrollWheelZoomHandler.prototype;
|
|
17025
16889
|
/**
|
|
17026
16890
|
* Map options of the map rotation (`maplair/map-rotation`).
|
|
17027
16891
|
* @typedef {object} RotationMapOptions
|
|
@@ -17267,7 +17131,7 @@
|
|
|
17267
17131
|
},
|
|
17268
17132
|
_updatePosition() {
|
|
17269
17133
|
if (!this._map) return;
|
|
17270
|
-
const map = this._map, pos = map.latLngToLayerPoint(this._latlng), anchor = map._rotateToPane(new Point(this._getAnchor()));
|
|
17134
|
+
const map = this._map, pos = map.latLngToLayerPoint(this._latlng)._round(), anchor = map._rotateToPane(new Point(this._getAnchor()));
|
|
17271
17135
|
let offset = Point.from(this.options.offset);
|
|
17272
17136
|
const transformed = this._zoomAnimated || this.options.overflow || map._bearing;
|
|
17273
17137
|
if (!transformed) offset = offset.add(pos).add(anchor);
|
|
@@ -17335,19 +17199,36 @@
|
|
|
17335
17199
|
container.style.top = `${delta.y}px`;
|
|
17336
17200
|
this._setContainerPosition(pos, `${-delta.x - margin[0]}px ${-delta.y - margin[1]}px`);
|
|
17337
17201
|
} });
|
|
17338
|
-
/** @typedef {typeof markerRotationMethods} MarkerMapRotationMethods */
|
|
17339
|
-
Marker.include({
|
|
17340
17202
|
/**
|
|
17341
|
-
*
|
|
17342
|
-
* @
|
|
17343
|
-
* @
|
|
17203
|
+
* Options of `Marker` for the map rotation.
|
|
17204
|
+
* @typedef {object} MarkerMapRotationOptions
|
|
17205
|
+
* @lends MarkerOptions
|
|
17206
|
+
* @property {boolean} [rotateWithView=false] On a rotated map (see
|
|
17207
|
+
* `MaplairMap.setBearing()`), whether the icon rotates with the map (e.g. for arrows
|
|
17208
|
+
* pointing in a geographic direction) instead of staying upright. The `rotation` of
|
|
17209
|
+
* the marker is relative to the screen, or to north with `rotateWithView`.
|
|
17344
17210
|
*/
|
|
17345
|
-
|
|
17346
|
-
|
|
17347
|
-
|
|
17348
|
-
|
|
17349
|
-
|
|
17350
|
-
|
|
17211
|
+
Marker.include({ options: { rotateWithView: false } });
|
|
17212
|
+
/** @typedef {typeof markerRotationMethods} MarkerMapRotationMethods */
|
|
17213
|
+
Marker.include({
|
|
17214
|
+
/**
|
|
17215
|
+
* Overrides `getEvents()` of `Marker` to update the marker on rotation.
|
|
17216
|
+
* @internal
|
|
17217
|
+
* @returns {Record<string, Function>}
|
|
17218
|
+
*/
|
|
17219
|
+
getEvents() {
|
|
17220
|
+
return {
|
|
17221
|
+
...getMarkerEvents.call(this),
|
|
17222
|
+
rotate: this.update
|
|
17223
|
+
};
|
|
17224
|
+
},
|
|
17225
|
+
_positionElements(pos) {
|
|
17226
|
+
positionMarkerElements.call(this, pos);
|
|
17227
|
+
const bearing = this.options.rotateWithView ? 0 : this._map?.getBearing() ?? 0;
|
|
17228
|
+
if (!bearing) return;
|
|
17229
|
+
for (const el of [this._icon, this._shadow]) if (el) el.style.transform += ` rotate(${bearing}deg)`;
|
|
17230
|
+
}
|
|
17231
|
+
});
|
|
17351
17232
|
/** @typedef {typeof markerDragRotationMethods} MarkerDragMapRotationMethods */
|
|
17352
17233
|
MarkerDrag.include({ _adjustPan(e) {
|
|
17353
17234
|
const marker = this._marker, map = marker._map, speed = this._marker.options.autoPanSpeed, padding = this._marker.options.autoPanPadding, iconPos = getPosition(marker._icon), bounds = map.getPixelBounds(), origin = map.getPixelOrigin();
|
|
@@ -17492,8 +17373,7 @@ getEvents() {
|
|
|
17492
17373
|
this._panTimer = setTimeout(this._endPan.bind(this), gestureEndDelay);
|
|
17493
17374
|
}
|
|
17494
17375
|
});
|
|
17495
|
-
|
|
17496
|
-
//#region src/layer/marker/Marker.Move.js
|
|
17376
|
+
// src/layer/marker/Marker.Move.js
|
|
17497
17377
|
/** @import {LatLngExpression} from '../../geo/LatLng.js' */
|
|
17498
17378
|
/** @import {MaplairMap} from '../../map/Map.js' */
|
|
17499
17379
|
/** @import {MaplairEvent} from '../../core/Events.js' */
|
|
@@ -17503,9 +17383,8 @@ getEvents() {
|
|
|
17503
17383
|
* @property {number} [duration=1000] The duration of the movement in milliseconds.
|
|
17504
17384
|
* @property {number} [speed] The speed in meters (or units of the CRS) per second
|
|
17505
17385
|
* instead of the `duration`.
|
|
17506
|
-
* @property {boolean} [rotate=false] Whether to set the `
|
|
17507
|
-
* the heading of the movement (for icons pointing up
|
|
17508
|
-
* `rotationAngle`).
|
|
17386
|
+
* @property {boolean} [rotate=false] Whether to set the `rotation` of the marker to
|
|
17387
|
+
* the heading of the movement (for icons pointing up).
|
|
17509
17388
|
*/
|
|
17510
17389
|
const { onRemove } = Marker.prototype;
|
|
17511
17390
|
/** @typedef {typeof markerMoveMethods} MarkerMoveMethods */
|
|
@@ -17544,7 +17423,7 @@ getEvents() {
|
|
|
17544
17423
|
i++;
|
|
17545
17424
|
}
|
|
17546
17425
|
const from = points[i], to = points[i + 1];
|
|
17547
|
-
if (options.rotate && !from.equals(to)) this.options.
|
|
17426
|
+
if (options.rotate && !from.equals(to)) this.options.rotation = this._heading(from, to);
|
|
17548
17427
|
this.setLatLng(this._interpolate(from, to, lengths[i] ? Math.min(1, distance / lengths[i]) : 1));
|
|
17549
17428
|
if (moved < total) this._moveFrame = requestAnimationFrame(frame);
|
|
17550
17429
|
else {
|
|
@@ -17593,8 +17472,7 @@ getEvents() {
|
|
|
17593
17472
|
return onRemove.call(this, map);
|
|
17594
17473
|
}
|
|
17595
17474
|
});
|
|
17596
|
-
|
|
17597
|
-
//#region src/layer/vector/Path.DashAnimation.js
|
|
17475
|
+
// src/layer/vector/Path.DashAnimation.js
|
|
17598
17476
|
const DASH_SEPARATOR_RE = /[ ,]+/;
|
|
17599
17477
|
const { _updateStyle: updateSvgStyle$1 } = SVG.prototype, { _fillStroke: fillStroke, _destroyContainer: destroyCanvasContainer } = Canvas.prototype;
|
|
17600
17478
|
/**
|
|
@@ -17664,8 +17542,7 @@ getEvents() {
|
|
|
17664
17542
|
return performance.now() / 1e3 * speed % length;
|
|
17665
17543
|
}
|
|
17666
17544
|
});
|
|
17667
|
-
|
|
17668
|
-
//#region src/layer/vector/Polyline.Decorations.js
|
|
17545
|
+
// src/layer/vector/Polyline.Decorations.js
|
|
17669
17546
|
/**
|
|
17670
17547
|
* Options of `Path` for arrowheads and text along lines (for `Polyline`s and
|
|
17671
17548
|
* `Polygon`s). They are an optional feature: import this module to add the
|
|
@@ -17900,8 +17777,7 @@ getEvents() {
|
|
|
17900
17777
|
}
|
|
17901
17778
|
}
|
|
17902
17779
|
});
|
|
17903
|
-
|
|
17904
|
-
//#region src/layer/GeoJSON.Load.js
|
|
17780
|
+
// src/layer/GeoJSON.Load.js
|
|
17905
17781
|
/** @import {GeoJsonObject} from 'geojson' */
|
|
17906
17782
|
/** @import {MaplairEvent} from '../core/Events.js' */
|
|
17907
17783
|
/**
|
|
@@ -17958,8 +17834,7 @@ load(source, fetchOptions = this.options.fetchOptions) {
|
|
|
17958
17834
|
GeoJSON.addInitHook(function() {
|
|
17959
17835
|
if (this.options.url) this.load(this.options.url).catch(() => {});
|
|
17960
17836
|
});
|
|
17961
|
-
|
|
17962
|
-
//#region src/layer/vector/Path.ZoomStyles.js
|
|
17837
|
+
// src/layer/vector/Path.ZoomStyles.js
|
|
17963
17838
|
/**
|
|
17964
17839
|
* A zoom-dependent style value, of the `weight` option of paths and the `radius` of
|
|
17965
17840
|
* circle markers: either a function of the zoom or an object of zoom stops
|
|
@@ -18031,8 +17906,7 @@ load(source, fetchOptions = this.options.fetchOptions) {
|
|
|
18031
17906
|
Path.addInitHook(function() {
|
|
18032
17907
|
this._takeZoomStyles(this.options);
|
|
18033
17908
|
});
|
|
18034
|
-
|
|
18035
|
-
//#region src/Maplair.all.js
|
|
17909
|
+
// src/Maplair.all.js
|
|
18036
17910
|
var Maplair_all_exports = /* @__PURE__ */ __exportAll({
|
|
18037
17911
|
AttributionControl: () => AttributionControl,
|
|
18038
17912
|
BlanketOverlay: () => BlanketOverlay,
|
|
@@ -18082,11 +17956,13 @@ load(source, fetchOptions = this.options.fetchOptions) {
|
|
|
18082
17956
|
LeafletMap: () => MaplairMap,
|
|
18083
17957
|
LegendControl: () => LegendControl,
|
|
18084
17958
|
LineUtil: () => LineUtil_exports,
|
|
17959
|
+
LonLatProjection: () => LonLatProjection,
|
|
18085
17960
|
Map: () => MaplairMap,
|
|
18086
17961
|
MapSync: () => MapSync,
|
|
18087
17962
|
MaplairMap: () => MaplairMap,
|
|
18088
17963
|
Marker: () => Marker,
|
|
18089
17964
|
MarkerClusterGroup: () => MarkerClusterGroup,
|
|
17965
|
+
MercatorProjection: () => MercatorProjection,
|
|
18090
17966
|
MiniMapControl: () => MiniMapControl,
|
|
18091
17967
|
Path: () => Path,
|
|
18092
17968
|
PinchZoomHandler: () => PinchZoomHandler,
|
|
@@ -18095,7 +17971,6 @@ load(source, fetchOptions = this.options.fetchOptions) {
|
|
|
18095
17971
|
Polygon: () => Polygon,
|
|
18096
17972
|
Polyline: () => Polyline,
|
|
18097
17973
|
Popup: () => Popup,
|
|
18098
|
-
Projection: () => projection_exports,
|
|
18099
17974
|
Rectangle: () => Rectangle,
|
|
18100
17975
|
Renderer: () => Renderer,
|
|
18101
17976
|
RotateControl: () => RotateControl,
|
|
@@ -18106,6 +17981,7 @@ load(source, fetchOptions = this.options.fetchOptions) {
|
|
|
18106
17981
|
SearchControl: () => SearchControl,
|
|
18107
17982
|
SideBySideControl: () => SideBySideControl,
|
|
18108
17983
|
SimpleCRS: () => SimpleCRS,
|
|
17984
|
+
SphericalMercatorProjection: () => SphericalMercatorProjection,
|
|
18109
17985
|
SvgIcon: () => SvgIcon,
|
|
18110
17986
|
TapDragZoomHandler: () => TapDragZoomHandler,
|
|
18111
17987
|
TapHoldHandler: () => TapHoldHandler,
|
|
@@ -18121,13 +17997,11 @@ load(source, fetchOptions = this.options.fetchOptions) {
|
|
|
18121
17997
|
displace: () => displace,
|
|
18122
17998
|
version: () => version
|
|
18123
17999
|
});
|
|
18124
|
-
|
|
18125
|
-
//#region build/global.js
|
|
18000
|
+
// build/global.js
|
|
18126
18001
|
const isNamespace = (value) => value?.[Symbol.toStringTag] === "Module";
|
|
18127
18002
|
function toPlain(ns) {
|
|
18128
18003
|
return Object.fromEntries(Object.entries(ns).map(([key, value]) => [key, isNamespace(value) ? toPlain(value) : value]));
|
|
18129
18004
|
}
|
|
18130
|
-
//#endregion
|
|
18131
18005
|
return toPlain(Maplair_all_exports);
|
|
18132
18006
|
});
|
|
18133
18007
|
|