@antv/l7-map 2.9.33 → 2.9.34

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 (56) hide show
  1. package/lib/camera.js +766 -508
  2. package/lib/earthmap.js +389 -223
  3. package/lib/geo/edge_insets.js +117 -64
  4. package/lib/geo/lng_lat.js +86 -65
  5. package/lib/geo/lng_lat_bounds.js +162 -123
  6. package/lib/geo/mercator.js +91 -62
  7. package/lib/geo/point.js +234 -171
  8. package/lib/geo/simple.js +93 -61
  9. package/lib/geo/transform.js +982 -472
  10. package/lib/handler/IHandler.js +4 -16
  11. package/lib/handler/blockable_map_event.js +84 -63
  12. package/lib/handler/box_zoom.js +201 -123
  13. package/lib/handler/click_zoom.js +63 -55
  14. package/lib/handler/events/event.js +20 -35
  15. package/lib/handler/events/index.js +28 -35
  16. package/lib/handler/events/map_mouse_event.js +85 -42
  17. package/lib/handler/events/map_touch_event.js +116 -45
  18. package/lib/handler/events/map_wheel_event.js +70 -34
  19. package/lib/handler/events/render_event.js +50 -31
  20. package/lib/handler/handler_inertia.js +158 -114
  21. package/lib/handler/handler_manager.js +640 -381
  22. package/lib/handler/handler_util.js +11 -29
  23. package/lib/handler/keyboard.js +155 -114
  24. package/lib/handler/map_event.js +133 -84
  25. package/lib/handler/mouse/index.js +28 -35
  26. package/lib/handler/mouse/mouse_handler.js +126 -90
  27. package/lib/handler/mouse/mousepan_handler.js +64 -46
  28. package/lib/handler/mouse/mousepitch_hander.js +64 -44
  29. package/lib/handler/mouse/mouserotate_hander.js +64 -44
  30. package/lib/handler/mouse/util.js +22 -40
  31. package/lib/handler/scroll_zoom.js +318 -176
  32. package/lib/handler/shim/dblclick_zoom.js +76 -42
  33. package/lib/handler/shim/drag_pan.js +98 -48
  34. package/lib/handler/shim/drag_rotate.js +82 -43
  35. package/lib/handler/shim/touch_zoom_rotate.js +127 -59
  36. package/lib/handler/tap/single_tap_recognizer.js +113 -84
  37. package/lib/handler/tap/tap_drag_zoom.js +111 -93
  38. package/lib/handler/tap/tap_recognizer.js +72 -60
  39. package/lib/handler/tap/tap_zoom.js +113 -88
  40. package/lib/handler/touch/index.js +36 -38
  41. package/lib/handler/touch/touch_pan.js +126 -98
  42. package/lib/handler/touch/touch_pitch.js +108 -74
  43. package/lib/handler/touch/touch_rotate.js +93 -59
  44. package/lib/handler/touch/touch_zoom.js +71 -49
  45. package/lib/handler/touch/two_touch.js +129 -90
  46. package/lib/hash.js +149 -100
  47. package/lib/index.js +43 -20
  48. package/lib/interface.js +4 -16
  49. package/lib/map.js +420 -240
  50. package/lib/util.js +88 -69
  51. package/lib/utils/Aabb.js +134 -81
  52. package/lib/utils/dom.js +162 -88
  53. package/lib/utils/performance.js +46 -54
  54. package/lib/utils/primitives.js +53 -59
  55. package/lib/utils/task_queue.js +104 -61
  56. package/package.json +3 -3
@@ -1,76 +1,129 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/geo/edge_insets.ts
23
- var edge_insets_exports = {};
24
- __export(edge_insets_exports, {
25
- default: () => EdgeInsets
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
26
7
  });
27
- module.exports = __toCommonJS(edge_insets_exports);
28
- var import_util = require("../util");
29
- var import_point = __toESM(require("./point"));
30
- var EdgeInsets = class {
31
- constructor(top = 0, bottom = 0, left = 0, right = 0) {
8
+ exports.default = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _util = require("../util");
15
+
16
+ var _point = _interopRequireDefault(require("./point"));
17
+
18
+ // @ts-ignore
19
+
20
+ /**
21
+ * An `EdgeInset` object represents screen space padding applied to the edges of the viewport.
22
+ * This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements
23
+ * on top of the map and having the vanishing point shift as UI elements resize.
24
+ *
25
+ * @param {number} [top=0]
26
+ * @param {number} [bottom=0]
27
+ * @param {number} [left=0]
28
+ * @param {number} [right=0]
29
+ */
30
+ var EdgeInsets = /*#__PURE__*/function () {
31
+ function EdgeInsets() {
32
+ var top = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
33
+ var bottom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
34
+ var left = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
35
+ var right = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
36
+ (0, _classCallCheck2.default)(this, EdgeInsets);
37
+
32
38
  if (isNaN(top) || top < 0 || isNaN(bottom) || bottom < 0 || isNaN(left) || left < 0 || isNaN(right) || right < 0) {
33
- throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");
39
+ throw new Error('Invalid value for edge-insets, top, bottom, left and right must all be numbers');
34
40
  }
41
+
35
42
  this.top = top;
36
43
  this.bottom = bottom;
37
44
  this.left = left;
38
45
  this.right = right;
39
46
  }
40
- interpolate(start, target, t) {
41
- if (target.top != null && start.top != null) {
42
- this.top = (0, import_util.interpolate)(start.top, target.top, t);
47
+ /**
48
+ * Interpolates the inset in-place.
49
+ * This maintains the current inset value for any inset not present in `target`.
50
+ *
51
+ * @param {PaddingOptions} target
52
+ * @param {number} t
53
+ * @returns {EdgeInsets}
54
+ * @memberof EdgeInsets
55
+ */
56
+
57
+
58
+ (0, _createClass2.default)(EdgeInsets, [{
59
+ key: "interpolate",
60
+ value: function interpolate(start, target, t) {
61
+ if (target.top != null && start.top != null) {
62
+ this.top = (0, _util.interpolate)(start.top, target.top, t);
63
+ }
64
+
65
+ if (target.bottom != null && start.bottom != null) {
66
+ this.bottom = (0, _util.interpolate)(start.bottom, target.bottom, t);
67
+ }
68
+
69
+ if (target.left != null && start.left != null) {
70
+ this.left = (0, _util.interpolate)(start.left, target.left, t);
71
+ }
72
+
73
+ if (target.right != null && start.right != null) {
74
+ this.right = (0, _util.interpolate)(start.right, target.right, t);
75
+ }
76
+
77
+ return this;
43
78
  }
44
- if (target.bottom != null && start.bottom != null) {
45
- this.bottom = (0, import_util.interpolate)(start.bottom, target.bottom, t);
79
+ /**
80
+ * Utility method that computes the new apprent center or vanishing point after applying insets.
81
+ * This is in pixels and with the top left being (0.0) and +y being downwards.
82
+ *
83
+ * @param {number} width
84
+ * @param {number} height
85
+ * @returns {Point}
86
+ * @memberof EdgeInsets
87
+ */
88
+
89
+ }, {
90
+ key: "getCenter",
91
+ value: function getCenter(width, height) {
92
+ // Clamp insets so they never overflow width/height and always calculate a valid center
93
+ var x = (0, _util.clamp)((this.left + width - this.right) / 2, 0, width);
94
+ var y = (0, _util.clamp)((this.top + height - this.bottom) / 2, 0, height);
95
+ return new _point.default(x, y);
46
96
  }
47
- if (target.left != null && start.left != null) {
48
- this.left = (0, import_util.interpolate)(start.left, target.left, t);
97
+ }, {
98
+ key: "equals",
99
+ value: function equals(other) {
100
+ return this.top === other.top && this.bottom === other.bottom && this.left === other.left && this.right === other.right;
49
101
  }
50
- if (target.right != null && start.right != null) {
51
- this.right = (0, import_util.interpolate)(start.right, target.right, t);
102
+ }, {
103
+ key: "clone",
104
+ value: function clone() {
105
+ return new EdgeInsets(this.top, this.bottom, this.left, this.right);
52
106
  }
53
- return this;
54
- }
55
- getCenter(width, height) {
56
- const x = (0, import_util.clamp)((this.left + width - this.right) / 2, 0, width);
57
- const y = (0, import_util.clamp)((this.top + height - this.bottom) / 2, 0, height);
58
- return new import_point.default(x, y);
59
- }
60
- equals(other) {
61
- return this.top === other.top && this.bottom === other.bottom && this.left === other.left && this.right === other.right;
62
- }
63
- clone() {
64
- return new EdgeInsets(this.top, this.bottom, this.left, this.right);
65
- }
66
- toJSON() {
67
- return {
68
- top: this.top,
69
- bottom: this.bottom,
70
- left: this.left,
71
- right: this.right
72
- };
73
- }
74
- };
75
- // Annotate the CommonJS export names for ESM import in node:
76
- 0 && (module.exports = {});
107
+ /**
108
+ * Returns the current sdtate as json, useful when you want to have a
109
+ * read-only representation of the inset.
110
+ *
111
+ * @returns {PaddingOptions}
112
+ * @memberof EdgeInsets
113
+ */
114
+
115
+ }, {
116
+ key: "toJSON",
117
+ value: function toJSON() {
118
+ return {
119
+ top: this.top,
120
+ bottom: this.bottom,
121
+ left: this.left,
122
+ right: this.right
123
+ };
124
+ }
125
+ }]);
126
+ return EdgeInsets;
127
+ }();
128
+
129
+ exports.default = EdgeInsets;
@@ -1,73 +1,94 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/geo/lng_lat.ts
20
- var lng_lat_exports = {};
21
- __export(lng_lat_exports, {
22
- default: () => LngLat,
23
- earthRadius: () => earthRadius
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
24
7
  });
25
- module.exports = __toCommonJS(lng_lat_exports);
26
- var import_util = require("../util");
27
- var earthRadius = 63710088e-1;
28
- var LngLat = class {
29
- static convert(input) {
30
- if (input instanceof LngLat) {
31
- return input;
32
- }
33
- if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {
34
- return new LngLat(Number(input[0]), Number(input[1]));
35
- }
36
- if (!Array.isArray(input) && typeof input === "object" && input !== null) {
37
- const lng = "lng" in input ? input.lng : input.lon;
38
- return new LngLat(Number(lng), Number(input.lat));
39
- }
40
- throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]");
41
- }
42
- constructor(lng, lat) {
8
+ exports.earthRadius = exports.default = void 0;
9
+
10
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
16
+ var _util = require("../util");
17
+
18
+ var earthRadius = 6371008.8;
19
+ exports.earthRadius = earthRadius;
20
+
21
+ var LngLat = /*#__PURE__*/function () {
22
+ function LngLat(lng, lat) {
23
+ (0, _classCallCheck2.default)(this, LngLat);
24
+
43
25
  if (isNaN(lng) || isNaN(lat)) {
44
- throw new Error(`Invalid LngLat object: (${lng}, ${lat})`);
26
+ throw new Error("Invalid LngLat object: (".concat(lng, ", ").concat(lat, ")"));
45
27
  }
28
+
46
29
  this.lng = +lng;
47
30
  this.lat = +lat;
31
+
48
32
  if (this.lat > 90 || this.lat < -90) {
49
- throw new Error("Invalid LngLat latitude value: must be between -90 and 90");
33
+ throw new Error('Invalid LngLat latitude value: must be between -90 and 90');
50
34
  }
51
35
  }
52
- wrap() {
53
- return new LngLat((0, import_util.wrap)(this.lng, -180, 180), this.lat);
54
- }
55
- toArray() {
56
- return [this.lng, this.lat];
57
- }
58
- toString() {
59
- return `LngLat(${this.lng}, ${this.lat})`;
60
- }
61
- distanceTo(lngLat) {
62
- const rad = Math.PI / 180;
63
- const lat1 = this.lat * rad;
64
- const lat2 = lngLat.lat * rad;
65
- const a = Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos((lngLat.lng - this.lng) * rad);
66
- const maxMeters = earthRadius * Math.acos(Math.min(a, 1));
67
- return maxMeters;
68
- }
69
- };
70
- // Annotate the CommonJS export names for ESM import in node:
71
- 0 && (module.exports = {
72
- earthRadius
73
- });
36
+
37
+ (0, _createClass2.default)(LngLat, [{
38
+ key: "wrap",
39
+ value: function wrap() {
40
+ return new LngLat((0, _util.wrap)(this.lng, -180, 180), this.lat);
41
+ }
42
+ }, {
43
+ key: "toArray",
44
+ value: function toArray() {
45
+ return [this.lng, this.lat];
46
+ } // public toBounds(radius: number = 0) {
47
+ // const earthCircumferenceInMetersAtEquator = 40075017;
48
+ // const latAccuracy = (360 * radius) / earthCircumferenceInMetersAtEquator;
49
+ // const lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);
50
+ // return new LngLatBounds(
51
+ // new LngLat(this.lng - lngAccuracy, this.lat - latAccuracy),
52
+ // new LngLat(this.lng + lngAccuracy, this.lat + latAccuracy),
53
+ // );
54
+ // }
55
+
56
+ }, {
57
+ key: "toString",
58
+ value: function toString() {
59
+ return "LngLat(".concat(this.lng, ", ").concat(this.lat, ")");
60
+ }
61
+ }, {
62
+ key: "distanceTo",
63
+ value: function distanceTo(lngLat) {
64
+ var rad = Math.PI / 180;
65
+ var lat1 = this.lat * rad;
66
+ var lat2 = lngLat.lat * rad;
67
+ var a = Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos((lngLat.lng - this.lng) * rad);
68
+ var maxMeters = earthRadius * Math.acos(Math.min(a, 1));
69
+ return maxMeters;
70
+ }
71
+ }], [{
72
+ key: "convert",
73
+ value: function convert(input) {
74
+ if (input instanceof LngLat) {
75
+ return input;
76
+ }
77
+
78
+ if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {
79
+ return new LngLat(Number(input[0]), Number(input[1]));
80
+ }
81
+
82
+ if (!Array.isArray(input) && (0, _typeof2.default)(input) === 'object' && input !== null) {
83
+ var lng = 'lng' in input ? input.lng : input.lon;
84
+ return new LngLat( // flow can't refine this to have one of lng or lat, so we have to cast to any
85
+ Number(lng), Number(input.lat));
86
+ }
87
+
88
+ throw new Error('`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]');
89
+ }
90
+ }]);
91
+ return LngLat;
92
+ }();
93
+
94
+ exports.default = LngLat;
@@ -1,40 +1,23 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/geo/lng_lat_bounds.ts
23
- var lng_lat_bounds_exports = {};
24
- __export(lng_lat_bounds_exports, {
25
- default: () => LngLatBounds
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
26
7
  });
27
- module.exports = __toCommonJS(lng_lat_bounds_exports);
28
- var import_lng_lat = __toESM(require("./lng_lat"));
29
- var LngLatBounds = class {
30
- static convert(input) {
31
- if (input instanceof LngLatBounds) {
32
- return input;
33
- }
34
- return new LngLatBounds(input);
35
- }
36
- constructor(sw, ne) {
37
- if (!sw) {
8
+ exports.default = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _lng_lat = _interopRequireDefault(require("./lng_lat"));
15
+
16
+ var LngLatBounds = /*#__PURE__*/function () {
17
+ function LngLatBounds(sw, ne) {
18
+ (0, _classCallCheck2.default)(this, LngLatBounds);
19
+
20
+ if (!sw) {// noop
38
21
  } else if (ne) {
39
22
  this.setSouthWest(sw).setNorthEast(ne);
40
23
  } else if (sw.length === 4) {
@@ -43,96 +26,152 @@ var LngLatBounds = class {
43
26
  this.setSouthWest(sw[0]).setNorthEast(sw[1]);
44
27
  }
45
28
  }
46
- setNorthEast(ne) {
47
- this.ne = ne instanceof import_lng_lat.default ? new import_lng_lat.default(ne.lng, ne.lat) : import_lng_lat.default.convert(ne);
48
- return this;
49
- }
50
- setSouthWest(sw) {
51
- this.sw = sw instanceof import_lng_lat.default ? new import_lng_lat.default(sw.lng, sw.lat) : import_lng_lat.default.convert(sw);
52
- return this;
53
- }
54
- extend(obj) {
55
- const sw = this.sw;
56
- const ne = this.ne;
57
- let sw2;
58
- let ne2;
59
- if (obj instanceof import_lng_lat.default) {
60
- sw2 = obj;
61
- ne2 = obj;
62
- } else if (obj instanceof LngLatBounds) {
63
- sw2 = obj.sw;
64
- ne2 = obj.ne;
65
- if (!sw2 || !ne2) {
29
+
30
+ (0, _createClass2.default)(LngLatBounds, [{
31
+ key: "setNorthEast",
32
+ value: function setNorthEast(ne) {
33
+ this.ne = ne instanceof _lng_lat.default ? new _lng_lat.default(ne.lng, ne.lat) : _lng_lat.default.convert(ne);
34
+ return this;
35
+ }
36
+ }, {
37
+ key: "setSouthWest",
38
+ value: function setSouthWest(sw) {
39
+ this.sw = sw instanceof _lng_lat.default ? new _lng_lat.default(sw.lng, sw.lat) : _lng_lat.default.convert(sw);
40
+ return this;
41
+ }
42
+ }, {
43
+ key: "extend",
44
+ value: function extend(obj) {
45
+ var sw = this.sw;
46
+ var ne = this.ne;
47
+ var sw2;
48
+ var ne2;
49
+
50
+ if (obj instanceof _lng_lat.default) {
51
+ sw2 = obj;
52
+ ne2 = obj;
53
+ } else if (obj instanceof LngLatBounds) {
54
+ sw2 = obj.sw;
55
+ ne2 = obj.ne;
56
+
57
+ if (!sw2 || !ne2) {
58
+ return this;
59
+ }
60
+ } else {
61
+ if (Array.isArray(obj)) {
62
+ //@ts-ignore
63
+ if (obj.length === 4 || obj.every(Array.isArray)) {
64
+ var lngLatBoundsObj = obj;
65
+ return this.extend(LngLatBounds.convert(lngLatBoundsObj));
66
+ } else {
67
+ var lngLatObj = obj;
68
+ return this.extend(_lng_lat.default.convert(lngLatObj));
69
+ }
70
+ }
71
+
66
72
  return this;
67
73
  }
68
- } else {
69
- if (Array.isArray(obj)) {
70
- if (obj.length === 4 || obj.every(Array.isArray)) {
71
- const lngLatBoundsObj = obj;
72
- return this.extend(LngLatBounds.convert(lngLatBoundsObj));
73
- } else {
74
- const lngLatObj = obj;
75
- return this.extend(import_lng_lat.default.convert(lngLatObj));
76
- }
74
+
75
+ if (!sw && !ne) {
76
+ this.sw = new _lng_lat.default(sw2.lng, sw2.lat);
77
+ this.ne = new _lng_lat.default(ne2.lng, ne2.lat);
78
+ } else {
79
+ sw.lng = Math.min(sw2.lng, sw.lng);
80
+ sw.lat = Math.min(sw2.lat, sw.lat);
81
+ ne.lng = Math.max(ne2.lng, ne.lng);
82
+ ne.lat = Math.max(ne2.lat, ne.lat);
77
83
  }
84
+
78
85
  return this;
79
86
  }
80
- if (!sw && !ne) {
81
- this.sw = new import_lng_lat.default(sw2.lng, sw2.lat);
82
- this.ne = new import_lng_lat.default(ne2.lng, ne2.lat);
83
- } else {
84
- sw.lng = Math.min(sw2.lng, sw.lng);
85
- sw.lat = Math.min(sw2.lat, sw.lat);
86
- ne.lng = Math.max(ne2.lng, ne.lng);
87
- ne.lat = Math.max(ne2.lat, ne.lat);
87
+ }, {
88
+ key: "getCenter",
89
+ value: function getCenter() {
90
+ return new _lng_lat.default((this.sw.lng + this.ne.lng) / 2, (this.sw.lat + this.ne.lat) / 2);
88
91
  }
89
- return this;
90
- }
91
- getCenter() {
92
- return new import_lng_lat.default((this.sw.lng + this.ne.lng) / 2, (this.sw.lat + this.ne.lat) / 2);
93
- }
94
- getSouthWest() {
95
- return this.sw;
96
- }
97
- getNorthEast() {
98
- return this.ne;
99
- }
100
- getNorthWest() {
101
- return new import_lng_lat.default(this.getWest(), this.getNorth());
102
- }
103
- getSouthEast() {
104
- return new import_lng_lat.default(this.getEast(), this.getSouth());
105
- }
106
- getWest() {
107
- return this.sw.lng;
108
- }
109
- getSouth() {
110
- return this.sw.lat;
111
- }
112
- getEast() {
113
- return this.ne.lng;
114
- }
115
- getNorth() {
116
- return this.ne.lat;
117
- }
118
- toArray() {
119
- return [this.sw.toArray(), this.ne.toArray()];
120
- }
121
- toString() {
122
- return `LngLatBounds(${this.sw.toString()}, ${this.ne.toString()})`;
123
- }
124
- isEmpty() {
125
- return !(this.sw && this.ne);
126
- }
127
- contains(lnglat) {
128
- const { lng, lat } = import_lng_lat.default.convert(lnglat);
129
- const containsLatitude = this.sw.lat <= lat && lat <= this.ne.lat;
130
- let containsLongitude = this.sw.lng <= lng && lng <= this.ne.lng;
131
- if (this.sw.lng > this.ne.lng) {
132
- containsLongitude = this.sw.lng >= lng && lng >= this.ne.lng;
133
- }
134
- return containsLatitude && containsLongitude;
135
- }
136
- };
137
- // Annotate the CommonJS export names for ESM import in node:
138
- 0 && (module.exports = {});
92
+ }, {
93
+ key: "getSouthWest",
94
+ value: function getSouthWest() {
95
+ return this.sw;
96
+ }
97
+ }, {
98
+ key: "getNorthEast",
99
+ value: function getNorthEast() {
100
+ return this.ne;
101
+ }
102
+ }, {
103
+ key: "getNorthWest",
104
+ value: function getNorthWest() {
105
+ return new _lng_lat.default(this.getWest(), this.getNorth());
106
+ }
107
+ }, {
108
+ key: "getSouthEast",
109
+ value: function getSouthEast() {
110
+ return new _lng_lat.default(this.getEast(), this.getSouth());
111
+ }
112
+ }, {
113
+ key: "getWest",
114
+ value: function getWest() {
115
+ return this.sw.lng;
116
+ }
117
+ }, {
118
+ key: "getSouth",
119
+ value: function getSouth() {
120
+ return this.sw.lat;
121
+ }
122
+ }, {
123
+ key: "getEast",
124
+ value: function getEast() {
125
+ return this.ne.lng;
126
+ }
127
+ }, {
128
+ key: "getNorth",
129
+ value: function getNorth() {
130
+ return this.ne.lat;
131
+ }
132
+ }, {
133
+ key: "toArray",
134
+ value: function toArray() {
135
+ return [this.sw.toArray(), this.ne.toArray()];
136
+ }
137
+ }, {
138
+ key: "toString",
139
+ value: function toString() {
140
+ return "LngLatBounds(".concat(this.sw.toString(), ", ").concat(this.ne.toString(), ")");
141
+ }
142
+ }, {
143
+ key: "isEmpty",
144
+ value: function isEmpty() {
145
+ return !(this.sw && this.ne);
146
+ }
147
+ }, {
148
+ key: "contains",
149
+ value: function contains(lnglat) {
150
+ var _LngLat$convert = _lng_lat.default.convert(lnglat),
151
+ lng = _LngLat$convert.lng,
152
+ lat = _LngLat$convert.lat;
153
+
154
+ var containsLatitude = this.sw.lat <= lat && lat <= this.ne.lat;
155
+ var containsLongitude = this.sw.lng <= lng && lng <= this.ne.lng;
156
+
157
+ if (this.sw.lng > this.ne.lng) {
158
+ // wrapped coordinates
159
+ containsLongitude = this.sw.lng >= lng && lng >= this.ne.lng;
160
+ }
161
+
162
+ return containsLatitude && containsLongitude;
163
+ }
164
+ }], [{
165
+ key: "convert",
166
+ value: function convert(input) {
167
+ if (input instanceof LngLatBounds) {
168
+ return input;
169
+ }
170
+
171
+ return new LngLatBounds(input);
172
+ }
173
+ }]);
174
+ return LngLatBounds;
175
+ }();
176
+
177
+ exports.default = LngLatBounds;