@antv/l7-map 2.18.2 → 2.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/es/camera.d.ts +85 -0
  2. package/es/camera.js +718 -0
  3. package/es/css/l7.css +98 -0
  4. package/es/earthmap.d.ts +66 -0
  5. package/es/earthmap.js +369 -0
  6. package/es/geo/edge_insets.d.ts +54 -0
  7. package/es/geo/edge_insets.js +108 -0
  8. package/es/geo/lng_lat.d.ts +18 -0
  9. package/es/geo/lng_lat.js +73 -0
  10. package/es/geo/lng_lat_bounds.d.ts +24 -0
  11. package/es/geo/lng_lat_bounds.js +154 -0
  12. package/es/geo/mercator.d.ts +29 -0
  13. package/es/geo/mercator.js +84 -0
  14. package/es/geo/point.d.ts +40 -0
  15. package/es/geo/point.js +224 -0
  16. package/es/geo/simple.d.ts +29 -0
  17. package/es/geo/simple.js +87 -0
  18. package/es/geo/transform.d.ts +198 -0
  19. package/es/geo/transform.js +961 -0
  20. package/es/handler/IHandler.d.ts +34 -0
  21. package/es/handler/IHandler.js +1 -0
  22. package/es/handler/blockable_map_event.d.ts +17 -0
  23. package/es/handler/blockable_map_event.js +78 -0
  24. package/es/handler/box_zoom.d.ts +59 -0
  25. package/es/handler/box_zoom.js +180 -0
  26. package/es/handler/click_zoom.d.ts +16 -0
  27. package/es/handler/click_zoom.js +54 -0
  28. package/es/handler/events/event.d.ts +4 -0
  29. package/es/handler/events/event.js +11 -0
  30. package/es/handler/events/index.d.ts +4 -0
  31. package/es/handler/events/index.js +4 -0
  32. package/es/handler/events/map_mouse_event.d.ts +34 -0
  33. package/es/handler/events/map_mouse_event.js +64 -0
  34. package/es/handler/events/map_touch_event.d.ts +57 -0
  35. package/es/handler/events/map_touch_event.js +95 -0
  36. package/es/handler/events/map_wheel_event.d.ts +33 -0
  37. package/es/handler/events/map_wheel_event.js +50 -0
  38. package/es/handler/events/render_event.d.ts +5 -0
  39. package/es/handler/events/render_event.js +26 -0
  40. package/es/handler/handler_inertia.d.ts +23 -0
  41. package/es/handler/handler_inertia.js +157 -0
  42. package/es/handler/handler_manager.d.ts +61 -0
  43. package/es/handler/handler_manager.js +577 -0
  44. package/es/handler/handler_util.d.ts +4 -0
  45. package/es/handler/handler_util.js +9 -0
  46. package/es/handler/keyboard.d.ts +36 -0
  47. package/es/handler/keyboard.js +143 -0
  48. package/es/handler/map_event.d.ts +29 -0
  49. package/es/handler/map_event.js +125 -0
  50. package/es/handler/mouse/index.d.ts +4 -0
  51. package/es/handler/mouse/index.js +4 -0
  52. package/es/handler/mouse/mouse_handler.d.ts +22 -0
  53. package/es/handler/mouse/mouse_handler.js +118 -0
  54. package/es/handler/mouse/mousepan_handler.d.ts +10 -0
  55. package/es/handler/mouse/mousepan_handler.js +44 -0
  56. package/es/handler/mouse/mousepitch_hander.d.ts +9 -0
  57. package/es/handler/mouse/mousepitch_hander.js +46 -0
  58. package/es/handler/mouse/mouserotate_hander.d.ts +9 -0
  59. package/es/handler/mouse/mouserotate_hander.js +46 -0
  60. package/es/handler/mouse/util.d.ts +6 -0
  61. package/es/handler/mouse/util.js +11 -0
  62. package/es/handler/scroll_zoom.d.ts +93 -0
  63. package/es/handler/scroll_zoom.js +325 -0
  64. package/es/handler/shim/dblclick_zoom.d.ts +40 -0
  65. package/es/handler/shim/dblclick_zoom.js +67 -0
  66. package/es/handler/shim/drag_pan.d.ts +61 -0
  67. package/es/handler/shim/drag_pan.js +84 -0
  68. package/es/handler/shim/drag_rotate.d.ts +46 -0
  69. package/es/handler/shim/drag_rotate.js +74 -0
  70. package/es/handler/shim/touch_zoom_rotate.d.ts +70 -0
  71. package/es/handler/shim/touch_zoom_rotate.js +115 -0
  72. package/es/handler/tap/single_tap_recognizer.d.ts +20 -0
  73. package/es/handler/tap/single_tap_recognizer.js +97 -0
  74. package/es/handler/tap/tap_drag_zoom.d.ts +22 -0
  75. package/es/handler/tap/tap_drag_zoom.js +106 -0
  76. package/es/handler/tap/tap_recognizer.d.ts +17 -0
  77. package/es/handler/tap/tap_recognizer.js +54 -0
  78. package/es/handler/tap/tap_zoom.d.ts +22 -0
  79. package/es/handler/tap/tap_zoom.js +109 -0
  80. package/es/handler/touch/index.d.ts +5 -0
  81. package/es/handler/touch/index.js +5 -0
  82. package/es/handler/touch/touch_pan.d.ts +30 -0
  83. package/es/handler/touch/touch_pan.js +110 -0
  84. package/es/handler/touch/touch_pitch.d.ts +13 -0
  85. package/es/handler/touch/touch_pitch.js +93 -0
  86. package/es/handler/touch/touch_rotate.d.ts +12 -0
  87. package/es/handler/touch/touch_rotate.js +77 -0
  88. package/es/handler/touch/touch_zoom.d.ts +12 -0
  89. package/es/handler/touch/touch_zoom.js +54 -0
  90. package/es/handler/touch/two_touch.d.ts +23 -0
  91. package/es/handler/touch/two_touch.js +125 -0
  92. package/es/hash.d.ts +14 -0
  93. package/es/hash.js +134 -0
  94. package/es/index.d.ts +4 -0
  95. package/es/index.js +4 -0
  96. package/es/interface.d.ts +34 -0
  97. package/es/interface.js +1 -0
  98. package/es/map.d.ts +70 -0
  99. package/es/map.js +387 -0
  100. package/es/util.d.ts +25 -0
  101. package/es/util.js +88 -0
  102. package/es/utils/Aabb.d.ts +12 -0
  103. package/es/utils/Aabb.js +112 -0
  104. package/es/utils/dom.d.ts +4 -0
  105. package/es/utils/dom.js +140 -0
  106. package/es/utils/performance.d.ts +17 -0
  107. package/es/utils/performance.js +62 -0
  108. package/es/utils/primitives.d.ts +6 -0
  109. package/es/utils/primitives.js +47 -0
  110. package/es/utils/task_queue.d.ts +13 -0
  111. package/es/utils/task_queue.js +89 -0
  112. package/lib/camera.js +724 -0
  113. package/lib/css/l7.css +98 -0
  114. package/lib/earthmap.js +376 -0
  115. package/lib/geo/edge_insets.js +114 -0
  116. package/lib/geo/lng_lat.js +81 -0
  117. package/lib/geo/lng_lat_bounds.js +161 -0
  118. package/lib/geo/mercator.js +100 -0
  119. package/lib/geo/point.js +231 -0
  120. package/lib/geo/simple.js +104 -0
  121. package/lib/geo/transform.js +971 -0
  122. package/lib/handler/IHandler.js +5 -0
  123. package/lib/handler/blockable_map_event.js +84 -0
  124. package/lib/handler/box_zoom.js +186 -0
  125. package/lib/handler/click_zoom.js +61 -0
  126. package/lib/handler/events/event.js +20 -0
  127. package/lib/handler/events/index.js +27 -0
  128. package/lib/handler/events/map_mouse_event.js +70 -0
  129. package/lib/handler/events/map_touch_event.js +100 -0
  130. package/lib/handler/events/map_wheel_event.js +57 -0
  131. package/lib/handler/events/render_event.js +33 -0
  132. package/lib/handler/handler_inertia.js +162 -0
  133. package/lib/handler/handler_manager.js +584 -0
  134. package/lib/handler/handler_util.js +15 -0
  135. package/lib/handler/keyboard.js +151 -0
  136. package/lib/handler/map_event.js +131 -0
  137. package/lib/handler/mouse/index.js +27 -0
  138. package/lib/handler/mouse/mouse_handler.js +124 -0
  139. package/lib/handler/mouse/mousepan_handler.js +49 -0
  140. package/lib/handler/mouse/mousepitch_hander.js +51 -0
  141. package/lib/handler/mouse/mouserotate_hander.js +51 -0
  142. package/lib/handler/mouse/util.js +22 -0
  143. package/lib/handler/scroll_zoom.js +333 -0
  144. package/lib/handler/shim/dblclick_zoom.js +74 -0
  145. package/lib/handler/shim/drag_pan.js +91 -0
  146. package/lib/handler/shim/drag_rotate.js +81 -0
  147. package/lib/handler/shim/touch_zoom_rotate.js +122 -0
  148. package/lib/handler/tap/single_tap_recognizer.js +106 -0
  149. package/lib/handler/tap/tap_drag_zoom.js +112 -0
  150. package/lib/handler/tap/tap_recognizer.js +63 -0
  151. package/lib/handler/tap/tap_zoom.js +115 -0
  152. package/lib/handler/touch/index.js +34 -0
  153. package/lib/handler/touch/touch_pan.js +117 -0
  154. package/lib/handler/touch/touch_pitch.js +98 -0
  155. package/lib/handler/touch/touch_rotate.js +82 -0
  156. package/lib/handler/touch/touch_zoom.js +59 -0
  157. package/lib/handler/touch/two_touch.js +131 -0
  158. package/lib/hash.js +143 -0
  159. package/lib/index.js +49 -0
  160. package/lib/interface.js +5 -0
  161. package/lib/map.js +394 -0
  162. package/lib/util.js +108 -0
  163. package/lib/utils/Aabb.js +119 -0
  164. package/lib/utils/dom.js +147 -0
  165. package/lib/utils/performance.js +70 -0
  166. package/lib/utils/primitives.js +54 -0
  167. package/lib/utils/task_queue.js +97 -0
  168. package/package.json +3 -3
@@ -0,0 +1,46 @@
1
+ import { MousePitchHandler, MouseRotateHandler } from '../mouse';
2
+ /**
3
+ * The `DragRotateHandler` allows the user to rotate the map by clicking and
4
+ * dragging the cursor while holding the right mouse button or `ctrl` key.
5
+ */
6
+ export default class DragRotateHandler {
7
+ private mouseRotate;
8
+ private mousePitch;
9
+ private pitchWithRotate;
10
+ /**
11
+ * @param {Object} [options]
12
+ * @param {number} [options.bearingSnap] The threshold, measured in degrees, that determines when the map's
13
+ * bearing will snap to north.
14
+ * @param {bool} [options.pitchWithRotate=true] Control the map pitch in addition to the bearing
15
+ * @private
16
+ */
17
+ constructor(options: {
18
+ pitchWithRotate: boolean;
19
+ }, mouseRotate: MouseRotateHandler, mousePitch: MousePitchHandler);
20
+ /**
21
+ * Enables the "drag to rotate" interaction.
22
+ *
23
+ * @example
24
+ * map.dragRotate.enable();
25
+ */
26
+ enable(): void;
27
+ /**
28
+ * Disables the "drag to rotate" interaction.
29
+ *
30
+ * @example
31
+ * map.dragRotate.disable();
32
+ */
33
+ disable(): void;
34
+ /**
35
+ * Returns a Boolean indicating whether the "drag to rotate" interaction is enabled.
36
+ *
37
+ * @returns {boolean} `true` if the "drag to rotate" interaction is enabled.
38
+ */
39
+ isEnabled(): boolean;
40
+ /**
41
+ * Returns a Boolean indicating whether the "drag to rotate" interaction is active, i.e. currently being used.
42
+ *
43
+ * @returns {boolean} `true` if the "drag to rotate" interaction is active.
44
+ */
45
+ isActive(): boolean;
46
+ }
@@ -0,0 +1,74 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ /**
4
+ * The `DragRotateHandler` allows the user to rotate the map by clicking and
5
+ * dragging the cursor while holding the right mouse button or `ctrl` key.
6
+ */
7
+ var DragRotateHandler = /*#__PURE__*/function () {
8
+ /**
9
+ * @param {Object} [options]
10
+ * @param {number} [options.bearingSnap] The threshold, measured in degrees, that determines when the map's
11
+ * bearing will snap to north.
12
+ * @param {bool} [options.pitchWithRotate=true] Control the map pitch in addition to the bearing
13
+ * @private
14
+ */
15
+ function DragRotateHandler(options, mouseRotate, mousePitch) {
16
+ _classCallCheck(this, DragRotateHandler);
17
+ this.pitchWithRotate = options.pitchWithRotate;
18
+ this.mouseRotate = mouseRotate;
19
+ this.mousePitch = mousePitch;
20
+ }
21
+
22
+ /**
23
+ * Enables the "drag to rotate" interaction.
24
+ *
25
+ * @example
26
+ * map.dragRotate.enable();
27
+ */
28
+ _createClass(DragRotateHandler, [{
29
+ key: "enable",
30
+ value: function enable() {
31
+ this.mouseRotate.enable();
32
+ if (this.pitchWithRotate) {
33
+ this.mousePitch.enable();
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Disables the "drag to rotate" interaction.
39
+ *
40
+ * @example
41
+ * map.dragRotate.disable();
42
+ */
43
+ }, {
44
+ key: "disable",
45
+ value: function disable() {
46
+ this.mouseRotate.disable();
47
+ this.mousePitch.disable();
48
+ }
49
+
50
+ /**
51
+ * Returns a Boolean indicating whether the "drag to rotate" interaction is enabled.
52
+ *
53
+ * @returns {boolean} `true` if the "drag to rotate" interaction is enabled.
54
+ */
55
+ }, {
56
+ key: "isEnabled",
57
+ value: function isEnabled() {
58
+ return this.mouseRotate.isEnabled() && (!this.pitchWithRotate || this.mousePitch.isEnabled());
59
+ }
60
+
61
+ /**
62
+ * Returns a Boolean indicating whether the "drag to rotate" interaction is active, i.e. currently being used.
63
+ *
64
+ * @returns {boolean} `true` if the "drag to rotate" interaction is active.
65
+ */
66
+ }, {
67
+ key: "isActive",
68
+ value: function isActive() {
69
+ return this.mouseRotate.isActive() || this.mousePitch.isActive();
70
+ }
71
+ }]);
72
+ return DragRotateHandler;
73
+ }();
74
+ export { DragRotateHandler as default };
@@ -0,0 +1,70 @@
1
+ import TapDragZoomHandler from '../tap/tap_drag_zoom';
2
+ import { TouchRotateHandler, TouchZoomHandler } from '../touch';
3
+ /**
4
+ * The `TouchZoomRotateHandler` allows the user to zoom and rotate the map by
5
+ * pinching on a touchscreen.
6
+ *
7
+ * They can zoom with one finger by double tapping and dragging. On the second tap,
8
+ * hold the finger down and drag up or down to zoom in or out.
9
+ */
10
+ export default class TouchZoomRotateHandler {
11
+ private el;
12
+ private touchZoom;
13
+ private touchRotate;
14
+ private tapDragZoom;
15
+ private rotationDisabled;
16
+ private enabled;
17
+ /**
18
+ * @private
19
+ */
20
+ constructor(el: HTMLElement, touchZoom: TouchZoomHandler, touchRotate: TouchRotateHandler, tapDragZoom: TapDragZoomHandler);
21
+ /**
22
+ * Enables the "pinch to rotate and zoom" interaction.
23
+ *
24
+ * @param {Object} [options] Options object.
25
+ * @param {string} [options.around] If "center" is passed, map will zoom around the center
26
+ *
27
+ * @example
28
+ * map.touchZoomRotate.enable();
29
+ * @example
30
+ * map.touchZoomRotate.enable({ around: 'center' });
31
+ */
32
+ enable(options: {
33
+ around?: 'center';
34
+ }): void;
35
+ /**
36
+ * Disables the "pinch to rotate and zoom" interaction.
37
+ *
38
+ * @example
39
+ * map.touchZoomRotate.disable();
40
+ */
41
+ disable(): void;
42
+ /**
43
+ * Returns a Boolean indicating whether the "pinch to rotate and zoom" interaction is enabled.
44
+ *
45
+ * @returns {boolean} `true` if the "pinch to rotate and zoom" interaction is enabled.
46
+ */
47
+ isEnabled(): boolean;
48
+ /**
49
+ * Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.
50
+ *
51
+ * @returns {boolean} //eslint-disable-line
52
+ */
53
+ isActive(): boolean;
54
+ /**
55
+ * Disables the "pinch to rotate" interaction, leaving the "pinch to zoom"
56
+ * interaction enabled.
57
+ *
58
+ * @example
59
+ * map.touchZoomRotate.disableRotation();
60
+ */
61
+ disableRotation(): void;
62
+ /**
63
+ * Enables the "pinch to rotate" interaction.
64
+ *
65
+ * @example
66
+ * map.touchZoomRotate.enable();
67
+ * map.touchZoomRotate.enableRotation();
68
+ */
69
+ enableRotation(): void;
70
+ }
@@ -0,0 +1,115 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ /**
4
+ * The `TouchZoomRotateHandler` allows the user to zoom and rotate the map by
5
+ * pinching on a touchscreen.
6
+ *
7
+ * They can zoom with one finger by double tapping and dragging. On the second tap,
8
+ * hold the finger down and drag up or down to zoom in or out.
9
+ */
10
+ var TouchZoomRotateHandler = /*#__PURE__*/function () {
11
+ /**
12
+ * @private
13
+ */
14
+ function TouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom) {
15
+ _classCallCheck(this, TouchZoomRotateHandler);
16
+ this.el = el;
17
+ this.touchZoom = touchZoom;
18
+ this.touchRotate = touchRotate;
19
+ this.tapDragZoom = tapDragZoom;
20
+ this.rotationDisabled = false;
21
+ this.enabled = true;
22
+ }
23
+
24
+ /**
25
+ * Enables the "pinch to rotate and zoom" interaction.
26
+ *
27
+ * @param {Object} [options] Options object.
28
+ * @param {string} [options.around] If "center" is passed, map will zoom around the center
29
+ *
30
+ * @example
31
+ * map.touchZoomRotate.enable();
32
+ * @example
33
+ * map.touchZoomRotate.enable({ around: 'center' });
34
+ */
35
+ _createClass(TouchZoomRotateHandler, [{
36
+ key: "enable",
37
+ value: function enable(options) {
38
+ this.touchZoom.enable(options);
39
+ if (!this.rotationDisabled) {
40
+ this.touchRotate.enable(options);
41
+ }
42
+ this.tapDragZoom.enable();
43
+ this.el.classList.add('l7-touch-zoom-rotate');
44
+ }
45
+
46
+ /**
47
+ * Disables the "pinch to rotate and zoom" interaction.
48
+ *
49
+ * @example
50
+ * map.touchZoomRotate.disable();
51
+ */
52
+ }, {
53
+ key: "disable",
54
+ value: function disable() {
55
+ this.touchZoom.disable();
56
+ this.touchRotate.disable();
57
+ this.tapDragZoom.disable();
58
+ this.el.classList.remove('l7-touch-zoom-rotate');
59
+ }
60
+
61
+ /**
62
+ * Returns a Boolean indicating whether the "pinch to rotate and zoom" interaction is enabled.
63
+ *
64
+ * @returns {boolean} `true` if the "pinch to rotate and zoom" interaction is enabled.
65
+ */
66
+ }, {
67
+ key: "isEnabled",
68
+ value: function isEnabled() {
69
+ return this.touchZoom.isEnabled() && (this.rotationDisabled || this.touchRotate.isEnabled()) && this.tapDragZoom.isEnabled();
70
+ }
71
+
72
+ /**
73
+ * Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.
74
+ *
75
+ * @returns {boolean} //eslint-disable-line
76
+ */
77
+ }, {
78
+ key: "isActive",
79
+ value: function isActive() {
80
+ return this.touchZoom.isActive() || this.touchRotate.isActive() || this.tapDragZoom.isActive();
81
+ }
82
+
83
+ /**
84
+ * Disables the "pinch to rotate" interaction, leaving the "pinch to zoom"
85
+ * interaction enabled.
86
+ *
87
+ * @example
88
+ * map.touchZoomRotate.disableRotation();
89
+ */
90
+ }, {
91
+ key: "disableRotation",
92
+ value: function disableRotation() {
93
+ this.rotationDisabled = true;
94
+ this.touchRotate.disable();
95
+ }
96
+
97
+ /**
98
+ * Enables the "pinch to rotate" interaction.
99
+ *
100
+ * @example
101
+ * map.touchZoomRotate.enable();
102
+ * map.touchZoomRotate.enableRotation();
103
+ */
104
+ }, {
105
+ key: "enableRotation",
106
+ value: function enableRotation() {
107
+ this.rotationDisabled = false;
108
+ if (this.touchZoom.isEnabled()) {
109
+ this.touchRotate.enable();
110
+ }
111
+ }
112
+ }]);
113
+ return TouchZoomRotateHandler;
114
+ }();
115
+ export { TouchZoomRotateHandler as default };
@@ -0,0 +1,20 @@
1
+ import Point from '../../geo/point';
2
+ export declare const MAX_TAP_INTERVAL = 500;
3
+ export declare const MAX_TOUCH_TIME = 500;
4
+ export declare const MAX_DIST = 30;
5
+ export default class SingleTapRecognizer {
6
+ numTouches: number;
7
+ centroid: Point;
8
+ startTime: number;
9
+ aborted: boolean;
10
+ touches: {
11
+ [key: string]: Point;
12
+ };
13
+ constructor(options: {
14
+ numTouches: number;
15
+ });
16
+ reset(): void;
17
+ touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
18
+ touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
19
+ touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): Point | undefined;
20
+ }
@@ -0,0 +1,97 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ 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; } } }; }
4
+ 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); }
5
+ 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; }
6
+ // @ts-ignore
7
+ import Point from "../../geo/point";
8
+ import { indexTouches } from "../handler_util";
9
+ function getCentroid(points) {
10
+ var sum = new Point(0, 0);
11
+ var _iterator = _createForOfIteratorHelper(points),
12
+ _step;
13
+ try {
14
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
15
+ var point = _step.value;
16
+ sum._add(point);
17
+ }
18
+ // @ts-ignore
19
+ } catch (err) {
20
+ _iterator.e(err);
21
+ } finally {
22
+ _iterator.f();
23
+ }
24
+ return sum.div(points.length);
25
+ }
26
+ export var MAX_TAP_INTERVAL = 500;
27
+ export var MAX_TOUCH_TIME = 500;
28
+ export var MAX_DIST = 30;
29
+ var SingleTapRecognizer = /*#__PURE__*/function () {
30
+ function SingleTapRecognizer(options) {
31
+ _classCallCheck(this, SingleTapRecognizer);
32
+ this.reset();
33
+ this.numTouches = options.numTouches;
34
+ }
35
+ _createClass(SingleTapRecognizer, [{
36
+ key: "reset",
37
+ value: function reset() {
38
+ // @ts-ignore
39
+ delete this.centroid;
40
+ // @ts-ignore
41
+ delete this.startTime;
42
+ // @ts-ignore
43
+ delete this.touches;
44
+ this.aborted = false;
45
+ }
46
+ }, {
47
+ key: "touchstart",
48
+ value: function touchstart(e, points, mapTouches) {
49
+ if (this.centroid || mapTouches.length > this.numTouches) {
50
+ this.aborted = true;
51
+ }
52
+ if (this.aborted) {
53
+ return;
54
+ }
55
+ if (this.startTime === undefined) {
56
+ this.startTime = e.timeStamp;
57
+ }
58
+ if (mapTouches.length === this.numTouches) {
59
+ this.centroid = getCentroid(points);
60
+ this.touches = indexTouches(mapTouches, points);
61
+ }
62
+ }
63
+ }, {
64
+ key: "touchmove",
65
+ value: function touchmove(e, points, mapTouches) {
66
+ if (this.aborted || !this.centroid) {
67
+ return;
68
+ }
69
+ var newTouches = indexTouches(mapTouches, points);
70
+ for (var id in this.touches) {
71
+ if (this.touches[id]) {
72
+ var prevPos = this.touches[id];
73
+ var pos = newTouches[id];
74
+ if (!pos || pos.dist(prevPos) > MAX_DIST) {
75
+ this.aborted = true;
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }, {
81
+ key: "touchend",
82
+ value: function touchend(e, points, mapTouches) {
83
+ if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) {
84
+ this.aborted = true;
85
+ }
86
+ if (mapTouches.length === 0) {
87
+ var centroid = !this.aborted && this.centroid;
88
+ this.reset();
89
+ if (centroid) {
90
+ return centroid;
91
+ }
92
+ }
93
+ }
94
+ }]);
95
+ return SingleTapRecognizer;
96
+ }();
97
+ export { SingleTapRecognizer as default };
@@ -0,0 +1,22 @@
1
+ import Point from '../../geo/point';
2
+ import TapRecognizer from './tap_recognizer';
3
+ export default class TapDragZoomHandler {
4
+ enabled: boolean;
5
+ active: boolean;
6
+ swipePoint: Point;
7
+ swipeTouch: number;
8
+ tapTime: number;
9
+ tap: TapRecognizer;
10
+ constructor();
11
+ reset(): void;
12
+ touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
13
+ touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): {
14
+ zoomDelta: number;
15
+ } | undefined;
16
+ touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
17
+ touchcancel(): void;
18
+ enable(): void;
19
+ disable(): void;
20
+ isEnabled(): boolean;
21
+ isActive(): boolean;
22
+ }
@@ -0,0 +1,106 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ // @ts-ignore
4
+
5
+ import { MAX_TAP_INTERVAL } from "./single_tap_recognizer";
6
+ import TapRecognizer from "./tap_recognizer";
7
+ var TapDragZoomHandler = /*#__PURE__*/function () {
8
+ function TapDragZoomHandler() {
9
+ _classCallCheck(this, TapDragZoomHandler);
10
+ this.tap = new TapRecognizer({
11
+ numTouches: 1,
12
+ numTaps: 1
13
+ });
14
+ this.reset();
15
+ }
16
+ _createClass(TapDragZoomHandler, [{
17
+ key: "reset",
18
+ value: function reset() {
19
+ this.active = false;
20
+ // @ts-ignore
21
+ delete this.swipePoint;
22
+ // @ts-ignore
23
+ delete this.swipeTouch;
24
+ // @ts-ignore
25
+ delete this.tapTime;
26
+ this.tap.reset();
27
+ }
28
+ }, {
29
+ key: "touchstart",
30
+ value: function touchstart(e, points, mapTouches) {
31
+ if (this.swipePoint) {
32
+ return;
33
+ }
34
+ if (this.tapTime && e.timeStamp - this.tapTime > MAX_TAP_INTERVAL) {
35
+ this.reset();
36
+ }
37
+ if (!this.tapTime) {
38
+ this.tap.touchstart(e, points, mapTouches);
39
+ } else if (mapTouches.length > 0) {
40
+ this.swipePoint = points[0];
41
+ this.swipeTouch = mapTouches[0].identifier;
42
+ }
43
+ }
44
+ }, {
45
+ key: "touchmove",
46
+ value: function touchmove(e, points, mapTouches) {
47
+ if (!this.tapTime) {
48
+ this.tap.touchmove(e, points, mapTouches);
49
+ } else if (this.swipePoint) {
50
+ if (mapTouches[0].identifier !== this.swipeTouch) {
51
+ return;
52
+ }
53
+ var newSwipePoint = points[0];
54
+ var dist = newSwipePoint.y - this.swipePoint.y;
55
+ this.swipePoint = newSwipePoint;
56
+ e.preventDefault();
57
+ this.active = true;
58
+ return {
59
+ zoomDelta: dist / 128
60
+ };
61
+ }
62
+ }
63
+ }, {
64
+ key: "touchend",
65
+ value: function touchend(e, points, mapTouches) {
66
+ if (!this.tapTime) {
67
+ var point = this.tap.touchend(e, points, mapTouches);
68
+ if (point) {
69
+ this.tapTime = e.timeStamp;
70
+ }
71
+ } else if (this.swipePoint) {
72
+ if (mapTouches.length === 0) {
73
+ this.reset();
74
+ }
75
+ }
76
+ }
77
+ }, {
78
+ key: "touchcancel",
79
+ value: function touchcancel() {
80
+ this.reset();
81
+ }
82
+ }, {
83
+ key: "enable",
84
+ value: function enable() {
85
+ this.enabled = true;
86
+ }
87
+ }, {
88
+ key: "disable",
89
+ value: function disable() {
90
+ this.enabled = false;
91
+ this.reset();
92
+ }
93
+ }, {
94
+ key: "isEnabled",
95
+ value: function isEnabled() {
96
+ return this.enabled;
97
+ }
98
+ }, {
99
+ key: "isActive",
100
+ value: function isActive() {
101
+ return this.active;
102
+ }
103
+ }]);
104
+ return TapDragZoomHandler;
105
+ }();
106
+ export { TapDragZoomHandler as default };
@@ -0,0 +1,17 @@
1
+ import Point from '../../geo/point';
2
+ import SingleTapRecognizer from './single_tap_recognizer';
3
+ export default class TapRecognizer {
4
+ singleTap: SingleTapRecognizer;
5
+ numTaps: number;
6
+ lastTime: number;
7
+ lastTap: Point;
8
+ count: number;
9
+ constructor(options: {
10
+ numTaps: number;
11
+ numTouches: number;
12
+ });
13
+ reset(): void;
14
+ touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
15
+ touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
16
+ touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): Point | undefined;
17
+ }
@@ -0,0 +1,54 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ // @ts-ignore
4
+
5
+ import SingleTapRecognizer, { MAX_DIST, MAX_TAP_INTERVAL } from "./single_tap_recognizer";
6
+ var TapRecognizer = /*#__PURE__*/function () {
7
+ function TapRecognizer(options) {
8
+ _classCallCheck(this, TapRecognizer);
9
+ this.singleTap = new SingleTapRecognizer(options);
10
+ this.numTaps = options.numTaps;
11
+ this.reset();
12
+ }
13
+ _createClass(TapRecognizer, [{
14
+ key: "reset",
15
+ value: function reset() {
16
+ this.lastTime = Infinity;
17
+ // @ts-ignore
18
+ delete this.lastTap;
19
+ this.count = 0;
20
+ this.singleTap.reset();
21
+ }
22
+ }, {
23
+ key: "touchstart",
24
+ value: function touchstart(e, points, mapTouches) {
25
+ this.singleTap.touchstart(e, points, mapTouches);
26
+ }
27
+ }, {
28
+ key: "touchmove",
29
+ value: function touchmove(e, points, mapTouches) {
30
+ this.singleTap.touchmove(e, points, mapTouches);
31
+ }
32
+ }, {
33
+ key: "touchend",
34
+ value: function touchend(e, points, mapTouches) {
35
+ var tap = this.singleTap.touchend(e, points, mapTouches);
36
+ if (tap) {
37
+ var soonEnough = e.timeStamp - this.lastTime < MAX_TAP_INTERVAL;
38
+ var closeEnough = !this.lastTap || this.lastTap.dist(tap) < MAX_DIST;
39
+ if (!soonEnough || !closeEnough) {
40
+ this.reset();
41
+ }
42
+ this.count++;
43
+ this.lastTime = e.timeStamp;
44
+ this.lastTap = tap;
45
+ if (this.count === this.numTaps) {
46
+ this.reset();
47
+ return tap;
48
+ }
49
+ }
50
+ }
51
+ }]);
52
+ return TapRecognizer;
53
+ }();
54
+ export { TapRecognizer as default };
@@ -0,0 +1,22 @@
1
+ import { EarthMap } from '../../earthmap';
2
+ import Point from '../../geo/point';
3
+ import { Map } from '../../map';
4
+ import TapRecognizer from './tap_recognizer';
5
+ export default class TapZoomHandler {
6
+ enabled: boolean;
7
+ active: boolean;
8
+ zoomIn: TapRecognizer;
9
+ zoomOut: TapRecognizer;
10
+ constructor();
11
+ reset(): void;
12
+ touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
13
+ touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
14
+ touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): {
15
+ cameraAnimation: (map: Map | EarthMap) => Map | EarthMap;
16
+ } | undefined;
17
+ touchcancel(): void;
18
+ enable(): void;
19
+ disable(): void;
20
+ isEnabled(): boolean;
21
+ isActive(): boolean;
22
+ }