@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/camera.js
CHANGED
|
@@ -1,746 +1,533 @@
|
|
|
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/camera.ts
|
|
23
|
+
var camera_exports = {};
|
|
24
|
+
__export(camera_exports, {
|
|
25
|
+
default: () => Camera
|
|
7
26
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var _merge2 = _interopRequireDefault(require("lodash/merge"));
|
|
25
|
-
|
|
26
|
-
var _eventemitter = require("eventemitter3");
|
|
27
|
-
|
|
28
|
-
var _lng_lat = _interopRequireDefault(require("./geo/lng_lat"));
|
|
29
|
-
|
|
30
|
-
var _lng_lat_bounds = _interopRequireDefault(require("./geo/lng_lat_bounds"));
|
|
31
|
-
|
|
32
|
-
var _point = _interopRequireDefault(require("./geo/point"));
|
|
33
|
-
|
|
34
|
-
var _transform = _interopRequireDefault(require("./geo/transform"));
|
|
35
|
-
|
|
36
|
-
var _event = require("./handler/events/event");
|
|
37
|
-
|
|
38
|
-
var _util = require("./util");
|
|
39
|
-
|
|
40
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
41
|
-
|
|
42
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
43
|
-
|
|
44
|
-
var Camera = function (_EventEmitter) {
|
|
45
|
-
(0, _inherits2.default)(Camera, _EventEmitter);
|
|
46
|
-
|
|
47
|
-
var _super = _createSuper(Camera);
|
|
48
|
-
|
|
49
|
-
function Camera(options) {
|
|
50
|
-
var _this;
|
|
51
|
-
|
|
52
|
-
(0, _classCallCheck2.default)(this, Camera);
|
|
53
|
-
_this = _super.call(this);
|
|
54
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "transform", void 0);
|
|
55
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "options", void 0);
|
|
56
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "moving", void 0);
|
|
57
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "zooming", void 0);
|
|
58
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "rotating", void 0);
|
|
59
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "pitching", void 0);
|
|
60
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "padding", void 0);
|
|
61
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "bearingSnap", void 0);
|
|
62
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "easeEndTimeoutID", void 0);
|
|
63
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "easeStart", void 0);
|
|
64
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "easeOptions", void 0);
|
|
65
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "easeId", void 0);
|
|
66
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onEaseFrame", void 0);
|
|
67
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onEaseEnd", void 0);
|
|
68
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "easeFrameId", void 0);
|
|
69
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "pitchEnabled", void 0);
|
|
70
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "rotateEnabled", void 0);
|
|
71
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderFrameCallback", function () {
|
|
72
|
-
var t = Math.min(((0, _util.now)() - _this.easeStart) / _this.easeOptions.duration, 1);
|
|
73
|
-
|
|
74
|
-
_this.onEaseFrame(_this.easeOptions.easing(t));
|
|
75
|
-
|
|
27
|
+
module.exports = __toCommonJS(camera_exports);
|
|
28
|
+
var import_eventemitter3 = require("eventemitter3");
|
|
29
|
+
var import_lodash = require("lodash");
|
|
30
|
+
var import_lng_lat = __toESM(require("./geo/lng_lat"));
|
|
31
|
+
var import_lng_lat_bounds = __toESM(require("./geo/lng_lat_bounds"));
|
|
32
|
+
var import_point = __toESM(require("./geo/point"));
|
|
33
|
+
var import_transform = __toESM(require("./geo/transform"));
|
|
34
|
+
var import_event = require("./handler/events/event");
|
|
35
|
+
var import_util = require("./util");
|
|
36
|
+
var Camera = class extends import_eventemitter3.EventEmitter {
|
|
37
|
+
constructor(options) {
|
|
38
|
+
super();
|
|
39
|
+
this.renderFrameCallback = () => {
|
|
40
|
+
const t = Math.min(((0, import_util.now)() - this.easeStart) / this.easeOptions.duration, 1);
|
|
41
|
+
this.onEaseFrame(this.easeOptions.easing(t));
|
|
76
42
|
if (t < 1) {
|
|
77
|
-
|
|
43
|
+
this.easeFrameId = this.requestRenderFrame(this.renderFrameCallback);
|
|
78
44
|
} else {
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
_this.bearingSnap = options.bearingSnap;
|
|
91
|
-
_this.pitchEnabled = options.pitchEnabled;
|
|
92
|
-
_this.rotateEnabled = options.rotateEnabled;
|
|
93
|
-
_this.transform = new _transform.default(minZoom, maxZoom, minPitch, maxPitch, renderWorldCopies);
|
|
94
|
-
return _this;
|
|
45
|
+
this.stop();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
this.options = options;
|
|
49
|
+
const { minZoom, maxZoom, minPitch, maxPitch, renderWorldCopies } = options;
|
|
50
|
+
this.moving = false;
|
|
51
|
+
this.zooming = false;
|
|
52
|
+
this.bearingSnap = options.bearingSnap;
|
|
53
|
+
this.pitchEnabled = options.pitchEnabled;
|
|
54
|
+
this.rotateEnabled = options.rotateEnabled;
|
|
55
|
+
this.transform = new import_transform.default(minZoom, maxZoom, minPitch, maxPitch, renderWorldCopies);
|
|
95
56
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
value: function zoomTo(zoom, options, eventData) {
|
|
183
|
-
return this.easeTo((0, _merge2.default)({
|
|
184
|
-
zoom: zoom
|
|
185
|
-
}, options), eventData);
|
|
186
|
-
}
|
|
187
|
-
}, {
|
|
188
|
-
key: "getPadding",
|
|
189
|
-
value: function getPadding() {
|
|
190
|
-
return this.transform.padding;
|
|
191
|
-
}
|
|
192
|
-
}, {
|
|
193
|
-
key: "setPadding",
|
|
194
|
-
value: function setPadding(padding, eventData) {
|
|
195
|
-
this.jumpTo({
|
|
196
|
-
padding: padding
|
|
197
|
-
}, eventData);
|
|
198
|
-
return this;
|
|
199
|
-
}
|
|
200
|
-
}, {
|
|
201
|
-
key: "rotateTo",
|
|
202
|
-
value: function rotateTo(bearing, options, eventData) {
|
|
203
|
-
return this.easeTo((0, _merge2.default)({
|
|
204
|
-
bearing: bearing
|
|
205
|
-
}, options), eventData);
|
|
206
|
-
}
|
|
207
|
-
}, {
|
|
208
|
-
key: "resetNorth",
|
|
209
|
-
value: function resetNorth(options, eventData) {
|
|
210
|
-
this.rotateTo(0, (0, _merge2.default)({
|
|
211
|
-
duration: 1000
|
|
212
|
-
}, options), eventData);
|
|
213
|
-
return this;
|
|
214
|
-
}
|
|
215
|
-
}, {
|
|
216
|
-
key: "resetNorthPitch",
|
|
217
|
-
value: function resetNorthPitch(options, eventData) {
|
|
218
|
-
this.easeTo((0, _merge2.default)({
|
|
219
|
-
bearing: 0,
|
|
220
|
-
pitch: 0,
|
|
221
|
-
duration: 1000
|
|
222
|
-
}, options), eventData);
|
|
223
|
-
return this;
|
|
224
|
-
}
|
|
225
|
-
}, {
|
|
226
|
-
key: "fitBounds",
|
|
227
|
-
value: function fitBounds(bounds, options, eventData) {
|
|
228
|
-
return this.fitInternal(this.cameraForBounds(bounds, options), options, eventData);
|
|
229
|
-
}
|
|
230
|
-
}, {
|
|
231
|
-
key: "cameraForBounds",
|
|
232
|
-
value: function cameraForBounds(bounds, options) {
|
|
233
|
-
bounds = _lng_lat_bounds.default.convert(bounds);
|
|
234
|
-
return this.cameraForBoxAndBearing(bounds.getNorthWest(), bounds.getSouthEast(), 0, options);
|
|
235
|
-
}
|
|
236
|
-
}, {
|
|
237
|
-
key: "snapToNorth",
|
|
238
|
-
value: function snapToNorth(options, eventData) {
|
|
239
|
-
if (Math.abs(this.getBearing()) < this.bearingSnap) {
|
|
240
|
-
return this.resetNorth(options, eventData);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return this;
|
|
244
|
-
}
|
|
245
|
-
}, {
|
|
246
|
-
key: "jumpTo",
|
|
247
|
-
value: function jumpTo() {
|
|
248
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
249
|
-
var eventData = arguments.length > 1 ? arguments[1] : undefined;
|
|
250
|
-
this.stop();
|
|
251
|
-
var tr = this.transform;
|
|
252
|
-
var zoomChanged = false;
|
|
253
|
-
var bearingChanged = false;
|
|
254
|
-
var pitchChanged = false;
|
|
255
|
-
|
|
256
|
-
if (options.zoom && tr.zoom !== +options.zoom) {
|
|
257
|
-
zoomChanged = true;
|
|
258
|
-
tr.zoom = +options.zoom;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (options.center !== undefined) {
|
|
262
|
-
tr.center = _lng_lat.default.convert(options.center);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (options.bearing && tr.bearing !== +options.bearing) {
|
|
266
|
-
bearingChanged = true;
|
|
267
|
-
tr.bearing = +options.bearing;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
if (options.pitch && tr.pitch !== +options.pitch) {
|
|
271
|
-
pitchChanged = true;
|
|
272
|
-
tr.pitch = +options.pitch;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if (options.padding != null && !tr.isPaddingEqual(options.padding)) {
|
|
276
|
-
tr.padding = options.padding;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
this.emit('movestart', new _event.Event('movestart', eventData));
|
|
280
|
-
this.emit('move', new _event.Event('move', eventData));
|
|
281
|
-
|
|
282
|
-
if (zoomChanged) {
|
|
283
|
-
this.emit('zoomstart', new _event.Event('zoomstart', eventData));
|
|
284
|
-
this.emit('zoom', new _event.Event('zoom', eventData));
|
|
285
|
-
this.emit('zoomend', new _event.Event('zoomend', eventData));
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (bearingChanged) {
|
|
289
|
-
this.emit('rotatestart', new _event.Event('rotatestart', eventData));
|
|
290
|
-
this.emit('rotate', new _event.Event('rotate', eventData));
|
|
291
|
-
this.emit('rotateend', new _event.Event('rotateend', eventData));
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if (pitchChanged) {
|
|
295
|
-
this.emit('pitchstart', new _event.Event('pitchstart', eventData));
|
|
296
|
-
this.emit('pitch', new _event.Event('pitch', eventData));
|
|
297
|
-
this.emit('pitchend', new _event.Event('pitchend', eventData));
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
return this.emit('moveend', new _event.Event('moveend', eventData));
|
|
301
|
-
}
|
|
302
|
-
}, {
|
|
303
|
-
key: "easeTo",
|
|
304
|
-
value: function easeTo() {
|
|
305
|
-
var _this2 = this;
|
|
306
|
-
|
|
307
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
308
|
-
var eventData = arguments.length > 1 ? arguments[1] : undefined;
|
|
309
|
-
options = (0, _merge2.default)({
|
|
310
|
-
offset: [0, 0],
|
|
311
|
-
duration: 500,
|
|
312
|
-
easing: _util.ease
|
|
313
|
-
}, options);
|
|
314
|
-
|
|
315
|
-
if (options.animate === false || !options.essential && (0, _util.prefersReducedMotion)()) {
|
|
316
|
-
options.duration = 0;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
var tr = this.transform;
|
|
320
|
-
var startZoom = this.getZoom();
|
|
321
|
-
var startBearing = this.getBearing();
|
|
322
|
-
var startPitch = this.getPitch();
|
|
323
|
-
var startPadding = this.getPadding();
|
|
324
|
-
var zoom = options.zoom ? +options.zoom : startZoom;
|
|
325
|
-
var bearing = options.bearing ? this.normalizeBearing(options.bearing, startBearing) : startBearing;
|
|
326
|
-
var pitch = options.pitch ? +options.pitch : startPitch;
|
|
327
|
-
var padding = options.padding ? options.padding : tr.padding;
|
|
328
|
-
|
|
329
|
-
var offsetAsPoint = _point.default.convert(options.offset);
|
|
330
|
-
|
|
331
|
-
var pointAtOffset = tr.centerPoint.add(offsetAsPoint);
|
|
332
|
-
var locationAtOffset = tr.pointLocation(pointAtOffset);
|
|
333
|
-
|
|
334
|
-
var center = _lng_lat.default.convert(options.center || locationAtOffset);
|
|
335
|
-
|
|
336
|
-
this.normalizeCenter(center);
|
|
337
|
-
var from = tr.project(locationAtOffset);
|
|
338
|
-
var delta = tr.project(center).sub(from);
|
|
339
|
-
var finalScale = tr.zoomScale(zoom - startZoom);
|
|
340
|
-
var around;
|
|
341
|
-
var aroundPoint;
|
|
342
|
-
|
|
343
|
-
if (options.around) {
|
|
344
|
-
around = _lng_lat.default.convert(options.around);
|
|
345
|
-
aroundPoint = tr.locationPoint(around);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
var currently = {
|
|
349
|
-
moving: this.moving,
|
|
350
|
-
zooming: this.zooming,
|
|
351
|
-
rotating: this.rotating,
|
|
352
|
-
pitching: this.pitching
|
|
353
|
-
};
|
|
354
|
-
this.zooming = this.zooming || zoom !== startZoom;
|
|
355
|
-
this.rotating = this.rotating || startBearing !== bearing;
|
|
356
|
-
this.pitching = this.pitching || pitch !== startPitch;
|
|
357
|
-
this.padding = !tr.isPaddingEqual(padding);
|
|
358
|
-
this.easeId = options.easeId;
|
|
359
|
-
this.prepareEase(eventData, options.noMoveStart, currently);
|
|
360
|
-
clearTimeout(this.easeEndTimeoutID);
|
|
361
|
-
this.ease(function (k) {
|
|
362
|
-
if (_this2.zooming) {
|
|
363
|
-
tr.zoom = (0, _util.interpolate)(startZoom, zoom, k);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
if (_this2.rotating && _this2.rotateEnabled) {
|
|
367
|
-
tr.bearing = (0, _util.interpolate)(startBearing, bearing, k);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
if (_this2.pitching && _this2.pitchEnabled) {
|
|
371
|
-
tr.pitch = (0, _util.interpolate)(startPitch, pitch, k);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if (_this2.padding) {
|
|
375
|
-
tr.interpolatePadding(startPadding, padding, k);
|
|
376
|
-
pointAtOffset = tr.centerPoint.add(offsetAsPoint);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
if (around) {
|
|
380
|
-
tr.setLocationAtPoint(around, aroundPoint);
|
|
381
|
-
} else {
|
|
382
|
-
var scale = tr.zoomScale(tr.zoom - startZoom);
|
|
383
|
-
var base = zoom > startZoom ? Math.min(2, finalScale) : Math.max(0.5, finalScale);
|
|
384
|
-
var speedup = Math.pow(base, 1 - k);
|
|
385
|
-
var newCenter = tr.unproject(from.add(delta.mult(k * speedup)).mult(scale));
|
|
386
|
-
tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
_this2.fireMoveEvents(eventData);
|
|
390
|
-
}, function (interruptingEaseId) {
|
|
391
|
-
_this2.afterEase(eventData, interruptingEaseId);
|
|
392
|
-
}, options);
|
|
393
|
-
return this;
|
|
57
|
+
requestRenderFrame(cb) {
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
cancelRenderFrame(_) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
getCenter() {
|
|
64
|
+
const { lng, lat } = this.transform.center;
|
|
65
|
+
return new import_lng_lat.default(lng, lat);
|
|
66
|
+
}
|
|
67
|
+
getZoom() {
|
|
68
|
+
return this.transform.zoom;
|
|
69
|
+
}
|
|
70
|
+
getPitch() {
|
|
71
|
+
return this.transform.pitch;
|
|
72
|
+
}
|
|
73
|
+
setCenter(center, eventData) {
|
|
74
|
+
return this.jumpTo({ center }, eventData);
|
|
75
|
+
}
|
|
76
|
+
setPitch(pitch, eventData) {
|
|
77
|
+
this.jumpTo({ pitch }, eventData);
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
getBearing() {
|
|
81
|
+
return this.transform.bearing;
|
|
82
|
+
}
|
|
83
|
+
panTo(lnglat, options, eventData) {
|
|
84
|
+
return this.easeTo((0, import_lodash.merge)({
|
|
85
|
+
center: lnglat
|
|
86
|
+
}, options), eventData);
|
|
87
|
+
}
|
|
88
|
+
zoomOut(options, eventData) {
|
|
89
|
+
this.zoomTo(this.getZoom() - 1, options, eventData);
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
setBearing(bearing, eventData) {
|
|
93
|
+
this.jumpTo({ bearing }, eventData);
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
setZoom(zoom, eventData) {
|
|
97
|
+
this.jumpTo({ zoom }, eventData);
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
zoomIn(options, eventData) {
|
|
101
|
+
this.zoomTo(this.getZoom() + 1, options, eventData);
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
zoomTo(zoom, options, eventData) {
|
|
105
|
+
return this.easeTo((0, import_lodash.merge)({
|
|
106
|
+
zoom
|
|
107
|
+
}, options), eventData);
|
|
108
|
+
}
|
|
109
|
+
getPadding() {
|
|
110
|
+
return this.transform.padding;
|
|
111
|
+
}
|
|
112
|
+
setPadding(padding, eventData) {
|
|
113
|
+
this.jumpTo({ padding }, eventData);
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
rotateTo(bearing, options, eventData) {
|
|
117
|
+
return this.easeTo((0, import_lodash.merge)({
|
|
118
|
+
bearing
|
|
119
|
+
}, options), eventData);
|
|
120
|
+
}
|
|
121
|
+
resetNorth(options, eventData) {
|
|
122
|
+
this.rotateTo(0, (0, import_lodash.merge)({ duration: 1e3 }, options), eventData);
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
resetNorthPitch(options, eventData) {
|
|
126
|
+
this.easeTo((0, import_lodash.merge)({
|
|
127
|
+
bearing: 0,
|
|
128
|
+
pitch: 0,
|
|
129
|
+
duration: 1e3
|
|
130
|
+
}, options), eventData);
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
fitBounds(bounds, options, eventData) {
|
|
134
|
+
return this.fitInternal(this.cameraForBounds(bounds, options), options, eventData);
|
|
135
|
+
}
|
|
136
|
+
cameraForBounds(bounds, options) {
|
|
137
|
+
bounds = import_lng_lat_bounds.default.convert(bounds);
|
|
138
|
+
return this.cameraForBoxAndBearing(bounds.getNorthWest(), bounds.getSouthEast(), 0, options);
|
|
139
|
+
}
|
|
140
|
+
snapToNorth(options, eventData) {
|
|
141
|
+
if (Math.abs(this.getBearing()) < this.bearingSnap) {
|
|
142
|
+
return this.resetNorth(options, eventData);
|
|
394
143
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
jumpTo(options = {}, eventData) {
|
|
147
|
+
this.stop();
|
|
148
|
+
const tr = this.transform;
|
|
149
|
+
let zoomChanged = false;
|
|
150
|
+
let bearingChanged = false;
|
|
151
|
+
let pitchChanged = false;
|
|
152
|
+
if (options.zoom && tr.zoom !== +options.zoom) {
|
|
153
|
+
zoomChanged = true;
|
|
154
|
+
tr.zoom = +options.zoom;
|
|
155
|
+
}
|
|
156
|
+
if (options.center !== void 0) {
|
|
157
|
+
tr.center = import_lng_lat.default.convert(options.center);
|
|
158
|
+
}
|
|
159
|
+
if (options.bearing && tr.bearing !== +options.bearing) {
|
|
160
|
+
bearingChanged = true;
|
|
161
|
+
tr.bearing = +options.bearing;
|
|
162
|
+
}
|
|
163
|
+
if (options.pitch && tr.pitch !== +options.pitch) {
|
|
164
|
+
pitchChanged = true;
|
|
165
|
+
tr.pitch = +options.pitch;
|
|
166
|
+
}
|
|
167
|
+
if (options.padding != null && !tr.isPaddingEqual(options.padding)) {
|
|
168
|
+
tr.padding = options.padding;
|
|
169
|
+
}
|
|
170
|
+
this.emit("movestart", new import_event.Event("movestart", eventData));
|
|
171
|
+
this.emit("move", new import_event.Event("move", eventData));
|
|
172
|
+
if (zoomChanged) {
|
|
173
|
+
this.emit("zoomstart", new import_event.Event("zoomstart", eventData));
|
|
174
|
+
this.emit("zoom", new import_event.Event("zoom", eventData));
|
|
175
|
+
this.emit("zoomend", new import_event.Event("zoomend", eventData));
|
|
176
|
+
}
|
|
177
|
+
if (bearingChanged) {
|
|
178
|
+
this.emit("rotatestart", new import_event.Event("rotatestart", eventData));
|
|
179
|
+
this.emit("rotate", new import_event.Event("rotate", eventData));
|
|
180
|
+
this.emit("rotateend", new import_event.Event("rotateend", eventData));
|
|
181
|
+
}
|
|
182
|
+
if (pitchChanged) {
|
|
183
|
+
this.emit("pitchstart", new import_event.Event("pitchstart", eventData));
|
|
184
|
+
this.emit("pitch", new import_event.Event("pitch", eventData));
|
|
185
|
+
this.emit("pitchend", new import_event.Event("pitchend", eventData));
|
|
186
|
+
}
|
|
187
|
+
return this.emit("moveend", new import_event.Event("moveend", eventData));
|
|
188
|
+
}
|
|
189
|
+
easeTo(options = {}, eventData) {
|
|
190
|
+
options = (0, import_lodash.merge)({
|
|
191
|
+
offset: [0, 0],
|
|
192
|
+
duration: 500,
|
|
193
|
+
easing: import_util.ease
|
|
194
|
+
}, options);
|
|
195
|
+
if (options.animate === false || !options.essential && (0, import_util.prefersReducedMotion)()) {
|
|
196
|
+
options.duration = 0;
|
|
197
|
+
}
|
|
198
|
+
const tr = this.transform;
|
|
199
|
+
const startZoom = this.getZoom();
|
|
200
|
+
const startBearing = this.getBearing();
|
|
201
|
+
const startPitch = this.getPitch();
|
|
202
|
+
const startPadding = this.getPadding();
|
|
203
|
+
const zoom = options.zoom ? +options.zoom : startZoom;
|
|
204
|
+
const bearing = options.bearing ? this.normalizeBearing(options.bearing, startBearing) : startBearing;
|
|
205
|
+
const pitch = options.pitch ? +options.pitch : startPitch;
|
|
206
|
+
const padding = options.padding ? options.padding : tr.padding;
|
|
207
|
+
const offsetAsPoint = import_point.default.convert(options.offset);
|
|
208
|
+
let pointAtOffset = tr.centerPoint.add(offsetAsPoint);
|
|
209
|
+
const locationAtOffset = tr.pointLocation(pointAtOffset);
|
|
210
|
+
const center = import_lng_lat.default.convert(options.center || locationAtOffset);
|
|
211
|
+
this.normalizeCenter(center);
|
|
212
|
+
const from = tr.project(locationAtOffset);
|
|
213
|
+
const delta = tr.project(center).sub(from);
|
|
214
|
+
const finalScale = tr.zoomScale(zoom - startZoom);
|
|
215
|
+
let around;
|
|
216
|
+
let aroundPoint;
|
|
217
|
+
if (options.around) {
|
|
218
|
+
around = import_lng_lat.default.convert(options.around);
|
|
219
|
+
aroundPoint = tr.locationPoint(around);
|
|
220
|
+
}
|
|
221
|
+
const currently = {
|
|
222
|
+
moving: this.moving,
|
|
223
|
+
zooming: this.zooming,
|
|
224
|
+
rotating: this.rotating,
|
|
225
|
+
pitching: this.pitching
|
|
226
|
+
};
|
|
227
|
+
this.zooming = this.zooming || zoom !== startZoom;
|
|
228
|
+
this.rotating = this.rotating || startBearing !== bearing;
|
|
229
|
+
this.pitching = this.pitching || pitch !== startPitch;
|
|
230
|
+
this.padding = !tr.isPaddingEqual(padding);
|
|
231
|
+
this.easeId = options.easeId;
|
|
232
|
+
this.prepareEase(eventData, options.noMoveStart, currently);
|
|
233
|
+
clearTimeout(this.easeEndTimeoutID);
|
|
234
|
+
this.ease((k) => {
|
|
235
|
+
if (this.zooming) {
|
|
236
|
+
tr.zoom = (0, import_util.interpolate)(startZoom, zoom, k);
|
|
445
237
|
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
function r(i) {
|
|
450
|
-
var b = (w1 * w1 - w0 * w0 + (i ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (i ? w1 : w0) * rho2 * u1);
|
|
451
|
-
return Math.log(Math.sqrt(b * b + 1) - b);
|
|
238
|
+
if (this.rotating && this.rotateEnabled) {
|
|
239
|
+
tr.bearing = (0, import_util.interpolate)(startBearing, bearing, k);
|
|
452
240
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
return (Math.exp(n) - Math.exp(-n)) / 2;
|
|
241
|
+
if (this.pitching && this.pitchEnabled) {
|
|
242
|
+
tr.pitch = (0, import_util.interpolate)(startPitch, pitch, k);
|
|
456
243
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
244
|
+
if (this.padding) {
|
|
245
|
+
tr.interpolatePadding(startPadding, padding, k);
|
|
246
|
+
pointAtOffset = tr.centerPoint.add(offsetAsPoint);
|
|
460
247
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
248
|
+
if (around) {
|
|
249
|
+
tr.setLocationAtPoint(around, aroundPoint);
|
|
250
|
+
} else {
|
|
251
|
+
const scale = tr.zoomScale(tr.zoom - startZoom);
|
|
252
|
+
const base = zoom > startZoom ? Math.min(2, finalScale) : Math.max(0.5, finalScale);
|
|
253
|
+
const speedup = Math.pow(base, 1 - k);
|
|
254
|
+
const newCenter = tr.unproject(from.add(delta.mult(k * speedup)).mult(scale));
|
|
255
|
+
tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);
|
|
464
256
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
257
|
+
this.fireMoveEvents(eventData);
|
|
258
|
+
}, (interruptingEaseId) => {
|
|
259
|
+
this.afterEase(eventData, interruptingEaseId);
|
|
260
|
+
}, options);
|
|
261
|
+
return this;
|
|
262
|
+
}
|
|
263
|
+
flyTo(options = {}, eventData) {
|
|
264
|
+
if (!options.essential && (0, import_util.prefersReducedMotion)()) {
|
|
265
|
+
const coercedOptions = (0, import_util.pick)(options, [
|
|
266
|
+
"center",
|
|
267
|
+
"zoom",
|
|
268
|
+
"bearing",
|
|
269
|
+
"pitch",
|
|
270
|
+
"around"
|
|
271
|
+
]);
|
|
272
|
+
return this.jumpTo(coercedOptions, eventData);
|
|
273
|
+
}
|
|
274
|
+
this.stop();
|
|
275
|
+
options = (0, import_lodash.merge)({
|
|
276
|
+
offset: [0, 0],
|
|
277
|
+
speed: 1.2,
|
|
278
|
+
curve: 1.42,
|
|
279
|
+
easing: import_util.ease
|
|
280
|
+
}, options);
|
|
281
|
+
const tr = this.transform;
|
|
282
|
+
const startZoom = this.getZoom();
|
|
283
|
+
const startBearing = this.getBearing();
|
|
284
|
+
const startPitch = this.getPitch();
|
|
285
|
+
const startPadding = this.getPadding();
|
|
286
|
+
const zoom = options.zoom ? (0, import_util.clamp)(+options.zoom, tr.minZoom, tr.maxZoom) : startZoom;
|
|
287
|
+
const bearing = options.bearing ? this.normalizeBearing(options.bearing, startBearing) : startBearing;
|
|
288
|
+
const pitch = options.pitch ? +options.pitch : startPitch;
|
|
289
|
+
const padding = "padding" in options ? options.padding : tr.padding;
|
|
290
|
+
const scale = tr.zoomScale(zoom - startZoom);
|
|
291
|
+
const offsetAsPoint = import_point.default.convert(options.offset);
|
|
292
|
+
let pointAtOffset = tr.centerPoint.add(offsetAsPoint);
|
|
293
|
+
const locationAtOffset = tr.pointLocation(pointAtOffset);
|
|
294
|
+
const center = import_lng_lat.default.convert(options.center || locationAtOffset);
|
|
295
|
+
this.normalizeCenter(center);
|
|
296
|
+
const from = tr.project(locationAtOffset);
|
|
297
|
+
const delta = tr.project(center).sub(from);
|
|
298
|
+
let rho = options.curve;
|
|
299
|
+
const w0 = Math.max(tr.width, tr.height);
|
|
300
|
+
const w1 = w0 / scale;
|
|
301
|
+
const u1 = delta.mag();
|
|
302
|
+
if ("minZoom" in options) {
|
|
303
|
+
const minZoom = (0, import_util.clamp)(Math.min(options.minZoom, startZoom, zoom), tr.minZoom, tr.maxZoom);
|
|
304
|
+
const wMax = w0 / tr.zoomScale(minZoom - startZoom);
|
|
305
|
+
rho = Math.sqrt(wMax / u1 * 2);
|
|
306
|
+
}
|
|
307
|
+
const rho2 = rho * rho;
|
|
308
|
+
function r(i) {
|
|
309
|
+
const b = (w1 * w1 - w0 * w0 + (i ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (i ? w1 : w0) * rho2 * u1);
|
|
310
|
+
return Math.log(Math.sqrt(b * b + 1) - b);
|
|
311
|
+
}
|
|
312
|
+
function sinh(n) {
|
|
313
|
+
return (Math.exp(n) - Math.exp(-n)) / 2;
|
|
314
|
+
}
|
|
315
|
+
function cosh(n) {
|
|
316
|
+
return (Math.exp(n) + Math.exp(-n)) / 2;
|
|
317
|
+
}
|
|
318
|
+
function tanh(n) {
|
|
319
|
+
return sinh(n) / cosh(n);
|
|
320
|
+
}
|
|
321
|
+
const r0 = r(0);
|
|
322
|
+
let w = (s) => {
|
|
323
|
+
return cosh(r0) / cosh(r0 + rho * s);
|
|
324
|
+
};
|
|
325
|
+
let u = (s) => {
|
|
326
|
+
return w0 * ((cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2) / u1;
|
|
327
|
+
};
|
|
328
|
+
let S = (r(1) - r0) / rho;
|
|
329
|
+
if (Math.abs(u1) < 1e-6 || !isFinite(S)) {
|
|
330
|
+
if (Math.abs(w0 - w1) < 1e-6) {
|
|
331
|
+
return this.easeTo(options, eventData);
|
|
332
|
+
}
|
|
333
|
+
const k = w1 < w0 ? -1 : 1;
|
|
334
|
+
S = Math.abs(Math.log(w1 / w0)) / rho;
|
|
335
|
+
u = () => {
|
|
336
|
+
return 0;
|
|
470
337
|
};
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
return w0 * ((cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2) / u1;
|
|
338
|
+
w = (s) => {
|
|
339
|
+
return Math.exp(k * rho * s);
|
|
474
340
|
};
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
341
|
+
}
|
|
342
|
+
if ("duration" in options) {
|
|
343
|
+
options.duration = +options.duration;
|
|
344
|
+
} else {
|
|
345
|
+
const V = "screenSpeed" in options ? +options.screenSpeed / rho : +options.speed;
|
|
346
|
+
options.duration = 1e3 * S / V;
|
|
347
|
+
}
|
|
348
|
+
if (options.maxDuration && options.duration > options.maxDuration) {
|
|
349
|
+
options.duration = 0;
|
|
350
|
+
}
|
|
351
|
+
this.zooming = true;
|
|
352
|
+
this.rotating = startBearing !== bearing;
|
|
353
|
+
this.pitching = pitch !== startPitch;
|
|
354
|
+
this.padding = !tr.isPaddingEqual(padding);
|
|
355
|
+
this.prepareEase(eventData, false);
|
|
356
|
+
this.ease((k) => {
|
|
357
|
+
const s = k * S;
|
|
358
|
+
const easeScale = 1 / w(s);
|
|
359
|
+
tr.zoom = k === 1 ? zoom : startZoom + tr.scaleZoom(easeScale);
|
|
360
|
+
if (this.rotating) {
|
|
361
|
+
tr.bearing = (0, import_util.interpolate)(startBearing, bearing, k);
|
|
493
362
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
options.duration = +options.duration;
|
|
497
|
-
} else {
|
|
498
|
-
var V = 'screenSpeed' in options ? +options.screenSpeed / rho : +options.speed;
|
|
499
|
-
options.duration = 1000 * S / V;
|
|
363
|
+
if (this.pitching) {
|
|
364
|
+
tr.pitch = (0, import_util.interpolate)(startPitch, pitch, k);
|
|
500
365
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
366
|
+
if (this.padding) {
|
|
367
|
+
tr.interpolatePadding(startPadding, padding, k);
|
|
368
|
+
pointAtOffset = tr.centerPoint.add(offsetAsPoint);
|
|
504
369
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
this.
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
_this3.fireMoveEvents(eventData);
|
|
533
|
-
}, function () {
|
|
534
|
-
return _this3.afterEase(eventData);
|
|
535
|
-
}, options);
|
|
536
|
-
return this;
|
|
370
|
+
const newCenter = k === 1 ? center : tr.unproject(from.add(delta.mult(u(s))).mult(easeScale));
|
|
371
|
+
tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);
|
|
372
|
+
this.fireMoveEvents(eventData);
|
|
373
|
+
}, () => this.afterEase(eventData), options);
|
|
374
|
+
return this;
|
|
375
|
+
}
|
|
376
|
+
fitScreenCoordinates(p0, p1, bearing, options, eventData) {
|
|
377
|
+
return this.fitInternal(this.cameraForBoxAndBearing(this.transform.pointLocation(import_point.default.convert(p0)), this.transform.pointLocation(import_point.default.convert(p1)), bearing, options), options, eventData);
|
|
378
|
+
}
|
|
379
|
+
stop(allowGestures, easeId) {
|
|
380
|
+
if (this.easeFrameId) {
|
|
381
|
+
this.cancelRenderFrame(this.easeFrameId);
|
|
382
|
+
delete this.easeFrameId;
|
|
383
|
+
delete this.onEaseFrame;
|
|
384
|
+
}
|
|
385
|
+
if (this.onEaseEnd) {
|
|
386
|
+
const onEaseEnd = this.onEaseEnd;
|
|
387
|
+
delete this.onEaseEnd;
|
|
388
|
+
onEaseEnd.call(this, easeId);
|
|
389
|
+
}
|
|
390
|
+
return this;
|
|
391
|
+
}
|
|
392
|
+
normalizeBearing(bearing, currentBearing) {
|
|
393
|
+
bearing = (0, import_util.wrap)(bearing, -180, 180);
|
|
394
|
+
const diff = Math.abs(bearing - currentBearing);
|
|
395
|
+
if (Math.abs(bearing - 360 - currentBearing) < diff) {
|
|
396
|
+
bearing -= 360;
|
|
537
397
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
value: function fitScreenCoordinates(p0, p1, bearing, options, eventData) {
|
|
541
|
-
return this.fitInternal(this.cameraForBoxAndBearing(this.transform.pointLocation(_point.default.convert(p0)), this.transform.pointLocation(_point.default.convert(p1)), bearing, options), options, eventData);
|
|
542
|
-
}
|
|
543
|
-
}, {
|
|
544
|
-
key: "stop",
|
|
545
|
-
value: function stop(allowGestures, easeId) {
|
|
546
|
-
if (this.easeFrameId) {
|
|
547
|
-
this.cancelRenderFrame(this.easeFrameId);
|
|
548
|
-
delete this.easeFrameId;
|
|
549
|
-
delete this.onEaseFrame;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
if (this.onEaseEnd) {
|
|
553
|
-
var onEaseEnd = this.onEaseEnd;
|
|
554
|
-
delete this.onEaseEnd;
|
|
555
|
-
onEaseEnd.call(this, easeId);
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
return this;
|
|
398
|
+
if (Math.abs(bearing + 360 - currentBearing) < diff) {
|
|
399
|
+
bearing += 360;
|
|
559
400
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
if (Math.abs(bearing - 360 - currentBearing) < diff) {
|
|
567
|
-
bearing -= 360;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
if (Math.abs(bearing + 360 - currentBearing) < diff) {
|
|
571
|
-
bearing += 360;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
return bearing;
|
|
401
|
+
return bearing;
|
|
402
|
+
}
|
|
403
|
+
normalizeCenter(center) {
|
|
404
|
+
const tr = this.transform;
|
|
405
|
+
if (!tr.renderWorldCopies || tr.lngRange) {
|
|
406
|
+
return;
|
|
575
407
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
var delta = center.lng - tr.center.lng;
|
|
586
|
-
center.lng += delta > 180 ? -360 : delta < -180 ? 360 : 0;
|
|
408
|
+
const delta = center.lng - tr.center.lng;
|
|
409
|
+
center.lng += delta > 180 ? -360 : delta < -180 ? 360 : 0;
|
|
410
|
+
}
|
|
411
|
+
fireMoveEvents(eventData) {
|
|
412
|
+
this.emit("move", new import_event.Event("move", eventData));
|
|
413
|
+
if (this.zooming) {
|
|
414
|
+
this.emit("zoom", new import_event.Event("zoom", eventData));
|
|
587
415
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
value: function fireMoveEvents(eventData) {
|
|
591
|
-
this.emit('move', new _event.Event('move', eventData));
|
|
592
|
-
|
|
593
|
-
if (this.zooming) {
|
|
594
|
-
this.emit('zoom', new _event.Event('zoom', eventData));
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
if (this.rotating) {
|
|
598
|
-
this.emit('rotate', new _event.Event('rotate', eventData));
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
if (this.pitching) {
|
|
602
|
-
this.emit('rotate', new _event.Event('pitch', eventData));
|
|
603
|
-
}
|
|
416
|
+
if (this.rotating) {
|
|
417
|
+
this.emit("rotate", new import_event.Event("rotate", eventData));
|
|
604
418
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
value: function prepareEase(eventData) {
|
|
608
|
-
var noMoveStart = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
609
|
-
var currently = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
610
|
-
this.moving = true;
|
|
611
|
-
|
|
612
|
-
if (!noMoveStart && !currently.moving) {
|
|
613
|
-
this.emit('movestart', new _event.Event('movestart', eventData));
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
if (this.zooming && !currently.zooming) {
|
|
617
|
-
this.emit('zoomstart', new _event.Event('zoomstart', eventData));
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
if (this.rotating && !currently.rotating) {
|
|
621
|
-
this.emit('rotatestart', new _event.Event('rotatestart', eventData));
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
if (this.pitching && !currently.pitching) {
|
|
625
|
-
this.emit('pitchstart', new _event.Event('pitchstart', eventData));
|
|
626
|
-
}
|
|
419
|
+
if (this.pitching) {
|
|
420
|
+
this.emit("rotate", new import_event.Event("pitch", eventData));
|
|
627
421
|
}
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
delete this.easeId;
|
|
636
|
-
var wasZooming = this.zooming;
|
|
637
|
-
var wasRotating = this.rotating;
|
|
638
|
-
var wasPitching = this.pitching;
|
|
639
|
-
this.moving = false;
|
|
640
|
-
this.zooming = false;
|
|
641
|
-
this.rotating = false;
|
|
642
|
-
this.pitching = false;
|
|
643
|
-
this.padding = false;
|
|
644
|
-
|
|
645
|
-
if (wasZooming) {
|
|
646
|
-
this.emit('zoomend', new _event.Event('zoomend', eventData));
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
if (wasRotating) {
|
|
650
|
-
this.emit('rotateend', new _event.Event('rotateend', eventData));
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
if (wasPitching) {
|
|
654
|
-
this.emit('pitchend', new _event.Event('pitchend', eventData));
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
this.emit('moveend', new _event.Event('moveend', eventData));
|
|
658
|
-
}
|
|
659
|
-
}, {
|
|
660
|
-
key: "ease",
|
|
661
|
-
value: function ease(frame, finish, options) {
|
|
662
|
-
if (options.animate === false || options.duration === 0) {
|
|
663
|
-
frame(1);
|
|
664
|
-
finish();
|
|
665
|
-
} else {
|
|
666
|
-
this.easeStart = (0, _util.now)();
|
|
667
|
-
this.easeOptions = options;
|
|
668
|
-
this.onEaseFrame = frame;
|
|
669
|
-
this.onEaseEnd = finish;
|
|
670
|
-
this.easeFrameId = this.requestRenderFrame(this.renderFrameCallback);
|
|
671
|
-
}
|
|
422
|
+
}
|
|
423
|
+
prepareEase(eventData, noMoveStart = false, currently = {}) {
|
|
424
|
+
this.moving = true;
|
|
425
|
+
if (!noMoveStart && !currently.moving) {
|
|
426
|
+
this.emit("movestart", new import_event.Event("movestart", eventData));
|
|
672
427
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
428
|
+
if (this.zooming && !currently.zooming) {
|
|
429
|
+
this.emit("zoomstart", new import_event.Event("zoomstart", eventData));
|
|
430
|
+
}
|
|
431
|
+
if (this.rotating && !currently.rotating) {
|
|
432
|
+
this.emit("rotatestart", new import_event.Event("rotatestart", eventData));
|
|
433
|
+
}
|
|
434
|
+
if (this.pitching && !currently.pitching) {
|
|
435
|
+
this.emit("pitchstart", new import_event.Event("pitchstart", eventData));
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
afterEase(eventData, easeId) {
|
|
439
|
+
if (this.easeId && easeId && this.easeId === easeId) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
delete this.easeId;
|
|
443
|
+
const wasZooming = this.zooming;
|
|
444
|
+
const wasRotating = this.rotating;
|
|
445
|
+
const wasPitching = this.pitching;
|
|
446
|
+
this.moving = false;
|
|
447
|
+
this.zooming = false;
|
|
448
|
+
this.rotating = false;
|
|
449
|
+
this.pitching = false;
|
|
450
|
+
this.padding = false;
|
|
451
|
+
if (wasZooming) {
|
|
452
|
+
this.emit("zoomend", new import_event.Event("zoomend", eventData));
|
|
453
|
+
}
|
|
454
|
+
if (wasRotating) {
|
|
455
|
+
this.emit("rotateend", new import_event.Event("rotateend", eventData));
|
|
456
|
+
}
|
|
457
|
+
if (wasPitching) {
|
|
458
|
+
this.emit("pitchend", new import_event.Event("pitchend", eventData));
|
|
459
|
+
}
|
|
460
|
+
this.emit("moveend", new import_event.Event("moveend", eventData));
|
|
461
|
+
}
|
|
462
|
+
ease(frame, finish, options) {
|
|
463
|
+
if (options.animate === false || options.duration === 0) {
|
|
464
|
+
frame(1);
|
|
465
|
+
finish();
|
|
466
|
+
} else {
|
|
467
|
+
this.easeStart = (0, import_util.now)();
|
|
468
|
+
this.easeOptions = options;
|
|
469
|
+
this.onEaseFrame = frame;
|
|
470
|
+
this.onEaseEnd = finish;
|
|
471
|
+
this.easeFrameId = this.requestRenderFrame(this.renderFrameCallback);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
cameraForBoxAndBearing(p0, p1, bearing, options) {
|
|
475
|
+
const defaultPadding = {
|
|
476
|
+
top: 0,
|
|
477
|
+
bottom: 0,
|
|
478
|
+
right: 0,
|
|
479
|
+
left: 0
|
|
480
|
+
};
|
|
481
|
+
options = (0, import_lodash.merge)({
|
|
482
|
+
padding: defaultPadding,
|
|
483
|
+
offset: [0, 0],
|
|
484
|
+
maxZoom: this.transform.maxZoom
|
|
485
|
+
}, options);
|
|
486
|
+
if (typeof options.padding === "number") {
|
|
487
|
+
const p = options.padding;
|
|
488
|
+
options.padding = {
|
|
489
|
+
top: p,
|
|
490
|
+
bottom: p,
|
|
491
|
+
right: p,
|
|
492
|
+
left: p
|
|
728
493
|
};
|
|
729
494
|
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
495
|
+
options.padding = (0, import_lodash.merge)(defaultPadding, options.padding);
|
|
496
|
+
const tr = this.transform;
|
|
497
|
+
const edgePadding = tr.padding;
|
|
498
|
+
const p0world = tr.project(import_lng_lat.default.convert(p0));
|
|
499
|
+
const p1world = tr.project(import_lng_lat.default.convert(p1));
|
|
500
|
+
const p0rotated = p0world.rotate(-bearing * Math.PI / 180);
|
|
501
|
+
const p1rotated = p1world.rotate(-bearing * Math.PI / 180);
|
|
502
|
+
const upperRight = new import_point.default(Math.max(p0rotated.x, p1rotated.x), Math.max(p0rotated.y, p1rotated.y));
|
|
503
|
+
const lowerLeft = new import_point.default(Math.min(p0rotated.x, p1rotated.x), Math.min(p0rotated.y, p1rotated.y));
|
|
504
|
+
const size = upperRight.sub(lowerLeft);
|
|
505
|
+
const scaleX = (tr.width - (edgePadding.left + edgePadding.right + options.padding.left + options.padding.right)) / size.x;
|
|
506
|
+
const scaleY = (tr.height - (edgePadding.top + edgePadding.bottom + options.padding.top + options.padding.bottom)) / size.y;
|
|
507
|
+
if (scaleY < 0 || scaleX < 0) {
|
|
508
|
+
return;
|
|
740
509
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
510
|
+
const zoom = Math.min(tr.scaleZoom(tr.scale * Math.min(scaleX, scaleY)), options.maxZoom);
|
|
511
|
+
const offset = import_point.default.convert(options.offset);
|
|
512
|
+
const paddingOffsetX = (options.padding.left - options.padding.right) / 2;
|
|
513
|
+
const paddingOffsetY = (options.padding.top - options.padding.bottom) / 2;
|
|
514
|
+
const offsetAtInitialZoom = new import_point.default(offset.x + paddingOffsetX, offset.y + paddingOffsetY);
|
|
515
|
+
const offsetAtFinalZoom = offsetAtInitialZoom.mult(tr.scale / tr.zoomScale(zoom));
|
|
516
|
+
const center = tr.unproject(p0world.add(p1world).div(2).sub(offsetAtFinalZoom));
|
|
517
|
+
return {
|
|
518
|
+
center,
|
|
519
|
+
zoom,
|
|
520
|
+
bearing
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
fitInternal(calculatedOptions, options, eventData) {
|
|
524
|
+
if (!calculatedOptions) {
|
|
525
|
+
return this;
|
|
526
|
+
}
|
|
527
|
+
options = (0, import_lodash.merge)(calculatedOptions, options);
|
|
528
|
+
delete options.padding;
|
|
529
|
+
return options.linear ? this.easeTo(options, eventData) : this.flyTo(options, eventData);
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
533
|
+
0 && (module.exports = {});
|