@antv/l7-map 2.9.32-alpha.1 → 2.9.32-alpha.3

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