@antv/l7-map 2.9.32-alpha.2 → 2.9.33

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 +84 -0
  2. package/es/camera.js +765 -0
  3. package/es/css/l7.css +98 -0
  4. package/es/earthmap.d.ts +66 -0
  5. package/es/earthmap.js +421 -0
  6. package/es/geo/edge_insets.d.ts +54 -0
  7. package/es/geo/edge_insets.js +118 -0
  8. package/es/geo/lng_lat.d.ts +18 -0
  9. package/es/geo/lng_lat.js +81 -0
  10. package/es/geo/lng_lat_bounds.d.ts +24 -0
  11. package/es/geo/lng_lat_bounds.js +167 -0
  12. package/es/geo/mercator.d.ts +28 -0
  13. package/es/geo/mercator.js +91 -0
  14. package/es/geo/point.d.ts +40 -0
  15. package/es/geo/point.js +231 -0
  16. package/es/geo/simple.d.ts +28 -0
  17. package/es/geo/simple.js +90 -0
  18. package/es/geo/transform.d.ts +198 -0
  19. package/es/geo/transform.js +971 -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 +83 -0
  24. package/es/handler/box_zoom.d.ts +59 -0
  25. package/es/handler/box_zoom.js +200 -0
  26. package/es/handler/click_zoom.d.ts +16 -0
  27. package/es/handler/click_zoom.js +59 -0
  28. package/es/handler/events/event.d.ts +4 -0
  29. package/es/handler/events/event.js +12 -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 +75 -0
  34. package/es/handler/events/map_touch_event.d.ts +57 -0
  35. package/es/handler/events/map_touch_event.js +105 -0
  36. package/es/handler/events/map_wheel_event.d.ts +33 -0
  37. package/es/handler/events/map_wheel_event.js +61 -0
  38. package/es/handler/events/render_event.d.ts +5 -0
  39. package/es/handler/events/render_event.js +39 -0
  40. package/es/handler/handler_inertia.d.ts +23 -0
  41. package/es/handler/handler_inertia.js +184 -0
  42. package/es/handler/handler_manager.d.ts +61 -0
  43. package/es/handler/handler_manager.js +684 -0
  44. package/es/handler/handler_util.d.ts +4 -0
  45. package/es/handler/handler_util.js +10 -0
  46. package/es/handler/keyboard.d.ts +36 -0
  47. package/es/handler/keyboard.js +162 -0
  48. package/es/handler/map_event.d.ts +29 -0
  49. package/es/handler/map_event.js +131 -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 +129 -0
  54. package/es/handler/mouse/mousepan_handler.d.ts +10 -0
  55. package/es/handler/mouse/mousepan_handler.js +54 -0
  56. package/es/handler/mouse/mousepitch_hander.d.ts +9 -0
  57. package/es/handler/mouse/mousepitch_hander.js +56 -0
  58. package/es/handler/mouse/mouserotate_hander.d.ts +9 -0
  59. package/es/handler/mouse/mouserotate_hander.js +56 -0
  60. package/es/handler/mouse/util.d.ts +6 -0
  61. package/es/handler/mouse/util.js +12 -0
  62. package/es/handler/scroll_zoom.d.ts +93 -0
  63. package/es/handler/scroll_zoom.js +353 -0
  64. package/es/handler/shim/dblclick_zoom.d.ts +40 -0
  65. package/es/handler/shim/dblclick_zoom.js +72 -0
  66. package/es/handler/shim/drag_pan.d.ts +61 -0
  67. package/es/handler/shim/drag_pan.js +96 -0
  68. package/es/handler/shim/drag_rotate.d.ts +46 -0
  69. package/es/handler/shim/drag_rotate.js +80 -0
  70. package/es/handler/shim/touch_zoom_rotate.d.ts +70 -0
  71. package/es/handler/shim/touch_zoom_rotate.js +130 -0
  72. package/es/handler/tap/single_tap_recognizer.d.ts +20 -0
  73. package/es/handler/tap/single_tap_recognizer.js +120 -0
  74. package/es/handler/tap/tap_drag_zoom.d.ts +22 -0
  75. package/es/handler/tap/tap_drag_zoom.js +114 -0
  76. package/es/handler/tap/tap_recognizer.d.ts +17 -0
  77. package/es/handler/tap/tap_recognizer.js +62 -0
  78. package/es/handler/tap/tap_zoom.d.ts +22 -0
  79. package/es/handler/tap/tap_zoom.js +115 -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 +128 -0
  84. package/es/handler/touch/touch_pitch.d.ts +13 -0
  85. package/es/handler/touch/touch_pitch.js +110 -0
  86. package/es/handler/touch/touch_rotate.d.ts +12 -0
  87. package/es/handler/touch/touch_rotate.js +88 -0
  88. package/es/handler/touch/touch_zoom.d.ts +12 -0
  89. package/es/handler/touch/touch_zoom.js +67 -0
  90. package/es/handler/touch/two_touch.d.ts +23 -0
  91. package/es/handler/touch/two_touch.js +134 -0
  92. package/es/hash.d.ts +14 -0
  93. package/es/hash.js +156 -0
  94. package/es/index.d.ts +3 -0
  95. package/es/index.js +3 -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 +463 -0
  100. package/es/util.d.ts +18 -0
  101. package/es/util.js +84 -0
  102. package/es/utils/Aabb.d.ts +12 -0
  103. package/es/utils/Aabb.js +133 -0
  104. package/es/utils/dom.d.ts +4 -0
  105. package/es/utils/dom.js +218 -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 +45 -0
  110. package/es/utils/task_queue.d.ts +13 -0
  111. package/es/utils/task_queue.js +106 -0
  112. package/lib/camera.js +533 -0
  113. package/lib/css/l7.css +98 -0
  114. package/lib/earthmap.js +278 -0
  115. package/lib/geo/edge_insets.js +76 -0
  116. package/lib/geo/lng_lat.js +73 -0
  117. package/lib/geo/lng_lat_bounds.js +138 -0
  118. package/lib/geo/mercator.js +91 -0
  119. package/lib/geo/point.js +176 -0
  120. package/lib/geo/simple.js +87 -0
  121. package/lib/geo/transform.js +503 -0
  122. package/lib/handler/IHandler.js +17 -0
  123. package/lib/handler/blockable_map_event.js +71 -0
  124. package/lib/handler/box_zoom.js +139 -0
  125. package/lib/handler/click_zoom.js +59 -0
  126. package/lib/handler/events/event.js +38 -0
  127. package/lib/handler/events/index.js +38 -0
  128. package/lib/handler/events/map_mouse_event.js +44 -0
  129. package/lib/handler/events/map_touch_event.js +48 -0
  130. package/lib/handler/events/map_wheel_event.js +36 -0
  131. package/lib/handler/events/render_event.js +33 -0
  132. package/lib/handler/handler_inertia.js +149 -0
  133. package/lib/handler/handler_manager.js +455 -0
  134. package/lib/handler/handler_util.js +35 -0
  135. package/lib/handler/keyboard.js +131 -0
  136. package/lib/handler/map_event.js +91 -0
  137. package/lib/handler/mouse/index.js +38 -0
  138. package/lib/handler/mouse/mouse_handler.js +103 -0
  139. package/lib/handler/mouse/mousepan_handler.js +48 -0
  140. package/lib/handler/mouse/mousepitch_hander.js +47 -0
  141. package/lib/handler/mouse/mouserotate_hander.js +47 -0
  142. package/lib/handler/mouse/util.js +44 -0
  143. package/lib/handler/scroll_zoom.js +225 -0
  144. package/lib/handler/shim/dblclick_zoom.js +46 -0
  145. package/lib/handler/shim/drag_pan.js +55 -0
  146. package/lib/handler/shim/drag_rotate.js +49 -0
  147. package/lib/handler/shim/touch_zoom_rotate.js +71 -0
  148. package/lib/handler/tap/single_tap_recognizer.js +102 -0
  149. package/lib/handler/tap/tap_drag_zoom.js +106 -0
  150. package/lib/handler/tap/tap_recognizer.js +66 -0
  151. package/lib/handler/tap/tap_zoom.js +99 -0
  152. package/lib/handler/touch/index.js +41 -0
  153. package/lib/handler/touch/touch_pan.js +110 -0
  154. package/lib/handler/touch/touch_pitch.js +86 -0
  155. package/lib/handler/touch/touch_rotate.js +65 -0
  156. package/lib/handler/touch/touch_zoom.js +56 -0
  157. package/lib/handler/touch/two_touch.js +105 -0
  158. package/lib/hash.js +120 -0
  159. package/lib/index.js +21 -0
  160. package/lib/interface.js +17 -0
  161. package/lib/map.js +308 -0
  162. package/lib/util.js +97 -0
  163. package/lib/utils/Aabb.js +90 -0
  164. package/lib/utils/dom.js +159 -0
  165. package/lib/utils/performance.js +80 -0
  166. package/lib/utils/primitives.js +63 -0
  167. package/lib/utils/task_queue.js +72 -0
  168. package/package.json +3 -3
@@ -0,0 +1,96 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import { isMini } from '@antv/l7-utils';
4
+
5
+ /**
6
+ * The `DragPanHandler` allows the user to pan the map by clicking and dragging
7
+ * the cursor.
8
+ */
9
+ var DragPanHandler = /*#__PURE__*/function () {
10
+ /**
11
+ * @private
12
+ */
13
+ function DragPanHandler(el, mousePan, touchPan) {
14
+ _classCallCheck(this, DragPanHandler);
15
+
16
+ this.el = el;
17
+ this.mousePan = mousePan;
18
+ this.touchPan = touchPan;
19
+ }
20
+ /**
21
+ * Enables the "drag to pan" interaction.
22
+ *
23
+ * @param {Object} [options] Options object
24
+ * @param {number} [options.linearity=0] factor used to scale the drag velocity
25
+ * @param {Function} [options.easing=bezier(0, 0, 0.3, 1)] easing function applled to `map.panTo` when applying the drag.
26
+ * @param {number} [options.maxSpeed=1400] the maximum value of the drag velocity.
27
+ * @param {number} [options.deceleration=2500] the rate at which the speed reduces after the pan ends.
28
+ *
29
+ * @example
30
+ * map.dragPan.enable();
31
+ * @example
32
+ * map.dragPan.enable({
33
+ * linearity: 0.3,
34
+ * easing: bezier(0, 0, 0.3, 1),
35
+ * maxSpeed: 1400,
36
+ * deceleration: 2500,
37
+ * });
38
+ */
39
+
40
+
41
+ _createClass(DragPanHandler, [{
42
+ key: "enable",
43
+ value: function enable(options) {
44
+ this.inertiaOptions = options || {};
45
+ this.mousePan.enable();
46
+ this.touchPan.enable();
47
+
48
+ if (!isMini) {
49
+ this.el.classList.add('l7-touch-drag-pan');
50
+ }
51
+ }
52
+ /**
53
+ * Disables the "drag to pan" interaction.
54
+ *
55
+ * @example
56
+ * map.dragPan.disable();
57
+ */
58
+
59
+ }, {
60
+ key: "disable",
61
+ value: function disable() {
62
+ this.mousePan.disable();
63
+ this.touchPan.disable();
64
+
65
+ if (!isMini) {
66
+ this.el.classList.remove('l7-touch-drag-pan');
67
+ }
68
+ }
69
+ /**
70
+ * Returns a Boolean indicating whether the "drag to pan" interaction is enabled.
71
+ *
72
+ * @returns {boolean} `true` if the "drag to pan" interaction is enabled.
73
+ */
74
+
75
+ }, {
76
+ key: "isEnabled",
77
+ value: function isEnabled() {
78
+ return this.mousePan.isEnabled() && this.touchPan.isEnabled();
79
+ }
80
+ /**
81
+ * Returns a Boolean indicating whether the "drag to pan" interaction is active, i.e. currently being used.
82
+ *
83
+ * @returns {boolean} `true` if the "drag to pan" interaction is active.
84
+ */
85
+
86
+ }, {
87
+ key: "isActive",
88
+ value: function isActive() {
89
+ return this.mousePan.isActive() || this.touchPan.isActive();
90
+ }
91
+ }]);
92
+
93
+ return DragPanHandler;
94
+ }();
95
+
96
+ export { DragPanHandler as default };
@@ -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,80 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+
4
+ /**
5
+ * The `DragRotateHandler` allows the user to rotate the map by clicking and
6
+ * dragging the cursor while holding the right mouse button or `ctrl` key.
7
+ */
8
+ var DragRotateHandler = /*#__PURE__*/function () {
9
+ /**
10
+ * @param {Object} [options]
11
+ * @param {number} [options.bearingSnap] The threshold, measured in degrees, that determines when the map's
12
+ * bearing will snap to north.
13
+ * @param {bool} [options.pitchWithRotate=true] Control the map pitch in addition to the bearing
14
+ * @private
15
+ */
16
+ function DragRotateHandler(options, mouseRotate, mousePitch) {
17
+ _classCallCheck(this, DragRotateHandler);
18
+
19
+ this.pitchWithRotate = options.pitchWithRotate;
20
+ this.mouseRotate = mouseRotate;
21
+ this.mousePitch = mousePitch;
22
+ }
23
+ /**
24
+ * Enables the "drag to rotate" interaction.
25
+ *
26
+ * @example
27
+ * map.dragRotate.enable();
28
+ */
29
+
30
+
31
+ _createClass(DragRotateHandler, [{
32
+ key: "enable",
33
+ value: function enable() {
34
+ this.mouseRotate.enable();
35
+
36
+ if (this.pitchWithRotate) {
37
+ this.mousePitch.enable();
38
+ }
39
+ }
40
+ /**
41
+ * Disables the "drag to rotate" interaction.
42
+ *
43
+ * @example
44
+ * map.dragRotate.disable();
45
+ */
46
+
47
+ }, {
48
+ key: "disable",
49
+ value: function disable() {
50
+ this.mouseRotate.disable();
51
+ this.mousePitch.disable();
52
+ }
53
+ /**
54
+ * Returns a Boolean indicating whether the "drag to rotate" interaction is enabled.
55
+ *
56
+ * @returns {boolean} `true` if the "drag to rotate" interaction is enabled.
57
+ */
58
+
59
+ }, {
60
+ key: "isEnabled",
61
+ value: function isEnabled() {
62
+ return this.mouseRotate.isEnabled() && (!this.pitchWithRotate || this.mousePitch.isEnabled());
63
+ }
64
+ /**
65
+ * Returns a Boolean indicating whether the "drag to rotate" interaction is active, i.e. currently being used.
66
+ *
67
+ * @returns {boolean} `true` if the "drag to rotate" interaction is active.
68
+ */
69
+
70
+ }, {
71
+ key: "isActive",
72
+ value: function isActive() {
73
+ return this.mouseRotate.isActive() || this.mousePitch.isActive();
74
+ }
75
+ }]);
76
+
77
+ return DragRotateHandler;
78
+ }();
79
+
80
+ 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,130 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import { isMini } from '@antv/l7-utils';
4
+
5
+ /**
6
+ * The `TouchZoomRotateHandler` allows the user to zoom and rotate the map by
7
+ * pinching on a touchscreen.
8
+ *
9
+ * They can zoom with one finger by double tapping and dragging. On the second tap,
10
+ * hold the finger down and drag up or down to zoom in or out.
11
+ */
12
+ var TouchZoomRotateHandler = /*#__PURE__*/function () {
13
+ /**
14
+ * @private
15
+ */
16
+ function TouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom) {
17
+ _classCallCheck(this, TouchZoomRotateHandler);
18
+
19
+ this.el = el;
20
+ this.touchZoom = touchZoom;
21
+ this.touchRotate = touchRotate;
22
+ this.tapDragZoom = tapDragZoom;
23
+ this.rotationDisabled = false;
24
+ this.enabled = true;
25
+ }
26
+ /**
27
+ * Enables the "pinch to rotate and zoom" interaction.
28
+ *
29
+ * @param {Object} [options] Options object.
30
+ * @param {string} [options.around] If "center" is passed, map will zoom around the center
31
+ *
32
+ * @example
33
+ * map.touchZoomRotate.enable();
34
+ * @example
35
+ * map.touchZoomRotate.enable({ around: 'center' });
36
+ */
37
+
38
+
39
+ _createClass(TouchZoomRotateHandler, [{
40
+ key: "enable",
41
+ value: function enable(options) {
42
+ this.touchZoom.enable(options);
43
+
44
+ if (!this.rotationDisabled) {
45
+ this.touchRotate.enable(options);
46
+ }
47
+
48
+ this.tapDragZoom.enable();
49
+
50
+ if (!isMini) {
51
+ this.el.classList.add('l7-touch-zoom-rotate');
52
+ }
53
+ }
54
+ /**
55
+ * Disables the "pinch to rotate and zoom" interaction.
56
+ *
57
+ * @example
58
+ * map.touchZoomRotate.disable();
59
+ */
60
+
61
+ }, {
62
+ key: "disable",
63
+ value: function disable() {
64
+ this.touchZoom.disable();
65
+ this.touchRotate.disable();
66
+ this.tapDragZoom.disable();
67
+
68
+ if (!isMini) {
69
+ this.el.classList.remove('l7-touch-zoom-rotate');
70
+ }
71
+ }
72
+ /**
73
+ * Returns a Boolean indicating whether the "pinch to rotate and zoom" interaction is enabled.
74
+ *
75
+ * @returns {boolean} `true` if the "pinch to rotate and zoom" interaction is enabled.
76
+ */
77
+
78
+ }, {
79
+ key: "isEnabled",
80
+ value: function isEnabled() {
81
+ return this.touchZoom.isEnabled() && (this.rotationDisabled || this.touchRotate.isEnabled()) && this.tapDragZoom.isEnabled();
82
+ }
83
+ /**
84
+ * Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.
85
+ *
86
+ * @returns {boolean} //eslint-disable-line
87
+ */
88
+
89
+ }, {
90
+ key: "isActive",
91
+ value: function isActive() {
92
+ return this.touchZoom.isActive() || this.touchRotate.isActive() || this.tapDragZoom.isActive();
93
+ }
94
+ /**
95
+ * Disables the "pinch to rotate" interaction, leaving the "pinch to zoom"
96
+ * interaction enabled.
97
+ *
98
+ * @example
99
+ * map.touchZoomRotate.disableRotation();
100
+ */
101
+
102
+ }, {
103
+ key: "disableRotation",
104
+ value: function disableRotation() {
105
+ this.rotationDisabled = true;
106
+ this.touchRotate.disable();
107
+ }
108
+ /**
109
+ * Enables the "pinch to rotate" interaction.
110
+ *
111
+ * @example
112
+ * map.touchZoomRotate.enable();
113
+ * map.touchZoomRotate.enableRotation();
114
+ */
115
+
116
+ }, {
117
+ key: "enableRotation",
118
+ value: function enableRotation() {
119
+ this.rotationDisabled = false;
120
+
121
+ if (this.touchZoom.isEnabled()) {
122
+ this.touchRotate.enable();
123
+ }
124
+ }
125
+ }]);
126
+
127
+ return TouchZoomRotateHandler;
128
+ }();
129
+
130
+ 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,120 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+
4
+ 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; } } }; }
5
+
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
+
8
+ 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; }
9
+
10
+ // @ts-ignore
11
+ import Point from "../../geo/point";
12
+ import { indexTouches } from "../handler_util";
13
+
14
+ function getCentroid(points) {
15
+ var sum = new Point(0, 0);
16
+
17
+ var _iterator = _createForOfIteratorHelper(points),
18
+ _step;
19
+
20
+ try {
21
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
22
+ var point = _step.value;
23
+
24
+ sum._add(point);
25
+ } // @ts-ignore
26
+
27
+ } catch (err) {
28
+ _iterator.e(err);
29
+ } finally {
30
+ _iterator.f();
31
+ }
32
+
33
+ return sum.div(points.length);
34
+ }
35
+
36
+ export var MAX_TAP_INTERVAL = 500;
37
+ export var MAX_TOUCH_TIME = 500;
38
+ export var MAX_DIST = 30;
39
+
40
+ var SingleTapRecognizer = /*#__PURE__*/function () {
41
+ function SingleTapRecognizer(options) {
42
+ _classCallCheck(this, SingleTapRecognizer);
43
+
44
+ this.reset();
45
+ this.numTouches = options.numTouches;
46
+ }
47
+
48
+ _createClass(SingleTapRecognizer, [{
49
+ key: "reset",
50
+ value: function reset() {
51
+ //@ts-ignore
52
+ delete this.centroid; //@ts-ignore
53
+
54
+ delete this.startTime; //@ts-ignore
55
+
56
+ delete this.touches;
57
+ this.aborted = false;
58
+ }
59
+ }, {
60
+ key: "touchstart",
61
+ value: function touchstart(e, points, mapTouches) {
62
+ if (this.centroid || mapTouches.length > this.numTouches) {
63
+ this.aborted = true;
64
+ }
65
+
66
+ if (this.aborted) {
67
+ return;
68
+ }
69
+
70
+ if (this.startTime === undefined) {
71
+ this.startTime = e.timeStamp;
72
+ }
73
+
74
+ if (mapTouches.length === this.numTouches) {
75
+ this.centroid = getCentroid(points);
76
+ this.touches = indexTouches(mapTouches, points);
77
+ }
78
+ }
79
+ }, {
80
+ key: "touchmove",
81
+ value: function touchmove(e, points, mapTouches) {
82
+ if (this.aborted || !this.centroid) {
83
+ return;
84
+ }
85
+
86
+ var newTouches = indexTouches(mapTouches, points);
87
+
88
+ for (var id in this.touches) {
89
+ if (this.touches[id]) {
90
+ var prevPos = this.touches[id];
91
+ var pos = newTouches[id];
92
+
93
+ if (!pos || pos.dist(prevPos) > MAX_DIST) {
94
+ this.aborted = true;
95
+ }
96
+ }
97
+ }
98
+ }
99
+ }, {
100
+ key: "touchend",
101
+ value: function touchend(e, points, mapTouches) {
102
+ if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) {
103
+ this.aborted = true;
104
+ }
105
+
106
+ if (mapTouches.length === 0) {
107
+ var centroid = !this.aborted && this.centroid;
108
+ this.reset();
109
+
110
+ if (centroid) {
111
+ return centroid;
112
+ }
113
+ }
114
+ }
115
+ }]);
116
+
117
+ return SingleTapRecognizer;
118
+ }();
119
+
120
+ 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,114 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ // @ts-ignore
4
+ import { MAX_TAP_INTERVAL } from "./single_tap_recognizer";
5
+ import TapRecognizer from "./tap_recognizer";
6
+
7
+ var TapDragZoomHandler = /*#__PURE__*/function () {
8
+ function TapDragZoomHandler() {
9
+ _classCallCheck(this, TapDragZoomHandler);
10
+
11
+ this.tap = new TapRecognizer({
12
+ numTouches: 1,
13
+ numTaps: 1
14
+ });
15
+ this.reset();
16
+ }
17
+
18
+ _createClass(TapDragZoomHandler, [{
19
+ key: "reset",
20
+ value: function reset() {
21
+ this.active = false; //@ts-ignore
22
+
23
+ delete this.swipePoint; //@ts-ignore
24
+
25
+ delete this.swipeTouch; //@ts-ignore
26
+
27
+ delete this.tapTime;
28
+ this.tap.reset();
29
+ }
30
+ }, {
31
+ key: "touchstart",
32
+ value: function touchstart(e, points, mapTouches) {
33
+ if (this.swipePoint) {
34
+ return;
35
+ }
36
+
37
+ if (this.tapTime && e.timeStamp - this.tapTime > MAX_TAP_INTERVAL) {
38
+ this.reset();
39
+ }
40
+
41
+ if (!this.tapTime) {
42
+ this.tap.touchstart(e, points, mapTouches);
43
+ } else if (mapTouches.length > 0) {
44
+ this.swipePoint = points[0];
45
+ this.swipeTouch = mapTouches[0].identifier;
46
+ }
47
+ }
48
+ }, {
49
+ key: "touchmove",
50
+ value: function touchmove(e, points, mapTouches) {
51
+ if (!this.tapTime) {
52
+ this.tap.touchmove(e, points, mapTouches);
53
+ } else if (this.swipePoint) {
54
+ if (mapTouches[0].identifier !== this.swipeTouch) {
55
+ return;
56
+ }
57
+
58
+ var newSwipePoint = points[0];
59
+ var dist = newSwipePoint.y - this.swipePoint.y;
60
+ this.swipePoint = newSwipePoint;
61
+ e.preventDefault();
62
+ this.active = true;
63
+ return {
64
+ zoomDelta: dist / 128
65
+ };
66
+ }
67
+ }
68
+ }, {
69
+ key: "touchend",
70
+ value: function touchend(e, points, mapTouches) {
71
+ if (!this.tapTime) {
72
+ var point = this.tap.touchend(e, points, mapTouches);
73
+
74
+ if (point) {
75
+ this.tapTime = e.timeStamp;
76
+ }
77
+ } else if (this.swipePoint) {
78
+ if (mapTouches.length === 0) {
79
+ this.reset();
80
+ }
81
+ }
82
+ }
83
+ }, {
84
+ key: "touchcancel",
85
+ value: function touchcancel() {
86
+ this.reset();
87
+ }
88
+ }, {
89
+ key: "enable",
90
+ value: function enable() {
91
+ this.enabled = true;
92
+ }
93
+ }, {
94
+ key: "disable",
95
+ value: function disable() {
96
+ this.enabled = false;
97
+ this.reset();
98
+ }
99
+ }, {
100
+ key: "isEnabled",
101
+ value: function isEnabled() {
102
+ return this.enabled;
103
+ }
104
+ }, {
105
+ key: "isActive",
106
+ value: function isActive() {
107
+ return this.active;
108
+ }
109
+ }]);
110
+
111
+ return TapDragZoomHandler;
112
+ }();
113
+
114
+ export { TapDragZoomHandler as default };