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/src/map/Map.js
CHANGED
|
@@ -341,7 +341,7 @@ export class MaplairMap extends Evented {
|
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
if (options.center && options.zoom !== undefined) {
|
|
344
|
-
this.setView(
|
|
344
|
+
this.setView(LatLng.from(options.center), options.zoom, {reset: true});
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
this.callInitHooks(MaplairMap);
|
|
@@ -463,10 +463,10 @@ export class MaplairMap extends Evented {
|
|
|
463
463
|
_getBoundsCenterZoom(bounds, options) {
|
|
464
464
|
|
|
465
465
|
options ??= {};
|
|
466
|
-
bounds = bounds.getBounds ? bounds.getBounds() :
|
|
466
|
+
bounds = bounds.getBounds ? bounds.getBounds() : LatLngBounds.from(bounds);
|
|
467
467
|
|
|
468
|
-
const paddingTL =
|
|
469
|
-
paddingBR =
|
|
468
|
+
const paddingTL = Point.from(options.paddingTopLeft || options.padding || [0, 0]),
|
|
469
|
+
paddingBR = Point.from(options.paddingBottomRight || options.padding || [0, 0]);
|
|
470
470
|
|
|
471
471
|
let zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR));
|
|
472
472
|
|
|
@@ -501,7 +501,7 @@ export class MaplairMap extends Evented {
|
|
|
501
501
|
*/
|
|
502
502
|
fitBounds(bounds, options) {
|
|
503
503
|
|
|
504
|
-
bounds =
|
|
504
|
+
bounds = LatLngBounds.from(bounds);
|
|
505
505
|
|
|
506
506
|
if (!bounds.isValid()) {
|
|
507
507
|
throw new Error('Bounds are not valid.');
|
|
@@ -541,7 +541,7 @@ export class MaplairMap extends Evented {
|
|
|
541
541
|
* @returns {this}
|
|
542
542
|
*/
|
|
543
543
|
panBy(offset, options) {
|
|
544
|
-
offset =
|
|
544
|
+
offset = Point.from(offset).round();
|
|
545
545
|
options ??= {};
|
|
546
546
|
|
|
547
547
|
if (!offset.x && !offset.y) {
|
|
@@ -803,7 +803,7 @@ export class MaplairMap extends Evented {
|
|
|
803
803
|
panInsideBounds(bounds, options) {
|
|
804
804
|
this._enforcingBounds = true;
|
|
805
805
|
const center = this.getCenter(),
|
|
806
|
-
newCenter = this._limitCenter(center, this._zoom,
|
|
806
|
+
newCenter = this._limitCenter(center, this._zoom, LatLngBounds.from(bounds));
|
|
807
807
|
|
|
808
808
|
if (!center.equals(newCenter)) {
|
|
809
809
|
this.panTo(newCenter, options);
|
|
@@ -826,8 +826,8 @@ export class MaplairMap extends Evented {
|
|
|
826
826
|
panInside(latlng, options) {
|
|
827
827
|
options ??= {};
|
|
828
828
|
|
|
829
|
-
const paddingTL =
|
|
830
|
-
paddingBR =
|
|
829
|
+
const paddingTL = Point.from(options.paddingTopLeft || options.padding || [0, 0]),
|
|
830
|
+
paddingBR = Point.from(options.paddingBottomRight || options.padding || [0, 0]),
|
|
831
831
|
pixelCenter = this.project(this.getCenter()),
|
|
832
832
|
pixelPoint = this.project(latlng),
|
|
833
833
|
pixelBounds = this.getPixelBounds(),
|
|
@@ -1197,8 +1197,8 @@ export class MaplairMap extends Evented {
|
|
|
1197
1197
|
* @returns {number}
|
|
1198
1198
|
*/
|
|
1199
1199
|
getBoundsZoom(bounds, inside, padding) {
|
|
1200
|
-
bounds =
|
|
1201
|
-
padding =
|
|
1200
|
+
bounds = LatLngBounds.from(bounds);
|
|
1201
|
+
padding = Point.from(padding ?? [0, 0]);
|
|
1202
1202
|
|
|
1203
1203
|
let zoom = this.getZoom() ?? 0;
|
|
1204
1204
|
const min = this.getMinZoom(),
|
|
@@ -1350,7 +1350,7 @@ export class MaplairMap extends Evented {
|
|
|
1350
1350
|
*/
|
|
1351
1351
|
project(latlng, zoom) {
|
|
1352
1352
|
zoom ??= this._zoom;
|
|
1353
|
-
return this.options.crs.latLngToPoint(
|
|
1353
|
+
return this.options.crs.latLngToPoint(LatLng.from(latlng), zoom);
|
|
1354
1354
|
}
|
|
1355
1355
|
|
|
1356
1356
|
/**
|
|
@@ -1362,7 +1362,7 @@ export class MaplairMap extends Evented {
|
|
|
1362
1362
|
*/
|
|
1363
1363
|
unproject(point, zoom) {
|
|
1364
1364
|
zoom ??= this._zoom;
|
|
1365
|
-
return this.options.crs.pointToLatLng(
|
|
1365
|
+
return this.options.crs.pointToLatLng(Point.from(point), zoom);
|
|
1366
1366
|
}
|
|
1367
1367
|
|
|
1368
1368
|
/**
|
|
@@ -1373,7 +1373,7 @@ export class MaplairMap extends Evented {
|
|
|
1373
1373
|
* @returns {LatLng}
|
|
1374
1374
|
*/
|
|
1375
1375
|
layerPointToLatLng(point) {
|
|
1376
|
-
const projectedPoint =
|
|
1376
|
+
const projectedPoint = Point.from(point).add(this.getPixelOrigin());
|
|
1377
1377
|
return this.unproject(projectedPoint);
|
|
1378
1378
|
}
|
|
1379
1379
|
|
|
@@ -1385,7 +1385,7 @@ export class MaplairMap extends Evented {
|
|
|
1385
1385
|
* @returns {Point}
|
|
1386
1386
|
*/
|
|
1387
1387
|
latLngToLayerPoint(latlng) {
|
|
1388
|
-
const projectedPoint = this.project(
|
|
1388
|
+
const projectedPoint = this.project(LatLng.from(latlng))._round();
|
|
1389
1389
|
return projectedPoint._subtract(this.getPixelOrigin());
|
|
1390
1390
|
}
|
|
1391
1391
|
|
|
@@ -1400,7 +1400,7 @@ export class MaplairMap extends Evented {
|
|
|
1400
1400
|
* @returns {LatLng}
|
|
1401
1401
|
*/
|
|
1402
1402
|
wrapLatLng(latlng) {
|
|
1403
|
-
return this.options.crs.wrapLatLng(
|
|
1403
|
+
return this.options.crs.wrapLatLng(LatLng.from(latlng));
|
|
1404
1404
|
}
|
|
1405
1405
|
|
|
1406
1406
|
/**
|
|
@@ -1426,7 +1426,7 @@ export class MaplairMap extends Evented {
|
|
|
1426
1426
|
* @returns {number}
|
|
1427
1427
|
*/
|
|
1428
1428
|
distance(latlng1, latlng2) {
|
|
1429
|
-
return this.options.crs.distance(
|
|
1429
|
+
return this.options.crs.distance(LatLng.from(latlng1), LatLng.from(latlng2));
|
|
1430
1430
|
}
|
|
1431
1431
|
|
|
1432
1432
|
/**
|
|
@@ -1437,7 +1437,7 @@ export class MaplairMap extends Evented {
|
|
|
1437
1437
|
* @returns {Point}
|
|
1438
1438
|
*/
|
|
1439
1439
|
containerPointToLayerPoint(point) {
|
|
1440
|
-
return
|
|
1440
|
+
return Point.from(point).subtract(this._getMapPanePos());
|
|
1441
1441
|
}
|
|
1442
1442
|
|
|
1443
1443
|
/**
|
|
@@ -1448,7 +1448,7 @@ export class MaplairMap extends Evented {
|
|
|
1448
1448
|
* @returns {Point}
|
|
1449
1449
|
*/
|
|
1450
1450
|
layerPointToContainerPoint(point) {
|
|
1451
|
-
return
|
|
1451
|
+
return Point.from(point).add(this._getMapPanePos());
|
|
1452
1452
|
}
|
|
1453
1453
|
|
|
1454
1454
|
/**
|
|
@@ -1459,7 +1459,7 @@ export class MaplairMap extends Evented {
|
|
|
1459
1459
|
* @returns {LatLng}
|
|
1460
1460
|
*/
|
|
1461
1461
|
containerPointToLatLng(point) {
|
|
1462
|
-
const layerPoint = this.containerPointToLayerPoint(
|
|
1462
|
+
const layerPoint = this.containerPointToLayerPoint(Point.from(point));
|
|
1463
1463
|
return this.layerPointToLatLng(layerPoint);
|
|
1464
1464
|
}
|
|
1465
1465
|
|
|
@@ -1471,7 +1471,7 @@ export class MaplairMap extends Evented {
|
|
|
1471
1471
|
* @returns {Point}
|
|
1472
1472
|
*/
|
|
1473
1473
|
latLngToContainerPoint(latlng) {
|
|
1474
|
-
return this.layerPointToContainerPoint(this.latLngToLayerPoint(
|
|
1474
|
+
return this.layerPointToContainerPoint(this.latLngToLayerPoint(LatLng.from(latlng)));
|
|
1475
1475
|
}
|
|
1476
1476
|
|
|
1477
1477
|
/**
|
|
@@ -113,7 +113,7 @@ export class DragHandler extends Handler {
|
|
|
113
113
|
map._stop();
|
|
114
114
|
map._setUserEvent(e.originalEvent);
|
|
115
115
|
if (this._map.options.maxBounds && this._map.options.maxBoundsViscosity) {
|
|
116
|
-
const bounds =
|
|
116
|
+
const bounds = LatLngBounds.from(this._map.options.maxBounds);
|
|
117
117
|
|
|
118
118
|
this._offsetLimit = new Bounds(
|
|
119
119
|
this._map.latLngToContainerPoint(bounds.getNorthWest()).multiplyBy(-1),
|
|
@@ -221,11 +221,11 @@ export class KeyboardHandler extends Handler {
|
|
|
221
221
|
if (!map._panAnim || !map._panAnim._inProgress) {
|
|
222
222
|
offset = this._panKeys[key];
|
|
223
223
|
if (e.shiftKey) {
|
|
224
|
-
offset =
|
|
224
|
+
offset = Point.from(offset).multiplyBy(3);
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
if (map.options.maxBounds) {
|
|
228
|
-
offset = map._limitOffset(
|
|
228
|
+
offset = map._limitOffset(Point.from(offset), map.options.maxBounds);
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
map._setUserEvent(e);
|