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