@antv/l7-map 2.9.19 → 2.9.22-alpha.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/es/camera.js +115 -85
- package/es/css/l7.css +98 -0
- package/es/earthmap.js +27 -43
- package/es/geo/edge_insets.js +44 -14
- package/es/geo/lng_lat.js +15 -11
- package/es/geo/lng_lat_bounds.js +6 -10
- package/es/geo/mercator.js +24 -12
- package/es/geo/point.js +2 -8
- package/es/geo/simple.js +24 -12
- package/es/geo/transform.js +421 -120
- package/es/handler/IHandler.js +1 -2
- package/es/handler/blockable_map_event.js +13 -14
- package/es/handler/box_zoom.js +43 -27
- package/es/handler/click_zoom.js +3 -8
- package/es/handler/events/event.js +3 -6
- package/es/handler/events/index.js +4 -5
- package/es/handler/events/map_mouse_event.js +30 -20
- package/es/handler/events/map_touch_event.js +55 -25
- package/es/handler/events/map_wheel_event.js +24 -15
- package/es/handler/events/render_event.js +3 -6
- package/es/handler/handler_inertia.js +10 -12
- package/es/handler/handler_manager.js +75 -72
- package/es/handler/handler_util.js +2 -2
- package/es/handler/keyboard.js +20 -15
- package/es/handler/map_event.js +23 -12
- package/es/handler/mouse/index.js +4 -5
- package/es/handler/mouse/mouse_handler.js +17 -21
- package/es/handler/mouse/mousepan_handler.js +5 -5
- package/es/handler/mouse/mousepitch_hander.js +7 -5
- package/es/handler/mouse/mouserotate_hander.js +7 -5
- package/es/handler/mouse/util.js +3 -3
- package/es/handler/scroll_zoom.js +103 -67
- package/es/handler/shim/dblclick_zoom.js +35 -8
- package/es/handler/shim/drag_pan.js +48 -12
- package/es/handler/shim/drag_rotate.js +39 -10
- package/es/handler/shim/touch_zoom_rotate.js +59 -16
- package/es/handler/tap/single_tap_recognizer.js +7 -17
- package/es/handler/tap/tap_drag_zoom.js +5 -18
- package/es/handler/tap/tap_recognizer.js +4 -15
- package/es/handler/tap/tap_zoom.js +4 -13
- package/es/handler/touch/index.js +5 -6
- package/es/handler/touch/touch_pan.js +9 -20
- package/es/handler/touch/touch_pitch.js +11 -23
- package/es/handler/touch/touch_rotate.js +15 -18
- package/es/handler/touch/touch_zoom.js +5 -19
- package/es/handler/touch/two_touch.js +14 -21
- package/es/hash.js +28 -16
- package/es/index.js +2 -3
- package/es/interface.js +1 -2
- package/es/map.js +26 -47
- package/es/util.js +15 -6
- package/es/utils/Aabb.js +11 -12
- package/es/utils/dom.js +30 -11
- package/es/utils/performance.js +10 -6
- package/es/utils/primitives.js +11 -10
- package/es/utils/task_queue.js +6 -13
- package/lib/camera.js +508 -721
- package/lib/css/l7.css +98 -0
- package/lib/earthmap.js +222 -392
- package/lib/geo/edge_insets.js +64 -83
- package/lib/geo/lng_lat.js +65 -81
- package/lib/geo/lng_lat_bounds.js +124 -165
- package/lib/geo/mercator.js +62 -78
- package/lib/geo/point.js +171 -239
- package/lib/geo/simple.js +61 -80
- package/lib/geo/transform.js +470 -653
- package/lib/handler/IHandler.js +17 -2
- package/lib/handler/blockable_map_event.js +63 -83
- package/lib/handler/box_zoom.js +123 -176
- package/lib/handler/click_zoom.js +56 -68
- package/lib/handler/events/event.js +35 -23
- package/lib/handler/events/index.js +35 -29
- package/lib/handler/events/map_mouse_event.js +42 -72
- package/lib/handler/events/map_touch_event.js +45 -80
- package/lib/handler/events/map_wheel_event.js +34 -58
- package/lib/handler/events/render_event.js +31 -52
- package/lib/handler/handler_inertia.js +113 -160
- package/lib/handler/handler_manager.js +379 -620
- package/lib/handler/handler_util.js +28 -10
- package/lib/handler/keyboard.js +114 -146
- package/lib/handler/map_event.js +84 -120
- package/lib/handler/mouse/index.js +35 -29
- package/lib/handler/mouse/mouse_handler.js +90 -123
- package/lib/handler/mouse/mousepan_handler.js +46 -65
- package/lib/handler/mouse/mousepitch_hander.js +44 -63
- package/lib/handler/mouse/mouserotate_hander.js +44 -63
- package/lib/handler/mouse/util.js +38 -20
- package/lib/handler/scroll_zoom.js +175 -258
- package/lib/handler/shim/dblclick_zoom.js +42 -48
- package/lib/handler/shim/drag_pan.js +48 -59
- package/lib/handler/shim/drag_rotate.js +43 -51
- package/lib/handler/shim/touch_zoom_rotate.js +58 -78
- package/lib/handler/tap/single_tap_recognizer.js +84 -117
- package/lib/handler/tap/tap_drag_zoom.js +92 -115
- package/lib/handler/tap/tap_recognizer.js +60 -78
- package/lib/handler/tap/tap_zoom.js +88 -119
- package/lib/handler/touch/index.js +38 -37
- package/lib/handler/touch/touch_pan.js +98 -132
- package/lib/handler/touch/touch_pitch.js +73 -117
- package/lib/handler/touch/touch_rotate.js +58 -94
- package/lib/handler/touch/touch_zoom.js +49 -84
- package/lib/handler/touch/two_touch.js +88 -128
- package/lib/hash.js +100 -133
- package/lib/index.js +19 -31
- package/lib/interface.js +17 -2
- package/lib/map.js +238 -420
- package/lib/util.js +67 -78
- package/lib/utils/Aabb.js +80 -132
- package/lib/utils/dom.js +84 -141
- package/lib/utils/performance.js +54 -42
- package/lib/utils/primitives.js +59 -51
- package/lib/utils/task_queue.js +61 -108
- package/package.json +11 -8
- package/es/camera.js.map +0 -1
- package/es/earthmap.js.map +0 -1
- package/es/geo/edge_insets.js.map +0 -1
- package/es/geo/lng_lat.js.map +0 -1
- package/es/geo/lng_lat_bounds.js.map +0 -1
- package/es/geo/mercator.js.map +0 -1
- package/es/geo/point.js.map +0 -1
- package/es/geo/simple.js.map +0 -1
- package/es/geo/transform.js.map +0 -1
- package/es/handler/IHandler.js.map +0 -1
- package/es/handler/blockable_map_event.js.map +0 -1
- package/es/handler/box_zoom.js.map +0 -1
- package/es/handler/click_zoom.js.map +0 -1
- package/es/handler/events/event.js.map +0 -1
- package/es/handler/events/index.js.map +0 -1
- package/es/handler/events/map_mouse_event.js.map +0 -1
- package/es/handler/events/map_touch_event.js.map +0 -1
- package/es/handler/events/map_wheel_event.js.map +0 -1
- package/es/handler/events/render_event.js.map +0 -1
- package/es/handler/handler_inertia.js.map +0 -1
- package/es/handler/handler_manager.js.map +0 -1
- package/es/handler/handler_util.js.map +0 -1
- package/es/handler/keyboard.js.map +0 -1
- package/es/handler/map_event.js.map +0 -1
- package/es/handler/mouse/index.js.map +0 -1
- package/es/handler/mouse/mouse_handler.js.map +0 -1
- package/es/handler/mouse/mousepan_handler.js.map +0 -1
- package/es/handler/mouse/mousepitch_hander.js.map +0 -1
- package/es/handler/mouse/mouserotate_hander.js.map +0 -1
- package/es/handler/mouse/util.js.map +0 -1
- package/es/handler/scroll_zoom.js.map +0 -1
- package/es/handler/shim/dblclick_zoom.js.map +0 -1
- package/es/handler/shim/drag_pan.js.map +0 -1
- package/es/handler/shim/drag_rotate.js.map +0 -1
- package/es/handler/shim/touch_zoom_rotate.js.map +0 -1
- package/es/handler/tap/single_tap_recognizer.js.map +0 -1
- package/es/handler/tap/tap_drag_zoom.js.map +0 -1
- package/es/handler/tap/tap_recognizer.js.map +0 -1
- package/es/handler/tap/tap_zoom.js.map +0 -1
- package/es/handler/touch/index.js.map +0 -1
- package/es/handler/touch/touch_pan.js.map +0 -1
- package/es/handler/touch/touch_pitch.js.map +0 -1
- package/es/handler/touch/touch_rotate.js.map +0 -1
- package/es/handler/touch/touch_zoom.js.map +0 -1
- package/es/handler/touch/two_touch.js.map +0 -1
- package/es/hash.js.map +0 -1
- package/es/index.js.map +0 -1
- package/es/interface.js.map +0 -1
- package/es/map.js.map +0 -1
- package/es/util.js.map +0 -1
- package/es/utils/Aabb.js.map +0 -1
- package/es/utils/dom.js.map +0 -1
- package/es/utils/performance.js.map +0 -1
- package/es/utils/primitives.js.map +0 -1
- package/es/utils/task_queue.js.map +0 -1
- package/lib/camera.js.map +0 -1
- package/lib/earthmap.js.map +0 -1
- package/lib/geo/edge_insets.js.map +0 -1
- package/lib/geo/lng_lat.js.map +0 -1
- package/lib/geo/lng_lat_bounds.js.map +0 -1
- package/lib/geo/mercator.js.map +0 -1
- package/lib/geo/point.js.map +0 -1
- package/lib/geo/simple.js.map +0 -1
- package/lib/geo/transform.js.map +0 -1
- package/lib/handler/IHandler.js.map +0 -1
- package/lib/handler/blockable_map_event.js.map +0 -1
- package/lib/handler/box_zoom.js.map +0 -1
- package/lib/handler/click_zoom.js.map +0 -1
- package/lib/handler/events/event.js.map +0 -1
- package/lib/handler/events/index.js.map +0 -1
- package/lib/handler/events/map_mouse_event.js.map +0 -1
- package/lib/handler/events/map_touch_event.js.map +0 -1
- package/lib/handler/events/map_wheel_event.js.map +0 -1
- package/lib/handler/events/render_event.js.map +0 -1
- package/lib/handler/handler_inertia.js.map +0 -1
- package/lib/handler/handler_manager.js.map +0 -1
- package/lib/handler/handler_util.js.map +0 -1
- package/lib/handler/keyboard.js.map +0 -1
- package/lib/handler/map_event.js.map +0 -1
- package/lib/handler/mouse/index.js.map +0 -1
- package/lib/handler/mouse/mouse_handler.js.map +0 -1
- package/lib/handler/mouse/mousepan_handler.js.map +0 -1
- package/lib/handler/mouse/mousepitch_hander.js.map +0 -1
- package/lib/handler/mouse/mouserotate_hander.js.map +0 -1
- package/lib/handler/mouse/util.js.map +0 -1
- package/lib/handler/scroll_zoom.js.map +0 -1
- package/lib/handler/shim/dblclick_zoom.js.map +0 -1
- package/lib/handler/shim/drag_pan.js.map +0 -1
- package/lib/handler/shim/drag_rotate.js.map +0 -1
- package/lib/handler/shim/touch_zoom_rotate.js.map +0 -1
- package/lib/handler/tap/single_tap_recognizer.js.map +0 -1
- package/lib/handler/tap/tap_drag_zoom.js.map +0 -1
- package/lib/handler/tap/tap_recognizer.js.map +0 -1
- package/lib/handler/tap/tap_zoom.js.map +0 -1
- package/lib/handler/touch/index.js.map +0 -1
- package/lib/handler/touch/touch_pan.js.map +0 -1
- package/lib/handler/touch/touch_pitch.js.map +0 -1
- package/lib/handler/touch/touch_rotate.js.map +0 -1
- package/lib/handler/touch/touch_zoom.js.map +0 -1
- package/lib/handler/touch/two_touch.js.map +0 -1
- package/lib/hash.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interface.js.map +0 -1
- package/lib/map.js.map +0 -1
- package/lib/util.js.map +0 -1
- package/lib/utils/Aabb.js.map +0 -1
- package/lib/utils/dom.js.map +0 -1
- package/lib/utils/performance.js.map +0 -1
- package/lib/utils/primitives.js.map +0 -1
- package/lib/utils/task_queue.js.map +0 -1
package/lib/geo/edge_insets.js
CHANGED
|
@@ -1,95 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
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
|
|
7
26
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
|
-
var _util = require("../util");
|
|
17
|
-
|
|
18
|
-
var _point = _interopRequireDefault(require("./point"));
|
|
19
|
-
|
|
20
|
-
var EdgeInsets = function () {
|
|
21
|
-
function EdgeInsets() {
|
|
22
|
-
var top = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
23
|
-
var bottom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
24
|
-
var left = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
25
|
-
var right = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
26
|
-
(0, _classCallCheck2.default)(this, EdgeInsets);
|
|
27
|
-
(0, _defineProperty2.default)(this, "top", void 0);
|
|
28
|
-
(0, _defineProperty2.default)(this, "bottom", void 0);
|
|
29
|
-
(0, _defineProperty2.default)(this, "left", void 0);
|
|
30
|
-
(0, _defineProperty2.default)(this, "right", void 0);
|
|
31
|
-
|
|
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) {
|
|
32
32
|
if (isNaN(top) || top < 0 || isNaN(bottom) || bottom < 0 || isNaN(left) || left < 0 || isNaN(right) || right < 0) {
|
|
33
|
-
throw new Error(
|
|
33
|
+
throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");
|
|
34
34
|
}
|
|
35
|
-
|
|
36
35
|
this.top = top;
|
|
37
36
|
this.bottom = bottom;
|
|
38
37
|
this.left = left;
|
|
39
38
|
this.right = right;
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
value: function interpolate(start, target, t) {
|
|
45
|
-
if (target.top != null && start.top != null) {
|
|
46
|
-
this.top = (0, _util.interpolate)(start.top, target.top, t);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (target.bottom != null && start.bottom != null) {
|
|
50
|
-
this.bottom = (0, _util.interpolate)(start.bottom, target.bottom, t);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (target.left != null && start.left != null) {
|
|
54
|
-
this.left = (0, _util.interpolate)(start.left, target.left, t);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (target.right != null && start.right != null) {
|
|
58
|
-
this.right = (0, _util.interpolate)(start.right, target.right, t);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
}, {
|
|
64
|
-
key: "getCenter",
|
|
65
|
-
value: function getCenter(width, height) {
|
|
66
|
-
var x = (0, _util.clamp)((this.left + width - this.right) / 2, 0, width);
|
|
67
|
-
var y = (0, _util.clamp)((this.top + height - this.bottom) / 2, 0, height);
|
|
68
|
-
return new _point.default(x, y);
|
|
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);
|
|
69
43
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
value: function equals(other) {
|
|
73
|
-
return this.top === other.top && this.bottom === other.bottom && this.left === other.left && this.right === other.right;
|
|
44
|
+
if (target.bottom != null && start.bottom != null) {
|
|
45
|
+
this.bottom = (0, import_util.interpolate)(start.bottom, target.bottom, t);
|
|
74
46
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
value: function clone() {
|
|
78
|
-
return new EdgeInsets(this.top, this.bottom, this.left, this.right);
|
|
47
|
+
if (target.left != null && start.left != null) {
|
|
48
|
+
this.left = (0, import_util.interpolate)(start.left, target.left, t);
|
|
79
49
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
value: function toJSON() {
|
|
83
|
-
return {
|
|
84
|
-
top: this.top,
|
|
85
|
-
bottom: this.bottom,
|
|
86
|
-
left: this.left,
|
|
87
|
-
right: this.right
|
|
88
|
-
};
|
|
50
|
+
if (target.right != null && start.right != null) {
|
|
51
|
+
this.right = (0, import_util.interpolate)(start.right, target.right, t);
|
|
89
52
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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 = {});
|
package/lib/geo/lng_lat.js
CHANGED
|
@@ -1,89 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
7
24
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
(0, _defineProperty2.default)(this, "lng", void 0);
|
|
27
|
-
(0, _defineProperty2.default)(this, "lat", void 0);
|
|
28
|
-
|
|
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) {
|
|
29
43
|
if (isNaN(lng) || isNaN(lat)) {
|
|
30
|
-
throw new Error(
|
|
44
|
+
throw new Error(`Invalid LngLat object: (${lng}, ${lat})`);
|
|
31
45
|
}
|
|
32
|
-
|
|
33
46
|
this.lng = +lng;
|
|
34
47
|
this.lat = +lat;
|
|
35
|
-
|
|
36
48
|
if (this.lat > 90 || this.lat < -90) {
|
|
37
|
-
throw new Error(
|
|
49
|
+
throw new Error("Invalid LngLat latitude value: must be between -90 and 90");
|
|
38
50
|
}
|
|
39
51
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var a = Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos((lngLat.lng - this.lng) * rad);
|
|
63
|
-
var maxMeters = earthRadius * Math.acos(Math.min(a, 1));
|
|
64
|
-
return maxMeters;
|
|
65
|
-
}
|
|
66
|
-
}], [{
|
|
67
|
-
key: "convert",
|
|
68
|
-
value: function convert(input) {
|
|
69
|
-
if (input instanceof LngLat) {
|
|
70
|
-
return input;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {
|
|
74
|
-
return new LngLat(Number(input[0]), Number(input[1]));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (!Array.isArray(input) && (0, _typeof2.default)(input) === 'object' && input !== null) {
|
|
78
|
-
var lng = 'lng' in input ? input.lng : input.lon;
|
|
79
|
-
return new LngLat(Number(lng), Number(input.lat));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
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>]');
|
|
83
|
-
}
|
|
84
|
-
}]);
|
|
85
|
-
return LngLat;
|
|
86
|
-
}();
|
|
87
|
-
|
|
88
|
-
exports.default = LngLat;
|
|
89
|
-
//# sourceMappingURL=lng_lat.js.map
|
|
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
|
+
});
|
|
@@ -1,27 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
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
|
|
7
26
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
(0, _classCallCheck2.default)(this, LngLatBounds);
|
|
21
|
-
(0, _defineProperty2.default)(this, "ne", void 0);
|
|
22
|
-
(0, _defineProperty2.default)(this, "sw", void 0);
|
|
23
|
-
|
|
24
|
-
if (!sw) {} else if (ne) {
|
|
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) {
|
|
38
|
+
} else if (ne) {
|
|
25
39
|
this.setSouthWest(sw).setNorthEast(ne);
|
|
26
40
|
} else if (sw.length === 4) {
|
|
27
41
|
this.setSouthWest([sw[0], sw[1]]).setNorthEast([sw[2], sw[3]]);
|
|
@@ -29,151 +43,96 @@ var LngLatBounds = function () {
|
|
|
29
43
|
this.setSouthWest(sw[0]).setNorthEast(sw[1]);
|
|
30
44
|
}
|
|
31
45
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (obj instanceof _lng_lat.default) {
|
|
54
|
-
sw2 = obj;
|
|
55
|
-
ne2 = obj;
|
|
56
|
-
} else if (obj instanceof LngLatBounds) {
|
|
57
|
-
sw2 = obj.sw;
|
|
58
|
-
ne2 = obj.ne;
|
|
59
|
-
|
|
60
|
-
if (!sw2 || !ne2) {
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
if (Array.isArray(obj)) {
|
|
65
|
-
if (obj.length === 4 || obj.every(Array.isArray)) {
|
|
66
|
-
var lngLatBoundsObj = obj;
|
|
67
|
-
return this.extend(LngLatBounds.convert(lngLatBoundsObj));
|
|
68
|
-
} else {
|
|
69
|
-
var lngLatObj = obj;
|
|
70
|
-
return this.extend(_lng_lat.default.convert(lngLatObj));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
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) {
|
|
74
66
|
return this;
|
|
75
67
|
}
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
+
}
|
|
85
77
|
}
|
|
86
|
-
|
|
87
78
|
return this;
|
|
88
79
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return this.sw;
|
|
98
|
-
}
|
|
99
|
-
}, {
|
|
100
|
-
key: "getNorthEast",
|
|
101
|
-
value: function getNorthEast() {
|
|
102
|
-
return this.ne;
|
|
103
|
-
}
|
|
104
|
-
}, {
|
|
105
|
-
key: "getNorthWest",
|
|
106
|
-
value: function getNorthWest() {
|
|
107
|
-
return new _lng_lat.default(this.getWest(), this.getNorth());
|
|
108
|
-
}
|
|
109
|
-
}, {
|
|
110
|
-
key: "getSouthEast",
|
|
111
|
-
value: function getSouthEast() {
|
|
112
|
-
return new _lng_lat.default(this.getEast(), this.getSouth());
|
|
113
|
-
}
|
|
114
|
-
}, {
|
|
115
|
-
key: "getWest",
|
|
116
|
-
value: function getWest() {
|
|
117
|
-
return this.sw.lng;
|
|
118
|
-
}
|
|
119
|
-
}, {
|
|
120
|
-
key: "getSouth",
|
|
121
|
-
value: function getSouth() {
|
|
122
|
-
return this.sw.lat;
|
|
123
|
-
}
|
|
124
|
-
}, {
|
|
125
|
-
key: "getEast",
|
|
126
|
-
value: function getEast() {
|
|
127
|
-
return this.ne.lng;
|
|
128
|
-
}
|
|
129
|
-
}, {
|
|
130
|
-
key: "getNorth",
|
|
131
|
-
value: function getNorth() {
|
|
132
|
-
return this.ne.lat;
|
|
133
|
-
}
|
|
134
|
-
}, {
|
|
135
|
-
key: "toArray",
|
|
136
|
-
value: function toArray() {
|
|
137
|
-
return [this.sw.toArray(), this.ne.toArray()];
|
|
138
|
-
}
|
|
139
|
-
}, {
|
|
140
|
-
key: "toString",
|
|
141
|
-
value: function toString() {
|
|
142
|
-
return "LngLatBounds(".concat(this.sw.toString(), ", ").concat(this.ne.toString(), ")");
|
|
143
|
-
}
|
|
144
|
-
}, {
|
|
145
|
-
key: "isEmpty",
|
|
146
|
-
value: function isEmpty() {
|
|
147
|
-
return !(this.sw && this.ne);
|
|
148
|
-
}
|
|
149
|
-
}, {
|
|
150
|
-
key: "contains",
|
|
151
|
-
value: function contains(lnglat) {
|
|
152
|
-
var _LngLat$convert = _lng_lat.default.convert(lnglat),
|
|
153
|
-
lng = _LngLat$convert.lng,
|
|
154
|
-
lat = _LngLat$convert.lat;
|
|
155
|
-
|
|
156
|
-
var containsLatitude = this.sw.lat <= lat && lat <= this.ne.lat;
|
|
157
|
-
var containsLongitude = this.sw.lng <= lng && lng <= this.ne.lng;
|
|
158
|
-
|
|
159
|
-
if (this.sw.lng > this.ne.lng) {
|
|
160
|
-
containsLongitude = this.sw.lng >= lng && lng >= this.ne.lng;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return containsLatitude && containsLongitude;
|
|
164
|
-
}
|
|
165
|
-
}], [{
|
|
166
|
-
key: "convert",
|
|
167
|
-
value: function convert(input) {
|
|
168
|
-
if (input instanceof LngLatBounds) {
|
|
169
|
-
return input;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return new LngLatBounds(input);
|
|
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);
|
|
173
88
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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 = {});
|