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