@antv/l7-map 2.5.35 → 2.5.37-mini11

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