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
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(new LatLng(options.center), options.zoom, {reset: true});
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() : new LatLngBounds(bounds);
466
+ bounds = bounds.getBounds ? bounds.getBounds() : LatLngBounds.from(bounds);
467
467
 
468
- const paddingTL = new Point(options.paddingTopLeft || options.padding || [0, 0]),
469
- paddingBR = new Point(options.paddingBottomRight || options.padding || [0, 0]);
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 = new LatLngBounds(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 = new Point(offset).round();
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, new LatLngBounds(bounds));
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 = new Point(options.paddingTopLeft || options.padding || [0, 0]),
830
- paddingBR = new Point(options.paddingBottomRight || options.padding || [0, 0]),
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 = new LatLngBounds(bounds);
1201
- padding = new Point(padding ?? [0, 0]);
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(new LatLng(latlng), zoom);
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(new Point(point), zoom);
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 = new Point(point).add(this.getPixelOrigin());
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(new LatLng(latlng))._round();
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(new LatLng(latlng));
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(new LatLng(latlng1), new LatLng(latlng2));
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 new Point(point).subtract(this._getMapPanePos());
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 new Point(point).add(this._getMapPanePos());
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(new Point(point));
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(new LatLng(latlng)));
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 = new LatLngBounds(this._map.options.maxBounds);
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 = new Point(offset).multiplyBy(3);
224
+ offset = Point.from(offset).multiplyBy(3);
225
225
  }
226
226
 
227
227
  if (map.options.maxBounds) {
228
- offset = map._limitOffset(new Point(offset), map.options.maxBounds);
228
+ offset = map._limitOffset(Point.from(offset), map.options.maxBounds);
229
229
  }
230
230
 
231
231
  map._setUserEvent(e);