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/esm/map/Map.js
CHANGED
|
@@ -313,7 +313,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
313
313
|
}, this);
|
|
314
314
|
if (options.maxBounds) this.setMaxBounds(options.maxBounds);
|
|
315
315
|
if (options.zoom !== void 0) this._zoom = this._limitZoom(options.zoom);
|
|
316
|
-
if (options.center && options.zoom !== void 0) this.setView(
|
|
316
|
+
if (options.center && options.zoom !== void 0) this.setView(LatLng.from(options.center), options.zoom, { reset: true });
|
|
317
317
|
this.callInitHooks(MaplairMap);
|
|
318
318
|
this._zoomAnimated = this.options.zoomAnimation;
|
|
319
319
|
if (this._zoomAnimated) this._createAnimProxy();
|
|
@@ -406,8 +406,8 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
406
406
|
}
|
|
407
407
|
_getBoundsCenterZoom(bounds, options) {
|
|
408
408
|
options ??= {};
|
|
409
|
-
bounds = bounds.getBounds ? bounds.getBounds() :
|
|
410
|
-
const paddingTL =
|
|
409
|
+
bounds = bounds.getBounds ? bounds.getBounds() : LatLngBounds.from(bounds);
|
|
410
|
+
const paddingTL = Point.from(options.paddingTopLeft || options.padding || [0, 0]), paddingBR = Point.from(options.paddingBottomRight || options.padding || [0, 0]);
|
|
411
411
|
let zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR));
|
|
412
412
|
zoom = typeof options.maxZoom === "number" ? Math.min(options.maxZoom, zoom) : zoom;
|
|
413
413
|
if (zoom === Infinity) return {
|
|
@@ -429,7 +429,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
429
429
|
* @returns {this}
|
|
430
430
|
*/
|
|
431
431
|
fitBounds(bounds, options) {
|
|
432
|
-
bounds =
|
|
432
|
+
bounds = LatLngBounds.from(bounds);
|
|
433
433
|
if (!bounds.isValid()) throw new Error("Bounds are not valid.");
|
|
434
434
|
const target = this._getBoundsCenterZoom(bounds, options);
|
|
435
435
|
return this.setView(target.center, target.zoom, options);
|
|
@@ -462,7 +462,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
462
462
|
* @returns {this}
|
|
463
463
|
*/
|
|
464
464
|
panBy(offset, options) {
|
|
465
|
-
offset =
|
|
465
|
+
offset = Point.from(offset).round();
|
|
466
466
|
options ??= {};
|
|
467
467
|
if (!offset.x && !offset.y) return this.fire("moveend");
|
|
468
468
|
if (options.animate !== true && !this.getSize().contains(offset)) {
|
|
@@ -643,7 +643,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
643
643
|
*/
|
|
644
644
|
panInsideBounds(bounds, options) {
|
|
645
645
|
this._enforcingBounds = true;
|
|
646
|
-
const center = this.getCenter(), newCenter = this._limitCenter(center, this._zoom,
|
|
646
|
+
const center = this.getCenter(), newCenter = this._limitCenter(center, this._zoom, LatLngBounds.from(bounds));
|
|
647
647
|
if (!center.equals(newCenter)) this.panTo(newCenter, options);
|
|
648
648
|
this._enforcingBounds = false;
|
|
649
649
|
return this;
|
|
@@ -660,7 +660,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
660
660
|
*/
|
|
661
661
|
panInside(latlng, options) {
|
|
662
662
|
options ??= {};
|
|
663
|
-
const paddingTL =
|
|
663
|
+
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();
|
|
664
664
|
if (!paddedBounds.contains(pixelPoint)) {
|
|
665
665
|
this._enforcingBounds = true;
|
|
666
666
|
const centerOffset = pixelPoint.subtract(paddedBounds.getCenter());
|
|
@@ -909,8 +909,8 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
909
909
|
* @returns {number}
|
|
910
910
|
*/
|
|
911
911
|
getBoundsZoom(bounds, inside, padding) {
|
|
912
|
-
bounds =
|
|
913
|
-
padding =
|
|
912
|
+
bounds = LatLngBounds.from(bounds);
|
|
913
|
+
padding = Point.from(padding ?? [0, 0]);
|
|
914
914
|
let zoom = this.getZoom() ?? 0;
|
|
915
915
|
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);
|
|
916
916
|
zoom = this.getScaleZoom(scale, zoom);
|
|
@@ -1031,7 +1031,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1031
1031
|
*/
|
|
1032
1032
|
project(latlng, zoom) {
|
|
1033
1033
|
zoom ??= this._zoom;
|
|
1034
|
-
return this.options.crs.latLngToPoint(
|
|
1034
|
+
return this.options.crs.latLngToPoint(LatLng.from(latlng), zoom);
|
|
1035
1035
|
}
|
|
1036
1036
|
/**
|
|
1037
1037
|
* Inverse of [`project`](#map-project).
|
|
@@ -1042,7 +1042,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1042
1042
|
*/
|
|
1043
1043
|
unproject(point, zoom) {
|
|
1044
1044
|
zoom ??= this._zoom;
|
|
1045
|
-
return this.options.crs.pointToLatLng(
|
|
1045
|
+
return this.options.crs.pointToLatLng(Point.from(point), zoom);
|
|
1046
1046
|
}
|
|
1047
1047
|
/**
|
|
1048
1048
|
* Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin),
|
|
@@ -1052,7 +1052,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1052
1052
|
* @returns {LatLng}
|
|
1053
1053
|
*/
|
|
1054
1054
|
layerPointToLatLng(point) {
|
|
1055
|
-
const projectedPoint =
|
|
1055
|
+
const projectedPoint = Point.from(point).add(this.getPixelOrigin());
|
|
1056
1056
|
return this.unproject(projectedPoint);
|
|
1057
1057
|
}
|
|
1058
1058
|
/**
|
|
@@ -1063,7 +1063,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1063
1063
|
* @returns {Point}
|
|
1064
1064
|
*/
|
|
1065
1065
|
latLngToLayerPoint(latlng) {
|
|
1066
|
-
return this.project(
|
|
1066
|
+
return this.project(LatLng.from(latlng))._round()._subtract(this.getPixelOrigin());
|
|
1067
1067
|
}
|
|
1068
1068
|
/**
|
|
1069
1069
|
* Returns a `LatLng` where `lat` and `lng` has been wrapped according to the
|
|
@@ -1076,7 +1076,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1076
1076
|
* @returns {LatLng}
|
|
1077
1077
|
*/
|
|
1078
1078
|
wrapLatLng(latlng) {
|
|
1079
|
-
return this.options.crs.wrapLatLng(
|
|
1079
|
+
return this.options.crs.wrapLatLng(LatLng.from(latlng));
|
|
1080
1080
|
}
|
|
1081
1081
|
/**
|
|
1082
1082
|
* Returns a `LatLngBounds` with the same size as the given one, ensuring that
|
|
@@ -1100,7 +1100,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1100
1100
|
* @returns {number}
|
|
1101
1101
|
*/
|
|
1102
1102
|
distance(latlng1, latlng2) {
|
|
1103
|
-
return this.options.crs.distance(
|
|
1103
|
+
return this.options.crs.distance(LatLng.from(latlng1), LatLng.from(latlng2));
|
|
1104
1104
|
}
|
|
1105
1105
|
/**
|
|
1106
1106
|
* Given a pixel coordinate relative to the map container, returns the corresponding
|
|
@@ -1110,7 +1110,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1110
1110
|
* @returns {Point}
|
|
1111
1111
|
*/
|
|
1112
1112
|
containerPointToLayerPoint(point) {
|
|
1113
|
-
return
|
|
1113
|
+
return Point.from(point).subtract(this._getMapPanePos());
|
|
1114
1114
|
}
|
|
1115
1115
|
/**
|
|
1116
1116
|
* Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin),
|
|
@@ -1120,7 +1120,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1120
1120
|
* @returns {Point}
|
|
1121
1121
|
*/
|
|
1122
1122
|
layerPointToContainerPoint(point) {
|
|
1123
|
-
return
|
|
1123
|
+
return Point.from(point).add(this._getMapPanePos());
|
|
1124
1124
|
}
|
|
1125
1125
|
/**
|
|
1126
1126
|
* Given a pixel coordinate relative to the map container, returns
|
|
@@ -1130,7 +1130,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1130
1130
|
* @returns {LatLng}
|
|
1131
1131
|
*/
|
|
1132
1132
|
containerPointToLatLng(point) {
|
|
1133
|
-
const layerPoint = this.containerPointToLayerPoint(
|
|
1133
|
+
const layerPoint = this.containerPointToLayerPoint(Point.from(point));
|
|
1134
1134
|
return this.layerPointToLatLng(layerPoint);
|
|
1135
1135
|
}
|
|
1136
1136
|
/**
|
|
@@ -1141,7 +1141,7 @@ var MaplairMap = class MaplairMap extends Evented {
|
|
|
1141
1141
|
* @returns {Point}
|
|
1142
1142
|
*/
|
|
1143
1143
|
latLngToContainerPoint(latlng) {
|
|
1144
|
-
return this.layerPointToContainerPoint(this.latLngToLayerPoint(
|
|
1144
|
+
return this.layerPointToContainerPoint(this.latLngToLayerPoint(LatLng.from(latlng)));
|
|
1145
1145
|
}
|
|
1146
1146
|
/**
|
|
1147
1147
|
* Given a PointerEvent object, returns the pixel coordinate relative to the
|