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
package/dist/maplair-src.js
CHANGED
|
@@ -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
|
|
|
6
6
|
//#region \0rolldown/runtime.js
|
|
@@ -16,7 +16,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
16
16
|
};
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region package.json
|
|
19
|
-
var version$1 = "4.0.0
|
|
19
|
+
var version$1 = "4.0.0";
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/core/Util.js
|
|
22
22
|
var Util_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -453,6 +453,24 @@ var Point = class Point {
|
|
|
453
453
|
this.y = round ? Math.round(_y) : _y;
|
|
454
454
|
}
|
|
455
455
|
/**
|
|
456
|
+
* Returns the given `Point` object as it is (unless `round` is set), or else a new
|
|
457
|
+
* `Point` object created from the given arguments (the same as of the constructor) —
|
|
458
|
+
* unlike the constructor, which always creates a new object.
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
* ```js
|
|
462
|
+
* Point.from(point) === point; // true
|
|
463
|
+
* Point.from([200, 300]); // Point(200, 300)
|
|
464
|
+
* ```
|
|
465
|
+
* @param {number|PointExpression} x The `x` coordinate, or the coordinates.
|
|
466
|
+
* @param {number} [y] The `y` coordinate.
|
|
467
|
+
* @param {boolean} [round]
|
|
468
|
+
* @returns {Point}
|
|
469
|
+
*/
|
|
470
|
+
static from(x, y, round) {
|
|
471
|
+
return x instanceof Point && !round ? x : new Point(x, y, round);
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
456
474
|
* Returns `true` if the Point object can be properly initialized with the given
|
|
457
475
|
* arguments (the same as of the constructor).
|
|
458
476
|
* @param {any} x
|
|
@@ -471,7 +489,7 @@ var Point = class Point {
|
|
|
471
489
|
* @returns {Point}
|
|
472
490
|
*/
|
|
473
491
|
add(point) {
|
|
474
|
-
return new Point(this)._add(
|
|
492
|
+
return new Point(this)._add(Point.from(point));
|
|
475
493
|
}
|
|
476
494
|
_add(point) {
|
|
477
495
|
this.x += point.x;
|
|
@@ -484,7 +502,7 @@ var Point = class Point {
|
|
|
484
502
|
* @returns {Point}
|
|
485
503
|
*/
|
|
486
504
|
subtract(point) {
|
|
487
|
-
return new Point(this)._subtract(
|
|
505
|
+
return new Point(this)._subtract(Point.from(point));
|
|
488
506
|
}
|
|
489
507
|
_subtract(point) {
|
|
490
508
|
this.x -= point.x;
|
|
@@ -592,7 +610,7 @@ var Point = class Point {
|
|
|
592
610
|
* @returns {number}
|
|
593
611
|
*/
|
|
594
612
|
distanceTo(point) {
|
|
595
|
-
point =
|
|
613
|
+
point = Point.from(point);
|
|
596
614
|
const x = point.x - this.x, y = point.y - this.y;
|
|
597
615
|
return Math.sqrt(x * x + y * y);
|
|
598
616
|
}
|
|
@@ -602,7 +620,7 @@ var Point = class Point {
|
|
|
602
620
|
* @returns {boolean}
|
|
603
621
|
*/
|
|
604
622
|
equals(point) {
|
|
605
|
-
point =
|
|
623
|
+
point = Point.from(point);
|
|
606
624
|
return point.x === this.x && point.y === this.y;
|
|
607
625
|
}
|
|
608
626
|
/**
|
|
@@ -612,7 +630,7 @@ var Point = class Point {
|
|
|
612
630
|
* @returns {boolean}
|
|
613
631
|
*/
|
|
614
632
|
contains(point) {
|
|
615
|
-
point =
|
|
633
|
+
point = Point.from(point);
|
|
616
634
|
return Math.abs(point.x) <= Math.abs(this.x) && Math.abs(point.y) <= Math.abs(this.y);
|
|
617
635
|
}
|
|
618
636
|
/**
|
|
@@ -3447,6 +3465,18 @@ var Bounds = class Bounds {
|
|
|
3447
3465
|
for (const point of points) this.extend(point);
|
|
3448
3466
|
}
|
|
3449
3467
|
/**
|
|
3468
|
+
* Returns the given `Bounds` object as it is, or else a new `Bounds` object created
|
|
3469
|
+
* from the given arguments (the same as of the constructor) — unlike the
|
|
3470
|
+
* constructor, which always creates a new object.
|
|
3471
|
+
* @param {PointExpression|BoundsExpression} [a] The first corner, the points or the
|
|
3472
|
+
* bounds.
|
|
3473
|
+
* @param {PointExpression} [b] The opposite corner.
|
|
3474
|
+
* @returns {Bounds}
|
|
3475
|
+
*/
|
|
3476
|
+
static from(a, b) {
|
|
3477
|
+
return a instanceof Bounds ? a : new Bounds(a, b);
|
|
3478
|
+
}
|
|
3479
|
+
/**
|
|
3450
3480
|
* Extends the bounds to contain the given point or bounds.
|
|
3451
3481
|
* @param {PointExpression|BoundsExpression} obj
|
|
3452
3482
|
* @returns {this}
|
|
@@ -3454,9 +3484,9 @@ var Bounds = class Bounds {
|
|
|
3454
3484
|
extend(obj) {
|
|
3455
3485
|
let min2, max2;
|
|
3456
3486
|
if (!obj) return this;
|
|
3457
|
-
if (obj instanceof Point || typeof obj[0] === "number" || "x" in obj) min2 = max2 =
|
|
3487
|
+
if (obj instanceof Point || typeof obj[0] === "number" || "x" in obj) min2 = max2 = Point.from(obj);
|
|
3458
3488
|
else {
|
|
3459
|
-
obj =
|
|
3489
|
+
obj = Bounds.from(obj);
|
|
3460
3490
|
min2 = obj.min;
|
|
3461
3491
|
max2 = obj.max;
|
|
3462
3492
|
if (!min2 || !max2) return this;
|
|
@@ -3522,8 +3552,8 @@ var Bounds = class Bounds {
|
|
|
3522
3552
|
*/
|
|
3523
3553
|
contains(obj) {
|
|
3524
3554
|
let min, max;
|
|
3525
|
-
if (typeof obj[0] === "number" || obj instanceof Point) obj =
|
|
3526
|
-
else obj =
|
|
3555
|
+
if (typeof obj[0] === "number" || obj instanceof Point) obj = Point.from(obj);
|
|
3556
|
+
else obj = Bounds.from(obj);
|
|
3527
3557
|
if (obj instanceof Bounds) {
|
|
3528
3558
|
min = obj.min;
|
|
3529
3559
|
max = obj.max;
|
|
@@ -3537,7 +3567,7 @@ var Bounds = class Bounds {
|
|
|
3537
3567
|
* @returns {boolean}
|
|
3538
3568
|
*/
|
|
3539
3569
|
intersects(bounds) {
|
|
3540
|
-
bounds =
|
|
3570
|
+
bounds = Bounds.from(bounds);
|
|
3541
3571
|
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;
|
|
3542
3572
|
return xIntersects && yIntersects;
|
|
3543
3573
|
}
|
|
@@ -3548,7 +3578,7 @@ var Bounds = class Bounds {
|
|
|
3548
3578
|
* @returns {boolean}
|
|
3549
3579
|
*/
|
|
3550
3580
|
overlaps(bounds) {
|
|
3551
|
-
bounds =
|
|
3581
|
+
bounds = Bounds.from(bounds);
|
|
3552
3582
|
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;
|
|
3553
3583
|
return xOverlaps && yOverlaps;
|
|
3554
3584
|
}
|
|
@@ -3577,7 +3607,7 @@ var Bounds = class Bounds {
|
|
|
3577
3607
|
*/
|
|
3578
3608
|
equals(bounds) {
|
|
3579
3609
|
if (!bounds) return false;
|
|
3580
|
-
bounds =
|
|
3610
|
+
bounds = Bounds.from(bounds);
|
|
3581
3611
|
return this.min.equals(bounds.getTopLeft()) && this.max.equals(bounds.getBottomRight());
|
|
3582
3612
|
}
|
|
3583
3613
|
};
|
|
@@ -3643,6 +3673,18 @@ var LatLngBounds = class LatLngBounds {
|
|
|
3643
3673
|
for (const latlng of latlngs) this.extend(latlng);
|
|
3644
3674
|
}
|
|
3645
3675
|
/**
|
|
3676
|
+
* Returns the given `LatLngBounds` object as it is, or else a new `LatLngBounds`
|
|
3677
|
+
* object created from the given arguments (the same as of the constructor) — unlike
|
|
3678
|
+
* the constructor, which always creates a new object.
|
|
3679
|
+
* @param {LatLngExpression|LatLngBoundsExpression} [corner1] The first corner, the
|
|
3680
|
+
* points or the bounds.
|
|
3681
|
+
* @param {LatLngExpression} [corner2] The opposite corner.
|
|
3682
|
+
* @returns {LatLngBounds}
|
|
3683
|
+
*/
|
|
3684
|
+
static from(corner1, corner2) {
|
|
3685
|
+
return corner1 instanceof LatLngBounds ? corner1 : new LatLngBounds(corner1, corner2);
|
|
3686
|
+
}
|
|
3687
|
+
/**
|
|
3646
3688
|
* Extend the bounds to contain the given point or bounds.
|
|
3647
3689
|
* @param {LatLngExpression|LatLngBoundsExpression} obj
|
|
3648
3690
|
* @returns {this}
|
|
@@ -3659,8 +3701,8 @@ var LatLngBounds = class LatLngBounds {
|
|
|
3659
3701
|
if (!sw2 || !ne2) return this;
|
|
3660
3702
|
} else {
|
|
3661
3703
|
if (!obj) return this;
|
|
3662
|
-
if (LatLng.validate(obj)) return this.extend(
|
|
3663
|
-
return this.extend(
|
|
3704
|
+
if (LatLng.validate(obj)) return this.extend(LatLng.from(obj));
|
|
3705
|
+
return this.extend(LatLngBounds.from(obj));
|
|
3664
3706
|
}
|
|
3665
3707
|
if (!sw && !ne) {
|
|
3666
3708
|
this._southWest = new LatLng(sw2.lat, sw2.lng);
|
|
@@ -3753,8 +3795,8 @@ var LatLngBounds = class LatLngBounds {
|
|
|
3753
3795
|
* @returns {boolean}
|
|
3754
3796
|
*/
|
|
3755
3797
|
contains(obj) {
|
|
3756
|
-
if (LatLng.validate(obj)) obj =
|
|
3757
|
-
else obj =
|
|
3798
|
+
if (LatLng.validate(obj)) obj = LatLng.from(obj);
|
|
3799
|
+
else obj = LatLngBounds.from(obj);
|
|
3758
3800
|
const sw = this._southWest, ne = this._northEast;
|
|
3759
3801
|
let sw2, ne2;
|
|
3760
3802
|
if (obj instanceof LatLngBounds) {
|
|
@@ -3770,7 +3812,7 @@ var LatLngBounds = class LatLngBounds {
|
|
|
3770
3812
|
* @returns {boolean}
|
|
3771
3813
|
*/
|
|
3772
3814
|
intersects(bounds) {
|
|
3773
|
-
bounds =
|
|
3815
|
+
bounds = LatLngBounds.from(bounds);
|
|
3774
3816
|
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;
|
|
3775
3817
|
return latIntersects && lngIntersects;
|
|
3776
3818
|
}
|
|
@@ -3781,7 +3823,7 @@ var LatLngBounds = class LatLngBounds {
|
|
|
3781
3823
|
* @returns {boolean}
|
|
3782
3824
|
*/
|
|
3783
3825
|
overlaps(bounds) {
|
|
3784
|
-
bounds =
|
|
3826
|
+
bounds = LatLngBounds.from(bounds);
|
|
3785
3827
|
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;
|
|
3786
3828
|
return latOverlaps && lngOverlaps;
|
|
3787
3829
|
}
|
|
@@ -3809,7 +3851,7 @@ var LatLngBounds = class LatLngBounds {
|
|
|
3809
3851
|
*/
|
|
3810
3852
|
equals(bounds, maxMargin) {
|
|
3811
3853
|
if (!bounds) return false;
|
|
3812
|
-
bounds =
|
|
3854
|
+
bounds = LatLngBounds.from(bounds);
|
|
3813
3855
|
return this._southWest.equals(bounds.getSouthWest(), maxMargin) && this._northEast.equals(bounds.getNorthEast(), maxMargin);
|
|
3814
3856
|
}
|
|
3815
3857
|
/**
|
|
@@ -3835,8 +3877,9 @@ var LatLngBounds = class LatLngBounds {
|
|
|
3835
3877
|
* [spatial reference system](https://en.wikipedia.org/wiki/Spatial_reference_system).
|
|
3836
3878
|
*
|
|
3837
3879
|
* Maplair defines the most usual CRSs by default. If you want to use a
|
|
3838
|
-
* CRS not defined by default,
|
|
3839
|
-
* [
|
|
3880
|
+
* CRS not defined by default, extend `CRS` with a projection of your own, e.g.
|
|
3881
|
+
* based on [Proj4js](https://github.com/proj4js/proj4js) (the Leaflet plugin
|
|
3882
|
+
* [Proj4Leaflet](https://github.com/kartena/Proj4Leaflet) doesn't work with Maplair).
|
|
3840
3883
|
*
|
|
3841
3884
|
* The CRSs are classes with static properties and methods only; they are not
|
|
3842
3885
|
* instantiated, the class itself is passed as the CRS, e.g. to the `crs` option of the
|
|
@@ -3946,7 +3989,7 @@ var CRS = class {
|
|
|
3946
3989
|
* @returns {LatLng}
|
|
3947
3990
|
*/
|
|
3948
3991
|
static wrapLatLng(latlng) {
|
|
3949
|
-
latlng =
|
|
3992
|
+
latlng = LatLng.from(latlng);
|
|
3950
3993
|
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;
|
|
3951
3994
|
return new LatLng(lat, lng, alt);
|
|
3952
3995
|
}
|
|
@@ -4090,6 +4133,24 @@ var LatLng = class LatLng {
|
|
|
4090
4133
|
this.alt = +_alt;
|
|
4091
4134
|
}
|
|
4092
4135
|
/**
|
|
4136
|
+
* Returns the given `LatLng` object as it is, or else a new `LatLng` object created
|
|
4137
|
+
* from the given arguments (the same as of the constructor) — unlike the
|
|
4138
|
+
* constructor, which always creates a new object.
|
|
4139
|
+
*
|
|
4140
|
+
* @example
|
|
4141
|
+
* ```js
|
|
4142
|
+
* LatLng.from(latlng) === latlng; // true
|
|
4143
|
+
* LatLng.from([50.5, 30.5]); // LatLng(50.5, 30.5)
|
|
4144
|
+
* ```
|
|
4145
|
+
* @param {number|LatLngExpression} lat Latitude in degrees, or the coordinates.
|
|
4146
|
+
* @param {number} [lng] Longitude in degrees.
|
|
4147
|
+
* @param {number} [alt] Altitude in meters.
|
|
4148
|
+
* @returns {LatLng}
|
|
4149
|
+
*/
|
|
4150
|
+
static from(lat, lng, alt) {
|
|
4151
|
+
return lat instanceof LatLng ? lat : new LatLng(lat, lng, alt);
|
|
4152
|
+
}
|
|
4153
|
+
/**
|
|
4093
4154
|
* Returns `true` if the LatLng object can be properly initialized with the given
|
|
4094
4155
|
* arguments (the same as of the constructor).
|
|
4095
4156
|
* @param {any} lat
|
|
@@ -4151,7 +4212,7 @@ var LatLng = class LatLng {
|
|
|
4151
4212
|
*/
|
|
4152
4213
|
equals(obj, maxMargin) {
|
|
4153
4214
|
if (!obj) return false;
|
|
4154
|
-
obj =
|
|
4215
|
+
obj = LatLng.from(obj);
|
|
4155
4216
|
return Math.max(Math.abs(this.lat - obj.lat), Math.abs(this.lng - obj.lng)) <= (maxMargin ?? 1e-9);
|
|
4156
4217
|
}
|
|
4157
4218
|
/**
|
|
@@ -4169,7 +4230,7 @@ var LatLng = class LatLng {
|
|
|
4169
4230
|
* @returns {number}
|
|
4170
4231
|
*/
|
|
4171
4232
|
distanceTo(other) {
|
|
4172
|
-
return EarthCRS.distance(this,
|
|
4233
|
+
return EarthCRS.distance(this, LatLng.from(other));
|
|
4173
4234
|
}
|
|
4174
4235
|
/**
|
|
4175
4236
|
* Returns a new `LatLng` object with the longitude wrapped so it's always between
|
|
@@ -4541,12 +4602,12 @@ const SphericalMercator = {
|
|
|
4541
4602
|
R: earthRadius$1,
|
|
4542
4603
|
MAX_LATITUDE: 85.0511287798,
|
|
4543
4604
|
project(latlng) {
|
|
4544
|
-
latlng =
|
|
4605
|
+
latlng = LatLng.from(latlng);
|
|
4545
4606
|
const d = Math.PI / 180, max = this.MAX_LATITUDE, lat = Math.max(Math.min(max, latlng.lat), -max), sin = Math.sin(lat * d);
|
|
4546
4607
|
return new Point(this.R * latlng.lng * d, this.R * Math.log((1 + sin) / (1 - sin)) / 2);
|
|
4547
4608
|
},
|
|
4548
4609
|
unproject(point) {
|
|
4549
|
-
point =
|
|
4610
|
+
point = Point.from(point);
|
|
4550
4611
|
const d = 180 / Math.PI;
|
|
4551
4612
|
return new LatLng((2 * Math.atan(Math.exp(point.y / this.R)) - Math.PI / 2) * d, point.x * d / this.R);
|
|
4552
4613
|
},
|
|
@@ -5466,7 +5527,7 @@ var DivOverlay = class DivOverlay extends Layer {
|
|
|
5466
5527
|
_updatePosition() {
|
|
5467
5528
|
if (!this._map) return;
|
|
5468
5529
|
const pos = this._map.latLngToLayerPoint(this._latlng), anchor = this._getAnchor();
|
|
5469
|
-
let offset =
|
|
5530
|
+
let offset = Point.from(this.options.offset);
|
|
5470
5531
|
if (this._zoomAnimated || this.options.overflow) this._setContainerPosition(pos.add(anchor));
|
|
5471
5532
|
else offset = offset.add(pos).add(anchor);
|
|
5472
5533
|
const bottom = this._containerBottom = -offset.y, left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x;
|
|
@@ -5930,7 +5991,7 @@ var Popup = class Popup extends DivOverlay {
|
|
|
5930
5991
|
}
|
|
5931
5992
|
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);
|
|
5932
5993
|
layerPos._add(this._getContainerPosition());
|
|
5933
|
-
const containerPos = map.layerPointToContainerPoint(layerPos), padding =
|
|
5994
|
+
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();
|
|
5934
5995
|
let dx = 0, dy = 0;
|
|
5935
5996
|
if (containerPos.x + containerWidth + paddingBR.x > size.x) dx = containerPos.x + containerWidth - size.x + paddingBR.x;
|
|
5936
5997
|
if (containerPos.x - dx - paddingTL.x < 0) dx = containerPos.x - paddingTL.x;
|
|
@@ -7715,7 +7776,7 @@ var DragHandler = class DragHandler extends Handler {
|
|
|
7715
7776
|
map._stop();
|
|
7716
7777
|
map._setUserEvent(e.originalEvent);
|
|
7717
7778
|
if (this._map.options.maxBounds && this._map.options.maxBoundsViscosity) {
|
|
7718
|
-
const bounds =
|
|
7779
|
+
const bounds = LatLngBounds.from(this._map.options.maxBounds);
|
|
7719
7780
|
this._offsetLimit = new Bounds(this._map.latLngToContainerPoint(bounds.getNorthWest()).multiplyBy(-1), this._map.latLngToContainerPoint(bounds.getSouthEast()).multiplyBy(-1).add(this._map.getSize()));
|
|
7720
7781
|
this._viscosity = Math.min(1, Math.max(0, this._map.options.maxBoundsViscosity));
|
|
7721
7782
|
} else this._offsetLimit = null;
|
|
@@ -7971,8 +8032,8 @@ var KeyboardHandler = class KeyboardHandler extends Handler {
|
|
|
7971
8032
|
if (key in this._panKeys) {
|
|
7972
8033
|
if (!map._panAnim || !map._panAnim._inProgress) {
|
|
7973
8034
|
offset = this._panKeys[key];
|
|
7974
|
-
if (e.shiftKey) offset =
|
|
7975
|
-
if (map.options.maxBounds) offset = map._limitOffset(
|
|
8035
|
+
if (e.shiftKey) offset = Point.from(offset).multiplyBy(3);
|
|
8036
|
+
if (map.options.maxBounds) offset = map._limitOffset(Point.from(offset), map.options.maxBounds);
|
|
7976
8037
|
map._setUserEvent(e);
|
|
7977
8038
|
if (map.options.worldCopyJump) {
|
|
7978
8039
|
const newLatLng = map.wrapLatLng(map.unproject(map.project(map.getCenter()).add(offset)));
|
|
@@ -8864,7 +8925,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
8864
8925
|
}, this);
|
|
8865
8926
|
if (options.maxBounds) this.setMaxBounds(options.maxBounds);
|
|
8866
8927
|
if (options.zoom !== void 0) this._zoom = this._limitZoom(options.zoom);
|
|
8867
|
-
if (options.center && options.zoom !== void 0) this.setView(
|
|
8928
|
+
if (options.center && options.zoom !== void 0) this.setView(LatLng.from(options.center), options.zoom, { reset: true });
|
|
8868
8929
|
this.callInitHooks(MaplairMap);
|
|
8869
8930
|
this._zoomAnimated = this.options.zoomAnimation;
|
|
8870
8931
|
if (this._zoomAnimated) this._createAnimProxy();
|
|
@@ -8957,8 +9018,8 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
8957
9018
|
}
|
|
8958
9019
|
_getBoundsCenterZoom(bounds, options) {
|
|
8959
9020
|
options ??= {};
|
|
8960
|
-
bounds = bounds.getBounds ? bounds.getBounds() :
|
|
8961
|
-
const paddingTL =
|
|
9021
|
+
bounds = bounds.getBounds ? bounds.getBounds() : LatLngBounds.from(bounds);
|
|
9022
|
+
const paddingTL = Point.from(options.paddingTopLeft || options.padding || [0, 0]), paddingBR = Point.from(options.paddingBottomRight || options.padding || [0, 0]);
|
|
8962
9023
|
let zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR));
|
|
8963
9024
|
zoom = typeof options.maxZoom === "number" ? Math.min(options.maxZoom, zoom) : zoom;
|
|
8964
9025
|
if (zoom === Infinity) return {
|
|
@@ -8980,7 +9041,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
8980
9041
|
* @returns {this}
|
|
8981
9042
|
*/
|
|
8982
9043
|
fitBounds(bounds, options) {
|
|
8983
|
-
bounds =
|
|
9044
|
+
bounds = LatLngBounds.from(bounds);
|
|
8984
9045
|
if (!bounds.isValid()) throw new Error("Bounds are not valid.");
|
|
8985
9046
|
const target = this._getBoundsCenterZoom(bounds, options);
|
|
8986
9047
|
return this.setView(target.center, target.zoom, options);
|
|
@@ -9013,7 +9074,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9013
9074
|
* @returns {this}
|
|
9014
9075
|
*/
|
|
9015
9076
|
panBy(offset, options) {
|
|
9016
|
-
offset =
|
|
9077
|
+
offset = Point.from(offset).round();
|
|
9017
9078
|
options ??= {};
|
|
9018
9079
|
if (!offset.x && !offset.y) return this.fire("moveend");
|
|
9019
9080
|
if (options.animate !== true && !this.getSize().contains(offset)) {
|
|
@@ -9194,7 +9255,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9194
9255
|
*/
|
|
9195
9256
|
panInsideBounds(bounds, options) {
|
|
9196
9257
|
this._enforcingBounds = true;
|
|
9197
|
-
const center = this.getCenter(), newCenter = this._limitCenter(center, this._zoom,
|
|
9258
|
+
const center = this.getCenter(), newCenter = this._limitCenter(center, this._zoom, LatLngBounds.from(bounds));
|
|
9198
9259
|
if (!center.equals(newCenter)) this.panTo(newCenter, options);
|
|
9199
9260
|
this._enforcingBounds = false;
|
|
9200
9261
|
return this;
|
|
@@ -9211,7 +9272,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9211
9272
|
*/
|
|
9212
9273
|
panInside(latlng, options) {
|
|
9213
9274
|
options ??= {};
|
|
9214
|
-
const paddingTL =
|
|
9275
|
+
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();
|
|
9215
9276
|
if (!paddedBounds.contains(pixelPoint)) {
|
|
9216
9277
|
this._enforcingBounds = true;
|
|
9217
9278
|
const centerOffset = pixelPoint.subtract(paddedBounds.getCenter());
|
|
@@ -9460,8 +9521,8 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9460
9521
|
* @returns {number}
|
|
9461
9522
|
*/
|
|
9462
9523
|
getBoundsZoom(bounds, inside, padding) {
|
|
9463
|
-
bounds =
|
|
9464
|
-
padding =
|
|
9524
|
+
bounds = LatLngBounds.from(bounds);
|
|
9525
|
+
padding = Point.from(padding ?? [0, 0]);
|
|
9465
9526
|
let zoom = this.getZoom() ?? 0;
|
|
9466
9527
|
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);
|
|
9467
9528
|
zoom = this.getScaleZoom(scale, zoom);
|
|
@@ -9582,7 +9643,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9582
9643
|
*/
|
|
9583
9644
|
project(latlng, zoom) {
|
|
9584
9645
|
zoom ??= this._zoom;
|
|
9585
|
-
return this.options.crs.latLngToPoint(
|
|
9646
|
+
return this.options.crs.latLngToPoint(LatLng.from(latlng), zoom);
|
|
9586
9647
|
}
|
|
9587
9648
|
/**
|
|
9588
9649
|
* Inverse of [`project`](#map-project).
|
|
@@ -9593,7 +9654,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9593
9654
|
*/
|
|
9594
9655
|
unproject(point, zoom) {
|
|
9595
9656
|
zoom ??= this._zoom;
|
|
9596
|
-
return this.options.crs.pointToLatLng(
|
|
9657
|
+
return this.options.crs.pointToLatLng(Point.from(point), zoom);
|
|
9597
9658
|
}
|
|
9598
9659
|
/**
|
|
9599
9660
|
* Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin),
|
|
@@ -9603,7 +9664,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9603
9664
|
* @returns {LatLng}
|
|
9604
9665
|
*/
|
|
9605
9666
|
layerPointToLatLng(point) {
|
|
9606
|
-
const projectedPoint =
|
|
9667
|
+
const projectedPoint = Point.from(point).add(this.getPixelOrigin());
|
|
9607
9668
|
return this.unproject(projectedPoint);
|
|
9608
9669
|
}
|
|
9609
9670
|
/**
|
|
@@ -9614,7 +9675,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9614
9675
|
* @returns {Point}
|
|
9615
9676
|
*/
|
|
9616
9677
|
latLngToLayerPoint(latlng) {
|
|
9617
|
-
return this.project(
|
|
9678
|
+
return this.project(LatLng.from(latlng))._round()._subtract(this.getPixelOrigin());
|
|
9618
9679
|
}
|
|
9619
9680
|
/**
|
|
9620
9681
|
* Returns a `LatLng` where `lat` and `lng` has been wrapped according to the
|
|
@@ -9627,7 +9688,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9627
9688
|
* @returns {LatLng}
|
|
9628
9689
|
*/
|
|
9629
9690
|
wrapLatLng(latlng) {
|
|
9630
|
-
return this.options.crs.wrapLatLng(
|
|
9691
|
+
return this.options.crs.wrapLatLng(LatLng.from(latlng));
|
|
9631
9692
|
}
|
|
9632
9693
|
/**
|
|
9633
9694
|
* Returns a `LatLngBounds` with the same size as the given one, ensuring that
|
|
@@ -9651,7 +9712,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9651
9712
|
* @returns {number}
|
|
9652
9713
|
*/
|
|
9653
9714
|
distance(latlng1, latlng2) {
|
|
9654
|
-
return this.options.crs.distance(
|
|
9715
|
+
return this.options.crs.distance(LatLng.from(latlng1), LatLng.from(latlng2));
|
|
9655
9716
|
}
|
|
9656
9717
|
/**
|
|
9657
9718
|
* Given a pixel coordinate relative to the map container, returns the corresponding
|
|
@@ -9661,7 +9722,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9661
9722
|
* @returns {Point}
|
|
9662
9723
|
*/
|
|
9663
9724
|
containerPointToLayerPoint(point) {
|
|
9664
|
-
return
|
|
9725
|
+
return Point.from(point).subtract(this._getMapPanePos());
|
|
9665
9726
|
}
|
|
9666
9727
|
/**
|
|
9667
9728
|
* Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin),
|
|
@@ -9671,7 +9732,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9671
9732
|
* @returns {Point}
|
|
9672
9733
|
*/
|
|
9673
9734
|
layerPointToContainerPoint(point) {
|
|
9674
|
-
return
|
|
9735
|
+
return Point.from(point).add(this._getMapPanePos());
|
|
9675
9736
|
}
|
|
9676
9737
|
/**
|
|
9677
9738
|
* Given a pixel coordinate relative to the map container, returns
|
|
@@ -9681,7 +9742,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9681
9742
|
* @returns {LatLng}
|
|
9682
9743
|
*/
|
|
9683
9744
|
containerPointToLatLng(point) {
|
|
9684
|
-
const layerPoint = this.containerPointToLayerPoint(
|
|
9745
|
+
const layerPoint = this.containerPointToLayerPoint(Point.from(point));
|
|
9685
9746
|
return this.layerPointToLatLng(layerPoint);
|
|
9686
9747
|
}
|
|
9687
9748
|
/**
|
|
@@ -9692,7 +9753,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
9692
9753
|
* @returns {Point}
|
|
9693
9754
|
*/
|
|
9694
9755
|
latLngToContainerPoint(latlng) {
|
|
9695
|
-
return this.layerPointToContainerPoint(this.latLngToLayerPoint(
|
|
9756
|
+
return this.layerPointToContainerPoint(this.latLngToLayerPoint(LatLng.from(latlng)));
|
|
9696
9757
|
}
|
|
9697
9758
|
/**
|
|
9698
9759
|
* Given a PointerEvent object, returns the pixel coordinate relative to the
|
|
@@ -10273,7 +10334,7 @@ function centroid(coords) {
|
|
|
10273
10334
|
let lngSum = 0;
|
|
10274
10335
|
let len = 0;
|
|
10275
10336
|
for (const coord of coords) {
|
|
10276
|
-
const latlng =
|
|
10337
|
+
const latlng = LatLng.from(coord);
|
|
10277
10338
|
latSum += latlng.lat;
|
|
10278
10339
|
lngSum += latlng.lng;
|
|
10279
10340
|
len++;
|
|
@@ -10594,7 +10655,7 @@ var Polyline = class Polyline extends Path {
|
|
|
10594
10655
|
* @returns {(Point & {distance: number})|null}
|
|
10595
10656
|
*/
|
|
10596
10657
|
closestLayerPoint(p) {
|
|
10597
|
-
p =
|
|
10658
|
+
p = Point.from(p);
|
|
10598
10659
|
let minDistance = Infinity, minPoint = null, p1, p2;
|
|
10599
10660
|
const closest = _sqClosestPointOnSegment;
|
|
10600
10661
|
for (const points of this._parts) for (let i = 1, len = points.length; i < len; i++) {
|
|
@@ -11241,9 +11302,9 @@ var Icon = class Icon extends Class {
|
|
|
11241
11302
|
const options = this.options;
|
|
11242
11303
|
let sizeOption = options[`${name}Size`];
|
|
11243
11304
|
if (typeof sizeOption === "number") sizeOption = [sizeOption, sizeOption];
|
|
11244
|
-
const size = Point.validate(sizeOption) &&
|
|
11305
|
+
const size = Point.validate(sizeOption) && Point.from(sizeOption);
|
|
11245
11306
|
const anchorPosition = name === "shadow" && options.shadowAnchor || options.iconAnchor || size && size.divideBy(2, true);
|
|
11246
|
-
const anchor = Point.validate(anchorPosition) &&
|
|
11307
|
+
const anchor = Point.validate(anchorPosition) && Point.from(anchorPosition);
|
|
11247
11308
|
img.className = `maplair-marker-${name} ${options.className || ""}`;
|
|
11248
11309
|
if (anchor) {
|
|
11249
11310
|
img.style.marginLeft = `${-anchor.x}px`;
|
|
@@ -11802,8 +11863,8 @@ var Marker = class Marker extends Layer {
|
|
|
11802
11863
|
const map = this._map;
|
|
11803
11864
|
if (!map) return;
|
|
11804
11865
|
const iconOpts = this.options.icon.options;
|
|
11805
|
-
const size = iconOpts.iconSize ?
|
|
11806
|
-
const anchor = iconOpts.iconAnchor ?
|
|
11866
|
+
const size = iconOpts.iconSize ? Point.from(iconOpts.iconSize) : new Point(0, 0);
|
|
11867
|
+
const anchor = iconOpts.iconAnchor ? Point.from(iconOpts.iconAnchor) : new Point(0, 0);
|
|
11807
11868
|
map.panInside(this._latlng, {
|
|
11808
11869
|
paddingTopLeft: anchor,
|
|
11809
11870
|
paddingBottomRight: size.subtract(anchor)
|
|
@@ -12131,7 +12192,7 @@ var SearchControl = class SearchControl extends Control {
|
|
|
12131
12192
|
* @returns {this}
|
|
12132
12193
|
*/
|
|
12133
12194
|
select(result) {
|
|
12134
|
-
const map = this._map, latlng =
|
|
12195
|
+
const map = this._map, latlng = LatLng.from(result.latlng), bounds = result.bounds ? LatLngBounds.from(result.bounds) : void 0;
|
|
12135
12196
|
this._input.value = result.label;
|
|
12136
12197
|
this._showResults([]);
|
|
12137
12198
|
if (bounds?.isValid() && !bounds.getNorthWest().equals(bounds.getSouthEast())) map.fitBounds(bounds, { maxZoom: this.options.zoom });
|
|
@@ -12537,11 +12598,11 @@ var TextControl = class TextControl extends Control {
|
|
|
12537
12598
|
*/
|
|
12538
12599
|
const LonLat = {
|
|
12539
12600
|
project(latlng) {
|
|
12540
|
-
latlng =
|
|
12601
|
+
latlng = LatLng.from(latlng);
|
|
12541
12602
|
return new Point(latlng.lng, latlng.lat);
|
|
12542
12603
|
},
|
|
12543
12604
|
unproject(point) {
|
|
12544
|
-
point =
|
|
12605
|
+
point = Point.from(point);
|
|
12545
12606
|
return new LatLng(point.y, point.x);
|
|
12546
12607
|
},
|
|
12547
12608
|
bounds: new Bounds([-180, -90], [180, 90])
|
|
@@ -12556,7 +12617,7 @@ const Mercator = {
|
|
|
12556
12617
|
R_MINOR: 6356752.314245179,
|
|
12557
12618
|
bounds: new Bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),
|
|
12558
12619
|
project(latlng) {
|
|
12559
|
-
latlng =
|
|
12620
|
+
latlng = LatLng.from(latlng);
|
|
12560
12621
|
const d = Math.PI / 180, r = this.R, tmp = this.R_MINOR / r, e = Math.sqrt(1 - tmp * tmp);
|
|
12561
12622
|
let y = latlng.lat * d;
|
|
12562
12623
|
const con = e * Math.sin(y);
|
|
@@ -12565,7 +12626,7 @@ const Mercator = {
|
|
|
12565
12626
|
return new Point(latlng.lng * d * r, y);
|
|
12566
12627
|
},
|
|
12567
12628
|
unproject(point) {
|
|
12568
|
-
point =
|
|
12629
|
+
point = Point.from(point);
|
|
12569
12630
|
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);
|
|
12570
12631
|
let phi = Math.PI / 2 - 2 * Math.atan(ts);
|
|
12571
12632
|
for (let i = 0, dphi = .1, con; i < 15 && Math.abs(dphi) > 1e-7; i++) {
|
|
@@ -12946,7 +13007,7 @@ var GeoJSON = class GeoJSON extends FeatureGroup {
|
|
|
12946
13007
|
* @returns {number[]}
|
|
12947
13008
|
*/
|
|
12948
13009
|
static latLngToCoords(latlng, precision) {
|
|
12949
|
-
latlng =
|
|
13010
|
+
latlng = LatLng.from(latlng);
|
|
12950
13011
|
return latlng.alt !== void 0 ? [
|
|
12951
13012
|
formatNum(latlng.lng, precision),
|
|
12952
13013
|
formatNum(latlng.lat, precision),
|
|
@@ -14041,7 +14102,7 @@ var DivIcon = class DivIcon extends Icon {
|
|
|
14041
14102
|
div.appendChild(options.html);
|
|
14042
14103
|
} else div.innerHTML = options.html !== false ? options.html : "";
|
|
14043
14104
|
if (options.bgPos) {
|
|
14044
|
-
const bgPos =
|
|
14105
|
+
const bgPos = Point.from(options.bgPos);
|
|
14045
14106
|
div.style.backgroundPosition = `${-bgPos.x}px ${-bgPos.y}px`;
|
|
14046
14107
|
}
|
|
14047
14108
|
this._setIconStyles(div, "icon");
|
|
@@ -14741,7 +14802,7 @@ var GridLayer = class GridLayer extends Layer {
|
|
|
14741
14802
|
}
|
|
14742
14803
|
if (!this.options.bounds) return true;
|
|
14743
14804
|
const tileBounds = this._tileCoordsToBounds(coords);
|
|
14744
|
-
return
|
|
14805
|
+
return LatLngBounds.from(this.options.bounds).overlaps(tileBounds);
|
|
14745
14806
|
}
|
|
14746
14807
|
_keyToBounds(key) {
|
|
14747
14808
|
return this._tileCoordsToBounds(this._keyToTileCoords(key));
|
|
@@ -16406,7 +16467,7 @@ MaplairMap.include({
|
|
|
16406
16467
|
* @returns {Point}
|
|
16407
16468
|
*/
|
|
16408
16469
|
containerPointToLayerPoint(point) {
|
|
16409
|
-
point =
|
|
16470
|
+
point = Point.from(point);
|
|
16410
16471
|
if (this._bearing) {
|
|
16411
16472
|
const center = this.getSize()._divideBy(2);
|
|
16412
16473
|
point = this._rotateToPane(point.subtract(center))._add(center);
|
|
@@ -16421,7 +16482,7 @@ MaplairMap.include({
|
|
|
16421
16482
|
* @returns {Point}
|
|
16422
16483
|
*/
|
|
16423
16484
|
layerPointToContainerPoint(point) {
|
|
16424
|
-
point =
|
|
16485
|
+
point = Point.from(point).add(this._getMapPanePos());
|
|
16425
16486
|
if (this._bearing) {
|
|
16426
16487
|
const center = this.getSize()._divideBy(2);
|
|
16427
16488
|
point = this._rotateToContainer(point.subtract(center))._add(center);
|
|
@@ -16451,7 +16512,7 @@ MaplairMap.include({
|
|
|
16451
16512
|
* @returns {this}
|
|
16452
16513
|
*/
|
|
16453
16514
|
panBy(offset, options) {
|
|
16454
|
-
return panBy.call(this, this._rotateToPane(
|
|
16515
|
+
return panBy.call(this, this._rotateToPane(Point.from(offset)), options);
|
|
16455
16516
|
},
|
|
16456
16517
|
_tryAnimatedPan(center, options) {
|
|
16457
16518
|
const offset = this._rotateToContainer(this._getCenterOffset(center)._trunc());
|
|
@@ -16550,7 +16611,7 @@ DivOverlay.include({
|
|
|
16550
16611
|
_updatePosition() {
|
|
16551
16612
|
if (!this._map) return;
|
|
16552
16613
|
const map = this._map, pos = map.latLngToLayerPoint(this._latlng), anchor = map._rotateToPane(new Point(this._getAnchor()));
|
|
16553
|
-
let offset =
|
|
16614
|
+
let offset = Point.from(this.options.offset);
|
|
16554
16615
|
const transformed = this._zoomAnimated || this.options.overflow || map._bearing;
|
|
16555
16616
|
if (!transformed) offset = offset.add(pos).add(anchor);
|
|
16556
16617
|
const bottom = this._containerBottom = -offset.y, left = this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x;
|
|
@@ -16585,7 +16646,7 @@ Popup.include({
|
|
|
16585
16646
|
return;
|
|
16586
16647
|
}
|
|
16587
16648
|
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);
|
|
16588
|
-
const containerPos = map.layerPointToContainerPoint(this._getContainerPosition())._add(topLeft), padding =
|
|
16649
|
+
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();
|
|
16589
16650
|
let dx = 0, dy = 0;
|
|
16590
16651
|
if (containerPos.x + containerWidth + paddingBR.x > size.x) dx = containerPos.x + containerWidth - size.x + paddingBR.x;
|
|
16591
16652
|
if (containerPos.x - dx - paddingTL.x < 0) dx = containerPos.x - paddingTL.x;
|
|
@@ -16812,7 +16873,7 @@ Marker.include({
|
|
|
16812
16873
|
*/
|
|
16813
16874
|
moveAlong(latlngs, options = {}) {
|
|
16814
16875
|
this.stopMoving();
|
|
16815
|
-
const points = [this._latlng, ...latlngs.map((latlng) =>
|
|
16876
|
+
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();
|
|
16816
16877
|
const frame = () => {
|
|
16817
16878
|
let distance = duration && !Browser_default.reducedMotion ? Math.min(1, (performance.now() - start) / duration) * total : total, i = 0;
|
|
16818
16879
|
const moved = distance;
|