@antv/l7-map 2.25.7 → 2.25.10

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 (159) hide show
  1. package/es/index.d.ts +5 -0
  2. package/es/index.js +4 -0
  3. package/es/map/camera.d.ts +690 -0
  4. package/es/map/camera.js +1138 -0
  5. package/es/map/css/l7.css +171 -0
  6. package/es/map/events.d.ts +384 -0
  7. package/es/map/events.js +231 -0
  8. package/es/map/geo/edge_insets.d.ts +97 -0
  9. package/es/map/geo/edge_insets.js +115 -0
  10. package/es/map/geo/lng_lat.d.ts +116 -0
  11. package/es/map/geo/lng_lat.js +159 -0
  12. package/es/map/geo/lng_lat_bounds.d.ts +217 -0
  13. package/es/map/geo/lng_lat_bounds.js +334 -0
  14. package/es/map/geo/mercator_coordinate.d.ts +113 -0
  15. package/es/map/geo/mercator_coordinate.js +142 -0
  16. package/es/map/geo/transform.d.ts +262 -0
  17. package/es/map/geo/transform.js +736 -0
  18. package/es/map/handler/box_zoom.d.ts +65 -0
  19. package/es/map/handler/box_zoom.js +145 -0
  20. package/es/map/handler/click_zoom.d.ts +24 -0
  21. package/es/map/handler/click_zoom.js +47 -0
  22. package/es/map/handler/cooperative_gestures.d.ts +40 -0
  23. package/es/map/handler/cooperative_gestures.js +94 -0
  24. package/es/map/handler/drag_handler.d.ts +88 -0
  25. package/es/map/handler/drag_handler.js +89 -0
  26. package/es/map/handler/drag_move_state_manager.d.ts +30 -0
  27. package/es/map/handler/drag_move_state_manager.js +94 -0
  28. package/es/map/handler/handler_util.d.ts +3 -0
  29. package/es/map/handler/handler_util.js +8 -0
  30. package/es/map/handler/keyboard.d.ts +88 -0
  31. package/es/map/handler/keyboard.js +197 -0
  32. package/es/map/handler/map_event.d.ts +46 -0
  33. package/es/map/handler/map_event.js +131 -0
  34. package/es/map/handler/mouse.d.ts +30 -0
  35. package/es/map/handler/mouse.js +85 -0
  36. package/es/map/handler/one_finger_touch_drag.d.ts +15 -0
  37. package/es/map/handler/one_finger_touch_drag.js +39 -0
  38. package/es/map/handler/scroll_zoom.d.ts +102 -0
  39. package/es/map/handler/scroll_zoom.js +312 -0
  40. package/es/map/handler/shim/dblclick_zoom.d.ts +44 -0
  41. package/es/map/handler/shim/dblclick_zoom.js +60 -0
  42. package/es/map/handler/shim/drag_pan.d.ts +79 -0
  43. package/es/map/handler/shim/drag_pan.js +77 -0
  44. package/es/map/handler/shim/drag_rotate.d.ts +54 -0
  45. package/es/map/handler/shim/drag_rotate.js +66 -0
  46. package/es/map/handler/shim/two_fingers_touch.d.ts +74 -0
  47. package/es/map/handler/shim/two_fingers_touch.js +106 -0
  48. package/es/map/handler/tap_drag_zoom.d.ts +28 -0
  49. package/es/map/handler/tap_drag_zoom.js +92 -0
  50. package/es/map/handler/tap_recognizer.d.ts +35 -0
  51. package/es/map/handler/tap_recognizer.js +107 -0
  52. package/es/map/handler/tap_zoom.d.ts +28 -0
  53. package/es/map/handler/tap_zoom.js +87 -0
  54. package/es/map/handler/touch_pan.d.ts +40 -0
  55. package/es/map/handler/touch_pan.js +85 -0
  56. package/es/map/handler/transform-provider.d.ts +23 -0
  57. package/es/map/handler/transform-provider.js +35 -0
  58. package/es/map/handler/two_fingers_touch.d.ts +107 -0
  59. package/es/map/handler/two_fingers_touch.js +289 -0
  60. package/es/map/handler_inertia.d.ts +20 -0
  61. package/es/map/handler_inertia.js +128 -0
  62. package/es/map/handler_manager.d.ts +154 -0
  63. package/es/map/handler_manager.js +466 -0
  64. package/es/map/map.d.ts +637 -0
  65. package/es/map/map.js +984 -0
  66. package/es/map/util/abort_error.d.ts +15 -0
  67. package/es/map/util/abort_error.js +21 -0
  68. package/es/map/util/browser.d.ts +10 -0
  69. package/es/map/util/browser.js +30 -0
  70. package/es/map/util/dom.d.ts +30 -0
  71. package/es/map/util/dom.js +105 -0
  72. package/es/map/util/evented.d.ts +75 -0
  73. package/es/map/util/evented.js +158 -0
  74. package/es/map/util/simpleMapCoord.d.ts +31 -0
  75. package/es/map/util/simpleMapCoord.js +54 -0
  76. package/es/map/util/task_queue.d.ts +18 -0
  77. package/es/map/util/task_queue.js +54 -0
  78. package/es/map/util/util.d.ts +104 -0
  79. package/es/map/util/util.js +155 -0
  80. package/lib/index.d.ts +5 -0
  81. package/lib/index.js +33 -0
  82. package/lib/map/camera.d.ts +690 -0
  83. package/lib/map/camera.js +1145 -0
  84. package/lib/map/css/l7.css +171 -0
  85. package/lib/map/events.d.ts +384 -0
  86. package/lib/map/events.js +240 -0
  87. package/lib/map/geo/edge_insets.d.ts +97 -0
  88. package/lib/map/geo/edge_insets.js +122 -0
  89. package/lib/map/geo/lng_lat.d.ts +116 -0
  90. package/lib/map/geo/lng_lat.js +166 -0
  91. package/lib/map/geo/lng_lat_bounds.d.ts +217 -0
  92. package/lib/map/geo/lng_lat_bounds.js +341 -0
  93. package/lib/map/geo/mercator_coordinate.d.ts +113 -0
  94. package/lib/map/geo/mercator_coordinate.js +157 -0
  95. package/lib/map/geo/transform.d.ts +262 -0
  96. package/lib/map/geo/transform.js +744 -0
  97. package/lib/map/handler/box_zoom.d.ts +65 -0
  98. package/lib/map/handler/box_zoom.js +153 -0
  99. package/lib/map/handler/click_zoom.d.ts +24 -0
  100. package/lib/map/handler/click_zoom.js +54 -0
  101. package/lib/map/handler/cooperative_gestures.d.ts +40 -0
  102. package/lib/map/handler/cooperative_gestures.js +101 -0
  103. package/lib/map/handler/drag_handler.d.ts +88 -0
  104. package/lib/map/handler/drag_handler.js +97 -0
  105. package/lib/map/handler/drag_move_state_manager.d.ts +30 -0
  106. package/lib/map/handler/drag_move_state_manager.js +103 -0
  107. package/lib/map/handler/handler_util.d.ts +3 -0
  108. package/lib/map/handler/handler_util.js +14 -0
  109. package/lib/map/handler/keyboard.d.ts +88 -0
  110. package/lib/map/handler/keyboard.js +205 -0
  111. package/lib/map/handler/map_event.d.ts +46 -0
  112. package/lib/map/handler/map_event.js +140 -0
  113. package/lib/map/handler/mouse.d.ts +30 -0
  114. package/lib/map/handler/mouse.js +93 -0
  115. package/lib/map/handler/one_finger_touch_drag.d.ts +15 -0
  116. package/lib/map/handler/one_finger_touch_drag.js +47 -0
  117. package/lib/map/handler/scroll_zoom.d.ts +102 -0
  118. package/lib/map/handler/scroll_zoom.js +320 -0
  119. package/lib/map/handler/shim/dblclick_zoom.d.ts +44 -0
  120. package/lib/map/handler/shim/dblclick_zoom.js +68 -0
  121. package/lib/map/handler/shim/drag_pan.d.ts +79 -0
  122. package/lib/map/handler/shim/drag_pan.js +85 -0
  123. package/lib/map/handler/shim/drag_rotate.d.ts +54 -0
  124. package/lib/map/handler/shim/drag_rotate.js +74 -0
  125. package/lib/map/handler/shim/two_fingers_touch.d.ts +74 -0
  126. package/lib/map/handler/shim/two_fingers_touch.js +114 -0
  127. package/lib/map/handler/tap_drag_zoom.d.ts +28 -0
  128. package/lib/map/handler/tap_drag_zoom.js +99 -0
  129. package/lib/map/handler/tap_recognizer.d.ts +35 -0
  130. package/lib/map/handler/tap_recognizer.js +116 -0
  131. package/lib/map/handler/tap_zoom.d.ts +28 -0
  132. package/lib/map/handler/tap_zoom.js +94 -0
  133. package/lib/map/handler/touch_pan.d.ts +40 -0
  134. package/lib/map/handler/touch_pan.js +92 -0
  135. package/lib/map/handler/transform-provider.d.ts +23 -0
  136. package/lib/map/handler/transform-provider.js +43 -0
  137. package/lib/map/handler/two_fingers_touch.d.ts +107 -0
  138. package/lib/map/handler/two_fingers_touch.js +296 -0
  139. package/lib/map/handler_inertia.d.ts +20 -0
  140. package/lib/map/handler_inertia.js +136 -0
  141. package/lib/map/handler_manager.d.ts +154 -0
  142. package/lib/map/handler_manager.js +474 -0
  143. package/lib/map/map.d.ts +637 -0
  144. package/lib/map/map.js +991 -0
  145. package/lib/map/util/abort_error.d.ts +15 -0
  146. package/lib/map/util/abort_error.js +29 -0
  147. package/lib/map/util/browser.d.ts +10 -0
  148. package/lib/map/util/browser.js +36 -0
  149. package/lib/map/util/dom.d.ts +30 -0
  150. package/lib/map/util/dom.js +113 -0
  151. package/lib/map/util/evented.d.ts +75 -0
  152. package/lib/map/util/evented.js +167 -0
  153. package/lib/map/util/simpleMapCoord.d.ts +31 -0
  154. package/lib/map/util/simpleMapCoord.js +62 -0
  155. package/lib/map/util/task_queue.d.ts +18 -0
  156. package/lib/map/util/task_queue.js +62 -0
  157. package/lib/map/util/util.d.ts +104 -0
  158. package/lib/map/util/util.js +171 -0
  159. package/package.json +2 -2
@@ -0,0 +1,77 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ /**
3
+ * A {@link DragPanHandler} options object
4
+ */
5
+
6
+ /**
7
+ * The `DragPanHandler` allows the user to pan the map by clicking and dragging
8
+ * the cursor.
9
+ *
10
+ * @group Handlers
11
+ */
12
+ export class DragPanHandler {
13
+ /** @internal */
14
+ constructor(el, mousePan, touchPan) {
15
+ _defineProperty(this, "_el", void 0);
16
+ _defineProperty(this, "_mousePan", void 0);
17
+ _defineProperty(this, "_touchPan", void 0);
18
+ _defineProperty(this, "_inertiaOptions", void 0);
19
+ this._el = el;
20
+ this._mousePan = mousePan;
21
+ this._touchPan = touchPan;
22
+ }
23
+
24
+ /**
25
+ * Enables the "drag to pan" interaction.
26
+ *
27
+ * @param options - Options object
28
+ * @example
29
+ * ```ts
30
+ * map.dragPan.enable();
31
+ * map.dragPan.enable({
32
+ * linearity: 0.3,
33
+ * easing: bezier(0, 0, 0.3, 1),
34
+ * maxSpeed: 1400,
35
+ * deceleration: 2500,
36
+ * });
37
+ * ```
38
+ */
39
+ enable(options) {
40
+ this._inertiaOptions = options || {};
41
+ this._mousePan.enable();
42
+ this._touchPan.enable();
43
+ this._el.classList.add('l7-touch-drag-pan');
44
+ }
45
+
46
+ /**
47
+ * Disables the "drag to pan" interaction.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * map.dragPan.disable();
52
+ * ```
53
+ */
54
+ disable() {
55
+ this._mousePan.disable();
56
+ this._touchPan.disable();
57
+ this._el.classList.remove('l7-touch-drag-pan');
58
+ }
59
+
60
+ /**
61
+ * Returns a Boolean indicating whether the "drag to pan" interaction is enabled.
62
+ *
63
+ * @returns `true` if the "drag to pan" interaction is enabled.
64
+ */
65
+ isEnabled() {
66
+ return this._mousePan.isEnabled() && this._touchPan.isEnabled();
67
+ }
68
+
69
+ /**
70
+ * Returns a Boolean indicating whether the "drag to pan" interaction is active, i.e. currently being used.
71
+ *
72
+ * @returns `true` if the "drag to pan" interaction is active.
73
+ */
74
+ isActive() {
75
+ return this._mousePan.isActive() || this._touchPan.isActive();
76
+ }
77
+ }
@@ -0,0 +1,54 @@
1
+ import type { MousePitchHandler, MouseRotateHandler } from '../mouse';
2
+ /**
3
+ * Options object for `DragRotateHandler`.
4
+ */
5
+ export type DragRotateHandlerOptions = {
6
+ /**
7
+ * Control the map pitch in addition to the bearing
8
+ * @defaultValue true
9
+ */
10
+ pitchWithRotate: boolean;
11
+ };
12
+ /**
13
+ * The `DragRotateHandler` allows the user to rotate the map by clicking and
14
+ * dragging the cursor while holding the right mouse button or `ctrl` key.
15
+ *
16
+ * @group Handlers
17
+ */
18
+ export declare class DragRotateHandler {
19
+ _mouseRotate: MouseRotateHandler;
20
+ _mousePitch: MousePitchHandler;
21
+ _pitchWithRotate: boolean;
22
+ /** @internal */
23
+ constructor(options: DragRotateHandlerOptions, mouseRotate: MouseRotateHandler, mousePitch: MousePitchHandler);
24
+ /**
25
+ * Enables the "drag to rotate" interaction.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * map.dragRotate.enable();
30
+ * ```
31
+ */
32
+ enable(): void;
33
+ /**
34
+ * Disables the "drag to rotate" interaction.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * map.dragRotate.disable();
39
+ * ```
40
+ */
41
+ disable(): void;
42
+ /**
43
+ * Returns a Boolean indicating whether the "drag to rotate" interaction is enabled.
44
+ *
45
+ * @returns `true` if the "drag to rotate" interaction is enabled.
46
+ */
47
+ isEnabled(): boolean;
48
+ /**
49
+ * Returns a Boolean indicating whether the "drag to rotate" interaction is active, i.e. currently being used.
50
+ *
51
+ * @returns `true` if the "drag to rotate" interaction is active.
52
+ */
53
+ isActive(): boolean;
54
+ }
@@ -0,0 +1,66 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ /**
3
+ * Options object for `DragRotateHandler`.
4
+ */
5
+
6
+ /**
7
+ * The `DragRotateHandler` allows the user to rotate the map by clicking and
8
+ * dragging the cursor while holding the right mouse button or `ctrl` key.
9
+ *
10
+ * @group Handlers
11
+ */
12
+ export class DragRotateHandler {
13
+ /** @internal */
14
+ constructor(options, mouseRotate, mousePitch) {
15
+ _defineProperty(this, "_mouseRotate", void 0);
16
+ _defineProperty(this, "_mousePitch", void 0);
17
+ _defineProperty(this, "_pitchWithRotate", void 0);
18
+ this._pitchWithRotate = options.pitchWithRotate;
19
+ this._mouseRotate = mouseRotate;
20
+ this._mousePitch = mousePitch;
21
+ }
22
+
23
+ /**
24
+ * Enables the "drag to rotate" interaction.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * map.dragRotate.enable();
29
+ * ```
30
+ */
31
+ enable() {
32
+ this._mouseRotate.enable();
33
+ if (this._pitchWithRotate) this._mousePitch.enable();
34
+ }
35
+
36
+ /**
37
+ * Disables the "drag to rotate" interaction.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * map.dragRotate.disable();
42
+ * ```
43
+ */
44
+ disable() {
45
+ this._mouseRotate.disable();
46
+ this._mousePitch.disable();
47
+ }
48
+
49
+ /**
50
+ * Returns a Boolean indicating whether the "drag to rotate" interaction is enabled.
51
+ *
52
+ * @returns `true` if the "drag to rotate" interaction is enabled.
53
+ */
54
+ isEnabled() {
55
+ return this._mouseRotate.isEnabled() && (!this._pitchWithRotate || this._mousePitch.isEnabled());
56
+ }
57
+
58
+ /**
59
+ * Returns a Boolean indicating whether the "drag to rotate" interaction is active, i.e. currently being used.
60
+ *
61
+ * @returns `true` if the "drag to rotate" interaction is active.
62
+ */
63
+ isActive() {
64
+ return this._mouseRotate.isActive() || this._mousePitch.isActive();
65
+ }
66
+ }
@@ -0,0 +1,74 @@
1
+ import type { TapDragZoomHandler } from '../tap_drag_zoom';
2
+ import type { AroundCenterOptions, TwoFingersTouchRotateHandler, TwoFingersTouchZoomHandler } from '../two_fingers_touch';
3
+ /**
4
+ * The `TwoFingersTouchZoomRotateHandler` 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
+ * @group Handlers
11
+ */
12
+ export declare class TwoFingersTouchZoomRotateHandler {
13
+ _el: HTMLElement;
14
+ _touchZoom: TwoFingersTouchZoomHandler;
15
+ _touchRotate: TwoFingersTouchRotateHandler;
16
+ _tapDragZoom: TapDragZoomHandler;
17
+ _rotationDisabled: boolean;
18
+ _enabled: boolean;
19
+ /** @internal */
20
+ constructor(el: HTMLElement, touchZoom: TwoFingersTouchZoomHandler, touchRotate: TwoFingersTouchRotateHandler, tapDragZoom: TapDragZoomHandler);
21
+ /**
22
+ * Enables the "pinch to rotate and zoom" interaction.
23
+ *
24
+ * @param options - Options object.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * map.touchZoomRotate.enable();
29
+ * map.touchZoomRotate.enable({ around: 'center' });
30
+ * ```
31
+ */
32
+ enable(options?: AroundCenterOptions | boolean | null): void;
33
+ /**
34
+ * Disables the "pinch to rotate and zoom" interaction.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * map.touchZoomRotate.disable();
39
+ * ```
40
+ */
41
+ disable(): void;
42
+ /**
43
+ * Returns a Boolean indicating whether the "pinch to rotate and zoom" interaction is enabled.
44
+ *
45
+ * @returns `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 `true` if the handler is active, `false` otherwise
52
+ */
53
+ isActive(): boolean;
54
+ /**
55
+ * Disables the "pinch to rotate" interaction, leaving the "pinch to zoom"
56
+ * interaction enabled.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * map.touchZoomRotate.disableRotation();
61
+ * ```
62
+ */
63
+ disableRotation(): void;
64
+ /**
65
+ * Enables the "pinch to rotate" interaction.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * map.touchZoomRotate.enable();
70
+ * map.touchZoomRotate.enableRotation();
71
+ * ```
72
+ */
73
+ enableRotation(): void;
74
+ }
@@ -0,0 +1,106 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ /**
3
+ * The `TwoFingersTouchZoomRotateHandler` allows the user to zoom and rotate the map by
4
+ * pinching on a touchscreen.
5
+ *
6
+ * They can zoom with one finger by double tapping and dragging. On the second tap,
7
+ * hold the finger down and drag up or down to zoom in or out.
8
+ *
9
+ * @group Handlers
10
+ */
11
+ export class TwoFingersTouchZoomRotateHandler {
12
+ /** @internal */
13
+ constructor(el, touchZoom, touchRotate, tapDragZoom) {
14
+ _defineProperty(this, "_el", void 0);
15
+ _defineProperty(this, "_touchZoom", void 0);
16
+ _defineProperty(this, "_touchRotate", void 0);
17
+ _defineProperty(this, "_tapDragZoom", void 0);
18
+ _defineProperty(this, "_rotationDisabled", void 0);
19
+ _defineProperty(this, "_enabled", void 0);
20
+ this._el = el;
21
+ this._touchZoom = touchZoom;
22
+ this._touchRotate = touchRotate;
23
+ this._tapDragZoom = tapDragZoom;
24
+ this._rotationDisabled = false;
25
+ this._enabled = true;
26
+ }
27
+
28
+ /**
29
+ * Enables the "pinch to rotate and zoom" interaction.
30
+ *
31
+ * @param options - Options object.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * map.touchZoomRotate.enable();
36
+ * map.touchZoomRotate.enable({ around: 'center' });
37
+ * ```
38
+ */
39
+ enable(options) {
40
+ this._touchZoom.enable(options);
41
+ if (!this._rotationDisabled) this._touchRotate.enable(options);
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
+ * ```ts
51
+ * map.touchZoomRotate.disable();
52
+ * ```
53
+ */
54
+ 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 `true` if the "pinch to rotate and zoom" interaction is enabled.
65
+ */
66
+ isEnabled() {
67
+ return this._touchZoom.isEnabled() && (this._rotationDisabled || this._touchRotate.isEnabled()) && this._tapDragZoom.isEnabled();
68
+ }
69
+
70
+ /**
71
+ * Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.
72
+ *
73
+ * @returns `true` if the handler is active, `false` otherwise
74
+ */
75
+ isActive() {
76
+ return this._touchZoom.isActive() || this._touchRotate.isActive() || this._tapDragZoom.isActive();
77
+ }
78
+
79
+ /**
80
+ * Disables the "pinch to rotate" interaction, leaving the "pinch to zoom"
81
+ * interaction enabled.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * map.touchZoomRotate.disableRotation();
86
+ * ```
87
+ */
88
+ disableRotation() {
89
+ this._rotationDisabled = true;
90
+ this._touchRotate.disable();
91
+ }
92
+
93
+ /**
94
+ * Enables the "pinch to rotate" interaction.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * map.touchZoomRotate.enable();
99
+ * map.touchZoomRotate.enableRotation();
100
+ * ```
101
+ */
102
+ enableRotation() {
103
+ this._rotationDisabled = false;
104
+ if (this._touchZoom.isEnabled()) this._touchRotate.enable();
105
+ }
106
+ }
@@ -0,0 +1,28 @@
1
+ /// <reference types="mapbox__point-geometry" />
2
+ import type Point from '@mapbox/point-geometry';
3
+ import type { Handler } from '../handler_manager';
4
+ import { TapRecognizer } from './tap_recognizer';
5
+ /**
6
+ * A `TapDragZoomHandler` allows the user to zoom the map at a point by double tapping. It also allows the user pan the map by dragging.
7
+ */
8
+ export declare class TapDragZoomHandler implements Handler {
9
+ _enabled: boolean;
10
+ _active: boolean;
11
+ _swipePoint: Point;
12
+ _swipeTouch: number;
13
+ _tapTime: number;
14
+ _tapPoint: Point;
15
+ _tap: TapRecognizer;
16
+ constructor();
17
+ reset(): void;
18
+ touchstart(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): void;
19
+ touchmove(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): {
20
+ zoomDelta: number;
21
+ };
22
+ touchend(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): void;
23
+ touchcancel(): void;
24
+ enable(): void;
25
+ disable(): void;
26
+ isEnabled(): boolean;
27
+ isActive(): boolean;
28
+ }
@@ -0,0 +1,92 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import { MAX_DIST, MAX_TAP_INTERVAL, TapRecognizer } from "./tap_recognizer";
3
+
4
+ /**
5
+ * A `TapDragZoomHandler` allows the user to zoom the map at a point by double tapping. It also allows the user pan the map by dragging.
6
+ */
7
+ export class TapDragZoomHandler {
8
+ constructor() {
9
+ _defineProperty(this, "_enabled", void 0);
10
+ _defineProperty(this, "_active", void 0);
11
+ _defineProperty(this, "_swipePoint", void 0);
12
+ _defineProperty(this, "_swipeTouch", void 0);
13
+ _defineProperty(this, "_tapTime", void 0);
14
+ _defineProperty(this, "_tapPoint", void 0);
15
+ _defineProperty(this, "_tap", void 0);
16
+ this._tap = new TapRecognizer({
17
+ numTouches: 1,
18
+ numTaps: 1
19
+ });
20
+ this.reset();
21
+ }
22
+ reset() {
23
+ this._active = false;
24
+ delete this._swipePoint;
25
+ delete this._swipeTouch;
26
+ delete this._tapTime;
27
+ delete this._tapPoint;
28
+ this._tap.reset();
29
+ }
30
+ touchstart(e, points, mapTouches) {
31
+ if (this._swipePoint) return;
32
+ if (!this._tapTime) {
33
+ this._tap.touchstart(e, points, mapTouches);
34
+ } else {
35
+ const swipePoint = points[0];
36
+ const soonEnough = e.timeStamp - this._tapTime < MAX_TAP_INTERVAL;
37
+ const closeEnough = this._tapPoint.dist(swipePoint) < MAX_DIST;
38
+ if (!soonEnough || !closeEnough) {
39
+ this.reset();
40
+ } else if (mapTouches.length > 0) {
41
+ this._swipePoint = swipePoint;
42
+ this._swipeTouch = mapTouches[0].identifier;
43
+ }
44
+ }
45
+ }
46
+ 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
+ const newSwipePoint = points[0];
54
+ const 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
+ touchend(e, points, mapTouches) {
64
+ if (!this._tapTime) {
65
+ const point = this._tap.touchend(e, points, mapTouches);
66
+ if (point) {
67
+ this._tapTime = e.timeStamp;
68
+ this._tapPoint = point;
69
+ }
70
+ } else if (this._swipePoint) {
71
+ if (mapTouches.length === 0) {
72
+ this.reset();
73
+ }
74
+ }
75
+ }
76
+ touchcancel() {
77
+ this.reset();
78
+ }
79
+ enable() {
80
+ this._enabled = true;
81
+ }
82
+ disable() {
83
+ this._enabled = false;
84
+ this.reset();
85
+ }
86
+ isEnabled() {
87
+ return this._enabled;
88
+ }
89
+ isActive() {
90
+ return this._active;
91
+ }
92
+ }
@@ -0,0 +1,35 @@
1
+ /// <reference types="mapbox__point-geometry" />
2
+ import Point from '@mapbox/point-geometry';
3
+ export declare const MAX_TAP_INTERVAL = 500;
4
+ export declare const MAX_DIST = 30;
5
+ export declare class SingleTapRecognizer {
6
+ numTouches: number;
7
+ centroid: Point;
8
+ startTime: number;
9
+ aborted: boolean;
10
+ touches: {
11
+ [k in number | string]: Point;
12
+ };
13
+ constructor(options: {
14
+ numTouches: number;
15
+ });
16
+ reset(): void;
17
+ touchstart(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): void;
18
+ touchmove(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): void;
19
+ touchend(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): Point;
20
+ }
21
+ export declare class TapRecognizer {
22
+ singleTap: SingleTapRecognizer;
23
+ numTaps: number;
24
+ lastTime: number;
25
+ lastTap: Point;
26
+ count: number;
27
+ constructor(options: {
28
+ numTaps: number;
29
+ numTouches: number;
30
+ });
31
+ reset(): void;
32
+ touchstart(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): void;
33
+ touchmove(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): void;
34
+ touchend(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): Point;
35
+ }
@@ -0,0 +1,107 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import Point from '@mapbox/point-geometry';
3
+ import { indexTouches } from "./handler_util";
4
+ function getCentroid(points) {
5
+ const sum = new Point(0, 0);
6
+ for (const point of points) {
7
+ sum._add(point);
8
+ }
9
+ return sum.div(points.length);
10
+ }
11
+ export const MAX_TAP_INTERVAL = 500;
12
+ const MAX_TOUCH_TIME = 500;
13
+ export const MAX_DIST = 30;
14
+ export class SingleTapRecognizer {
15
+ constructor(options) {
16
+ _defineProperty(this, "numTouches", void 0);
17
+ _defineProperty(this, "centroid", void 0);
18
+ _defineProperty(this, "startTime", void 0);
19
+ _defineProperty(this, "aborted", void 0);
20
+ _defineProperty(this, "touches", void 0);
21
+ this.reset();
22
+ this.numTouches = options.numTouches;
23
+ }
24
+ reset() {
25
+ delete this.centroid;
26
+ delete this.startTime;
27
+ delete this.touches;
28
+ this.aborted = false;
29
+ }
30
+ touchstart(e, points, mapTouches) {
31
+ if (this.centroid || mapTouches.length > this.numTouches) {
32
+ this.aborted = true;
33
+ }
34
+ if (this.aborted) {
35
+ return;
36
+ }
37
+ if (this.startTime === undefined) {
38
+ this.startTime = e.timeStamp;
39
+ }
40
+ if (mapTouches.length === this.numTouches) {
41
+ this.centroid = getCentroid(points);
42
+ this.touches = indexTouches(mapTouches, points);
43
+ }
44
+ }
45
+ touchmove(e, points, mapTouches) {
46
+ if (this.aborted || !this.centroid) return;
47
+ const newTouches = indexTouches(mapTouches, points);
48
+ for (const id in this.touches) {
49
+ const prevPos = this.touches[id];
50
+ const pos = newTouches[id];
51
+ if (!pos || pos.dist(prevPos) > MAX_DIST) {
52
+ this.aborted = true;
53
+ }
54
+ }
55
+ }
56
+ touchend(e, points, mapTouches) {
57
+ if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) {
58
+ this.aborted = true;
59
+ }
60
+ if (mapTouches.length === 0) {
61
+ const centroid = !this.aborted && this.centroid;
62
+ this.reset();
63
+ if (centroid) return centroid;
64
+ }
65
+ }
66
+ }
67
+ export class TapRecognizer {
68
+ constructor(options) {
69
+ _defineProperty(this, "singleTap", void 0);
70
+ _defineProperty(this, "numTaps", void 0);
71
+ _defineProperty(this, "lastTime", void 0);
72
+ _defineProperty(this, "lastTap", void 0);
73
+ _defineProperty(this, "count", void 0);
74
+ this.singleTap = new SingleTapRecognizer(options);
75
+ this.numTaps = options.numTaps;
76
+ this.reset();
77
+ }
78
+ reset() {
79
+ this.lastTime = Infinity;
80
+ delete this.lastTap;
81
+ this.count = 0;
82
+ this.singleTap.reset();
83
+ }
84
+ touchstart(e, points, mapTouches) {
85
+ this.singleTap.touchstart(e, points, mapTouches);
86
+ }
87
+ touchmove(e, points, mapTouches) {
88
+ this.singleTap.touchmove(e, points, mapTouches);
89
+ }
90
+ touchend(e, points, mapTouches) {
91
+ const tap = this.singleTap.touchend(e, points, mapTouches);
92
+ if (tap) {
93
+ const soonEnough = e.timeStamp - this.lastTime < MAX_TAP_INTERVAL;
94
+ const closeEnough = !this.lastTap || this.lastTap.dist(tap) < MAX_DIST;
95
+ if (!soonEnough || !closeEnough) {
96
+ this.reset();
97
+ }
98
+ this.count++;
99
+ this.lastTime = e.timeStamp;
100
+ this.lastTap = tap;
101
+ if (this.count === this.numTaps) {
102
+ this.reset();
103
+ return tap;
104
+ }
105
+ }
106
+ }
107
+ }
@@ -0,0 +1,28 @@
1
+ /// <reference types="mapbox__point-geometry" />
2
+ import type Point from '@mapbox/point-geometry';
3
+ import type { Handler } from '../handler_manager';
4
+ import type { Map } from '../map';
5
+ import { TapRecognizer } from './tap_recognizer';
6
+ import { TransformProvider } from './transform-provider';
7
+ /**
8
+ * A `TapZoomHandler` allows the user to zoom the map at a point by double tapping
9
+ */
10
+ export declare class TapZoomHandler implements Handler {
11
+ _tr: TransformProvider;
12
+ _enabled: boolean;
13
+ _active: boolean;
14
+ _zoomIn: TapRecognizer;
15
+ _zoomOut: TapRecognizer;
16
+ constructor(map: Map);
17
+ reset(): void;
18
+ touchstart(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): void;
19
+ touchmove(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): void;
20
+ touchend(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): {
21
+ cameraAnimation: (map: Map) => Map;
22
+ };
23
+ touchcancel(): void;
24
+ enable(): void;
25
+ disable(): void;
26
+ isEnabled(): boolean;
27
+ isActive(): boolean;
28
+ }