@antv/l7-map 2.18.0 → 2.18.2
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/package.json +3 -3
- package/es/camera.d.ts +0 -85
- package/es/camera.js +0 -718
- package/es/css/l7.css +0 -98
- package/es/earthmap.d.ts +0 -66
- package/es/earthmap.js +0 -369
- package/es/geo/edge_insets.d.ts +0 -54
- package/es/geo/edge_insets.js +0 -108
- package/es/geo/lng_lat.d.ts +0 -18
- package/es/geo/lng_lat.js +0 -73
- package/es/geo/lng_lat_bounds.d.ts +0 -24
- package/es/geo/lng_lat_bounds.js +0 -154
- package/es/geo/mercator.d.ts +0 -29
- package/es/geo/mercator.js +0 -84
- package/es/geo/point.d.ts +0 -40
- package/es/geo/point.js +0 -224
- package/es/geo/simple.d.ts +0 -29
- package/es/geo/simple.js +0 -87
- package/es/geo/transform.d.ts +0 -198
- package/es/geo/transform.js +0 -961
- package/es/handler/IHandler.d.ts +0 -34
- package/es/handler/IHandler.js +0 -1
- package/es/handler/blockable_map_event.d.ts +0 -17
- package/es/handler/blockable_map_event.js +0 -78
- package/es/handler/box_zoom.d.ts +0 -59
- package/es/handler/box_zoom.js +0 -180
- package/es/handler/click_zoom.d.ts +0 -16
- package/es/handler/click_zoom.js +0 -54
- package/es/handler/events/event.d.ts +0 -4
- package/es/handler/events/event.js +0 -11
- package/es/handler/events/index.d.ts +0 -4
- package/es/handler/events/index.js +0 -4
- package/es/handler/events/map_mouse_event.d.ts +0 -34
- package/es/handler/events/map_mouse_event.js +0 -64
- package/es/handler/events/map_touch_event.d.ts +0 -57
- package/es/handler/events/map_touch_event.js +0 -95
- package/es/handler/events/map_wheel_event.d.ts +0 -33
- package/es/handler/events/map_wheel_event.js +0 -50
- package/es/handler/events/render_event.d.ts +0 -5
- package/es/handler/events/render_event.js +0 -26
- package/es/handler/handler_inertia.d.ts +0 -23
- package/es/handler/handler_inertia.js +0 -157
- package/es/handler/handler_manager.d.ts +0 -61
- package/es/handler/handler_manager.js +0 -577
- package/es/handler/handler_util.d.ts +0 -4
- package/es/handler/handler_util.js +0 -9
- package/es/handler/keyboard.d.ts +0 -36
- package/es/handler/keyboard.js +0 -143
- package/es/handler/map_event.d.ts +0 -29
- package/es/handler/map_event.js +0 -125
- package/es/handler/mouse/index.d.ts +0 -4
- package/es/handler/mouse/index.js +0 -4
- package/es/handler/mouse/mouse_handler.d.ts +0 -22
- package/es/handler/mouse/mouse_handler.js +0 -118
- package/es/handler/mouse/mousepan_handler.d.ts +0 -10
- package/es/handler/mouse/mousepan_handler.js +0 -44
- package/es/handler/mouse/mousepitch_hander.d.ts +0 -9
- package/es/handler/mouse/mousepitch_hander.js +0 -46
- package/es/handler/mouse/mouserotate_hander.d.ts +0 -9
- package/es/handler/mouse/mouserotate_hander.js +0 -46
- package/es/handler/mouse/util.d.ts +0 -6
- package/es/handler/mouse/util.js +0 -11
- package/es/handler/scroll_zoom.d.ts +0 -93
- package/es/handler/scroll_zoom.js +0 -325
- package/es/handler/shim/dblclick_zoom.d.ts +0 -40
- package/es/handler/shim/dblclick_zoom.js +0 -67
- package/es/handler/shim/drag_pan.d.ts +0 -61
- package/es/handler/shim/drag_pan.js +0 -84
- package/es/handler/shim/drag_rotate.d.ts +0 -46
- package/es/handler/shim/drag_rotate.js +0 -74
- package/es/handler/shim/touch_zoom_rotate.d.ts +0 -70
- package/es/handler/shim/touch_zoom_rotate.js +0 -115
- package/es/handler/tap/single_tap_recognizer.d.ts +0 -20
- package/es/handler/tap/single_tap_recognizer.js +0 -97
- package/es/handler/tap/tap_drag_zoom.d.ts +0 -22
- package/es/handler/tap/tap_drag_zoom.js +0 -106
- package/es/handler/tap/tap_recognizer.d.ts +0 -17
- package/es/handler/tap/tap_recognizer.js +0 -54
- package/es/handler/tap/tap_zoom.d.ts +0 -22
- package/es/handler/tap/tap_zoom.js +0 -109
- package/es/handler/touch/index.d.ts +0 -5
- package/es/handler/touch/index.js +0 -5
- package/es/handler/touch/touch_pan.d.ts +0 -30
- package/es/handler/touch/touch_pan.js +0 -110
- package/es/handler/touch/touch_pitch.d.ts +0 -13
- package/es/handler/touch/touch_pitch.js +0 -93
- package/es/handler/touch/touch_rotate.d.ts +0 -12
- package/es/handler/touch/touch_rotate.js +0 -77
- package/es/handler/touch/touch_zoom.d.ts +0 -12
- package/es/handler/touch/touch_zoom.js +0 -54
- package/es/handler/touch/two_touch.d.ts +0 -23
- package/es/handler/touch/two_touch.js +0 -125
- package/es/hash.d.ts +0 -14
- package/es/hash.js +0 -134
- package/es/index.d.ts +0 -4
- package/es/index.js +0 -4
- package/es/interface.d.ts +0 -34
- package/es/interface.js +0 -1
- package/es/map.d.ts +0 -70
- package/es/map.js +0 -387
- package/es/util.d.ts +0 -25
- package/es/util.js +0 -88
- package/es/utils/Aabb.d.ts +0 -12
- package/es/utils/Aabb.js +0 -112
- package/es/utils/dom.d.ts +0 -4
- package/es/utils/dom.js +0 -140
- package/es/utils/performance.d.ts +0 -17
- package/es/utils/performance.js +0 -62
- package/es/utils/primitives.d.ts +0 -6
- package/es/utils/primitives.js +0 -47
- package/es/utils/task_queue.d.ts +0 -13
- package/es/utils/task_queue.js +0 -89
- package/lib/camera.js +0 -724
- package/lib/css/l7.css +0 -98
- package/lib/earthmap.js +0 -376
- package/lib/geo/edge_insets.js +0 -114
- package/lib/geo/lng_lat.js +0 -81
- package/lib/geo/lng_lat_bounds.js +0 -161
- package/lib/geo/mercator.js +0 -100
- package/lib/geo/point.js +0 -231
- package/lib/geo/simple.js +0 -104
- package/lib/geo/transform.js +0 -971
- package/lib/handler/IHandler.js +0 -5
- package/lib/handler/blockable_map_event.js +0 -84
- package/lib/handler/box_zoom.js +0 -186
- package/lib/handler/click_zoom.js +0 -61
- package/lib/handler/events/event.js +0 -20
- package/lib/handler/events/index.js +0 -27
- package/lib/handler/events/map_mouse_event.js +0 -70
- package/lib/handler/events/map_touch_event.js +0 -100
- package/lib/handler/events/map_wheel_event.js +0 -57
- package/lib/handler/events/render_event.js +0 -33
- package/lib/handler/handler_inertia.js +0 -162
- package/lib/handler/handler_manager.js +0 -584
- package/lib/handler/handler_util.js +0 -15
- package/lib/handler/keyboard.js +0 -151
- package/lib/handler/map_event.js +0 -131
- package/lib/handler/mouse/index.js +0 -27
- package/lib/handler/mouse/mouse_handler.js +0 -124
- package/lib/handler/mouse/mousepan_handler.js +0 -49
- package/lib/handler/mouse/mousepitch_hander.js +0 -51
- package/lib/handler/mouse/mouserotate_hander.js +0 -51
- package/lib/handler/mouse/util.js +0 -22
- package/lib/handler/scroll_zoom.js +0 -333
- package/lib/handler/shim/dblclick_zoom.js +0 -74
- package/lib/handler/shim/drag_pan.js +0 -91
- package/lib/handler/shim/drag_rotate.js +0 -81
- package/lib/handler/shim/touch_zoom_rotate.js +0 -122
- package/lib/handler/tap/single_tap_recognizer.js +0 -106
- package/lib/handler/tap/tap_drag_zoom.js +0 -112
- package/lib/handler/tap/tap_recognizer.js +0 -63
- package/lib/handler/tap/tap_zoom.js +0 -115
- package/lib/handler/touch/index.js +0 -34
- package/lib/handler/touch/touch_pan.js +0 -117
- package/lib/handler/touch/touch_pitch.js +0 -98
- package/lib/handler/touch/touch_rotate.js +0 -82
- package/lib/handler/touch/touch_zoom.js +0 -59
- package/lib/handler/touch/two_touch.js +0 -131
- package/lib/hash.js +0 -143
- package/lib/index.js +0 -49
- package/lib/interface.js +0 -5
- package/lib/map.js +0 -394
- package/lib/util.js +0 -108
- package/lib/utils/Aabb.js +0 -119
- package/lib/utils/dom.js +0 -147
- package/lib/utils/performance.js +0 -70
- package/lib/utils/primitives.js +0 -54
- package/lib/utils/task_queue.js +0 -97
package/es/camera.js
DELETED
|
@@ -1,718 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
-
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; } }
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
import { lodashUtil } from '@antv/l7-utils';
|
|
12
|
-
import { EventEmitter } from 'eventemitter3';
|
|
13
|
-
import LngLat from "./geo/lng_lat";
|
|
14
|
-
import LngLatBounds from "./geo/lng_lat_bounds";
|
|
15
|
-
import Point from "./geo/point";
|
|
16
|
-
import Transform from "./geo/transform";
|
|
17
|
-
import { Event } from "./handler/events/event";
|
|
18
|
-
import { clamp, ease as defaultEasing, extend, interpolate, now, pick, prefersReducedMotion, wrap } from "./util";
|
|
19
|
-
var merge = lodashUtil.merge;
|
|
20
|
-
var Camera = /*#__PURE__*/function (_EventEmitter) {
|
|
21
|
-
_inherits(Camera, _EventEmitter);
|
|
22
|
-
var _super = _createSuper(Camera);
|
|
23
|
-
// public requestRenderFrame: (_: any) => number;
|
|
24
|
-
// public cancelRenderFrame: (_: number) => void;
|
|
25
|
-
|
|
26
|
-
function Camera(options) {
|
|
27
|
-
var _this;
|
|
28
|
-
_classCallCheck(this, Camera);
|
|
29
|
-
_this = _super.call(this);
|
|
30
|
-
_defineProperty(_assertThisInitialized(_this), "renderFrameCallback", function () {
|
|
31
|
-
var t = Math.min((now() - _this.easeStart) / _this.easeOptions.duration, 1);
|
|
32
|
-
_this.onEaseFrame(_this.easeOptions.easing(t));
|
|
33
|
-
if (t < 1) {
|
|
34
|
-
// this.easeFrameId = window.requestAnimationFrame(this.renderFrameCallback);
|
|
35
|
-
_this.easeFrameId = _this.requestRenderFrame(_this.renderFrameCallback);
|
|
36
|
-
} else {
|
|
37
|
-
_this.stop();
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
_this.options = options;
|
|
41
|
-
var minZoom = options.minZoom,
|
|
42
|
-
maxZoom = options.maxZoom,
|
|
43
|
-
minPitch = options.minPitch,
|
|
44
|
-
maxPitch = options.maxPitch,
|
|
45
|
-
renderWorldCopies = options.renderWorldCopies;
|
|
46
|
-
_this.moving = false;
|
|
47
|
-
_this.zooming = false;
|
|
48
|
-
_this.bearingSnap = options.bearingSnap;
|
|
49
|
-
_this.pitchEnabled = options.pitchEnabled;
|
|
50
|
-
_this.rotateEnabled = options.rotateEnabled;
|
|
51
|
-
_this.transform = new Transform(minZoom, maxZoom, minPitch, maxPitch, renderWorldCopies);
|
|
52
|
-
return _this;
|
|
53
|
-
}
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
55
|
-
_createClass(Camera, [{
|
|
56
|
-
key: "requestRenderFrame",
|
|
57
|
-
value: function requestRenderFrame(cb) {
|
|
58
|
-
return 0;
|
|
59
|
-
}
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
61
|
-
}, {
|
|
62
|
-
key: "cancelRenderFrame",
|
|
63
|
-
value: function cancelRenderFrame(_) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
}, {
|
|
67
|
-
key: "getCenter",
|
|
68
|
-
value: function getCenter() {
|
|
69
|
-
var _this$transform$cente = this.transform.center,
|
|
70
|
-
lng = _this$transform$cente.lng,
|
|
71
|
-
lat = _this$transform$cente.lat;
|
|
72
|
-
return new LngLat(lng, lat);
|
|
73
|
-
}
|
|
74
|
-
}, {
|
|
75
|
-
key: "getZoom",
|
|
76
|
-
value: function getZoom() {
|
|
77
|
-
return this.transform.zoom;
|
|
78
|
-
}
|
|
79
|
-
}, {
|
|
80
|
-
key: "getPitch",
|
|
81
|
-
value: function getPitch() {
|
|
82
|
-
return this.transform.pitch;
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
key: "setCenter",
|
|
86
|
-
value: function setCenter(center, eventData) {
|
|
87
|
-
return this.jumpTo({
|
|
88
|
-
center: center
|
|
89
|
-
}, eventData);
|
|
90
|
-
}
|
|
91
|
-
}, {
|
|
92
|
-
key: "setPitch",
|
|
93
|
-
value: function setPitch(pitch, eventData) {
|
|
94
|
-
this.jumpTo({
|
|
95
|
-
pitch: pitch
|
|
96
|
-
}, eventData);
|
|
97
|
-
return this;
|
|
98
|
-
}
|
|
99
|
-
}, {
|
|
100
|
-
key: "getBearing",
|
|
101
|
-
value: function getBearing() {
|
|
102
|
-
return this.transform.bearing;
|
|
103
|
-
}
|
|
104
|
-
}, {
|
|
105
|
-
key: "panTo",
|
|
106
|
-
value: function panTo(lnglat, options, eventData) {
|
|
107
|
-
return this.easeTo(merge({
|
|
108
|
-
center: lnglat
|
|
109
|
-
}, options), eventData);
|
|
110
|
-
}
|
|
111
|
-
}, {
|
|
112
|
-
key: "panBy",
|
|
113
|
-
value: function panBy(offset, options, eventData) {
|
|
114
|
-
offset = Point.convert(offset).mult(-1);
|
|
115
|
-
return this.panTo(this.transform.center, extend({
|
|
116
|
-
offset: offset
|
|
117
|
-
}, options || {}), eventData);
|
|
118
|
-
}
|
|
119
|
-
}, {
|
|
120
|
-
key: "zoomOut",
|
|
121
|
-
value: function zoomOut(options, eventData) {
|
|
122
|
-
this.zoomTo(this.getZoom() - 1, options, eventData);
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
}, {
|
|
126
|
-
key: "setBearing",
|
|
127
|
-
value: function setBearing(bearing, eventData) {
|
|
128
|
-
this.jumpTo({
|
|
129
|
-
bearing: bearing
|
|
130
|
-
}, eventData);
|
|
131
|
-
return this;
|
|
132
|
-
}
|
|
133
|
-
}, {
|
|
134
|
-
key: "setZoom",
|
|
135
|
-
value: function setZoom(zoom, eventData) {
|
|
136
|
-
this.jumpTo({
|
|
137
|
-
zoom: zoom
|
|
138
|
-
}, eventData);
|
|
139
|
-
return this;
|
|
140
|
-
}
|
|
141
|
-
}, {
|
|
142
|
-
key: "zoomIn",
|
|
143
|
-
value: function zoomIn(options, eventData) {
|
|
144
|
-
this.zoomTo(this.getZoom() + 1, options, eventData);
|
|
145
|
-
return this;
|
|
146
|
-
}
|
|
147
|
-
}, {
|
|
148
|
-
key: "zoomTo",
|
|
149
|
-
value: function zoomTo(zoom, options, eventData) {
|
|
150
|
-
return this.easeTo(merge({
|
|
151
|
-
zoom: zoom
|
|
152
|
-
}, options), eventData);
|
|
153
|
-
}
|
|
154
|
-
}, {
|
|
155
|
-
key: "getPadding",
|
|
156
|
-
value: function getPadding() {
|
|
157
|
-
return this.transform.padding;
|
|
158
|
-
}
|
|
159
|
-
}, {
|
|
160
|
-
key: "setPadding",
|
|
161
|
-
value: function setPadding(padding, eventData) {
|
|
162
|
-
this.jumpTo({
|
|
163
|
-
padding: padding
|
|
164
|
-
}, eventData);
|
|
165
|
-
return this;
|
|
166
|
-
}
|
|
167
|
-
}, {
|
|
168
|
-
key: "rotateTo",
|
|
169
|
-
value: function rotateTo(bearing, options, eventData) {
|
|
170
|
-
return this.easeTo(merge({
|
|
171
|
-
bearing: bearing
|
|
172
|
-
}, options), eventData);
|
|
173
|
-
}
|
|
174
|
-
}, {
|
|
175
|
-
key: "resetNorth",
|
|
176
|
-
value: function resetNorth(options, eventData) {
|
|
177
|
-
this.rotateTo(0, merge({
|
|
178
|
-
duration: 1000
|
|
179
|
-
}, options), eventData);
|
|
180
|
-
return this;
|
|
181
|
-
}
|
|
182
|
-
}, {
|
|
183
|
-
key: "resetNorthPitch",
|
|
184
|
-
value: function resetNorthPitch(options, eventData) {
|
|
185
|
-
this.easeTo(merge({
|
|
186
|
-
bearing: 0,
|
|
187
|
-
pitch: 0,
|
|
188
|
-
duration: 1000
|
|
189
|
-
}, options), eventData);
|
|
190
|
-
return this;
|
|
191
|
-
}
|
|
192
|
-
}, {
|
|
193
|
-
key: "fitBounds",
|
|
194
|
-
value: function fitBounds(bounds, options, eventData) {
|
|
195
|
-
return this.fitInternal(
|
|
196
|
-
// @ts-ignore
|
|
197
|
-
this.cameraForBounds(bounds, options), options, eventData);
|
|
198
|
-
}
|
|
199
|
-
}, {
|
|
200
|
-
key: "cameraForBounds",
|
|
201
|
-
value: function cameraForBounds(bounds, options) {
|
|
202
|
-
bounds = LngLatBounds.convert(bounds);
|
|
203
|
-
return this.cameraForBoxAndBearing(bounds.getNorthWest(), bounds.getSouthEast(), 0,
|
|
204
|
-
// @ts-ignore
|
|
205
|
-
options);
|
|
206
|
-
}
|
|
207
|
-
}, {
|
|
208
|
-
key: "snapToNorth",
|
|
209
|
-
value: function snapToNorth(options, eventData) {
|
|
210
|
-
if (Math.abs(this.getBearing()) < this.bearingSnap) {
|
|
211
|
-
return this.resetNorth(options, eventData);
|
|
212
|
-
}
|
|
213
|
-
return this;
|
|
214
|
-
}
|
|
215
|
-
}, {
|
|
216
|
-
key: "jumpTo",
|
|
217
|
-
value: function jumpTo() {
|
|
218
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
219
|
-
var eventData = arguments.length > 1 ? arguments[1] : undefined;
|
|
220
|
-
this.stop();
|
|
221
|
-
var tr = this.transform;
|
|
222
|
-
var zoomChanged = false;
|
|
223
|
-
var bearingChanged = false;
|
|
224
|
-
var pitchChanged = false;
|
|
225
|
-
if (options.zoom !== undefined && tr.zoom !== +options.zoom) {
|
|
226
|
-
zoomChanged = true;
|
|
227
|
-
tr.zoom = +options.zoom;
|
|
228
|
-
}
|
|
229
|
-
if (options.center !== undefined) {
|
|
230
|
-
tr.center = LngLat.convert(options.center);
|
|
231
|
-
}
|
|
232
|
-
if (options.bearing !== undefined && tr.bearing !== +options.bearing) {
|
|
233
|
-
bearingChanged = true;
|
|
234
|
-
tr.bearing = +options.bearing;
|
|
235
|
-
}
|
|
236
|
-
if (options.pitch !== undefined && tr.pitch !== +options.pitch) {
|
|
237
|
-
pitchChanged = true;
|
|
238
|
-
tr.pitch = +options.pitch;
|
|
239
|
-
}
|
|
240
|
-
if (options.padding !== undefined && !tr.isPaddingEqual(options.padding)) {
|
|
241
|
-
tr.padding = options.padding;
|
|
242
|
-
}
|
|
243
|
-
this.emit('movestart', new Event('movestart', eventData));
|
|
244
|
-
this.emit('move', new Event('move', eventData));
|
|
245
|
-
if (zoomChanged) {
|
|
246
|
-
this.emit('zoomstart', new Event('zoomstart', eventData));
|
|
247
|
-
this.emit('zoom', new Event('zoom', eventData));
|
|
248
|
-
this.emit('zoomend', new Event('zoomend', eventData));
|
|
249
|
-
}
|
|
250
|
-
if (bearingChanged) {
|
|
251
|
-
this.emit('rotatestart', new Event('rotatestart', eventData));
|
|
252
|
-
this.emit('rotate', new Event('rotate', eventData));
|
|
253
|
-
this.emit('rotateend', new Event('rotateend', eventData));
|
|
254
|
-
}
|
|
255
|
-
if (pitchChanged) {
|
|
256
|
-
this.emit('pitchstart', new Event('pitchstart', eventData));
|
|
257
|
-
this.emit('pitch', new Event('pitch', eventData));
|
|
258
|
-
this.emit('pitchend', new Event('pitchend', eventData));
|
|
259
|
-
}
|
|
260
|
-
return this.emit('moveend', new Event('moveend', eventData));
|
|
261
|
-
}
|
|
262
|
-
}, {
|
|
263
|
-
key: "easeTo",
|
|
264
|
-
value: function easeTo() {
|
|
265
|
-
var _this2 = this;
|
|
266
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
267
|
-
var eventData = arguments.length > 1 ? arguments[1] : undefined;
|
|
268
|
-
options = merge({
|
|
269
|
-
offset: [0, 0],
|
|
270
|
-
duration: 500,
|
|
271
|
-
easing: defaultEasing
|
|
272
|
-
}, options);
|
|
273
|
-
if (options.animate === false || !options.essential && prefersReducedMotion()) {
|
|
274
|
-
options.duration = 0;
|
|
275
|
-
}
|
|
276
|
-
var tr = this.transform;
|
|
277
|
-
var startZoom = this.getZoom();
|
|
278
|
-
var startBearing = this.getBearing();
|
|
279
|
-
var startPitch = this.getPitch();
|
|
280
|
-
var startPadding = this.getPadding();
|
|
281
|
-
var zoom = options.zoom ? +options.zoom : startZoom;
|
|
282
|
-
var bearing = options.bearing ? this.normalizeBearing(options.bearing, startBearing) : startBearing;
|
|
283
|
-
var pitch = options.pitch ? +options.pitch : startPitch;
|
|
284
|
-
var padding = options.padding ? options.padding : tr.padding;
|
|
285
|
-
var offsetAsPoint = Point.convert(options.offset);
|
|
286
|
-
var pointAtOffset = tr.centerPoint.add(offsetAsPoint);
|
|
287
|
-
var locationAtOffset = tr.pointLocation(pointAtOffset);
|
|
288
|
-
var center = LngLat.convert(options.center || locationAtOffset);
|
|
289
|
-
this.normalizeCenter(center);
|
|
290
|
-
var from = tr.project(locationAtOffset);
|
|
291
|
-
var delta = tr.project(center).sub(from);
|
|
292
|
-
var finalScale = tr.zoomScale(zoom - startZoom);
|
|
293
|
-
var around;
|
|
294
|
-
var aroundPoint;
|
|
295
|
-
if (options.around) {
|
|
296
|
-
around = LngLat.convert(options.around);
|
|
297
|
-
aroundPoint = tr.locationPoint(around);
|
|
298
|
-
}
|
|
299
|
-
var currently = {
|
|
300
|
-
moving: this.moving,
|
|
301
|
-
zooming: this.zooming,
|
|
302
|
-
rotating: this.rotating,
|
|
303
|
-
pitching: this.pitching
|
|
304
|
-
};
|
|
305
|
-
this.zooming = this.zooming || zoom !== startZoom;
|
|
306
|
-
this.rotating = this.rotating || startBearing !== bearing;
|
|
307
|
-
this.pitching = this.pitching || pitch !== startPitch;
|
|
308
|
-
this.padding = !tr.isPaddingEqual(padding);
|
|
309
|
-
this.easeId = options.easeId;
|
|
310
|
-
this.prepareEase(eventData, options.noMoveStart, currently);
|
|
311
|
-
clearTimeout(this.easeEndTimeoutID);
|
|
312
|
-
this.ease(function (k) {
|
|
313
|
-
if (_this2.zooming) {
|
|
314
|
-
tr.zoom = interpolate(startZoom, zoom, k);
|
|
315
|
-
}
|
|
316
|
-
if (_this2.rotating && _this2.rotateEnabled) {
|
|
317
|
-
tr.bearing = interpolate(startBearing, bearing, k);
|
|
318
|
-
}
|
|
319
|
-
if (_this2.pitching && _this2.pitchEnabled) {
|
|
320
|
-
tr.pitch = interpolate(startPitch, pitch, k);
|
|
321
|
-
}
|
|
322
|
-
if (_this2.padding) {
|
|
323
|
-
tr.interpolatePadding(startPadding, padding, k);
|
|
324
|
-
// When padding is being applied, Transform#centerPoint is changing continously,
|
|
325
|
-
// thus we need to recalculate offsetPoint every fra,e
|
|
326
|
-
pointAtOffset = tr.centerPoint.add(offsetAsPoint);
|
|
327
|
-
}
|
|
328
|
-
if (around) {
|
|
329
|
-
tr.setLocationAtPoint(around, aroundPoint);
|
|
330
|
-
} else {
|
|
331
|
-
var scale = tr.zoomScale(tr.zoom - startZoom);
|
|
332
|
-
var base = zoom > startZoom ? Math.min(2, finalScale) : Math.max(0.5, finalScale);
|
|
333
|
-
var speedup = Math.pow(base, 1 - k);
|
|
334
|
-
var newCenter = tr.unproject(from.add(delta.mult(k * speedup)).mult(scale));
|
|
335
|
-
tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);
|
|
336
|
-
}
|
|
337
|
-
_this2.fireMoveEvents(eventData);
|
|
338
|
-
}, function (interruptingEaseId) {
|
|
339
|
-
_this2.afterEase(eventData, interruptingEaseId);
|
|
340
|
-
},
|
|
341
|
-
// @ts-ignore
|
|
342
|
-
options);
|
|
343
|
-
return this;
|
|
344
|
-
}
|
|
345
|
-
}, {
|
|
346
|
-
key: "flyTo",
|
|
347
|
-
value: function flyTo() {
|
|
348
|
-
var _this3 = this;
|
|
349
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
350
|
-
var eventData = arguments.length > 1 ? arguments[1] : undefined;
|
|
351
|
-
// Fall through to jumpTo if user has set prefers-reduced-motion
|
|
352
|
-
if (!options.essential && prefersReducedMotion()) {
|
|
353
|
-
var coercedOptions = pick(options, ['center', 'zoom', 'bearing', 'pitch', 'around']);
|
|
354
|
-
return this.jumpTo(coercedOptions, eventData);
|
|
355
|
-
}
|
|
356
|
-
this.stop();
|
|
357
|
-
options = merge({
|
|
358
|
-
offset: [0, 0],
|
|
359
|
-
speed: 1.2,
|
|
360
|
-
curve: 1.42,
|
|
361
|
-
easing: defaultEasing
|
|
362
|
-
}, options);
|
|
363
|
-
var tr = this.transform;
|
|
364
|
-
var startZoom = this.getZoom();
|
|
365
|
-
var startBearing = this.getBearing();
|
|
366
|
-
var startPitch = this.getPitch();
|
|
367
|
-
var startPadding = this.getPadding();
|
|
368
|
-
var zoom = options.zoom ? clamp(+options.zoom, tr.minZoom, tr.maxZoom) : startZoom;
|
|
369
|
-
var bearing = options.bearing ? this.normalizeBearing(options.bearing, startBearing) : startBearing;
|
|
370
|
-
var pitch = options.pitch ? +options.pitch : startPitch;
|
|
371
|
-
var padding = 'padding' in options ? options.padding : tr.padding;
|
|
372
|
-
var scale = tr.zoomScale(zoom - startZoom);
|
|
373
|
-
var offsetAsPoint = Point.convert(options.offset);
|
|
374
|
-
var pointAtOffset = tr.centerPoint.add(offsetAsPoint);
|
|
375
|
-
var locationAtOffset = tr.pointLocation(pointAtOffset);
|
|
376
|
-
var center = LngLat.convert(options.center || locationAtOffset);
|
|
377
|
-
this.normalizeCenter(center);
|
|
378
|
-
var from = tr.project(locationAtOffset);
|
|
379
|
-
var delta = tr.project(center).sub(from);
|
|
380
|
-
var rho = options.curve;
|
|
381
|
-
|
|
382
|
-
// w₀: Initial visible span, measured in pixels at the initial scale.
|
|
383
|
-
var w0 = Math.max(tr.width, tr.height);
|
|
384
|
-
// w₁: Final visible span, measured in pixels with respect to the initial scale.
|
|
385
|
-
var w1 = w0 / scale;
|
|
386
|
-
// Length of the flight path as projected onto the ground plane, measured in pixels from
|
|
387
|
-
// the world image origin at the initial scale.
|
|
388
|
-
var u1 = delta.mag();
|
|
389
|
-
if ('minZoom' in options) {
|
|
390
|
-
var minZoom = clamp(Math.min(options.minZoom, startZoom, zoom), tr.minZoom, tr.maxZoom);
|
|
391
|
-
// w<sub>m</sub>: Maximum visible span, measured in pixels with respect to the initial
|
|
392
|
-
// scale.
|
|
393
|
-
var wMax = w0 / tr.zoomScale(minZoom - startZoom);
|
|
394
|
-
rho = Math.sqrt(wMax / u1 * 2);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
// ρ²
|
|
398
|
-
var rho2 = rho * rho;
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* rᵢ: Returns the zoom-out factor at one end of the animation.
|
|
402
|
-
*
|
|
403
|
-
* @param i 0 for the ascent or 1 for the descent.
|
|
404
|
-
* @private
|
|
405
|
-
*/
|
|
406
|
-
function r(i) {
|
|
407
|
-
var b = (w1 * w1 - w0 * w0 + (i ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (i ? w1 : w0) * rho2 * u1);
|
|
408
|
-
return Math.log(Math.sqrt(b * b + 1) - b);
|
|
409
|
-
}
|
|
410
|
-
function sinh(n) {
|
|
411
|
-
return (Math.exp(n) - Math.exp(-n)) / 2;
|
|
412
|
-
}
|
|
413
|
-
function cosh(n) {
|
|
414
|
-
return (Math.exp(n) + Math.exp(-n)) / 2;
|
|
415
|
-
}
|
|
416
|
-
function tanh(n) {
|
|
417
|
-
return sinh(n) / cosh(n);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// r₀: Zoom-out factor during ascent.
|
|
421
|
-
var r0 = r(0);
|
|
422
|
-
|
|
423
|
-
// w(s): Returns the visible span on the ground, measured in pixels with respect to the
|
|
424
|
-
// initial scale. Assumes an angular field of view of 2 arctan ½ ≈ 53°.
|
|
425
|
-
var w = function w(s) {
|
|
426
|
-
return cosh(r0) / cosh(r0 + rho * s);
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
// u(s): Returns the distance along the flight path as projected onto the ground plane,
|
|
430
|
-
// measured in pixels from the world image origin at the initial scale.
|
|
431
|
-
var u = function u(s) {
|
|
432
|
-
return w0 * ((cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2) / u1;
|
|
433
|
-
};
|
|
434
|
-
|
|
435
|
-
// S: Total length of the flight path, measured in ρ-screenfuls.
|
|
436
|
-
var S = (r(1) - r0) / rho;
|
|
437
|
-
|
|
438
|
-
// When u₀ = u₁, the optimal path doesn’t require both ascent and descent.
|
|
439
|
-
if (Math.abs(u1) < 0.000001 || !isFinite(S)) {
|
|
440
|
-
// Perform a more or less instantaneous transition if the path is too short.
|
|
441
|
-
if (Math.abs(w0 - w1) < 0.000001) {
|
|
442
|
-
return this.easeTo(options, eventData);
|
|
443
|
-
}
|
|
444
|
-
var k = w1 < w0 ? -1 : 1;
|
|
445
|
-
S = Math.abs(Math.log(w1 / w0)) / rho;
|
|
446
|
-
u = function u() {
|
|
447
|
-
return 0;
|
|
448
|
-
};
|
|
449
|
-
w = function w(s) {
|
|
450
|
-
return Math.exp(k * rho * s);
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
if ('duration' in options) {
|
|
454
|
-
options.duration = +options.duration;
|
|
455
|
-
} else {
|
|
456
|
-
var V = 'screenSpeed' in options ? +options.screenSpeed / rho : +options.speed;
|
|
457
|
-
options.duration = 1000 * S / V;
|
|
458
|
-
}
|
|
459
|
-
if (options.maxDuration && options.duration > options.maxDuration) {
|
|
460
|
-
options.duration = 0;
|
|
461
|
-
}
|
|
462
|
-
this.zooming = true;
|
|
463
|
-
this.rotating = startBearing !== bearing;
|
|
464
|
-
this.pitching = pitch !== startPitch;
|
|
465
|
-
this.padding = !tr.isPaddingEqual(padding);
|
|
466
|
-
this.prepareEase(eventData, false);
|
|
467
|
-
this.ease(function (k) {
|
|
468
|
-
// s: The distance traveled along the flight path, measured in ρ-screenfuls.
|
|
469
|
-
var s = k * S;
|
|
470
|
-
// @ts-ignore
|
|
471
|
-
var easeScale = 1 / w(s);
|
|
472
|
-
tr.zoom = k === 1 ? zoom : startZoom + tr.scaleZoom(easeScale);
|
|
473
|
-
if (_this3.rotating) {
|
|
474
|
-
tr.bearing = interpolate(startBearing, bearing, k);
|
|
475
|
-
}
|
|
476
|
-
if (_this3.pitching) {
|
|
477
|
-
tr.pitch = interpolate(startPitch, pitch, k);
|
|
478
|
-
}
|
|
479
|
-
if (_this3.padding) {
|
|
480
|
-
tr.interpolatePadding(startPadding, padding, k);
|
|
481
|
-
// When padding is being applied, Transform#centerPoint is changing continously,
|
|
482
|
-
// thus we need to recalculate offsetPoint every frame
|
|
483
|
-
pointAtOffset = tr.centerPoint.add(offsetAsPoint);
|
|
484
|
-
}
|
|
485
|
-
var newCenter = k === 1 ? center : tr.unproject(from.add(delta.mult(u(s))).mult(easeScale));
|
|
486
|
-
tr.setLocationAtPoint(tr.renderWorldCopies ? newCenter.wrap() : newCenter, pointAtOffset);
|
|
487
|
-
_this3.fireMoveEvents(eventData);
|
|
488
|
-
}, function () {
|
|
489
|
-
return _this3.afterEase(eventData);
|
|
490
|
-
}, options);
|
|
491
|
-
return this;
|
|
492
|
-
}
|
|
493
|
-
}, {
|
|
494
|
-
key: "fitScreenCoordinates",
|
|
495
|
-
value: function fitScreenCoordinates(p0, p1, bearing, options, eventData) {
|
|
496
|
-
return this.fitInternal(
|
|
497
|
-
// @ts-ignore
|
|
498
|
-
this.cameraForBoxAndBearing(this.transform.pointLocation(Point.convert(p0)), this.transform.pointLocation(Point.convert(p1)), bearing,
|
|
499
|
-
// @ts-ignore
|
|
500
|
-
options), options, eventData);
|
|
501
|
-
}
|
|
502
|
-
}, {
|
|
503
|
-
key: "stop",
|
|
504
|
-
value: function stop(allowGestures, easeId) {
|
|
505
|
-
if (this.easeFrameId) {
|
|
506
|
-
this.cancelRenderFrame(this.easeFrameId);
|
|
507
|
-
// @ts-ignore
|
|
508
|
-
delete this.easeFrameId;
|
|
509
|
-
// @ts-ignore
|
|
510
|
-
delete this.onEaseFrame;
|
|
511
|
-
}
|
|
512
|
-
if (this.onEaseEnd) {
|
|
513
|
-
// The _onEaseEnd function might emit events which trigger new
|
|
514
|
-
// animation, which sets a new _onEaseEnd. Ensure we don't delete
|
|
515
|
-
// it unintentionally.
|
|
516
|
-
var onEaseEnd = this.onEaseEnd;
|
|
517
|
-
// @ts-ignore
|
|
518
|
-
delete this.onEaseEnd;
|
|
519
|
-
onEaseEnd.call(this, easeId);
|
|
520
|
-
}
|
|
521
|
-
// if (!allowGestures) {
|
|
522
|
-
// const handlers = (this: any).handlers;
|
|
523
|
-
// if (handlers) handlers.stop();
|
|
524
|
-
// }
|
|
525
|
-
return this;
|
|
526
|
-
}
|
|
527
|
-
}, {
|
|
528
|
-
key: "normalizeBearing",
|
|
529
|
-
value: function normalizeBearing(bearing, currentBearing) {
|
|
530
|
-
bearing = wrap(bearing, -180, 180);
|
|
531
|
-
var diff = Math.abs(bearing - currentBearing);
|
|
532
|
-
if (Math.abs(bearing - 360 - currentBearing) < diff) {
|
|
533
|
-
bearing -= 360;
|
|
534
|
-
}
|
|
535
|
-
if (Math.abs(bearing + 360 - currentBearing) < diff) {
|
|
536
|
-
bearing += 360;
|
|
537
|
-
}
|
|
538
|
-
return bearing;
|
|
539
|
-
}
|
|
540
|
-
}, {
|
|
541
|
-
key: "normalizeCenter",
|
|
542
|
-
value: function normalizeCenter(center) {
|
|
543
|
-
var tr = this.transform;
|
|
544
|
-
if (!tr.renderWorldCopies || tr.lngRange) {
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
var delta = center.lng - tr.center.lng;
|
|
548
|
-
center.lng += delta > 180 ? -360 : delta < -180 ? 360 : 0;
|
|
549
|
-
}
|
|
550
|
-
}, {
|
|
551
|
-
key: "fireMoveEvents",
|
|
552
|
-
value: function fireMoveEvents(eventData) {
|
|
553
|
-
this.emit('move', new Event('move', eventData));
|
|
554
|
-
if (this.zooming) {
|
|
555
|
-
this.emit('zoom', new Event('zoom', eventData));
|
|
556
|
-
}
|
|
557
|
-
if (this.rotating) {
|
|
558
|
-
this.emit('rotate', new Event('rotate', eventData));
|
|
559
|
-
}
|
|
560
|
-
if (this.pitching) {
|
|
561
|
-
this.emit('rotate', new Event('pitch', eventData));
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
}, {
|
|
565
|
-
key: "prepareEase",
|
|
566
|
-
value: function prepareEase(eventData) {
|
|
567
|
-
var noMoveStart = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
568
|
-
var currently = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
569
|
-
this.moving = true;
|
|
570
|
-
if (!noMoveStart && !currently.moving) {
|
|
571
|
-
this.emit('movestart', new Event('movestart', eventData));
|
|
572
|
-
}
|
|
573
|
-
if (this.zooming && !currently.zooming) {
|
|
574
|
-
this.emit('zoomstart', new Event('zoomstart', eventData));
|
|
575
|
-
}
|
|
576
|
-
if (this.rotating && !currently.rotating) {
|
|
577
|
-
this.emit('rotatestart', new Event('rotatestart', eventData));
|
|
578
|
-
}
|
|
579
|
-
if (this.pitching && !currently.pitching) {
|
|
580
|
-
this.emit('pitchstart', new Event('pitchstart', eventData));
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}, {
|
|
584
|
-
key: "afterEase",
|
|
585
|
-
value: function afterEase(eventData, easeId) {
|
|
586
|
-
// if this easing is being stopped to start another easing with
|
|
587
|
-
// the same id then don't fire any events to avoid extra start/stop events
|
|
588
|
-
if (this.easeId && easeId && this.easeId === easeId) {
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
// @ts-ignore
|
|
592
|
-
delete this.easeId;
|
|
593
|
-
var wasZooming = this.zooming;
|
|
594
|
-
var wasRotating = this.rotating;
|
|
595
|
-
var wasPitching = this.pitching;
|
|
596
|
-
this.moving = false;
|
|
597
|
-
this.zooming = false;
|
|
598
|
-
this.rotating = false;
|
|
599
|
-
this.pitching = false;
|
|
600
|
-
this.padding = false;
|
|
601
|
-
if (wasZooming) {
|
|
602
|
-
this.emit('zoomend', new Event('zoomend', eventData));
|
|
603
|
-
}
|
|
604
|
-
if (wasRotating) {
|
|
605
|
-
this.emit('rotateend', new Event('rotateend', eventData));
|
|
606
|
-
}
|
|
607
|
-
if (wasPitching) {
|
|
608
|
-
this.emit('pitchend', new Event('pitchend', eventData));
|
|
609
|
-
}
|
|
610
|
-
this.emit('moveend', new Event('moveend', eventData));
|
|
611
|
-
}
|
|
612
|
-
}, {
|
|
613
|
-
key: "ease",
|
|
614
|
-
value: function ease(frame, finish, options) {
|
|
615
|
-
if (options.animate === false || options.duration === 0) {
|
|
616
|
-
frame(1);
|
|
617
|
-
finish();
|
|
618
|
-
} else {
|
|
619
|
-
this.easeStart = now();
|
|
620
|
-
this.easeOptions = options;
|
|
621
|
-
this.onEaseFrame = frame;
|
|
622
|
-
this.onEaseEnd = finish;
|
|
623
|
-
this.easeFrameId = this.requestRenderFrame(this.renderFrameCallback);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
}, {
|
|
627
|
-
key: "cameraForBoxAndBearing",
|
|
628
|
-
value: function cameraForBoxAndBearing(p0, p1, bearing, options) {
|
|
629
|
-
var defaultPadding = {
|
|
630
|
-
top: 0,
|
|
631
|
-
bottom: 0,
|
|
632
|
-
right: 0,
|
|
633
|
-
left: 0
|
|
634
|
-
};
|
|
635
|
-
options = merge({
|
|
636
|
-
padding: defaultPadding,
|
|
637
|
-
offset: [0, 0],
|
|
638
|
-
maxZoom: this.transform.maxZoom
|
|
639
|
-
}, options);
|
|
640
|
-
if (typeof options.padding === 'number') {
|
|
641
|
-
var p = options.padding;
|
|
642
|
-
options.padding = {
|
|
643
|
-
top: p,
|
|
644
|
-
bottom: p,
|
|
645
|
-
right: p,
|
|
646
|
-
left: p
|
|
647
|
-
};
|
|
648
|
-
}
|
|
649
|
-
options.padding = merge(defaultPadding, options.padding);
|
|
650
|
-
var tr = this.transform;
|
|
651
|
-
var edgePadding = tr.padding;
|
|
652
|
-
|
|
653
|
-
// We want to calculate the upper right and lower left of the box defined by p0 and p1
|
|
654
|
-
// in a coordinate system rotate to match the destination bearing.
|
|
655
|
-
var p0world = tr.project(LngLat.convert(p0));
|
|
656
|
-
var p1world = tr.project(LngLat.convert(p1));
|
|
657
|
-
var p0rotated = p0world.rotate(-bearing * Math.PI / 180);
|
|
658
|
-
var p1rotated = p1world.rotate(-bearing * Math.PI / 180);
|
|
659
|
-
var upperRight = new Point(Math.max(p0rotated.x, p1rotated.x), Math.max(p0rotated.y, p1rotated.y));
|
|
660
|
-
var lowerLeft = new Point(Math.min(p0rotated.x, p1rotated.x), Math.min(p0rotated.y, p1rotated.y));
|
|
661
|
-
|
|
662
|
-
// Calculate zoom: consider the original bbox and padding.
|
|
663
|
-
var size = upperRight.sub(lowerLeft);
|
|
664
|
-
var scaleX = (tr.width - (
|
|
665
|
-
// @ts-ignore
|
|
666
|
-
edgePadding.left +
|
|
667
|
-
// @ts-ignore
|
|
668
|
-
edgePadding.right +
|
|
669
|
-
// @ts-ignore
|
|
670
|
-
options.padding.left +
|
|
671
|
-
// @ts-ignore
|
|
672
|
-
options.padding.right)) / size.x;
|
|
673
|
-
var scaleY = (tr.height - (
|
|
674
|
-
// @ts-ignore
|
|
675
|
-
edgePadding.top +
|
|
676
|
-
// @ts-ignore
|
|
677
|
-
edgePadding.bottom +
|
|
678
|
-
// @ts-ignore
|
|
679
|
-
options.padding.top +
|
|
680
|
-
// @ts-ignore
|
|
681
|
-
options.padding.bottom)) / size.y;
|
|
682
|
-
if (scaleY < 0 || scaleX < 0) {
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
var zoom = Math.min(tr.scaleZoom(tr.scale * Math.min(scaleX, scaleY)), options.maxZoom);
|
|
686
|
-
|
|
687
|
-
// Calculate center: apply the zoom, the configured offset, as well as offset that exists as a result of padding.
|
|
688
|
-
var offset = Point.convert(options.offset);
|
|
689
|
-
// @ts-ignore
|
|
690
|
-
var paddingOffsetX = (options.padding.left - options.padding.right) / 2;
|
|
691
|
-
// @ts-ignore
|
|
692
|
-
var paddingOffsetY = (options.padding.top - options.padding.bottom) / 2;
|
|
693
|
-
var offsetAtInitialZoom = new Point(offset.x + paddingOffsetX, offset.y + paddingOffsetY);
|
|
694
|
-
var offsetAtFinalZoom = offsetAtInitialZoom.mult(tr.scale / tr.zoomScale(zoom));
|
|
695
|
-
var center = tr.unproject(p0world.add(p1world).div(2).sub(offsetAtFinalZoom));
|
|
696
|
-
return {
|
|
697
|
-
center: center,
|
|
698
|
-
zoom: zoom,
|
|
699
|
-
bearing: bearing
|
|
700
|
-
};
|
|
701
|
-
}
|
|
702
|
-
}, {
|
|
703
|
-
key: "fitInternal",
|
|
704
|
-
value: function fitInternal(calculatedOptions, options, eventData) {
|
|
705
|
-
// cameraForBounds warns + returns undefined if unable to fit:
|
|
706
|
-
if (!calculatedOptions) {
|
|
707
|
-
return this;
|
|
708
|
-
}
|
|
709
|
-
options = merge(calculatedOptions, options);
|
|
710
|
-
// Explictly remove the padding field because, calculatedOptions already accounts for padding by setting zoom and center accordingly.
|
|
711
|
-
delete options.padding;
|
|
712
|
-
// @ts-ignore
|
|
713
|
-
return options.linear ? this.easeTo(options, eventData) : this.flyTo(options, eventData);
|
|
714
|
-
}
|
|
715
|
-
}]);
|
|
716
|
-
return Camera;
|
|
717
|
-
}(EventEmitter);
|
|
718
|
-
export { Camera as default };
|