maplair 4.0.0-alpha.2 → 4.0.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 +22 -38
- package/LICENSE +1 -1
- package/README.md +10 -9
- package/dist/esm/control/SearchControl.js +1 -1
- package/dist/esm/control/SearchControl.js.map +1 -1
- package/dist/esm/geo/LatLng.js +20 -2
- package/dist/esm/geo/LatLng.js.map +1 -1
- package/dist/esm/geo/LatLngBounds.js +19 -7
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geo/crs/CRS.js +4 -3
- package/dist/esm/geo/crs/CRS.js.map +1 -1
- package/dist/esm/geo/projection/Projection.LonLat.js +2 -2
- package/dist/esm/geo/projection/Projection.LonLat.js.map +1 -1
- package/dist/esm/geo/projection/Projection.Mercator.js +2 -2
- package/dist/esm/geo/projection/Projection.Mercator.js.map +1 -1
- package/dist/esm/geo/projection/Projection.SphericalMercator.js +2 -2
- package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +1 -1
- package/dist/esm/geometry/Bounds.js +19 -7
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/Point.js +23 -5
- package/dist/esm/geometry/Point.js.map +1 -1
- package/dist/esm/geometry/PolyUtil.js +1 -1
- package/dist/esm/geometry/PolyUtil.js.map +1 -1
- package/dist/esm/layer/DivOverlay.js +1 -1
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/GeoJSON.js +1 -1
- package/dist/esm/layer/GeoJSON.js.map +1 -1
- package/dist/esm/layer/Popup.js +1 -1
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/marker/DivIcon.js +1 -1
- package/dist/esm/layer/marker/DivIcon.js.map +1 -1
- 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.Move.js +1 -1
- package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +2 -2
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/tile/GridLayer.js +1 -1
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/vector/Polyline.js +1 -1
- package/dist/esm/layer/vector/Polyline.js.map +1 -1
- package/dist/esm/map/Map.Rotation.js +5 -5
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +19 -19
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/handler/DragHandler.js +1 -1
- package/dist/esm/map/handler/DragHandler.js.map +1 -1
- package/dist/esm/map/handler/KeyboardHandler.js +2 -2
- package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
- package/dist/esm/package.js +1 -1
- package/dist/maplair-global-src.js +134 -73
- package/dist/maplair-global-src.js.map +1 -1
- package/dist/maplair-global.js +3 -3
- package/dist/maplair-global.js.map +1 -1
- package/dist/maplair-src.js +134 -73
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.js +3 -3
- package/dist/maplair.js.map +1 -1
- package/package.json +4 -4
- package/src/control/SearchControl.js +2 -2
- package/src/geo/LatLng.js +21 -2
- package/src/geo/LatLngBounds.js +20 -7
- package/src/geo/crs/CRS.js +4 -3
- package/src/geo/projection/Projection.LonLat.js +2 -2
- package/src/geo/projection/Projection.Mercator.js +2 -2
- package/src/geo/projection/Projection.SphericalMercator.js +2 -2
- package/src/geometry/Bounds.js +20 -7
- package/src/geometry/Point.js +24 -5
- package/src/geometry/PolyUtil.js +1 -1
- package/src/layer/DivOverlay.js +1 -1
- package/src/layer/GeoJSON.js +1 -1
- package/src/layer/Popup.js +3 -3
- package/src/layer/marker/DivIcon.js +1 -1
- package/src/layer/marker/Icon.js +2 -2
- package/src/layer/marker/Marker.Move.js +1 -1
- package/src/layer/marker/Marker.js +2 -2
- package/src/layer/tile/GridLayer.js +1 -1
- package/src/layer/vector/Polyline.js +1 -1
- package/src/map/Map.Rotation.js +7 -7
- package/src/map/Map.js +21 -21
- package/src/map/handler/DragHandler.js +1 -1
- package/src/map/handler/KeyboardHandler.js +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* Maplair 4.0.0
|
|
3
|
-
* (c) 2026 Maplair contributors, (c) 2010-2026 Volodymyr Agafonkin, (c) 2010-2011 CloudMade
|
|
2
|
+
* Maplair 4.0.0, a JS library for interactive maps. https://maplair.org
|
|
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) {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
};
|
|
21
21
|
//#endregion
|
|
22
22
|
//#region package.json
|
|
23
|
-
var version$1 = "4.0.0
|
|
23
|
+
var version$1 = "4.0.0";
|
|
24
24
|
//#endregion
|
|
25
25
|
//#region src/core/Util.js
|
|
26
26
|
var Util_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -457,6 +457,24 @@
|
|
|
457
457
|
this.y = round ? Math.round(_y) : _y;
|
|
458
458
|
}
|
|
459
459
|
/**
|
|
460
|
+
* Returns the given `Point` object as it is (unless `round` is set), or else a new
|
|
461
|
+
* `Point` object created from the given arguments (the same as of the constructor) —
|
|
462
|
+
* unlike the constructor, which always creates a new object.
|
|
463
|
+
*
|
|
464
|
+
* @example
|
|
465
|
+
* ```js
|
|
466
|
+
* Point.from(point) === point; // true
|
|
467
|
+
* Point.from([200, 300]); // Point(200, 300)
|
|
468
|
+
* ```
|
|
469
|
+
* @param {number|PointExpression} x The `x` coordinate, or the coordinates.
|
|
470
|
+
* @param {number} [y] The `y` coordinate.
|
|
471
|
+
* @param {boolean} [round]
|
|
472
|
+
* @returns {Point}
|
|
473
|
+
*/
|
|
474
|
+
static from(x, y, round) {
|
|
475
|
+
return x instanceof Point && !round ? x : new Point(x, y, round);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
460
478
|
* Returns `true` if the Point object can be properly initialized with the given
|
|
461
479
|
* arguments (the same as of the constructor).
|
|
462
480
|
* @param {any} x
|
|
@@ -475,7 +493,7 @@
|
|
|
475
493
|
* @returns {Point}
|
|
476
494
|
*/
|
|
477
495
|
add(point) {
|
|
478
|
-
return new Point(this)._add(
|
|
496
|
+
return new Point(this)._add(Point.from(point));
|
|
479
497
|
}
|
|
480
498
|
_add(point) {
|
|
481
499
|
this.x += point.x;
|
|
@@ -488,7 +506,7 @@
|
|
|
488
506
|
* @returns {Point}
|
|
489
507
|
*/
|
|
490
508
|
subtract(point) {
|
|
491
|
-
return new Point(this)._subtract(
|
|
509
|
+
return new Point(this)._subtract(Point.from(point));
|
|
492
510
|
}
|
|
493
511
|
_subtract(point) {
|
|
494
512
|
this.x -= point.x;
|
|
@@ -596,7 +614,7 @@
|
|
|
596
614
|
* @returns {number}
|
|
597
615
|
*/
|
|
598
616
|
distanceTo(point) {
|
|
599
|
-
point =
|
|
617
|
+
point = Point.from(point);
|
|
600
618
|
const x = point.x - this.x, y = point.y - this.y;
|
|
601
619
|
return Math.sqrt(x * x + y * y);
|
|
602
620
|
}
|
|
@@ -606,7 +624,7 @@
|
|
|
606
624
|
* @returns {boolean}
|
|
607
625
|
*/
|
|
608
626
|
equals(point) {
|
|
609
|
-
point =
|
|
627
|
+
point = Point.from(point);
|
|
610
628
|
return point.x === this.x && point.y === this.y;
|
|
611
629
|
}
|
|
612
630
|
/**
|
|
@@ -616,7 +634,7 @@
|
|
|
616
634
|
* @returns {boolean}
|
|
617
635
|
*/
|
|
618
636
|
contains(point) {
|
|
619
|
-
point =
|
|
637
|
+
point = Point.from(point);
|
|
620
638
|
return Math.abs(point.x) <= Math.abs(this.x) && Math.abs(point.y) <= Math.abs(this.y);
|
|
621
639
|
}
|
|
622
640
|
/**
|
|
@@ -3451,6 +3469,18 @@
|
|
|
3451
3469
|
for (const point of points) this.extend(point);
|
|
3452
3470
|
}
|
|
3453
3471
|
/**
|
|
3472
|
+
* Returns the given `Bounds` object as it is, or else a new `Bounds` object created
|
|
3473
|
+
* from the given arguments (the same as of the constructor) — unlike the
|
|
3474
|
+
* constructor, which always creates a new object.
|
|
3475
|
+
* @param {PointExpression|BoundsExpression} [a] The first corner, the points or the
|
|
3476
|
+
* bounds.
|
|
3477
|
+
* @param {PointExpression} [b] The opposite corner.
|
|
3478
|
+
* @returns {Bounds}
|
|
3479
|
+
*/
|
|
3480
|
+
static from(a, b) {
|
|
3481
|
+
return a instanceof Bounds ? a : new Bounds(a, b);
|
|
3482
|
+
}
|
|
3483
|
+
/**
|
|
3454
3484
|
* Extends the bounds to contain the given point or bounds.
|
|
3455
3485
|
* @param {PointExpression|BoundsExpression} obj
|
|
3456
3486
|
* @returns {this}
|
|
@@ -3458,9 +3488,9 @@
|
|
|
3458
3488
|
extend(obj) {
|
|
3459
3489
|
let min2, max2;
|
|
3460
3490
|
if (!obj) return this;
|
|
3461
|
-
if (obj instanceof Point || typeof obj[0] === "number" || "x" in obj) min2 = max2 =
|
|
3491
|
+
if (obj instanceof Point || typeof obj[0] === "number" || "x" in obj) min2 = max2 = Point.from(obj);
|
|
3462
3492
|
else {
|
|
3463
|
-
obj =
|
|
3493
|
+
obj = Bounds.from(obj);
|
|
3464
3494
|
min2 = obj.min;
|
|
3465
3495
|
max2 = obj.max;
|
|
3466
3496
|
if (!min2 || !max2) return this;
|
|
@@ -3526,8 +3556,8 @@
|
|
|
3526
3556
|
*/
|
|
3527
3557
|
contains(obj) {
|
|
3528
3558
|
let min, max;
|
|
3529
|
-
if (typeof obj[0] === "number" || obj instanceof Point) obj =
|
|
3530
|
-
else obj =
|
|
3559
|
+
if (typeof obj[0] === "number" || obj instanceof Point) obj = Point.from(obj);
|
|
3560
|
+
else obj = Bounds.from(obj);
|
|
3531
3561
|
if (obj instanceof Bounds) {
|
|
3532
3562
|
min = obj.min;
|
|
3533
3563
|
max = obj.max;
|
|
@@ -3541,7 +3571,7 @@
|
|
|
3541
3571
|
* @returns {boolean}
|
|
3542
3572
|
*/
|
|
3543
3573
|
intersects(bounds) {
|
|
3544
|
-
bounds =
|
|
3574
|
+
bounds = Bounds.from(bounds);
|
|
3545
3575
|
const min = this.min, max = this.max, min2 = bounds.min, max2 = bounds.max, xIntersects = max2.x >= min.x && min2.x <= max.x, yIntersects = max2.y >= min.y && min2.y <= max.y;
|
|
3546
3576
|
return xIntersects && yIntersects;
|
|
3547
3577
|
}
|
|
@@ -3552,7 +3582,7 @@
|
|
|
3552
3582
|
* @returns {boolean}
|
|
3553
3583
|
*/
|
|
3554
3584
|
overlaps(bounds) {
|
|
3555
|
-
bounds =
|
|
3585
|
+
bounds = Bounds.from(bounds);
|
|
3556
3586
|
const min = this.min, max = this.max, min2 = bounds.min, max2 = bounds.max, xOverlaps = max2.x > min.x && min2.x < max.x, yOverlaps = max2.y > min.y && min2.y < max.y;
|
|
3557
3587
|
return xOverlaps && yOverlaps;
|
|
3558
3588
|
}
|
|
@@ -3581,7 +3611,7 @@
|
|
|
3581
3611
|
*/
|
|
3582
3612
|
equals(bounds) {
|
|
3583
3613
|
if (!bounds) return false;
|
|
3584
|
-
bounds =
|
|
3614
|
+
bounds = Bounds.from(bounds);
|
|
3585
3615
|
return this.min.equals(bounds.getTopLeft()) && this.max.equals(bounds.getBottomRight());
|
|
3586
3616
|
}
|
|
3587
3617
|
};
|
|
@@ -3647,6 +3677,18 @@
|
|
|
3647
3677
|
for (const latlng of latlngs) this.extend(latlng);
|
|
3648
3678
|
}
|
|
3649
3679
|
/**
|
|
3680
|
+
* Returns the given `LatLngBounds` object as it is, or else a new `LatLngBounds`
|
|
3681
|
+
* object created from the given arguments (the same as of the constructor) — unlike
|
|
3682
|
+
* the constructor, which always creates a new object.
|
|
3683
|
+
* @param {LatLngExpression|LatLngBoundsExpression} [corner1] The first corner, the
|
|
3684
|
+
* points or the bounds.
|
|
3685
|
+
* @param {LatLngExpression} [corner2] The opposite corner.
|
|
3686
|
+
* @returns {LatLngBounds}
|
|
3687
|
+
*/
|
|
3688
|
+
static from(corner1, corner2) {
|
|
3689
|
+
return corner1 instanceof LatLngBounds ? corner1 : new LatLngBounds(corner1, corner2);
|
|
3690
|
+
}
|
|
3691
|
+
/**
|
|
3650
3692
|
* Extend the bounds to contain the given point or bounds.
|
|
3651
3693
|
* @param {LatLngExpression|LatLngBoundsExpression} obj
|
|
3652
3694
|
* @returns {this}
|
|
@@ -3663,8 +3705,8 @@
|
|
|
3663
3705
|
if (!sw2 || !ne2) return this;
|
|
3664
3706
|
} else {
|
|
3665
3707
|
if (!obj) return this;
|
|
3666
|
-
if (LatLng.validate(obj)) return this.extend(
|
|
3667
|
-
return this.extend(
|
|
3708
|
+
if (LatLng.validate(obj)) return this.extend(LatLng.from(obj));
|
|
3709
|
+
return this.extend(LatLngBounds.from(obj));
|
|
3668
3710
|
}
|
|
3669
3711
|
if (!sw && !ne) {
|
|
3670
3712
|
this._southWest = new LatLng(sw2.lat, sw2.lng);
|
|
@@ -3757,8 +3799,8 @@
|
|
|
3757
3799
|
* @returns {boolean}
|
|
3758
3800
|
*/
|
|
3759
3801
|
contains(obj) {
|
|
3760
|
-
if (LatLng.validate(obj)) obj =
|
|
3761
|
-
else obj =
|
|
3802
|
+
if (LatLng.validate(obj)) obj = LatLng.from(obj);
|
|
3803
|
+
else obj = LatLngBounds.from(obj);
|
|
3762
3804
|
const sw = this._southWest, ne = this._northEast;
|
|
3763
3805
|
let sw2, ne2;
|
|
3764
3806
|
if (obj instanceof LatLngBounds) {
|
|
@@ -3774,7 +3816,7 @@
|
|
|
3774
3816
|
* @returns {boolean}
|
|
3775
3817
|
*/
|
|
3776
3818
|
intersects(bounds) {
|
|
3777
|
-
bounds =
|
|
3819
|
+
bounds = LatLngBounds.from(bounds);
|
|
3778
3820
|
const sw = this._southWest, ne = this._northEast, sw2 = bounds.getSouthWest(), ne2 = bounds.getNorthEast(), latIntersects = ne2.lat >= sw.lat && sw2.lat <= ne.lat, lngIntersects = ne2.lng >= sw.lng && sw2.lng <= ne.lng;
|
|
3779
3821
|
return latIntersects && lngIntersects;
|
|
3780
3822
|
}
|
|
@@ -3785,7 +3827,7 @@
|
|
|
3785
3827
|
* @returns {boolean}
|
|
3786
3828
|
*/
|
|
3787
3829
|
overlaps(bounds) {
|
|
3788
|
-
bounds =
|
|
3830
|
+
bounds = LatLngBounds.from(bounds);
|
|
3789
3831
|
const sw = this._southWest, ne = this._northEast, sw2 = bounds.getSouthWest(), ne2 = bounds.getNorthEast(), latOverlaps = ne2.lat > sw.lat && sw2.lat < ne.lat, lngOverlaps = ne2.lng > sw.lng && sw2.lng < ne.lng;
|
|
3790
3832
|
return latOverlaps && lngOverlaps;
|
|
3791
3833
|
}
|
|
@@ -3813,7 +3855,7 @@
|
|
|
3813
3855
|
*/
|
|
3814
3856
|
equals(bounds, maxMargin) {
|
|
3815
3857
|
if (!bounds) return false;
|
|
3816
|
-
bounds =
|
|
3858
|
+
bounds = LatLngBounds.from(bounds);
|
|
3817
3859
|
return this._southWest.equals(bounds.getSouthWest(), maxMargin) && this._northEast.equals(bounds.getNorthEast(), maxMargin);
|
|
3818
3860
|
}
|
|
3819
3861
|
/**
|
|
@@ -3839,8 +3881,9 @@
|
|
|
3839
3881
|
* [spatial reference system](https://en.wikipedia.org/wiki/Spatial_reference_system).
|
|
3840
3882
|
*
|
|
3841
3883
|
* Maplair defines the most usual CRSs by default. If you want to use a
|
|
3842
|
-
* CRS not defined by default,
|
|
3843
|
-
* [
|
|
3884
|
+
* CRS not defined by default, extend `CRS` with a projection of your own, e.g.
|
|
3885
|
+
* based on [Proj4js](https://github.com/proj4js/proj4js) (the Leaflet plugin
|
|
3886
|
+
* [Proj4Leaflet](https://github.com/kartena/Proj4Leaflet) doesn't work with Maplair).
|
|
3844
3887
|
*
|
|
3845
3888
|
* The CRSs are classes with static properties and methods only; they are not
|
|
3846
3889
|
* instantiated, the class itself is passed as the CRS, e.g. to the `crs` option of the
|
|
@@ -3950,7 +3993,7 @@
|
|
|
3950
3993
|
* @returns {LatLng}
|
|
3951
3994
|
*/
|
|
3952
3995
|
static wrapLatLng(latlng) {
|
|
3953
|
-
latlng =
|
|
3996
|
+
latlng = LatLng.from(latlng);
|
|
3954
3997
|
const lng = this.wrapLng ? wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng, lat = this.wrapLat ? wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat, alt = latlng.alt;
|
|
3955
3998
|
return new LatLng(lat, lng, alt);
|
|
3956
3999
|
}
|
|
@@ -4094,6 +4137,24 @@
|
|
|
4094
4137
|
this.alt = +_alt;
|
|
4095
4138
|
}
|
|
4096
4139
|
/**
|
|
4140
|
+
* Returns the given `LatLng` object as it is, or else a new `LatLng` object created
|
|
4141
|
+
* from the given arguments (the same as of the constructor) — unlike the
|
|
4142
|
+
* constructor, which always creates a new object.
|
|
4143
|
+
*
|
|
4144
|
+
* @example
|
|
4145
|
+
* ```js
|
|
4146
|
+
* LatLng.from(latlng) === latlng; // true
|
|
4147
|
+
* LatLng.from([50.5, 30.5]); // LatLng(50.5, 30.5)
|
|
4148
|
+
* ```
|
|
4149
|
+
* @param {number|LatLngExpression} lat Latitude in degrees, or the coordinates.
|
|
4150
|
+
* @param {number} [lng] Longitude in degrees.
|
|
4151
|
+
* @param {number} [alt] Altitude in meters.
|
|
4152
|
+
* @returns {LatLng}
|
|
4153
|
+
*/
|
|
4154
|
+
static from(lat, lng, alt) {
|
|
4155
|
+
return lat instanceof LatLng ? lat : new LatLng(lat, lng, alt);
|
|
4156
|
+
}
|
|
4157
|
+
/**
|
|
4097
4158
|
* Returns `true` if the LatLng object can be properly initialized with the given
|
|
4098
4159
|
* arguments (the same as of the constructor).
|
|
4099
4160
|
* @param {any} lat
|
|
@@ -4155,7 +4216,7 @@
|
|
|
4155
4216
|
*/
|
|
4156
4217
|
equals(obj, maxMargin) {
|
|
4157
4218
|
if (!obj) return false;
|
|
4158
|
-
obj =
|
|
4219
|
+
obj = LatLng.from(obj);
|
|
4159
4220
|
return Math.max(Math.abs(this.lat - obj.lat), Math.abs(this.lng - obj.lng)) <= (maxMargin ?? 1e-9);
|
|
4160
4221
|
}
|
|
4161
4222
|
/**
|
|
@@ -4173,7 +4234,7 @@
|
|
|
4173
4234
|
* @returns {number}
|
|
4174
4235
|
*/
|
|
4175
4236
|
distanceTo(other) {
|
|
4176
|
-
return EarthCRS.distance(this,
|
|
4237
|
+
return EarthCRS.distance(this, LatLng.from(other));
|
|
4177
4238
|
}
|
|
4178
4239
|
/**
|
|
4179
4240
|
* Returns a new `LatLng` object with the longitude wrapped so it's always between
|
|
@@ -4545,12 +4606,12 @@
|
|
|
4545
4606
|
R: earthRadius$1,
|
|
4546
4607
|
MAX_LATITUDE: 85.0511287798,
|
|
4547
4608
|
project(latlng) {
|
|
4548
|
-
latlng =
|
|
4609
|
+
latlng = LatLng.from(latlng);
|
|
4549
4610
|
const d = Math.PI / 180, max = this.MAX_LATITUDE, lat = Math.max(Math.min(max, latlng.lat), -max), sin = Math.sin(lat * d);
|
|
4550
4611
|
return new Point(this.R * latlng.lng * d, this.R * Math.log((1 + sin) / (1 - sin)) / 2);
|
|
4551
4612
|
},
|
|
4552
4613
|
unproject(point) {
|
|
4553
|
-
point =
|
|
4614
|
+
point = Point.from(point);
|
|
4554
4615
|
const d = 180 / Math.PI;
|
|
4555
4616
|
return new LatLng((2 * Math.atan(Math.exp(point.y / this.R)) - Math.PI / 2) * d, point.x * d / this.R);
|
|
4556
4617
|
},
|
|
@@ -5470,7 +5531,7 @@
|
|
|
5470
5531
|
_updatePosition() {
|
|
5471
5532
|
if (!this._map) return;
|
|
5472
5533
|
const pos = this._map.latLngToLayerPoint(this._latlng), anchor = this._getAnchor();
|
|
5473
|
-
let offset =
|
|
5534
|
+
let offset = Point.from(this.options.offset);
|
|
5474
5535
|
if (this._zoomAnimated || this.options.overflow) this._setContainerPosition(pos.add(anchor));
|
|
5475
5536
|
else offset = offset.add(pos).add(anchor);
|
|
5476
5537
|
const bottom = this._containerBottom = -offset.y, left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x;
|
|
@@ -5934,7 +5995,7 @@
|
|
|
5934
5995
|
}
|
|
5935
5996
|
const map = this._map, marginBottom = this._containerMarginBottom ?? (parseInt(getComputedStyle(this._container).marginBottom, 10) || 0), containerHeight = this._containerHeight + marginBottom, containerWidth = this._containerWidth, layerPos = new Point(this._containerLeft, -containerHeight - this._containerBottom);
|
|
5936
5997
|
layerPos._add(this._getContainerPosition());
|
|
5937
|
-
const containerPos = map.layerPointToContainerPoint(layerPos), padding =
|
|
5998
|
+
const containerPos = map.layerPointToContainerPoint(layerPos), padding = Point.from(this.options.autoPanPadding), paddingTL = Point.from(this.options.autoPanPaddingTopLeft ?? padding), paddingBR = Point.from(this.options.autoPanPaddingBottomRight ?? padding), size = map.getSize();
|
|
5938
5999
|
let dx = 0, dy = 0;
|
|
5939
6000
|
if (containerPos.x + containerWidth + paddingBR.x > size.x) dx = containerPos.x + containerWidth - size.x + paddingBR.x;
|
|
5940
6001
|
if (containerPos.x - dx - paddingTL.x < 0) dx = containerPos.x - paddingTL.x;
|
|
@@ -7719,7 +7780,7 @@
|
|
|
7719
7780
|
map._stop();
|
|
7720
7781
|
map._setUserEvent(e.originalEvent);
|
|
7721
7782
|
if (this._map.options.maxBounds && this._map.options.maxBoundsViscosity) {
|
|
7722
|
-
const bounds =
|
|
7783
|
+
const bounds = LatLngBounds.from(this._map.options.maxBounds);
|
|
7723
7784
|
this._offsetLimit = new Bounds(this._map.latLngToContainerPoint(bounds.getNorthWest()).multiplyBy(-1), this._map.latLngToContainerPoint(bounds.getSouthEast()).multiplyBy(-1).add(this._map.getSize()));
|
|
7724
7785
|
this._viscosity = Math.min(1, Math.max(0, this._map.options.maxBoundsViscosity));
|
|
7725
7786
|
} else this._offsetLimit = null;
|
|
@@ -7975,8 +8036,8 @@
|
|
|
7975
8036
|
if (key in this._panKeys) {
|
|
7976
8037
|
if (!map._panAnim || !map._panAnim._inProgress) {
|
|
7977
8038
|
offset = this._panKeys[key];
|
|
7978
|
-
if (e.shiftKey) offset =
|
|
7979
|
-
if (map.options.maxBounds) offset = map._limitOffset(
|
|
8039
|
+
if (e.shiftKey) offset = Point.from(offset).multiplyBy(3);
|
|
8040
|
+
if (map.options.maxBounds) offset = map._limitOffset(Point.from(offset), map.options.maxBounds);
|
|
7980
8041
|
map._setUserEvent(e);
|
|
7981
8042
|
if (map.options.worldCopyJump) {
|
|
7982
8043
|
const newLatLng = map.wrapLatLng(map.unproject(map.project(map.getCenter()).add(offset)));
|
|
@@ -8868,7 +8929,7 @@
|
|
|
8868
8929
|
}, this);
|
|
8869
8930
|
if (options.maxBounds) this.setMaxBounds(options.maxBounds);
|
|
8870
8931
|
if (options.zoom !== void 0) this._zoom = this._limitZoom(options.zoom);
|
|
8871
|
-
if (options.center && options.zoom !== void 0) this.setView(
|
|
8932
|
+
if (options.center && options.zoom !== void 0) this.setView(LatLng.from(options.center), options.zoom, { reset: true });
|
|
8872
8933
|
this.callInitHooks(MaplairMap);
|
|
8873
8934
|
this._zoomAnimated = this.options.zoomAnimation;
|
|
8874
8935
|
if (this._zoomAnimated) this._createAnimProxy();
|
|
@@ -8961,8 +9022,8 @@
|
|
|
8961
9022
|
}
|
|
8962
9023
|
_getBoundsCenterZoom(bounds, options) {
|
|
8963
9024
|
options ??= {};
|
|
8964
|
-
bounds = bounds.getBounds ? bounds.getBounds() :
|
|
8965
|
-
const paddingTL =
|
|
9025
|
+
bounds = bounds.getBounds ? bounds.getBounds() : LatLngBounds.from(bounds);
|
|
9026
|
+
const paddingTL = Point.from(options.paddingTopLeft || options.padding || [0, 0]), paddingBR = Point.from(options.paddingBottomRight || options.padding || [0, 0]);
|
|
8966
9027
|
let zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR));
|
|
8967
9028
|
zoom = typeof options.maxZoom === "number" ? Math.min(options.maxZoom, zoom) : zoom;
|
|
8968
9029
|
if (zoom === Infinity) return {
|
|
@@ -8984,7 +9045,7 @@
|
|
|
8984
9045
|
* @returns {this}
|
|
8985
9046
|
*/
|
|
8986
9047
|
fitBounds(bounds, options) {
|
|
8987
|
-
bounds =
|
|
9048
|
+
bounds = LatLngBounds.from(bounds);
|
|
8988
9049
|
if (!bounds.isValid()) throw new Error("Bounds are not valid.");
|
|
8989
9050
|
const target = this._getBoundsCenterZoom(bounds, options);
|
|
8990
9051
|
return this.setView(target.center, target.zoom, options);
|
|
@@ -9017,7 +9078,7 @@
|
|
|
9017
9078
|
* @returns {this}
|
|
9018
9079
|
*/
|
|
9019
9080
|
panBy(offset, options) {
|
|
9020
|
-
offset =
|
|
9081
|
+
offset = Point.from(offset).round();
|
|
9021
9082
|
options ??= {};
|
|
9022
9083
|
if (!offset.x && !offset.y) return this.fire("moveend");
|
|
9023
9084
|
if (options.animate !== true && !this.getSize().contains(offset)) {
|
|
@@ -9198,7 +9259,7 @@
|
|
|
9198
9259
|
*/
|
|
9199
9260
|
panInsideBounds(bounds, options) {
|
|
9200
9261
|
this._enforcingBounds = true;
|
|
9201
|
-
const center = this.getCenter(), newCenter = this._limitCenter(center, this._zoom,
|
|
9262
|
+
const center = this.getCenter(), newCenter = this._limitCenter(center, this._zoom, LatLngBounds.from(bounds));
|
|
9202
9263
|
if (!center.equals(newCenter)) this.panTo(newCenter, options);
|
|
9203
9264
|
this._enforcingBounds = false;
|
|
9204
9265
|
return this;
|
|
@@ -9215,7 +9276,7 @@
|
|
|
9215
9276
|
*/
|
|
9216
9277
|
panInside(latlng, options) {
|
|
9217
9278
|
options ??= {};
|
|
9218
|
-
const paddingTL =
|
|
9279
|
+
const paddingTL = Point.from(options.paddingTopLeft || options.padding || [0, 0]), paddingBR = Point.from(options.paddingBottomRight || options.padding || [0, 0]), pixelCenter = this.project(this.getCenter()), pixelPoint = this.project(latlng), pixelBounds = this.getPixelBounds(), paddedBounds = new Bounds([pixelBounds.min.add(paddingTL), pixelBounds.max.subtract(paddingBR)]), paddedSize = paddedBounds.getSize();
|
|
9219
9280
|
if (!paddedBounds.contains(pixelPoint)) {
|
|
9220
9281
|
this._enforcingBounds = true;
|
|
9221
9282
|
const centerOffset = pixelPoint.subtract(paddedBounds.getCenter());
|
|
@@ -9464,8 +9525,8 @@
|
|
|
9464
9525
|
* @returns {number}
|
|
9465
9526
|
*/
|
|
9466
9527
|
getBoundsZoom(bounds, inside, padding) {
|
|
9467
|
-
bounds =
|
|
9468
|
-
padding =
|
|
9528
|
+
bounds = LatLngBounds.from(bounds);
|
|
9529
|
+
padding = Point.from(padding ?? [0, 0]);
|
|
9469
9530
|
let zoom = this.getZoom() ?? 0;
|
|
9470
9531
|
const min = this.getMinZoom(), max = this.getMaxZoom(), nw = bounds.getNorthWest(), se = bounds.getSouthEast(), size = this.getSize().subtract(padding), boundsSize = new Bounds(this.project(se, zoom), this.project(nw, zoom)).getSize(), snap = this.options.zoomSnap, scalex = size.x / boundsSize.x, scaley = size.y / boundsSize.y, scale = inside ? Math.max(scalex, scaley) : Math.min(scalex, scaley);
|
|
9471
9532
|
zoom = this.getScaleZoom(scale, zoom);
|
|
@@ -9586,7 +9647,7 @@
|
|
|
9586
9647
|
*/
|
|
9587
9648
|
project(latlng, zoom) {
|
|
9588
9649
|
zoom ??= this._zoom;
|
|
9589
|
-
return this.options.crs.latLngToPoint(
|
|
9650
|
+
return this.options.crs.latLngToPoint(LatLng.from(latlng), zoom);
|
|
9590
9651
|
}
|
|
9591
9652
|
/**
|
|
9592
9653
|
* Inverse of [`project`](#map-project).
|
|
@@ -9597,7 +9658,7 @@
|
|
|
9597
9658
|
*/
|
|
9598
9659
|
unproject(point, zoom) {
|
|
9599
9660
|
zoom ??= this._zoom;
|
|
9600
|
-
return this.options.crs.pointToLatLng(
|
|
9661
|
+
return this.options.crs.pointToLatLng(Point.from(point), zoom);
|
|
9601
9662
|
}
|
|
9602
9663
|
/**
|
|
9603
9664
|
* Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin),
|
|
@@ -9607,7 +9668,7 @@
|
|
|
9607
9668
|
* @returns {LatLng}
|
|
9608
9669
|
*/
|
|
9609
9670
|
layerPointToLatLng(point) {
|
|
9610
|
-
const projectedPoint =
|
|
9671
|
+
const projectedPoint = Point.from(point).add(this.getPixelOrigin());
|
|
9611
9672
|
return this.unproject(projectedPoint);
|
|
9612
9673
|
}
|
|
9613
9674
|
/**
|
|
@@ -9618,7 +9679,7 @@
|
|
|
9618
9679
|
* @returns {Point}
|
|
9619
9680
|
*/
|
|
9620
9681
|
latLngToLayerPoint(latlng) {
|
|
9621
|
-
return this.project(
|
|
9682
|
+
return this.project(LatLng.from(latlng))._round()._subtract(this.getPixelOrigin());
|
|
9622
9683
|
}
|
|
9623
9684
|
/**
|
|
9624
9685
|
* Returns a `LatLng` where `lat` and `lng` has been wrapped according to the
|
|
@@ -9631,7 +9692,7 @@
|
|
|
9631
9692
|
* @returns {LatLng}
|
|
9632
9693
|
*/
|
|
9633
9694
|
wrapLatLng(latlng) {
|
|
9634
|
-
return this.options.crs.wrapLatLng(
|
|
9695
|
+
return this.options.crs.wrapLatLng(LatLng.from(latlng));
|
|
9635
9696
|
}
|
|
9636
9697
|
/**
|
|
9637
9698
|
* Returns a `LatLngBounds` with the same size as the given one, ensuring that
|
|
@@ -9655,7 +9716,7 @@
|
|
|
9655
9716
|
* @returns {number}
|
|
9656
9717
|
*/
|
|
9657
9718
|
distance(latlng1, latlng2) {
|
|
9658
|
-
return this.options.crs.distance(
|
|
9719
|
+
return this.options.crs.distance(LatLng.from(latlng1), LatLng.from(latlng2));
|
|
9659
9720
|
}
|
|
9660
9721
|
/**
|
|
9661
9722
|
* Given a pixel coordinate relative to the map container, returns the corresponding
|
|
@@ -9665,7 +9726,7 @@
|
|
|
9665
9726
|
* @returns {Point}
|
|
9666
9727
|
*/
|
|
9667
9728
|
containerPointToLayerPoint(point) {
|
|
9668
|
-
return
|
|
9729
|
+
return Point.from(point).subtract(this._getMapPanePos());
|
|
9669
9730
|
}
|
|
9670
9731
|
/**
|
|
9671
9732
|
* Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin),
|
|
@@ -9675,7 +9736,7 @@
|
|
|
9675
9736
|
* @returns {Point}
|
|
9676
9737
|
*/
|
|
9677
9738
|
layerPointToContainerPoint(point) {
|
|
9678
|
-
return
|
|
9739
|
+
return Point.from(point).add(this._getMapPanePos());
|
|
9679
9740
|
}
|
|
9680
9741
|
/**
|
|
9681
9742
|
* Given a pixel coordinate relative to the map container, returns
|
|
@@ -9685,7 +9746,7 @@
|
|
|
9685
9746
|
* @returns {LatLng}
|
|
9686
9747
|
*/
|
|
9687
9748
|
containerPointToLatLng(point) {
|
|
9688
|
-
const layerPoint = this.containerPointToLayerPoint(
|
|
9749
|
+
const layerPoint = this.containerPointToLayerPoint(Point.from(point));
|
|
9689
9750
|
return this.layerPointToLatLng(layerPoint);
|
|
9690
9751
|
}
|
|
9691
9752
|
/**
|
|
@@ -9696,7 +9757,7 @@
|
|
|
9696
9757
|
* @returns {Point}
|
|
9697
9758
|
*/
|
|
9698
9759
|
latLngToContainerPoint(latlng) {
|
|
9699
|
-
return this.layerPointToContainerPoint(this.latLngToLayerPoint(
|
|
9760
|
+
return this.layerPointToContainerPoint(this.latLngToLayerPoint(LatLng.from(latlng)));
|
|
9700
9761
|
}
|
|
9701
9762
|
/**
|
|
9702
9763
|
* Given a PointerEvent object, returns the pixel coordinate relative to the
|
|
@@ -10277,7 +10338,7 @@
|
|
|
10277
10338
|
let lngSum = 0;
|
|
10278
10339
|
let len = 0;
|
|
10279
10340
|
for (const coord of coords) {
|
|
10280
|
-
const latlng =
|
|
10341
|
+
const latlng = LatLng.from(coord);
|
|
10281
10342
|
latSum += latlng.lat;
|
|
10282
10343
|
lngSum += latlng.lng;
|
|
10283
10344
|
len++;
|
|
@@ -10598,7 +10659,7 @@
|
|
|
10598
10659
|
* @returns {(Point & {distance: number})|null}
|
|
10599
10660
|
*/
|
|
10600
10661
|
closestLayerPoint(p) {
|
|
10601
|
-
p =
|
|
10662
|
+
p = Point.from(p);
|
|
10602
10663
|
let minDistance = Infinity, minPoint = null, p1, p2;
|
|
10603
10664
|
const closest = _sqClosestPointOnSegment;
|
|
10604
10665
|
for (const points of this._parts) for (let i = 1, len = points.length; i < len; i++) {
|
|
@@ -11245,9 +11306,9 @@
|
|
|
11245
11306
|
const options = this.options;
|
|
11246
11307
|
let sizeOption = options[`${name}Size`];
|
|
11247
11308
|
if (typeof sizeOption === "number") sizeOption = [sizeOption, sizeOption];
|
|
11248
|
-
const size = Point.validate(sizeOption) &&
|
|
11309
|
+
const size = Point.validate(sizeOption) && Point.from(sizeOption);
|
|
11249
11310
|
const anchorPosition = name === "shadow" && options.shadowAnchor || options.iconAnchor || size && size.divideBy(2, true);
|
|
11250
|
-
const anchor = Point.validate(anchorPosition) &&
|
|
11311
|
+
const anchor = Point.validate(anchorPosition) && Point.from(anchorPosition);
|
|
11251
11312
|
img.className = `maplair-marker-${name} ${options.className || ""}`;
|
|
11252
11313
|
if (anchor) {
|
|
11253
11314
|
img.style.marginLeft = `${-anchor.x}px`;
|
|
@@ -11806,8 +11867,8 @@
|
|
|
11806
11867
|
const map = this._map;
|
|
11807
11868
|
if (!map) return;
|
|
11808
11869
|
const iconOpts = this.options.icon.options;
|
|
11809
|
-
const size = iconOpts.iconSize ?
|
|
11810
|
-
const anchor = iconOpts.iconAnchor ?
|
|
11870
|
+
const size = iconOpts.iconSize ? Point.from(iconOpts.iconSize) : new Point(0, 0);
|
|
11871
|
+
const anchor = iconOpts.iconAnchor ? Point.from(iconOpts.iconAnchor) : new Point(0, 0);
|
|
11811
11872
|
map.panInside(this._latlng, {
|
|
11812
11873
|
paddingTopLeft: anchor,
|
|
11813
11874
|
paddingBottomRight: size.subtract(anchor)
|
|
@@ -12135,7 +12196,7 @@
|
|
|
12135
12196
|
* @returns {this}
|
|
12136
12197
|
*/
|
|
12137
12198
|
select(result) {
|
|
12138
|
-
const map = this._map, latlng =
|
|
12199
|
+
const map = this._map, latlng = LatLng.from(result.latlng), bounds = result.bounds ? LatLngBounds.from(result.bounds) : void 0;
|
|
12139
12200
|
this._input.value = result.label;
|
|
12140
12201
|
this._showResults([]);
|
|
12141
12202
|
if (bounds?.isValid() && !bounds.getNorthWest().equals(bounds.getSouthEast())) map.fitBounds(bounds, { maxZoom: this.options.zoom });
|
|
@@ -12541,11 +12602,11 @@
|
|
|
12541
12602
|
*/
|
|
12542
12603
|
const LonLat = {
|
|
12543
12604
|
project(latlng) {
|
|
12544
|
-
latlng =
|
|
12605
|
+
latlng = LatLng.from(latlng);
|
|
12545
12606
|
return new Point(latlng.lng, latlng.lat);
|
|
12546
12607
|
},
|
|
12547
12608
|
unproject(point) {
|
|
12548
|
-
point =
|
|
12609
|
+
point = Point.from(point);
|
|
12549
12610
|
return new LatLng(point.y, point.x);
|
|
12550
12611
|
},
|
|
12551
12612
|
bounds: new Bounds([-180, -90], [180, 90])
|
|
@@ -12560,7 +12621,7 @@
|
|
|
12560
12621
|
R_MINOR: 6356752.314245179,
|
|
12561
12622
|
bounds: new Bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),
|
|
12562
12623
|
project(latlng) {
|
|
12563
|
-
latlng =
|
|
12624
|
+
latlng = LatLng.from(latlng);
|
|
12564
12625
|
const d = Math.PI / 180, r = this.R, tmp = this.R_MINOR / r, e = Math.sqrt(1 - tmp * tmp);
|
|
12565
12626
|
let y = latlng.lat * d;
|
|
12566
12627
|
const con = e * Math.sin(y);
|
|
@@ -12569,7 +12630,7 @@
|
|
|
12569
12630
|
return new Point(latlng.lng * d * r, y);
|
|
12570
12631
|
},
|
|
12571
12632
|
unproject(point) {
|
|
12572
|
-
point =
|
|
12633
|
+
point = Point.from(point);
|
|
12573
12634
|
const d = 180 / Math.PI, r = this.R, tmp = this.R_MINOR / r, e = Math.sqrt(1 - tmp * tmp), ts = Math.exp(-point.y / r);
|
|
12574
12635
|
let phi = Math.PI / 2 - 2 * Math.atan(ts);
|
|
12575
12636
|
for (let i = 0, dphi = .1, con; i < 15 && Math.abs(dphi) > 1e-7; i++) {
|
|
@@ -12950,7 +13011,7 @@
|
|
|
12950
13011
|
* @returns {number[]}
|
|
12951
13012
|
*/
|
|
12952
13013
|
static latLngToCoords(latlng, precision) {
|
|
12953
|
-
latlng =
|
|
13014
|
+
latlng = LatLng.from(latlng);
|
|
12954
13015
|
return latlng.alt !== void 0 ? [
|
|
12955
13016
|
formatNum(latlng.lng, precision),
|
|
12956
13017
|
formatNum(latlng.lat, precision),
|
|
@@ -14045,7 +14106,7 @@ toGeoJSON(precision) {
|
|
|
14045
14106
|
div.appendChild(options.html);
|
|
14046
14107
|
} else div.innerHTML = options.html !== false ? options.html : "";
|
|
14047
14108
|
if (options.bgPos) {
|
|
14048
|
-
const bgPos =
|
|
14109
|
+
const bgPos = Point.from(options.bgPos);
|
|
14049
14110
|
div.style.backgroundPosition = `${-bgPos.x}px ${-bgPos.y}px`;
|
|
14050
14111
|
}
|
|
14051
14112
|
this._setIconStyles(div, "icon");
|
|
@@ -14745,7 +14806,7 @@ toGeoJSON(precision) {
|
|
|
14745
14806
|
}
|
|
14746
14807
|
if (!this.options.bounds) return true;
|
|
14747
14808
|
const tileBounds = this._tileCoordsToBounds(coords);
|
|
14748
|
-
return
|
|
14809
|
+
return LatLngBounds.from(this.options.bounds).overlaps(tileBounds);
|
|
14749
14810
|
}
|
|
14750
14811
|
_keyToBounds(key) {
|
|
14751
14812
|
return this._tileCoordsToBounds(this._keyToTileCoords(key));
|
|
@@ -16410,7 +16471,7 @@ toGeoJSON(precision) {
|
|
|
16410
16471
|
* @returns {Point}
|
|
16411
16472
|
*/
|
|
16412
16473
|
containerPointToLayerPoint(point) {
|
|
16413
|
-
point =
|
|
16474
|
+
point = Point.from(point);
|
|
16414
16475
|
if (this._bearing) {
|
|
16415
16476
|
const center = this.getSize()._divideBy(2);
|
|
16416
16477
|
point = this._rotateToPane(point.subtract(center))._add(center);
|
|
@@ -16425,7 +16486,7 @@ toGeoJSON(precision) {
|
|
|
16425
16486
|
* @returns {Point}
|
|
16426
16487
|
*/
|
|
16427
16488
|
layerPointToContainerPoint(point) {
|
|
16428
|
-
point =
|
|
16489
|
+
point = Point.from(point).add(this._getMapPanePos());
|
|
16429
16490
|
if (this._bearing) {
|
|
16430
16491
|
const center = this.getSize()._divideBy(2);
|
|
16431
16492
|
point = this._rotateToContainer(point.subtract(center))._add(center);
|
|
@@ -16455,7 +16516,7 @@ toGeoJSON(precision) {
|
|
|
16455
16516
|
* @returns {this}
|
|
16456
16517
|
*/
|
|
16457
16518
|
panBy(offset, options) {
|
|
16458
|
-
return panBy.call(this, this._rotateToPane(
|
|
16519
|
+
return panBy.call(this, this._rotateToPane(Point.from(offset)), options);
|
|
16459
16520
|
},
|
|
16460
16521
|
_tryAnimatedPan(center, options) {
|
|
16461
16522
|
const offset = this._rotateToContainer(this._getCenterOffset(center)._trunc());
|
|
@@ -16554,7 +16615,7 @@ toGeoJSON(precision) {
|
|
|
16554
16615
|
_updatePosition() {
|
|
16555
16616
|
if (!this._map) return;
|
|
16556
16617
|
const map = this._map, pos = map.latLngToLayerPoint(this._latlng), anchor = map._rotateToPane(new Point(this._getAnchor()));
|
|
16557
|
-
let offset =
|
|
16618
|
+
let offset = Point.from(this.options.offset);
|
|
16558
16619
|
const transformed = this._zoomAnimated || this.options.overflow || map._bearing;
|
|
16559
16620
|
if (!transformed) offset = offset.add(pos).add(anchor);
|
|
16560
16621
|
const bottom = this._containerBottom = -offset.y, left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x;
|
|
@@ -16589,7 +16650,7 @@ toGeoJSON(precision) {
|
|
|
16589
16650
|
return;
|
|
16590
16651
|
}
|
|
16591
16652
|
const map = this._map, marginBottom = this._containerMarginBottom ?? (parseInt(getComputedStyle(this._container).marginBottom, 10) || 0), containerHeight = this._containerHeight + marginBottom, containerWidth = this._containerWidth, topLeft = new Point(this._containerLeft, -containerHeight - this._containerBottom);
|
|
16592
|
-
const containerPos = map.layerPointToContainerPoint(this._getContainerPosition())._add(topLeft), padding =
|
|
16653
|
+
const containerPos = map.layerPointToContainerPoint(this._getContainerPosition())._add(topLeft), padding = Point.from(this.options.autoPanPadding), paddingTL = Point.from(this.options.autoPanPaddingTopLeft ?? padding), paddingBR = Point.from(this.options.autoPanPaddingBottomRight ?? padding), size = map.getSize();
|
|
16593
16654
|
let dx = 0, dy = 0;
|
|
16594
16655
|
if (containerPos.x + containerWidth + paddingBR.x > size.x) dx = containerPos.x + containerWidth - size.x + paddingBR.x;
|
|
16595
16656
|
if (containerPos.x - dx - paddingTL.x < 0) dx = containerPos.x - paddingTL.x;
|
|
@@ -16816,7 +16877,7 @@ getEvents() {
|
|
|
16816
16877
|
*/
|
|
16817
16878
|
moveAlong(latlngs, options = {}) {
|
|
16818
16879
|
this.stopMoving();
|
|
16819
|
-
const points = [this._latlng, ...latlngs.map((latlng) =>
|
|
16880
|
+
const points = [this._latlng, ...latlngs.map((latlng) => LatLng.from(latlng))], lengths = points.slice(1).map((point, i) => this._map?.distance(points[i], point) ?? points[i].distanceTo(point)), total = lengths.reduce((sum, length) => sum + length, 0), duration = options.speed ? total / options.speed * 1e3 : options.duration ?? 1e3, start = performance.now();
|
|
16820
16881
|
const frame = () => {
|
|
16821
16882
|
let distance = duration && !Browser_default.reducedMotion ? Math.min(1, (performance.now() - start) / duration) * total : total, i = 0;
|
|
16822
16883
|
const moved = distance;
|