@antv/l7-map 2.18.0 → 2.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/package.json +3 -3
  2. package/es/camera.d.ts +0 -85
  3. package/es/camera.js +0 -718
  4. package/es/css/l7.css +0 -98
  5. package/es/earthmap.d.ts +0 -66
  6. package/es/earthmap.js +0 -369
  7. package/es/geo/edge_insets.d.ts +0 -54
  8. package/es/geo/edge_insets.js +0 -108
  9. package/es/geo/lng_lat.d.ts +0 -18
  10. package/es/geo/lng_lat.js +0 -73
  11. package/es/geo/lng_lat_bounds.d.ts +0 -24
  12. package/es/geo/lng_lat_bounds.js +0 -154
  13. package/es/geo/mercator.d.ts +0 -29
  14. package/es/geo/mercator.js +0 -84
  15. package/es/geo/point.d.ts +0 -40
  16. package/es/geo/point.js +0 -224
  17. package/es/geo/simple.d.ts +0 -29
  18. package/es/geo/simple.js +0 -87
  19. package/es/geo/transform.d.ts +0 -198
  20. package/es/geo/transform.js +0 -961
  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 -78
  25. package/es/handler/box_zoom.d.ts +0 -59
  26. package/es/handler/box_zoom.js +0 -180
  27. package/es/handler/click_zoom.d.ts +0 -16
  28. package/es/handler/click_zoom.js +0 -54
  29. package/es/handler/events/event.d.ts +0 -4
  30. package/es/handler/events/event.js +0 -11
  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 -64
  35. package/es/handler/events/map_touch_event.d.ts +0 -57
  36. package/es/handler/events/map_touch_event.js +0 -95
  37. package/es/handler/events/map_wheel_event.d.ts +0 -33
  38. package/es/handler/events/map_wheel_event.js +0 -50
  39. package/es/handler/events/render_event.d.ts +0 -5
  40. package/es/handler/events/render_event.js +0 -26
  41. package/es/handler/handler_inertia.d.ts +0 -23
  42. package/es/handler/handler_inertia.js +0 -157
  43. package/es/handler/handler_manager.d.ts +0 -61
  44. package/es/handler/handler_manager.js +0 -577
  45. package/es/handler/handler_util.d.ts +0 -4
  46. package/es/handler/handler_util.js +0 -9
  47. package/es/handler/keyboard.d.ts +0 -36
  48. package/es/handler/keyboard.js +0 -143
  49. package/es/handler/map_event.d.ts +0 -29
  50. package/es/handler/map_event.js +0 -125
  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 -118
  55. package/es/handler/mouse/mousepan_handler.d.ts +0 -10
  56. package/es/handler/mouse/mousepan_handler.js +0 -44
  57. package/es/handler/mouse/mousepitch_hander.d.ts +0 -9
  58. package/es/handler/mouse/mousepitch_hander.js +0 -46
  59. package/es/handler/mouse/mouserotate_hander.d.ts +0 -9
  60. package/es/handler/mouse/mouserotate_hander.js +0 -46
  61. package/es/handler/mouse/util.d.ts +0 -6
  62. package/es/handler/mouse/util.js +0 -11
  63. package/es/handler/scroll_zoom.d.ts +0 -93
  64. package/es/handler/scroll_zoom.js +0 -325
  65. package/es/handler/shim/dblclick_zoom.d.ts +0 -40
  66. package/es/handler/shim/dblclick_zoom.js +0 -67
  67. package/es/handler/shim/drag_pan.d.ts +0 -61
  68. package/es/handler/shim/drag_pan.js +0 -84
  69. package/es/handler/shim/drag_rotate.d.ts +0 -46
  70. package/es/handler/shim/drag_rotate.js +0 -74
  71. package/es/handler/shim/touch_zoom_rotate.d.ts +0 -70
  72. package/es/handler/shim/touch_zoom_rotate.js +0 -115
  73. package/es/handler/tap/single_tap_recognizer.d.ts +0 -20
  74. package/es/handler/tap/single_tap_recognizer.js +0 -97
  75. package/es/handler/tap/tap_drag_zoom.d.ts +0 -22
  76. package/es/handler/tap/tap_drag_zoom.js +0 -106
  77. package/es/handler/tap/tap_recognizer.d.ts +0 -17
  78. package/es/handler/tap/tap_recognizer.js +0 -54
  79. package/es/handler/tap/tap_zoom.d.ts +0 -22
  80. package/es/handler/tap/tap_zoom.js +0 -109
  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 -110
  85. package/es/handler/touch/touch_pitch.d.ts +0 -13
  86. package/es/handler/touch/touch_pitch.js +0 -93
  87. package/es/handler/touch/touch_rotate.d.ts +0 -12
  88. package/es/handler/touch/touch_rotate.js +0 -77
  89. package/es/handler/touch/touch_zoom.d.ts +0 -12
  90. package/es/handler/touch/touch_zoom.js +0 -54
  91. package/es/handler/touch/two_touch.d.ts +0 -23
  92. package/es/handler/touch/two_touch.js +0 -125
  93. package/es/hash.d.ts +0 -14
  94. package/es/hash.js +0 -134
  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 -387
  101. package/es/util.d.ts +0 -25
  102. package/es/util.js +0 -88
  103. package/es/utils/Aabb.d.ts +0 -12
  104. package/es/utils/Aabb.js +0 -112
  105. package/es/utils/dom.d.ts +0 -4
  106. package/es/utils/dom.js +0 -140
  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 -47
  111. package/es/utils/task_queue.d.ts +0 -13
  112. package/es/utils/task_queue.js +0 -89
  113. package/lib/camera.js +0 -724
  114. package/lib/css/l7.css +0 -98
  115. package/lib/earthmap.js +0 -376
  116. package/lib/geo/edge_insets.js +0 -114
  117. package/lib/geo/lng_lat.js +0 -81
  118. package/lib/geo/lng_lat_bounds.js +0 -161
  119. package/lib/geo/mercator.js +0 -100
  120. package/lib/geo/point.js +0 -231
  121. package/lib/geo/simple.js +0 -104
  122. package/lib/geo/transform.js +0 -971
  123. package/lib/handler/IHandler.js +0 -5
  124. package/lib/handler/blockable_map_event.js +0 -84
  125. package/lib/handler/box_zoom.js +0 -186
  126. package/lib/handler/click_zoom.js +0 -61
  127. package/lib/handler/events/event.js +0 -20
  128. package/lib/handler/events/index.js +0 -27
  129. package/lib/handler/events/map_mouse_event.js +0 -70
  130. package/lib/handler/events/map_touch_event.js +0 -100
  131. package/lib/handler/events/map_wheel_event.js +0 -57
  132. package/lib/handler/events/render_event.js +0 -33
  133. package/lib/handler/handler_inertia.js +0 -162
  134. package/lib/handler/handler_manager.js +0 -584
  135. package/lib/handler/handler_util.js +0 -15
  136. package/lib/handler/keyboard.js +0 -151
  137. package/lib/handler/map_event.js +0 -131
  138. package/lib/handler/mouse/index.js +0 -27
  139. package/lib/handler/mouse/mouse_handler.js +0 -124
  140. package/lib/handler/mouse/mousepan_handler.js +0 -49
  141. package/lib/handler/mouse/mousepitch_hander.js +0 -51
  142. package/lib/handler/mouse/mouserotate_hander.js +0 -51
  143. package/lib/handler/mouse/util.js +0 -22
  144. package/lib/handler/scroll_zoom.js +0 -333
  145. package/lib/handler/shim/dblclick_zoom.js +0 -74
  146. package/lib/handler/shim/drag_pan.js +0 -91
  147. package/lib/handler/shim/drag_rotate.js +0 -81
  148. package/lib/handler/shim/touch_zoom_rotate.js +0 -122
  149. package/lib/handler/tap/single_tap_recognizer.js +0 -106
  150. package/lib/handler/tap/tap_drag_zoom.js +0 -112
  151. package/lib/handler/tap/tap_recognizer.js +0 -63
  152. package/lib/handler/tap/tap_zoom.js +0 -115
  153. package/lib/handler/touch/index.js +0 -34
  154. package/lib/handler/touch/touch_pan.js +0 -117
  155. package/lib/handler/touch/touch_pitch.js +0 -98
  156. package/lib/handler/touch/touch_rotate.js +0 -82
  157. package/lib/handler/touch/touch_zoom.js +0 -59
  158. package/lib/handler/touch/two_touch.js +0 -131
  159. package/lib/hash.js +0 -143
  160. package/lib/index.js +0 -49
  161. package/lib/interface.js +0 -5
  162. package/lib/map.js +0 -394
  163. package/lib/util.js +0 -108
  164. package/lib/utils/Aabb.js +0 -119
  165. package/lib/utils/dom.js +0 -147
  166. package/lib/utils/performance.js +0 -70
  167. package/lib/utils/primitives.js +0 -54
  168. package/lib/utils/task_queue.js +0 -97
@@ -1,577 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
- // @ts-ignore
9
- // tslint:disable-next-line: no-submodule-imports
10
- import { lodashUtil } from '@antv/l7-utils';
11
- import Point from "../geo/point";
12
- import DOM from "../utils/dom";
13
- import BlockableMapEventHandler from "./blockable_map_event";
14
- import BoxZoomHandler from "./box_zoom";
15
- import ClickZoomHandler from "./click_zoom";
16
- import { Event } from "./events/event";
17
- import RenderFrameEvent from "./events/render_event";
18
- import HandlerInertia from "./handler_inertia";
19
- import KeyboardHandler from "./keyboard";
20
- import MapEventHandler from "./map_event";
21
- import { MousePanHandler, MousePitchHandler, MouseRotateHandler } from "./mouse";
22
- import ScrollZoomHandler from "./scroll_zoom";
23
- import DoubleClickZoomHandler from "./shim/dblclick_zoom";
24
- import DragPanHandler from "./shim/drag_pan";
25
- import DragRotateHandler from "./shim/drag_rotate";
26
- import TouchZoomRotateHandler from "./shim/touch_zoom_rotate";
27
- import TapDragZoomHandler from "./tap/tap_drag_zoom";
28
- import TapZoomHandler from "./tap/tap_zoom";
29
- import { TouchPanHandler, TouchPitchHandler, TouchRotateHandler, TouchZoomHandler } from "./touch";
30
- var merge = lodashUtil.merge;
31
- var _isMoving = function isMoving(p) {
32
- return p.zoom || p.drag || p.pitch || p.rotate;
33
- };
34
- function hasChange(result) {
35
- return result.panDelta && result.panDelta.mag() || result.zoomDelta || result.bearingDelta || result.pitchDelta;
36
- }
37
- var HandlerManager = /*#__PURE__*/function () {
38
- function HandlerManager(map, options) {
39
- var _this = this;
40
- _classCallCheck(this, HandlerManager);
41
- _defineProperty(this, "handleWindowEvent", function (e) {
42
- _this.handleEvent(e, "".concat(e.type, "Window"));
43
- });
44
- _defineProperty(this, "handleEvent", function (e, eventName) {
45
- if (e.type === 'blur') {
46
- _this.stop();
47
- return;
48
- }
49
- _this.updatingCamera = true;
50
- var inputEvent = e.type === 'renderFrame' ? undefined : e;
51
-
52
- /*
53
- * We don't call e.preventDefault() for any events by default.
54
- * Handlers are responsible for calling it where necessary.
55
- */
56
-
57
- var mergedIHandlerResult = {
58
- needsRenderFrame: false
59
- };
60
- var eventsInProgress = {};
61
- var activeHandlers = {};
62
- // @ts-ignore
63
- var mapTouches = e.touches ?
64
- // @ts-ignore
65
- _this.getMapTouches(e.touches) : undefined;
66
- var points = mapTouches ? DOM.touchPos(_this.el, mapTouches) : DOM.mousePos(_this.el, e);
67
- var _iterator = _createForOfIteratorHelper(_this.handlers),
68
- _step;
69
- try {
70
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
71
- var _step$value = _step.value,
72
- handlerName = _step$value.handlerName,
73
- handler = _step$value.handler,
74
- allowed = _step$value.allowed;
75
- if (!handler.isEnabled()) {
76
- continue;
77
- }
78
- var data = void 0;
79
- if (_this.blockedByActive(activeHandlers, allowed, handlerName)) {
80
- handler.reset();
81
- } else {
82
- var handerName = eventName || e.type;
83
- // @ts-ignore
84
- if (handler && handler[handerName]) {
85
- // @ts-ignore
86
- data = handler[handerName](e, points, mapTouches);
87
- _this.mergeIHandlerResult(mergedIHandlerResult, eventsInProgress, data, handlerName, inputEvent);
88
- if (data && data.needsRenderFrame) {
89
- _this.triggerRenderFrame();
90
- }
91
- }
92
- }
93
- // @ts-ignore
94
- if (data || handler.isActive()) {
95
- activeHandlers[handlerName] = handler;
96
- }
97
- }
98
- } catch (err) {
99
- _iterator.e(err);
100
- } finally {
101
- _iterator.f();
102
- }
103
- var deactivatedHandlers = {};
104
- for (var name in _this.previousActiveHandlers) {
105
- if (!activeHandlers[name]) {
106
- deactivatedHandlers[name] = inputEvent;
107
- }
108
- }
109
- _this.previousActiveHandlers = activeHandlers;
110
- if (Object.keys(deactivatedHandlers).length || hasChange(mergedIHandlerResult)) {
111
- _this.changes.push([mergedIHandlerResult, eventsInProgress, deactivatedHandlers]);
112
- _this.triggerRenderFrame();
113
- }
114
- if (Object.keys(activeHandlers).length || hasChange(mergedIHandlerResult)) {
115
- _this.map.stop(true);
116
- }
117
- _this.updatingCamera = false;
118
- var cameraAnimation = mergedIHandlerResult.cameraAnimation;
119
- if (cameraAnimation) {
120
- _this.inertia.clear();
121
- _this.fireEvents({}, {});
122
- _this.changes = [];
123
- cameraAnimation(_this.map);
124
- }
125
- });
126
- this.map = map;
127
- this.el = this.map.getCanvasContainer();
128
- this.handlers = [];
129
- this.handlersById = {};
130
- this.changes = [];
131
- this.inertia = new HandlerInertia(map);
132
- this.bearingSnap = options.bearingSnap;
133
- this.rotateEnabled = options.rotateEnabled;
134
- this.pitchEnabled = options.pitchEnabled;
135
- this.previousActiveHandlers = {};
136
-
137
- // Track whether map is currently moving, to compute start/move/end events
138
- this.eventsInProgress = {};
139
- this.addDefaultHandlers(options);
140
- var el = this.el;
141
- this.listeners = [];
142
- // l7 - mini
143
- this.listeners = [
144
- // Bind touchstart and touchmove with passive: false because, even though
145
- // they only fire a map events and therefore could theoretically be
146
- // passive, binding with passive: true causes iOS not to respect
147
- // e.preventDefault() in _other_ handlers, even if they are non-passive
148
- // (see https://bugs.webkit.org/show_bug.cgi?id=184251)
149
- [el, 'touchstart', {
150
- passive: false
151
- }], [el, 'touchmove', {
152
- passive: false
153
- }], [el, 'touchend', undefined], [el, 'touchcancel', undefined], [el, 'mousedown', undefined], [el, 'mousemove', undefined], [el, 'mouseup', undefined],
154
- // Bind window-level event listeners for move and up/end events. In the absence of
155
- // the pointer capture API, which is not supported by all necessary platforms,
156
- // window-level event listeners give us the best shot at capturing events that
157
- // fall outside the map canvas element. Use `{capture: true}` for the move event
158
- // to prevent map move events from being fired during a drag.
159
- // @ts-ignore
160
- [window.document, 'mousemove', {
161
- capture: true
162
- }],
163
- // @ts-ignore
164
- [window.document, 'mouseup', undefined], [el, 'mouseover', undefined], [el, 'mouseout', undefined], [el, 'dblclick', undefined], [el, 'click', undefined], [el, 'keydown', {
165
- capture: false
166
- }], [el, 'keyup', undefined], [el, 'wheel', {
167
- passive: false
168
- }], [el, 'contextmenu', undefined],
169
- // @ts-ignore
170
- [window, 'blur', undefined]];
171
- var _iterator2 = _createForOfIteratorHelper(this.listeners),
172
- _step2;
173
- try {
174
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
175
- var _step2$value = _slicedToArray(_step2.value, 3),
176
- target = _step2$value[0],
177
- type = _step2$value[1],
178
- listenerOptions = _step2$value[2];
179
- // @ts-ignore
180
- DOM.addEventListener(target, type,
181
- // @ts-ignore
182
- target === window.document ? this.handleWindowEvent : this.handleEvent, listenerOptions);
183
- }
184
- } catch (err) {
185
- _iterator2.e(err);
186
- } finally {
187
- _iterator2.f();
188
- }
189
- }
190
- _createClass(HandlerManager, [{
191
- key: "destroy",
192
- value: function destroy() {
193
- var _iterator3 = _createForOfIteratorHelper(this.listeners),
194
- _step3;
195
- try {
196
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
197
- var _step3$value = _slicedToArray(_step3.value, 3),
198
- target = _step3$value[0],
199
- type = _step3$value[1],
200
- listenerOptions = _step3$value[2];
201
- // @ts-ignore
202
- DOM.removeEventListener(target, type,
203
- // @ts-ignore
204
- target === window.document ? this.handleWindowEvent : this.handleEvent, listenerOptions);
205
- }
206
- } catch (err) {
207
- _iterator3.e(err);
208
- } finally {
209
- _iterator3.f();
210
- }
211
- }
212
- }, {
213
- key: "stop",
214
- value: function stop() {
215
- // do nothing if this method was triggered by a gesture update
216
- if (this.updatingCamera) {
217
- return;
218
- }
219
- var _iterator4 = _createForOfIteratorHelper(this.handlers),
220
- _step4;
221
- try {
222
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
223
- var handler = _step4.value.handler;
224
- handler.reset();
225
- }
226
- } catch (err) {
227
- _iterator4.e(err);
228
- } finally {
229
- _iterator4.f();
230
- }
231
- this.inertia.clear();
232
- this.fireEvents({}, {});
233
- this.changes = [];
234
- }
235
- }, {
236
- key: "isActive",
237
- value: function isActive() {
238
- var _iterator5 = _createForOfIteratorHelper(this.handlers),
239
- _step5;
240
- try {
241
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
242
- var handler = _step5.value.handler;
243
- if (handler.isActive()) {
244
- return true;
245
- }
246
- }
247
- } catch (err) {
248
- _iterator5.e(err);
249
- } finally {
250
- _iterator5.f();
251
- }
252
- return false;
253
- }
254
- }, {
255
- key: "isZooming",
256
- value: function isZooming() {
257
- return !!this.eventsInProgress.zoom || this.map.scrollZoom.isZooming();
258
- }
259
- }, {
260
- key: "isRotating",
261
- value: function isRotating() {
262
- return !!this.eventsInProgress.rotate;
263
- }
264
- }, {
265
- key: "isMoving",
266
- value: function isMoving() {
267
- return Boolean(_isMoving(this.eventsInProgress)) || this.isZooming();
268
- }
269
- }, {
270
- key: "mergeIHandlerResult",
271
- value: function mergeIHandlerResult(mergedIHandlerResult, eventsInProgress, HandlerResult, name, e) {
272
- if (!HandlerResult) {
273
- return;
274
- }
275
- merge(mergedIHandlerResult, HandlerResult);
276
- var eventData = {
277
- handlerName: name,
278
- originalEvent: HandlerResult.originalEvent || e
279
- };
280
-
281
- // track which handler changed which camera property
282
- if (HandlerResult.zoomDelta !== undefined) {
283
- eventsInProgress.zoom = eventData;
284
- }
285
- if (HandlerResult.panDelta !== undefined) {
286
- eventsInProgress.drag = eventData;
287
- }
288
- if (HandlerResult.pitchDelta !== undefined) {
289
- eventsInProgress.pitch = eventData;
290
- }
291
- if (HandlerResult.bearingDelta !== undefined) {
292
- eventsInProgress.rotate = eventData;
293
- }
294
- }
295
- }, {
296
- key: "triggerRenderFrame",
297
- value: function triggerRenderFrame() {
298
- var _this2 = this;
299
- if (this.frameId === undefined) {
300
- this.frameId = this.map.requestRenderFrame(function (timeStamp) {
301
- // @ts-ignore
302
- delete _this2.frameId;
303
- _this2.handleEvent(new RenderFrameEvent('renderFrame', {
304
- timeStamp: timeStamp
305
- }));
306
- _this2.applyChanges();
307
- });
308
- }
309
- }
310
- }, {
311
- key: "addDefaultHandlers",
312
- value: function addDefaultHandlers(options) {
313
- var map = this.map;
314
- var el = map.getCanvasContainer();
315
- this.add('mapEvent', new MapEventHandler(map, options));
316
- var boxZoom = map.boxZoom = new BoxZoomHandler(map, options);
317
- this.add('boxZoom', boxZoom);
318
- var tapZoom = new TapZoomHandler();
319
- var clickZoom = new ClickZoomHandler();
320
- map.doubleClickZoom = new DoubleClickZoomHandler(clickZoom, tapZoom);
321
- this.add('tapZoom', tapZoom);
322
- this.add('clickZoom', clickZoom);
323
- var tapDragZoom = new TapDragZoomHandler();
324
- this.add('tapDragZoom', tapDragZoom);
325
- var touchPitch = map.touchPitch = new TouchPitchHandler();
326
- this.add('touchPitch', touchPitch);
327
- var mouseRotate = new MouseRotateHandler(options);
328
- var mousePitch = new MousePitchHandler(options);
329
- map.dragRotate = new DragRotateHandler(options, mouseRotate, mousePitch);
330
- this.add('mouseRotate', mouseRotate, ['mousePitch']);
331
- this.add('mousePitch', mousePitch, ['mouseRotate']);
332
- var mousePan = new MousePanHandler(options);
333
- var touchPan = new TouchPanHandler(options);
334
- map.dragPan = new DragPanHandler(el, mousePan, touchPan);
335
- this.add('mousePan', mousePan);
336
- this.add('touchPan', touchPan, ['touchZoom', 'touchRotate']);
337
- var touchRotate = new TouchRotateHandler();
338
- var touchZoom = new TouchZoomHandler();
339
- map.touchZoomRotate = new TouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom);
340
- this.add('touchRotate', touchRotate, ['touchPan', 'touchZoom']);
341
- this.add('touchZoom', touchZoom, ['touchPan', 'touchRotate']);
342
- var scrollZoom = map.scrollZoom = new ScrollZoomHandler(map, this);
343
- this.add('scrollZoom', scrollZoom, ['mousePan']);
344
- var keyboard = map.keyboard = new KeyboardHandler();
345
- this.add('keyboard', keyboard);
346
- this.add('blockableMapEvent', new BlockableMapEventHandler(map));
347
- for (var _i = 0, _arr = ['boxZoom', 'doubleClickZoom', 'tapDragZoom', 'touchPitch', 'dragRotate', 'dragPan', 'touchZoomRotate', 'scrollZoom', 'keyboard']; _i < _arr.length; _i++) {
348
- var name = _arr[_i];
349
- // @ts-ignore
350
- if (options.interactive && options[name]) {
351
- // @ts-ignore
352
- map[name].enable(options[name]);
353
- }
354
- }
355
- }
356
- }, {
357
- key: "add",
358
- value: function add(handlerName, handler, allowed) {
359
- this.handlers.push({
360
- handlerName: handlerName,
361
- handler: handler,
362
- allowed: allowed
363
- });
364
- this.handlersById[handlerName] = handler;
365
- }
366
- }, {
367
- key: "blockedByActive",
368
- value: function blockedByActive(activeHandlers, allowed, myName) {
369
- for (var name in activeHandlers) {
370
- if (name === myName) {
371
- continue;
372
- }
373
- if (!allowed || allowed.indexOf(name) < 0) {
374
- return true;
375
- }
376
- }
377
- return false;
378
- }
379
- }, {
380
- key: "getMapTouches",
381
- value: function getMapTouches(touches) {
382
- var mapTouches = [];
383
- var _iterator6 = _createForOfIteratorHelper(touches),
384
- _step6;
385
- try {
386
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
387
- var t = _step6.value;
388
- var target = t.target;
389
- if (this.el.contains(target)) {
390
- mapTouches.push(t);
391
- }
392
- }
393
- } catch (err) {
394
- _iterator6.e(err);
395
- } finally {
396
- _iterator6.f();
397
- }
398
- return mapTouches;
399
- }
400
- }, {
401
- key: "applyChanges",
402
- value: function applyChanges() {
403
- var combined = {};
404
- var combinedEventsInProgress = {};
405
- var combinedDeactivatedHandlers = {};
406
- var _iterator7 = _createForOfIteratorHelper(this.changes),
407
- _step7;
408
- try {
409
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
410
- var _step7$value = _slicedToArray(_step7.value, 3),
411
- change = _step7$value[0],
412
- eventsInProgress = _step7$value[1],
413
- deactivatedHandlers = _step7$value[2];
414
- if (change.panDelta) {
415
- combined.panDelta = (combined.panDelta || new Point(0, 0))._add(change.panDelta);
416
- }
417
- if (change.zoomDelta) {
418
- combined.zoomDelta = (combined.zoomDelta || 0) + change.zoomDelta;
419
- }
420
- if (change.bearingDelta) {
421
- combined.bearingDelta = (combined.bearingDelta || 0) + change.bearingDelta;
422
- }
423
- if (change.pitchDelta) {
424
- combined.pitchDelta = (combined.pitchDelta || 0) + change.pitchDelta;
425
- }
426
- if (change.around !== undefined) {
427
- combined.around = change.around;
428
- }
429
- if (change.pinchAround !== undefined) {
430
- combined.pinchAround = change.pinchAround;
431
- }
432
- if (change.noInertia) {
433
- combined.noInertia = change.noInertia;
434
- }
435
- merge(combinedEventsInProgress, eventsInProgress);
436
- merge(combinedDeactivatedHandlers, deactivatedHandlers);
437
- }
438
- } catch (err) {
439
- _iterator7.e(err);
440
- } finally {
441
- _iterator7.f();
442
- }
443
- this.updateMapTransform(combined, combinedEventsInProgress, combinedDeactivatedHandlers);
444
- this.changes = [];
445
- }
446
- }, {
447
- key: "updateMapTransform",
448
- value: function updateMapTransform(combinedResult, combinedEventsInProgress, deactivatedHandlers) {
449
- var map = this.map;
450
- var tr = map.transform;
451
- if (!hasChange(combinedResult)) {
452
- return this.fireEvents(combinedEventsInProgress, deactivatedHandlers);
453
- }
454
- var panDelta = combinedResult.panDelta,
455
- zoomDelta = combinedResult.zoomDelta,
456
- bearingDelta = combinedResult.bearingDelta,
457
- pitchDelta = combinedResult.pitchDelta,
458
- pinchAround = combinedResult.pinchAround;
459
- var around = combinedResult.around;
460
- if (pinchAround !== undefined) {
461
- around = pinchAround;
462
- }
463
-
464
- // stop any ongoing camera animations (easeTo, flyTo)
465
- map.stop(true);
466
- around = around || map.transform.centerPoint;
467
- var loc = tr.pointLocation(panDelta ? around.sub(panDelta) : around);
468
- if (bearingDelta && this.rotateEnabled) {
469
- tr.bearing += bearingDelta;
470
- }
471
- if (pitchDelta && this.pitchEnabled) {
472
- tr.pitch += pitchDelta;
473
- }
474
- if (zoomDelta) {
475
- tr.zoom += zoomDelta;
476
- }
477
- tr.setLocationAtPoint(loc, around);
478
- this.map.update();
479
- if (!combinedResult.noInertia) {
480
- this.inertia.record(combinedResult);
481
- }
482
- this.fireEvents(combinedEventsInProgress, deactivatedHandlers);
483
- }
484
- }, {
485
- key: "fireEvents",
486
- value: function fireEvents(newEventsInProgress, deactivatedHandlers) {
487
- var _this3 = this;
488
- var wasMoving = _isMoving(this.eventsInProgress);
489
- var nowMoving = _isMoving(newEventsInProgress);
490
- var startEvents = {};
491
- for (var eventName in newEventsInProgress) {
492
- if (newEventsInProgress[eventName]) {
493
- var originalEvent = newEventsInProgress[eventName].originalEvent;
494
- if (!this.eventsInProgress[eventName]) {
495
- startEvents["".concat(eventName, "start")] = originalEvent;
496
- }
497
- this.eventsInProgress[eventName] = newEventsInProgress[eventName];
498
- }
499
- }
500
-
501
- // fire start events only after this.eventsInProgress has been updated
502
- if (!wasMoving && nowMoving) {
503
- this.fireEvent('movestart', nowMoving.originalEvent);
504
- }
505
- for (var name in startEvents) {
506
- if (startEvents[name]) {
507
- this.fireEvent(name, startEvents[name]);
508
- }
509
- }
510
- if (newEventsInProgress.rotate) {
511
- this.bearingChanged = true;
512
- }
513
- if (nowMoving) {
514
- this.fireEvent('move', nowMoving.originalEvent);
515
- }
516
- for (var _eventName in newEventsInProgress) {
517
- if (newEventsInProgress[_eventName]) {
518
- var _originalEvent = newEventsInProgress[_eventName].originalEvent;
519
- this.fireEvent(_eventName, _originalEvent);
520
- }
521
- }
522
- var endEvents = {};
523
- var originalEndEvent;
524
- for (var _eventName2 in this.eventsInProgress) {
525
- if (this.eventsInProgress[_eventName2]) {
526
- var _this$eventsInProgres = this.eventsInProgress[_eventName2],
527
- handlerName = _this$eventsInProgres.handlerName,
528
- _originalEvent2 = _this$eventsInProgres.originalEvent;
529
- if (!this.handlersById[handlerName].isActive()) {
530
- delete this.eventsInProgress[_eventName2];
531
- originalEndEvent = deactivatedHandlers[handlerName] || _originalEvent2;
532
- endEvents["".concat(_eventName2, "end")] = originalEndEvent;
533
- }
534
- }
535
- }
536
- for (var _name in endEvents) {
537
- if (endEvents[_name]) {
538
- this.fireEvent(_name, endEvents[_name]);
539
- }
540
- }
541
- var stillMoving = _isMoving(this.eventsInProgress);
542
- if ((wasMoving || nowMoving) && !stillMoving) {
543
- this.updatingCamera = true;
544
- var inertialEase = this.inertia.onMoveEnd(this.map.dragPan.inertiaOptions);
545
- var shouldSnapToNorth = function shouldSnapToNorth(bearing) {
546
- return bearing !== 0 && -_this3.bearingSnap < bearing && bearing < _this3.bearingSnap;
547
- };
548
- if (inertialEase) {
549
- if (shouldSnapToNorth(inertialEase.bearing || this.map.getBearing())) {
550
- inertialEase.bearing = 0;
551
- }
552
- this.map.easeTo(inertialEase, {
553
- originalEvent: originalEndEvent
554
- });
555
- } else {
556
- this.map.emit('moveend', new Event('moveend', {
557
- originalEvent: originalEndEvent
558
- }));
559
- if (shouldSnapToNorth(this.map.getBearing())) {
560
- this.map.resetNorth();
561
- }
562
- }
563
- this.bearingChanged = false;
564
- this.updatingCamera = false;
565
- }
566
- }
567
- }, {
568
- key: "fireEvent",
569
- value: function fireEvent(type, e) {
570
- this.map.emit(type, new Event(type, e ? {
571
- originalEvent: e
572
- } : {}));
573
- }
574
- }]);
575
- return HandlerManager;
576
- }();
577
- export default HandlerManager;
@@ -1,4 +0,0 @@
1
- import Point from '../geo/point';
2
- export declare function indexTouches(touches: Touch[], points: Point[]): {
3
- [key: string]: any;
4
- };
@@ -1,9 +0,0 @@
1
- // @ts-ignore
2
-
3
- export function indexTouches(touches, points) {
4
- var obj = {};
5
- for (var i = 0; i < touches.length; i++) {
6
- obj[touches[i].identifier] = points[i];
7
- }
8
- return obj;
9
- }
@@ -1,36 +0,0 @@
1
- import { EarthMap } from '../earthmap';
2
- import { Map } from '../map';
3
- /**
4
- * The `KeyboardHandler` allows the user to zoom, rotate, and pan the map using
5
- * the following keyboard shortcuts:
6
- *
7
- * - `=` / `+`: Increase the zoom level by 1.
8
- * - `Shift-=` / `Shift-+`: Increase the zoom level by 2.
9
- * - `-`: Decrease the zoom level by 1.
10
- * - `Shift--`: Decrease the zoom level by 2.
11
- * - Arrow keys: Pan by 100 pixels.
12
- * - `Shift+⇢`: Increase the rotation by 15 degrees.
13
- * - `Shift+⇠`: Decrease the rotation by 15 degrees.
14
- * - `Shift+⇡`: Increase the pitch by 10 degrees.
15
- * - `Shift+⇣`: Decrease the pitch by 10 degrees.
16
- */
17
- declare class KeyboardHandler {
18
- private enabled;
19
- private active;
20
- private panStep;
21
- private bearingStep;
22
- private pitchStep;
23
- /**
24
- * @private
25
- */
26
- constructor();
27
- reset(): void;
28
- keydown(e: KeyboardEvent): {
29
- cameraAnimation: (map: Map | EarthMap) => void;
30
- } | undefined;
31
- enable(): void;
32
- disable(): void;
33
- isEnabled(): boolean;
34
- isActive(): boolean;
35
- }
36
- export default KeyboardHandler;