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/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "maplair",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"homepage": "https://maplair.org/",
|
|
5
5
|
"description": "JavaScript library for mobile-friendly interactive maps",
|
|
6
|
-
"author": "
|
|
6
|
+
"author": "Simon Legner",
|
|
7
7
|
"contributors": [
|
|
8
|
+
"Volodymyr Agafonkin",
|
|
8
9
|
"Iván Sánchez Ortega",
|
|
9
10
|
"Dave Leaver",
|
|
10
11
|
"Yohan Boniface",
|
|
11
12
|
"Jon Koops",
|
|
12
13
|
"Florian Bischof",
|
|
13
14
|
"Per Liedman",
|
|
14
|
-
"John Firebaugh"
|
|
15
|
-
"Simon Legner"
|
|
15
|
+
"John Firebaugh"
|
|
16
16
|
],
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@e18e/eslint-plugin": "^0.8.1",
|
|
@@ -372,8 +372,8 @@ export class SearchControl extends Control {
|
|
|
372
372
|
*/
|
|
373
373
|
select(result) {
|
|
374
374
|
const map = this._map,
|
|
375
|
-
latlng =
|
|
376
|
-
bounds = result.bounds ?
|
|
375
|
+
latlng = LatLng.from(result.latlng),
|
|
376
|
+
bounds = result.bounds ? LatLngBounds.from(result.bounds) : undefined;
|
|
377
377
|
|
|
378
378
|
this._input.value = result.label;
|
|
379
379
|
this._showResults([]);
|
package/src/geo/LatLng.js
CHANGED
|
@@ -107,6 +107,25 @@ export class LatLng {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Returns the given `LatLng` object as it is, or else a new `LatLng` object created
|
|
112
|
+
* from the given arguments (the same as of the constructor) — unlike the
|
|
113
|
+
* constructor, which always creates a new object.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```js
|
|
117
|
+
* LatLng.from(latlng) === latlng; // true
|
|
118
|
+
* LatLng.from([50.5, 30.5]); // LatLng(50.5, 30.5)
|
|
119
|
+
* ```
|
|
120
|
+
* @param {number|LatLngExpression} lat Latitude in degrees, or the coordinates.
|
|
121
|
+
* @param {number} [lng] Longitude in degrees.
|
|
122
|
+
* @param {number} [alt] Altitude in meters.
|
|
123
|
+
* @returns {LatLng}
|
|
124
|
+
*/
|
|
125
|
+
static from(lat, lng, alt) {
|
|
126
|
+
return lat instanceof LatLng ? lat : new LatLng(lat, lng, alt);
|
|
127
|
+
}
|
|
128
|
+
|
|
110
129
|
/**
|
|
111
130
|
* Returns `true` if the LatLng object can be properly initialized with the given
|
|
112
131
|
* arguments (the same as of the constructor).
|
|
@@ -185,7 +204,7 @@ export class LatLng {
|
|
|
185
204
|
equals(obj, maxMargin) {
|
|
186
205
|
if (!obj) { return false; }
|
|
187
206
|
|
|
188
|
-
obj =
|
|
207
|
+
obj = LatLng.from(obj);
|
|
189
208
|
|
|
190
209
|
const margin = Math.max(
|
|
191
210
|
Math.abs(this.lat - obj.lat),
|
|
@@ -210,7 +229,7 @@ export class LatLng {
|
|
|
210
229
|
* @returns {number}
|
|
211
230
|
*/
|
|
212
231
|
distanceTo(other) {
|
|
213
|
-
return EarthCRS.distance(this,
|
|
232
|
+
return EarthCRS.distance(this, LatLng.from(other));
|
|
214
233
|
}
|
|
215
234
|
|
|
216
235
|
/**
|
package/src/geo/LatLngBounds.js
CHANGED
|
@@ -68,6 +68,19 @@ export class LatLngBounds {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Returns the given `LatLngBounds` object as it is, or else a new `LatLngBounds`
|
|
73
|
+
* object created from the given arguments (the same as of the constructor) — unlike
|
|
74
|
+
* the constructor, which always creates a new object.
|
|
75
|
+
* @param {LatLngExpression|LatLngBoundsExpression} [corner1] The first corner, the
|
|
76
|
+
* points or the bounds.
|
|
77
|
+
* @param {LatLngExpression} [corner2] The opposite corner.
|
|
78
|
+
* @returns {LatLngBounds}
|
|
79
|
+
*/
|
|
80
|
+
static from(corner1, corner2) {
|
|
81
|
+
return corner1 instanceof LatLngBounds ? corner1 : new LatLngBounds(corner1, corner2);
|
|
82
|
+
}
|
|
83
|
+
|
|
71
84
|
/**
|
|
72
85
|
* Extend the bounds to contain the given point or bounds.
|
|
73
86
|
* @param {LatLngExpression|LatLngBoundsExpression} obj
|
|
@@ -93,9 +106,9 @@ export class LatLngBounds {
|
|
|
93
106
|
return this;
|
|
94
107
|
}
|
|
95
108
|
if (LatLng.validate(obj)) {
|
|
96
|
-
return this.extend(
|
|
109
|
+
return this.extend(LatLng.from(obj));
|
|
97
110
|
}
|
|
98
|
-
return this.extend(
|
|
111
|
+
return this.extend(LatLngBounds.from(obj));
|
|
99
112
|
}
|
|
100
113
|
|
|
101
114
|
if (!sw && !ne) {
|
|
@@ -210,9 +223,9 @@ export class LatLngBounds {
|
|
|
210
223
|
*/
|
|
211
224
|
contains(obj) { // (LatLngBounds) or (LatLng) -> Boolean
|
|
212
225
|
if (LatLng.validate(obj)) {
|
|
213
|
-
obj =
|
|
226
|
+
obj = LatLng.from(obj);
|
|
214
227
|
} else {
|
|
215
|
-
obj =
|
|
228
|
+
obj = LatLngBounds.from(obj);
|
|
216
229
|
}
|
|
217
230
|
|
|
218
231
|
const sw = this._southWest,
|
|
@@ -237,7 +250,7 @@ export class LatLngBounds {
|
|
|
237
250
|
* @returns {boolean}
|
|
238
251
|
*/
|
|
239
252
|
intersects(bounds) {
|
|
240
|
-
bounds =
|
|
253
|
+
bounds = LatLngBounds.from(bounds);
|
|
241
254
|
|
|
242
255
|
const sw = this._southWest,
|
|
243
256
|
ne = this._northEast,
|
|
@@ -257,7 +270,7 @@ export class LatLngBounds {
|
|
|
257
270
|
* @returns {boolean}
|
|
258
271
|
*/
|
|
259
272
|
overlaps(bounds) {
|
|
260
|
-
bounds =
|
|
273
|
+
bounds = LatLngBounds.from(bounds);
|
|
261
274
|
|
|
262
275
|
const sw = this._southWest,
|
|
263
276
|
ne = this._northEast,
|
|
@@ -291,7 +304,7 @@ export class LatLngBounds {
|
|
|
291
304
|
equals(bounds, maxMargin) {
|
|
292
305
|
if (!bounds) { return false; }
|
|
293
306
|
|
|
294
|
-
bounds =
|
|
307
|
+
bounds = LatLngBounds.from(bounds);
|
|
295
308
|
|
|
296
309
|
return this._southWest.equals(bounds.getSouthWest(), maxMargin) &&
|
|
297
310
|
this._northEast.equals(bounds.getNorthEast(), maxMargin);
|
package/src/geo/crs/CRS.js
CHANGED
|
@@ -17,8 +17,9 @@ import * as Util from '../../core/Util.js';
|
|
|
17
17
|
* [spatial reference system](https://en.wikipedia.org/wiki/Spatial_reference_system).
|
|
18
18
|
*
|
|
19
19
|
* Maplair defines the most usual CRSs by default. If you want to use a
|
|
20
|
-
* CRS not defined by default,
|
|
21
|
-
* [
|
|
20
|
+
* CRS not defined by default, extend `CRS` with a projection of your own, e.g.
|
|
21
|
+
* based on [Proj4js](https://github.com/proj4js/proj4js) (the Leaflet plugin
|
|
22
|
+
* [Proj4Leaflet](https://github.com/kartena/Proj4Leaflet) doesn't work with Maplair).
|
|
22
23
|
*
|
|
23
24
|
* The CRSs are classes with static properties and methods only; they are not
|
|
24
25
|
* instantiated, the class itself is passed as the CRS, e.g. to the `crs` option of the
|
|
@@ -146,7 +147,7 @@ export class CRS {
|
|
|
146
147
|
* @returns {LatLng}
|
|
147
148
|
*/
|
|
148
149
|
static wrapLatLng(latlng) {
|
|
149
|
-
latlng =
|
|
150
|
+
latlng = LatLng.from(latlng);
|
|
150
151
|
const lng = this.wrapLng ? Util.wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng,
|
|
151
152
|
lat = this.wrapLat ? Util.wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat,
|
|
152
153
|
alt = latlng.alt;
|
|
@@ -13,12 +13,12 @@ import {Point} from '../../geometry/Point.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export const LonLat = {
|
|
15
15
|
project(latlng) {
|
|
16
|
-
latlng =
|
|
16
|
+
latlng = LatLng.from(latlng);
|
|
17
17
|
return new Point(latlng.lng, latlng.lat);
|
|
18
18
|
},
|
|
19
19
|
|
|
20
20
|
unproject(point) {
|
|
21
|
-
point =
|
|
21
|
+
point = Point.from(point);
|
|
22
22
|
return new LatLng(point.y, point.x);
|
|
23
23
|
},
|
|
24
24
|
|
|
@@ -18,7 +18,7 @@ export const Mercator = {
|
|
|
18
18
|
bounds: new Bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]),
|
|
19
19
|
|
|
20
20
|
project(latlng) {
|
|
21
|
-
latlng =
|
|
21
|
+
latlng = LatLng.from(latlng);
|
|
22
22
|
const d = Math.PI / 180,
|
|
23
23
|
r = this.R,
|
|
24
24
|
tmp = this.R_MINOR / r,
|
|
@@ -33,7 +33,7 @@ export const Mercator = {
|
|
|
33
33
|
},
|
|
34
34
|
|
|
35
35
|
unproject(point) {
|
|
36
|
-
point =
|
|
36
|
+
point = Point.from(point);
|
|
37
37
|
const d = 180 / Math.PI,
|
|
38
38
|
r = this.R,
|
|
39
39
|
tmp = this.R_MINOR / r,
|
|
@@ -18,7 +18,7 @@ export const SphericalMercator = {
|
|
|
18
18
|
MAX_LATITUDE: 85.0511287798,
|
|
19
19
|
|
|
20
20
|
project(latlng) {
|
|
21
|
-
latlng =
|
|
21
|
+
latlng = LatLng.from(latlng);
|
|
22
22
|
const d = Math.PI / 180,
|
|
23
23
|
max = this.MAX_LATITUDE,
|
|
24
24
|
lat = Math.max(Math.min(max, latlng.lat), -max),
|
|
@@ -30,7 +30,7 @@ export const SphericalMercator = {
|
|
|
30
30
|
},
|
|
31
31
|
|
|
32
32
|
unproject(point) {
|
|
33
|
-
point =
|
|
33
|
+
point = Point.from(point);
|
|
34
34
|
const d = 180 / Math.PI;
|
|
35
35
|
|
|
36
36
|
return new LatLng(
|
package/src/geometry/Bounds.js
CHANGED
|
@@ -62,6 +62,19 @@ export class Bounds {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Returns the given `Bounds` object as it is, or else a new `Bounds` object created
|
|
67
|
+
* from the given arguments (the same as of the constructor) — unlike the
|
|
68
|
+
* constructor, which always creates a new object.
|
|
69
|
+
* @param {PointExpression|BoundsExpression} [a] The first corner, the points or the
|
|
70
|
+
* bounds.
|
|
71
|
+
* @param {PointExpression} [b] The opposite corner.
|
|
72
|
+
* @returns {Bounds}
|
|
73
|
+
*/
|
|
74
|
+
static from(a, b) {
|
|
75
|
+
return a instanceof Bounds ? a : new Bounds(a, b);
|
|
76
|
+
}
|
|
77
|
+
|
|
65
78
|
/**
|
|
66
79
|
* Extends the bounds to contain the given point or bounds.
|
|
67
80
|
* @param {PointExpression|BoundsExpression} obj
|
|
@@ -72,9 +85,9 @@ export class Bounds {
|
|
|
72
85
|
if (!obj) { return this; }
|
|
73
86
|
|
|
74
87
|
if (obj instanceof Point || typeof obj[0] === 'number' || 'x' in obj) {
|
|
75
|
-
min2 = max2 =
|
|
88
|
+
min2 = max2 = Point.from(obj);
|
|
76
89
|
} else {
|
|
77
|
-
obj =
|
|
90
|
+
obj = Bounds.from(obj);
|
|
78
91
|
min2 = obj.min;
|
|
79
92
|
max2 = obj.max;
|
|
80
93
|
|
|
@@ -153,9 +166,9 @@ export class Bounds {
|
|
|
153
166
|
let min, max;
|
|
154
167
|
|
|
155
168
|
if (typeof obj[0] === 'number' || obj instanceof Point) {
|
|
156
|
-
obj =
|
|
169
|
+
obj = Point.from(obj);
|
|
157
170
|
} else {
|
|
158
|
-
obj =
|
|
171
|
+
obj = Bounds.from(obj);
|
|
159
172
|
}
|
|
160
173
|
|
|
161
174
|
if (obj instanceof Bounds) {
|
|
@@ -178,7 +191,7 @@ export class Bounds {
|
|
|
178
191
|
* @returns {boolean}
|
|
179
192
|
*/
|
|
180
193
|
intersects(bounds) { // (Bounds) -> Boolean
|
|
181
|
-
bounds =
|
|
194
|
+
bounds = Bounds.from(bounds);
|
|
182
195
|
|
|
183
196
|
const min = this.min,
|
|
184
197
|
max = this.max,
|
|
@@ -197,7 +210,7 @@ export class Bounds {
|
|
|
197
210
|
* @returns {boolean}
|
|
198
211
|
*/
|
|
199
212
|
overlaps(bounds) { // (Bounds) -> Boolean
|
|
200
|
-
bounds =
|
|
213
|
+
bounds = Bounds.from(bounds);
|
|
201
214
|
|
|
202
215
|
const min = this.min,
|
|
203
216
|
max = this.max,
|
|
@@ -246,7 +259,7 @@ export class Bounds {
|
|
|
246
259
|
equals(bounds) {
|
|
247
260
|
if (!bounds) { return false; }
|
|
248
261
|
|
|
249
|
-
bounds =
|
|
262
|
+
bounds = Bounds.from(bounds);
|
|
250
263
|
|
|
251
264
|
return this.min.equals(bounds.getTopLeft()) &&
|
|
252
265
|
this.max.equals(bounds.getBottomRight());
|
package/src/geometry/Point.js
CHANGED
|
@@ -71,6 +71,25 @@ export class Point {
|
|
|
71
71
|
this.y = (round ? Math.round(_y) : _y);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Returns the given `Point` object as it is (unless `round` is set), or else a new
|
|
76
|
+
* `Point` object created from the given arguments (the same as of the constructor) —
|
|
77
|
+
* unlike the constructor, which always creates a new object.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```js
|
|
81
|
+
* Point.from(point) === point; // true
|
|
82
|
+
* Point.from([200, 300]); // Point(200, 300)
|
|
83
|
+
* ```
|
|
84
|
+
* @param {number|PointExpression} x The `x` coordinate, or the coordinates.
|
|
85
|
+
* @param {number} [y] The `y` coordinate.
|
|
86
|
+
* @param {boolean} [round]
|
|
87
|
+
* @returns {Point}
|
|
88
|
+
*/
|
|
89
|
+
static from(x, y, round) {
|
|
90
|
+
return x instanceof Point && !round ? x : new Point(x, y, round);
|
|
91
|
+
}
|
|
92
|
+
|
|
74
93
|
/**
|
|
75
94
|
* Returns `true` if the Point object can be properly initialized with the given
|
|
76
95
|
* arguments (the same as of the constructor).
|
|
@@ -96,7 +115,7 @@ export class Point {
|
|
|
96
115
|
*/
|
|
97
116
|
add(point) {
|
|
98
117
|
// non-destructive, returns a new point
|
|
99
|
-
return new Point(this)._add(
|
|
118
|
+
return new Point(this)._add(Point.from(point));
|
|
100
119
|
}
|
|
101
120
|
|
|
102
121
|
_add(point) {
|
|
@@ -112,7 +131,7 @@ export class Point {
|
|
|
112
131
|
* @returns {Point}
|
|
113
132
|
*/
|
|
114
133
|
subtract(point) {
|
|
115
|
-
return new Point(this)._subtract(
|
|
134
|
+
return new Point(this)._subtract(Point.from(point));
|
|
116
135
|
}
|
|
117
136
|
|
|
118
137
|
_subtract(point) {
|
|
@@ -236,7 +255,7 @@ export class Point {
|
|
|
236
255
|
* @returns {number}
|
|
237
256
|
*/
|
|
238
257
|
distanceTo(point) {
|
|
239
|
-
point =
|
|
258
|
+
point = Point.from(point);
|
|
240
259
|
|
|
241
260
|
const x = point.x - this.x,
|
|
242
261
|
y = point.y - this.y;
|
|
@@ -250,7 +269,7 @@ export class Point {
|
|
|
250
269
|
* @returns {boolean}
|
|
251
270
|
*/
|
|
252
271
|
equals(point) {
|
|
253
|
-
point =
|
|
272
|
+
point = Point.from(point);
|
|
254
273
|
|
|
255
274
|
return point.x === this.x &&
|
|
256
275
|
point.y === this.y;
|
|
@@ -263,7 +282,7 @@ export class Point {
|
|
|
263
282
|
* @returns {boolean}
|
|
264
283
|
*/
|
|
265
284
|
contains(point) {
|
|
266
|
-
point =
|
|
285
|
+
point = Point.from(point);
|
|
267
286
|
|
|
268
287
|
return Math.abs(point.x) <= Math.abs(this.x) &&
|
|
269
288
|
Math.abs(point.y) <= Math.abs(this.y);
|
package/src/geometry/PolyUtil.js
CHANGED
package/src/layer/DivOverlay.js
CHANGED
|
@@ -451,7 +451,7 @@ export class DivOverlay extends Layer {
|
|
|
451
451
|
|
|
452
452
|
const pos = this._map.latLngToLayerPoint(this._latlng),
|
|
453
453
|
anchor = this._getAnchor();
|
|
454
|
-
let offset =
|
|
454
|
+
let offset = Point.from(this.options.offset);
|
|
455
455
|
|
|
456
456
|
if (this._zoomAnimated || this.options.overflow) {
|
|
457
457
|
this._setContainerPosition(pos.add(anchor));
|
package/src/layer/GeoJSON.js
CHANGED
|
@@ -292,7 +292,7 @@ export class GeoJSON extends FeatureGroup {
|
|
|
292
292
|
* @returns {number[]}
|
|
293
293
|
*/
|
|
294
294
|
static latLngToCoords(latlng, precision) {
|
|
295
|
-
latlng =
|
|
295
|
+
latlng = LatLng.from(latlng);
|
|
296
296
|
return latlng.alt !== undefined ?
|
|
297
297
|
[Util.formatNum(latlng.lng, precision), Util.formatNum(latlng.lat, precision), Util.formatNum(latlng.alt, precision)] :
|
|
298
298
|
[Util.formatNum(latlng.lng, precision), Util.formatNum(latlng.lat, precision)];
|
package/src/layer/Popup.js
CHANGED
|
@@ -547,9 +547,9 @@ export class Popup extends DivOverlay {
|
|
|
547
547
|
layerPos._add(this._getContainerPosition());
|
|
548
548
|
|
|
549
549
|
const containerPos = map.layerPointToContainerPoint(layerPos),
|
|
550
|
-
padding =
|
|
551
|
-
paddingTL =
|
|
552
|
-
paddingBR =
|
|
550
|
+
padding = Point.from(this.options.autoPanPadding),
|
|
551
|
+
paddingTL = Point.from(this.options.autoPanPaddingTopLeft ?? padding),
|
|
552
|
+
paddingBR = Point.from(this.options.autoPanPaddingBottomRight ?? padding),
|
|
553
553
|
size = map.getSize();
|
|
554
554
|
let dx = 0,
|
|
555
555
|
dy = 0;
|
|
@@ -74,7 +74,7 @@ export class DivIcon extends Icon {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
if (options.bgPos) {
|
|
77
|
-
const bgPos =
|
|
77
|
+
const bgPos = Point.from(options.bgPos);
|
|
78
78
|
div.style.backgroundPosition = `${-bgPos.x}px ${-bgPos.y}px`;
|
|
79
79
|
}
|
|
80
80
|
this._setIconStyles(div, 'icon');
|
package/src/layer/marker/Icon.js
CHANGED
|
@@ -129,10 +129,10 @@ export class Icon extends Class {
|
|
|
129
129
|
sizeOption = [sizeOption, sizeOption];
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
const size = Point.validate(sizeOption) &&
|
|
132
|
+
const size = Point.validate(sizeOption) && Point.from(sizeOption);
|
|
133
133
|
|
|
134
134
|
const anchorPosition = name === 'shadow' && options.shadowAnchor || options.iconAnchor || size && size.divideBy(2, true);
|
|
135
|
-
const anchor = Point.validate(anchorPosition) &&
|
|
135
|
+
const anchor = Point.validate(anchorPosition) && Point.from(anchorPosition);
|
|
136
136
|
|
|
137
137
|
img.className = `maplair-marker-${name} ${options.className || ''}`;
|
|
138
138
|
|
|
@@ -65,7 +65,7 @@ const markerMoveMethods = {
|
|
|
65
65
|
moveAlong(latlngs, options = {}) {
|
|
66
66
|
this.stopMoving();
|
|
67
67
|
|
|
68
|
-
const points = [this._latlng, ...latlngs.map(latlng =>
|
|
68
|
+
const points = [this._latlng, ...latlngs.map(latlng => LatLng.from(latlng))],
|
|
69
69
|
lengths = points.slice(1).map((point, i) => this._map?.distance(points[i], point) ?? points[i].distanceTo(point)),
|
|
70
70
|
total = lengths.reduce((sum, length) => sum + length, 0),
|
|
71
71
|
duration = options.speed ? total / options.speed * 1000 : (options.duration ?? 1000),
|
|
@@ -505,8 +505,8 @@ export class Marker extends Layer {
|
|
|
505
505
|
if (!map) { return; }
|
|
506
506
|
|
|
507
507
|
const iconOpts = this.options.icon.options;
|
|
508
|
-
const size = iconOpts.iconSize ?
|
|
509
|
-
const anchor = iconOpts.iconAnchor ?
|
|
508
|
+
const size = iconOpts.iconSize ? Point.from(iconOpts.iconSize) : new Point(0, 0);
|
|
509
|
+
const anchor = iconOpts.iconAnchor ? Point.from(iconOpts.iconAnchor) : new Point(0, 0);
|
|
510
510
|
|
|
511
511
|
map.panInside(this._latlng, {
|
|
512
512
|
paddingTopLeft: anchor,
|
|
@@ -835,7 +835,7 @@ export class GridLayer extends Layer {
|
|
|
835
835
|
|
|
836
836
|
// don't load tile if it doesn't intersect the bounds in options
|
|
837
837
|
const tileBounds = this._tileCoordsToBounds(coords);
|
|
838
|
-
return
|
|
838
|
+
return LatLngBounds.from(this.options.bounds).overlaps(tileBounds);
|
|
839
839
|
}
|
|
840
840
|
|
|
841
841
|
_keyToBounds(key) {
|
package/src/map/Map.Rotation.js
CHANGED
|
@@ -236,7 +236,7 @@ const mapRotationMethods = {
|
|
|
236
236
|
* @returns {Point}
|
|
237
237
|
*/
|
|
238
238
|
containerPointToLayerPoint(point) { // (Point)
|
|
239
|
-
point =
|
|
239
|
+
point = Point.from(point);
|
|
240
240
|
if (this._bearing) {
|
|
241
241
|
// the map pane is rotated around the center of the container
|
|
242
242
|
const center = this.getSize()._divideBy(2);
|
|
@@ -253,7 +253,7 @@ const mapRotationMethods = {
|
|
|
253
253
|
* @returns {Point}
|
|
254
254
|
*/
|
|
255
255
|
layerPointToContainerPoint(point) { // (Point)
|
|
256
|
-
point =
|
|
256
|
+
point = Point.from(point).add(this._getMapPanePos());
|
|
257
257
|
if (this._bearing) {
|
|
258
258
|
const center = this.getSize()._divideBy(2);
|
|
259
259
|
point = this._rotateToContainer(point.subtract(center))._add(center);
|
|
@@ -289,7 +289,7 @@ const mapRotationMethods = {
|
|
|
289
289
|
* @returns {this}
|
|
290
290
|
*/
|
|
291
291
|
panBy(offset, options) {
|
|
292
|
-
return panBy.call(this, this._rotateToPane(
|
|
292
|
+
return panBy.call(this, this._rotateToPane(Point.from(offset)), options);
|
|
293
293
|
},
|
|
294
294
|
|
|
295
295
|
_tryAnimatedPan(center, options) {
|
|
@@ -475,7 +475,7 @@ const divOverlayRotationMethods = {
|
|
|
475
475
|
pos = map.latLngToLayerPoint(this._latlng),
|
|
476
476
|
// on a rotated map, the anchor is relative to the upright overlay
|
|
477
477
|
anchor = map._rotateToPane(new Point(this._getAnchor()));
|
|
478
|
-
let offset =
|
|
478
|
+
let offset = Point.from(this.options.offset);
|
|
479
479
|
|
|
480
480
|
const transformed = this._zoomAnimated || this.options.overflow || map._bearing;
|
|
481
481
|
if (!transformed) {
|
|
@@ -553,9 +553,9 @@ const popupRotationMethods = {
|
|
|
553
553
|
topLeft = new Point(this._containerLeft, -containerHeight - this._containerBottom);
|
|
554
554
|
|
|
555
555
|
const containerPos = map.layerPointToContainerPoint(this._getContainerPosition())._add(topLeft),
|
|
556
|
-
padding =
|
|
557
|
-
paddingTL =
|
|
558
|
-
paddingBR =
|
|
556
|
+
padding = Point.from(this.options.autoPanPadding),
|
|
557
|
+
paddingTL = Point.from(this.options.autoPanPaddingTopLeft ?? padding),
|
|
558
|
+
paddingBR = Point.from(this.options.autoPanPaddingBottomRight ?? padding),
|
|
559
559
|
size = map.getSize();
|
|
560
560
|
let dx = 0,
|
|
561
561
|
dy = 0;
|