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.
Files changed (82) hide show
  1. package/CHANGELOG.md +22 -38
  2. package/LICENSE +1 -1
  3. package/README.md +10 -9
  4. package/dist/esm/control/SearchControl.js +1 -1
  5. package/dist/esm/control/SearchControl.js.map +1 -1
  6. package/dist/esm/geo/LatLng.js +20 -2
  7. package/dist/esm/geo/LatLng.js.map +1 -1
  8. package/dist/esm/geo/LatLngBounds.js +19 -7
  9. package/dist/esm/geo/LatLngBounds.js.map +1 -1
  10. package/dist/esm/geo/crs/CRS.js +4 -3
  11. package/dist/esm/geo/crs/CRS.js.map +1 -1
  12. package/dist/esm/geo/projection/Projection.LonLat.js +2 -2
  13. package/dist/esm/geo/projection/Projection.LonLat.js.map +1 -1
  14. package/dist/esm/geo/projection/Projection.Mercator.js +2 -2
  15. package/dist/esm/geo/projection/Projection.Mercator.js.map +1 -1
  16. package/dist/esm/geo/projection/Projection.SphericalMercator.js +2 -2
  17. package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +1 -1
  18. package/dist/esm/geometry/Bounds.js +19 -7
  19. package/dist/esm/geometry/Bounds.js.map +1 -1
  20. package/dist/esm/geometry/Point.js +23 -5
  21. package/dist/esm/geometry/Point.js.map +1 -1
  22. package/dist/esm/geometry/PolyUtil.js +1 -1
  23. package/dist/esm/geometry/PolyUtil.js.map +1 -1
  24. package/dist/esm/layer/DivOverlay.js +1 -1
  25. package/dist/esm/layer/DivOverlay.js.map +1 -1
  26. package/dist/esm/layer/GeoJSON.js +1 -1
  27. package/dist/esm/layer/GeoJSON.js.map +1 -1
  28. package/dist/esm/layer/Popup.js +1 -1
  29. package/dist/esm/layer/Popup.js.map +1 -1
  30. package/dist/esm/layer/marker/DivIcon.js +1 -1
  31. package/dist/esm/layer/marker/DivIcon.js.map +1 -1
  32. package/dist/esm/layer/marker/Icon.js +2 -2
  33. package/dist/esm/layer/marker/Icon.js.map +1 -1
  34. package/dist/esm/layer/marker/Marker.Move.js +1 -1
  35. package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
  36. package/dist/esm/layer/marker/Marker.js +2 -2
  37. package/dist/esm/layer/marker/Marker.js.map +1 -1
  38. package/dist/esm/layer/tile/GridLayer.js +1 -1
  39. package/dist/esm/layer/tile/GridLayer.js.map +1 -1
  40. package/dist/esm/layer/vector/Polyline.js +1 -1
  41. package/dist/esm/layer/vector/Polyline.js.map +1 -1
  42. package/dist/esm/map/Map.Rotation.js +5 -5
  43. package/dist/esm/map/Map.Rotation.js.map +1 -1
  44. package/dist/esm/map/Map.js +19 -19
  45. package/dist/esm/map/Map.js.map +1 -1
  46. package/dist/esm/map/handler/DragHandler.js +1 -1
  47. package/dist/esm/map/handler/DragHandler.js.map +1 -1
  48. package/dist/esm/map/handler/KeyboardHandler.js +2 -2
  49. package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
  50. package/dist/esm/package.js +1 -1
  51. package/dist/maplair-global-src.js +134 -73
  52. package/dist/maplair-global-src.js.map +1 -1
  53. package/dist/maplair-global.js +3 -3
  54. package/dist/maplair-global.js.map +1 -1
  55. package/dist/maplair-src.js +134 -73
  56. package/dist/maplair-src.js.map +1 -1
  57. package/dist/maplair.js +3 -3
  58. package/dist/maplair.js.map +1 -1
  59. package/package.json +4 -4
  60. package/src/control/SearchControl.js +2 -2
  61. package/src/geo/LatLng.js +21 -2
  62. package/src/geo/LatLngBounds.js +20 -7
  63. package/src/geo/crs/CRS.js +4 -3
  64. package/src/geo/projection/Projection.LonLat.js +2 -2
  65. package/src/geo/projection/Projection.Mercator.js +2 -2
  66. package/src/geo/projection/Projection.SphericalMercator.js +2 -2
  67. package/src/geometry/Bounds.js +20 -7
  68. package/src/geometry/Point.js +24 -5
  69. package/src/geometry/PolyUtil.js +1 -1
  70. package/src/layer/DivOverlay.js +1 -1
  71. package/src/layer/GeoJSON.js +1 -1
  72. package/src/layer/Popup.js +3 -3
  73. package/src/layer/marker/DivIcon.js +1 -1
  74. package/src/layer/marker/Icon.js +2 -2
  75. package/src/layer/marker/Marker.Move.js +1 -1
  76. package/src/layer/marker/Marker.js +2 -2
  77. package/src/layer/tile/GridLayer.js +1 -1
  78. package/src/layer/vector/Polyline.js +1 -1
  79. package/src/map/Map.Rotation.js +7 -7
  80. package/src/map/Map.js +21 -21
  81. package/src/map/handler/DragHandler.js +1 -1
  82. package/src/map/handler/KeyboardHandler.js +2 -2
@@ -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(new LatLng(options.center), options.zoom, { reset: true });
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() : new LatLngBounds(bounds);
410
- const paddingTL = new Point(options.paddingTopLeft || options.padding || [0, 0]), paddingBR = new Point(options.paddingBottomRight || options.padding || [0, 0]);
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 = new LatLngBounds(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 = new Point(offset).round();
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, new LatLngBounds(bounds));
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 = new Point(options.paddingTopLeft || options.padding || [0, 0]), paddingBR = new Point(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();
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 = new LatLngBounds(bounds);
913
- padding = new Point(padding ?? [0, 0]);
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(new LatLng(latlng), zoom);
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(new Point(point), zoom);
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 = new Point(point).add(this.getPixelOrigin());
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(new LatLng(latlng))._round()._subtract(this.getPixelOrigin());
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(new LatLng(latlng));
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(new LatLng(latlng1), new LatLng(latlng2));
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 new Point(point).subtract(this._getMapPanePos());
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 new Point(point).add(this._getMapPanePos());
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(new Point(point));
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(new LatLng(latlng)));
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