@antv/l7-map 2.21.0 → 2.21.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.
- package/es/camera.js +595 -674
- package/es/earthmap.js +313 -276
- package/es/geo/edge_insets.js +57 -72
- package/es/geo/lng_lat.js +50 -64
- package/es/geo/lng_lat_bounds.js +101 -137
- package/es/geo/mercator.js +23 -35
- package/es/geo/point.js +150 -221
- package/es/geo/simple.js +22 -34
- package/es/geo/transform.js +839 -905
- package/es/handler/blockable_map_event.js +46 -66
- package/es/handler/box_zoom.js +125 -143
- package/es/handler/click_zoom.js +37 -51
- package/es/handler/events/event.js +11 -9
- package/es/handler/events/map_mouse_event.js +39 -54
- package/es/handler/events/map_touch_event.js +54 -73
- package/es/handler/events/map_wheel_event.js +22 -38
- package/es/handler/events/render_event.js +6 -23
- package/es/handler/handler_inertia.js +98 -113
- package/es/handler/handler_manager.js +349 -437
- package/es/handler/handler_util.js +2 -2
- package/es/handler/keyboard.js +98 -110
- package/es/handler/map_event.js +81 -117
- package/es/handler/mouse/mouse_handler.js +81 -100
- package/es/handler/mouse/mousepan_handler.js +16 -39
- package/es/handler/mouse/mousepitch_hander.js +18 -40
- package/es/handler/mouse/mouserotate_hander.js +18 -40
- package/es/handler/mouse/util.js +7 -6
- package/es/handler/scroll_zoom.js +221 -231
- package/es/handler/shim/dblclick_zoom.js +36 -47
- package/es/handler/shim/drag_pan.js +41 -50
- package/es/handler/shim/drag_rotate.js +38 -48
- package/es/handler/shim/touch_zoom_rotate.js +68 -79
- package/es/handler/tap/single_tap_recognizer.js +60 -80
- package/es/handler/tap/tap_drag_zoom.js +72 -89
- package/es/handler/tap/tap_recognizer.js +37 -45
- package/es/handler/tap/tap_zoom.js +67 -95
- package/es/handler/touch/touch_pan.js +77 -96
- package/es/handler/touch/touch_pitch.js +61 -79
- package/es/handler/touch/touch_rotate.js +47 -67
- package/es/handler/touch/touch_zoom.js +29 -46
- package/es/handler/touch/two_touch.js +79 -104
- package/es/hash.js +75 -88
- package/es/map.js +318 -284
- package/es/util.js +18 -37
- package/es/utils/Aabb.js +60 -100
- package/es/utils/dom.js +32 -55
- package/es/utils/performance.js +25 -29
- package/es/utils/primitives.js +33 -43
- package/es/utils/task_queue.js +47 -76
- package/lib/camera.d.ts +86 -0
- package/lib/camera.js +597 -672
- package/lib/earthmap.d.ts +69 -0
- package/lib/earthmap.js +314 -276
- package/lib/geo/edge_insets.d.ts +54 -0
- package/lib/geo/edge_insets.js +58 -70
- package/lib/geo/lng_lat.d.ts +18 -0
- package/lib/geo/lng_lat.js +50 -62
- package/lib/geo/lng_lat_bounds.d.ts +25 -0
- package/lib/geo/lng_lat_bounds.js +102 -136
- package/lib/geo/mercator.d.ts +30 -0
- package/lib/geo/mercator.js +26 -37
- package/lib/geo/point.d.ts +40 -0
- package/lib/geo/point.js +151 -220
- package/lib/geo/simple.d.ts +30 -0
- package/lib/geo/simple.js +25 -36
- package/lib/geo/transform.d.ts +198 -0
- package/lib/geo/transform.js +844 -907
- package/lib/handler/IHandler.d.ts +34 -0
- package/lib/handler/blockable_map_event.d.ts +17 -0
- package/lib/handler/blockable_map_event.js +48 -65
- package/lib/handler/box_zoom.d.ts +59 -0
- package/lib/handler/box_zoom.js +126 -143
- package/lib/handler/click_zoom.d.ts +16 -0
- package/lib/handler/click_zoom.js +38 -50
- package/lib/handler/events/event.d.ts +4 -0
- package/lib/handler/events/event.js +12 -9
- package/lib/handler/events/index.d.ts +4 -0
- package/lib/handler/events/index.js +3 -3
- package/lib/handler/events/map_mouse_event.d.ts +34 -0
- package/lib/handler/events/map_mouse_event.js +41 -52
- package/lib/handler/events/map_touch_event.d.ts +57 -0
- package/lib/handler/events/map_touch_event.js +56 -71
- package/lib/handler/events/map_wheel_event.d.ts +33 -0
- package/lib/handler/events/map_wheel_event.js +23 -37
- package/lib/handler/events/render_event.d.ts +5 -0
- package/lib/handler/events/render_event.js +7 -22
- package/lib/handler/handler_inertia.d.ts +23 -0
- package/lib/handler/handler_inertia.js +102 -112
- package/lib/handler/handler_manager.d.ts +61 -0
- package/lib/handler/handler_manager.js +351 -437
- package/lib/handler/handler_util.d.ts +4 -0
- package/lib/handler/handler_util.js +2 -2
- package/lib/handler/keyboard.d.ts +36 -0
- package/lib/handler/keyboard.js +98 -110
- package/lib/handler/map_event.d.ts +29 -0
- package/lib/handler/map_event.js +83 -116
- package/lib/handler/mouse/index.d.ts +4 -0
- package/lib/handler/mouse/index.js +3 -3
- package/lib/handler/mouse/mouse_handler.d.ts +22 -0
- package/lib/handler/mouse/mouse_handler.js +83 -99
- package/lib/handler/mouse/mousepan_handler.d.ts +10 -0
- package/lib/handler/mouse/mousepan_handler.js +19 -38
- package/lib/handler/mouse/mousepitch_hander.d.ts +9 -0
- package/lib/handler/mouse/mousepitch_hander.js +21 -39
- package/lib/handler/mouse/mouserotate_hander.d.ts +9 -0
- package/lib/handler/mouse/mouserotate_hander.js +21 -39
- package/lib/handler/mouse/util.d.ts +6 -0
- package/lib/handler/mouse/util.js +7 -7
- package/lib/handler/scroll_zoom.d.ts +93 -0
- package/lib/handler/scroll_zoom.js +221 -231
- package/lib/handler/shim/dblclick_zoom.d.ts +40 -0
- package/lib/handler/shim/dblclick_zoom.js +37 -46
- package/lib/handler/shim/drag_pan.d.ts +61 -0
- package/lib/handler/shim/drag_pan.js +42 -49
- package/lib/handler/shim/drag_rotate.d.ts +46 -0
- package/lib/handler/shim/drag_rotate.js +39 -47
- package/lib/handler/shim/touch_zoom_rotate.d.ts +70 -0
- package/lib/handler/shim/touch_zoom_rotate.js +69 -78
- package/lib/handler/tap/single_tap_recognizer.d.ts +20 -0
- package/lib/handler/tap/single_tap_recognizer.js +63 -79
- package/lib/handler/tap/tap_drag_zoom.d.ts +22 -0
- package/lib/handler/tap/tap_drag_zoom.js +74 -88
- package/lib/handler/tap/tap_recognizer.d.ts +17 -0
- package/lib/handler/tap/tap_recognizer.js +41 -47
- package/lib/handler/tap/tap_zoom.d.ts +22 -0
- package/lib/handler/tap/tap_zoom.js +69 -94
- package/lib/handler/touch/index.d.ts +5 -0
- package/lib/handler/touch/index.js +4 -4
- package/lib/handler/touch/touch_pan.d.ts +30 -0
- package/lib/handler/touch/touch_pan.js +79 -95
- package/lib/handler/touch/touch_pitch.d.ts +13 -0
- package/lib/handler/touch/touch_pitch.js +64 -78
- package/lib/handler/touch/touch_rotate.d.ts +12 -0
- package/lib/handler/touch/touch_rotate.js +50 -66
- package/lib/handler/touch/touch_zoom.d.ts +12 -0
- package/lib/handler/touch/touch_zoom.js +32 -45
- package/lib/handler/touch/two_touch.d.ts +23 -0
- package/lib/handler/touch/two_touch.js +81 -103
- package/lib/hash.d.ts +14 -0
- package/lib/hash.js +75 -88
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -4
- package/lib/interface.d.ts +34 -0
- package/lib/map.d.ts +70 -0
- package/lib/map.js +319 -284
- package/lib/util.d.ts +25 -0
- package/lib/util.js +20 -36
- package/lib/utils/Aabb.d.ts +12 -0
- package/lib/utils/Aabb.js +61 -99
- package/lib/utils/dom.d.ts +4 -0
- package/lib/utils/dom.js +34 -55
- package/lib/utils/performance.d.ts +17 -0
- package/lib/utils/performance.js +25 -29
- package/lib/utils/primitives.d.ts +6 -0
- package/lib/utils/primitives.js +34 -42
- package/lib/utils/task_queue.d.ts +13 -0
- package/lib/utils/task_queue.js +47 -76
- package/package.json +25 -32
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
/**
|
|
4
3
|
* The `DragPanHandler` allows the user to pan the map by clicking and dragging
|
|
5
4
|
* the cursor.
|
|
6
5
|
*/
|
|
7
|
-
|
|
6
|
+
export default class DragPanHandler {
|
|
8
7
|
/**
|
|
9
8
|
* @private
|
|
10
9
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
constructor(el, mousePan, touchPan) {
|
|
11
|
+
_defineProperty(this, "inertiaOptions", void 0);
|
|
12
|
+
_defineProperty(this, "el", void 0);
|
|
13
|
+
_defineProperty(this, "mousePan", void 0);
|
|
14
|
+
_defineProperty(this, "touchPan", void 0);
|
|
13
15
|
this.el = el;
|
|
14
16
|
this.mousePan = mousePan;
|
|
15
17
|
this.touchPan = touchPan;
|
|
@@ -34,51 +36,40 @@ var DragPanHandler = /*#__PURE__*/function () {
|
|
|
34
36
|
* deceleration: 2500,
|
|
35
37
|
* });
|
|
36
38
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.el.classList.add('l7-touch-drag-pan');
|
|
44
|
-
}
|
|
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
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.el.classList.remove('l7-touch-drag-pan');
|
|
58
|
-
}
|
|
46
|
+
/**
|
|
47
|
+
* Disables the "drag to pan" interaction.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* map.dragPan.disable();
|
|
51
|
+
*/
|
|
52
|
+
disable() {
|
|
53
|
+
this.mousePan.disable();
|
|
54
|
+
this.touchPan.disable();
|
|
55
|
+
this.el.classList.remove('l7-touch-drag-pan');
|
|
56
|
+
}
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return this.mousePan.isEnabled() && this.touchPan.isEnabled();
|
|
69
|
-
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns a Boolean indicating whether the "drag to pan" interaction is enabled.
|
|
60
|
+
*
|
|
61
|
+
* @returns {boolean} `true` if the "drag to pan" interaction is enabled.
|
|
62
|
+
*/
|
|
63
|
+
isEnabled() {
|
|
64
|
+
return this.mousePan.isEnabled() && this.touchPan.isEnabled();
|
|
65
|
+
}
|
|
70
66
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
}]);
|
|
82
|
-
return DragPanHandler;
|
|
83
|
-
}();
|
|
84
|
-
export { DragPanHandler as default };
|
|
67
|
+
/**
|
|
68
|
+
* Returns a Boolean indicating whether the "drag to pan" interaction is active, i.e. currently being used.
|
|
69
|
+
*
|
|
70
|
+
* @returns {boolean} `true` if the "drag to pan" interaction is active.
|
|
71
|
+
*/
|
|
72
|
+
isActive() {
|
|
73
|
+
return this.mousePan.isActive() || this.touchPan.isActive();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
/**
|
|
4
3
|
* The `DragRotateHandler` allows the user to rotate the map by clicking and
|
|
5
4
|
* dragging the cursor while holding the right mouse button or `ctrl` key.
|
|
6
5
|
*/
|
|
7
|
-
|
|
6
|
+
export default class DragRotateHandler {
|
|
8
7
|
/**
|
|
9
8
|
* @param {Object} [options]
|
|
10
9
|
* @param {number} [options.bearingSnap] The threshold, measured in degrees, that determines when the map's
|
|
@@ -12,8 +11,10 @@ var DragRotateHandler = /*#__PURE__*/function () {
|
|
|
12
11
|
* @param {bool} [options.pitchWithRotate=true] Control the map pitch in addition to the bearing
|
|
13
12
|
* @private
|
|
14
13
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
constructor(options, mouseRotate, mousePitch) {
|
|
15
|
+
_defineProperty(this, "mouseRotate", void 0);
|
|
16
|
+
_defineProperty(this, "mousePitch", void 0);
|
|
17
|
+
_defineProperty(this, "pitchWithRotate", void 0);
|
|
17
18
|
this.pitchWithRotate = options.pitchWithRotate;
|
|
18
19
|
this.mouseRotate = mouseRotate;
|
|
19
20
|
this.mousePitch = mousePitch;
|
|
@@ -25,50 +26,39 @@ var DragRotateHandler = /*#__PURE__*/function () {
|
|
|
25
26
|
* @example
|
|
26
27
|
* map.dragRotate.enable();
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.
|
|
32
|
-
if (this.pitchWithRotate) {
|
|
33
|
-
this.mousePitch.enable();
|
|
34
|
-
}
|
|
29
|
+
enable() {
|
|
30
|
+
this.mouseRotate.enable();
|
|
31
|
+
if (this.pitchWithRotate) {
|
|
32
|
+
this.mousePitch.enable();
|
|
35
33
|
}
|
|
34
|
+
}
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
this.mousePitch.disable();
|
|
48
|
-
}
|
|
36
|
+
/**
|
|
37
|
+
* Disables the "drag to rotate" interaction.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* map.dragRotate.disable();
|
|
41
|
+
*/
|
|
42
|
+
disable() {
|
|
43
|
+
this.mouseRotate.disable();
|
|
44
|
+
this.mousePitch.disable();
|
|
45
|
+
}
|
|
49
46
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return this.mouseRotate.isEnabled() && (!this.pitchWithRotate || this.mousePitch.isEnabled());
|
|
59
|
-
}
|
|
47
|
+
/**
|
|
48
|
+
* Returns a Boolean indicating whether the "drag to rotate" interaction is enabled.
|
|
49
|
+
*
|
|
50
|
+
* @returns {boolean} `true` if the "drag to rotate" interaction is enabled.
|
|
51
|
+
*/
|
|
52
|
+
isEnabled() {
|
|
53
|
+
return this.mouseRotate.isEnabled() && (!this.pitchWithRotate || this.mousePitch.isEnabled());
|
|
54
|
+
}
|
|
60
55
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
}]);
|
|
72
|
-
return DragRotateHandler;
|
|
73
|
-
}();
|
|
74
|
-
export { DragRotateHandler as default };
|
|
56
|
+
/**
|
|
57
|
+
* Returns a Boolean indicating whether the "drag to rotate" interaction is active, i.e. currently being used.
|
|
58
|
+
*
|
|
59
|
+
* @returns {boolean} `true` if the "drag to rotate" interaction is active.
|
|
60
|
+
*/
|
|
61
|
+
isActive() {
|
|
62
|
+
return this.mouseRotate.isActive() || this.mousePitch.isActive();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
/**
|
|
4
3
|
* The `TouchZoomRotateHandler` allows the user to zoom and rotate the map by
|
|
5
4
|
* pinching on a touchscreen.
|
|
@@ -7,12 +6,17 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
7
6
|
* They can zoom with one finger by double tapping and dragging. On the second tap,
|
|
8
7
|
* hold the finger down and drag up or down to zoom in or out.
|
|
9
8
|
*/
|
|
10
|
-
|
|
9
|
+
export default class TouchZoomRotateHandler {
|
|
11
10
|
/**
|
|
12
11
|
* @private
|
|
13
12
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
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);
|
|
16
20
|
this.el = el;
|
|
17
21
|
this.touchZoom = touchZoom;
|
|
18
22
|
this.touchRotate = touchRotate;
|
|
@@ -32,84 +36,69 @@ var TouchZoomRotateHandler = /*#__PURE__*/function () {
|
|
|
32
36
|
* @example
|
|
33
37
|
* map.touchZoomRotate.enable({ around: 'center' });
|
|
34
38
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.
|
|
39
|
-
if (!this.rotationDisabled) {
|
|
40
|
-
this.touchRotate.enable(options);
|
|
41
|
-
}
|
|
42
|
-
this.tapDragZoom.enable();
|
|
43
|
-
this.el.classList.add('l7-touch-zoom-rotate');
|
|
39
|
+
enable(options) {
|
|
40
|
+
this.touchZoom.enable(options);
|
|
41
|
+
if (!this.rotationDisabled) {
|
|
42
|
+
this.touchRotate.enable(options);
|
|
44
43
|
}
|
|
44
|
+
this.tapDragZoom.enable();
|
|
45
|
+
this.el.classList.add('l7-touch-zoom-rotate');
|
|
46
|
+
}
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.el.classList.remove('l7-touch-zoom-rotate');
|
|
59
|
-
}
|
|
48
|
+
/**
|
|
49
|
+
* Disables the "pinch to rotate and zoom" interaction.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* map.touchZoomRotate.disable();
|
|
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
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return this.touchZoom.isEnabled() && (this.rotationDisabled || this.touchRotate.isEnabled()) && this.tapDragZoom.isEnabled();
|
|
70
|
-
}
|
|
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
|
+
isEnabled() {
|
|
67
|
+
return this.touchZoom.isEnabled() && (this.rotationDisabled || this.touchRotate.isEnabled()) && this.tapDragZoom.isEnabled();
|
|
68
|
+
}
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return this.touchZoom.isActive() || this.touchRotate.isActive() || this.tapDragZoom.isActive();
|
|
81
|
-
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.
|
|
72
|
+
*
|
|
73
|
+
* @returns {boolean} //eslint-disable-line
|
|
74
|
+
*/
|
|
75
|
+
isActive() {
|
|
76
|
+
return this.touchZoom.isActive() || this.touchRotate.isActive() || this.tapDragZoom.isActive();
|
|
77
|
+
}
|
|
82
78
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.touchRotate.disable();
|
|
95
|
-
}
|
|
79
|
+
/**
|
|
80
|
+
* Disables the "pinch to rotate" interaction, leaving the "pinch to zoom"
|
|
81
|
+
* interaction enabled.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* map.touchZoomRotate.disableRotation();
|
|
85
|
+
*/
|
|
86
|
+
disableRotation() {
|
|
87
|
+
this.rotationDisabled = true;
|
|
88
|
+
this.touchRotate.disable();
|
|
89
|
+
}
|
|
96
90
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
this.
|
|
108
|
-
if (this.touchZoom.isEnabled()) {
|
|
109
|
-
this.touchRotate.enable();
|
|
110
|
-
}
|
|
91
|
+
/**
|
|
92
|
+
* Enables the "pinch to rotate" interaction.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* map.touchZoomRotate.enable();
|
|
96
|
+
* map.touchZoomRotate.enableRotation();
|
|
97
|
+
*/
|
|
98
|
+
enableRotation() {
|
|
99
|
+
this.rotationDisabled = false;
|
|
100
|
+
if (this.touchZoom.isEnabled()) {
|
|
101
|
+
this.touchRotate.enable();
|
|
111
102
|
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
}();
|
|
115
|
-
export { TouchZoomRotateHandler as default };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -1,97 +1,77 @@
|
|
|
1
|
-
import
|
|
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; }
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
2
|
// @ts-ignore
|
|
7
3
|
import Point from "../../geo/point";
|
|
8
4
|
import { indexTouches } from "../handler_util";
|
|
9
5
|
function getCentroid(points) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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();
|
|
6
|
+
const sum = new Point(0, 0);
|
|
7
|
+
for (const point of points) {
|
|
8
|
+
sum._add(point);
|
|
23
9
|
}
|
|
10
|
+
// @ts-ignore
|
|
24
11
|
return sum.div(points.length);
|
|
25
12
|
}
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
export const MAX_TAP_INTERVAL = 500;
|
|
14
|
+
export const MAX_TOUCH_TIME = 500;
|
|
15
|
+
export const MAX_DIST = 30;
|
|
16
|
+
export default class SingleTapRecognizer {
|
|
17
|
+
constructor(options) {
|
|
18
|
+
_defineProperty(this, "numTouches", void 0);
|
|
19
|
+
_defineProperty(this, "centroid", void 0);
|
|
20
|
+
_defineProperty(this, "startTime", void 0);
|
|
21
|
+
_defineProperty(this, "aborted", void 0);
|
|
22
|
+
_defineProperty(this, "touches", void 0);
|
|
32
23
|
this.reset();
|
|
33
24
|
this.numTouches = options.numTouches;
|
|
34
25
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
26
|
+
reset() {
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
delete this.centroid;
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
delete this.startTime;
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
delete this.touches;
|
|
33
|
+
this.aborted = false;
|
|
34
|
+
}
|
|
35
|
+
touchstart(e, points, mapTouches) {
|
|
36
|
+
if (this.centroid || mapTouches.length > this.numTouches) {
|
|
37
|
+
this.aborted = true;
|
|
45
38
|
}
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
}
|
|
39
|
+
if (this.aborted) {
|
|
40
|
+
return;
|
|
62
41
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
42
|
+
if (this.startTime === undefined) {
|
|
43
|
+
this.startTime = e.timeStamp;
|
|
44
|
+
}
|
|
45
|
+
if (mapTouches.length === this.numTouches) {
|
|
46
|
+
this.centroid = getCentroid(points);
|
|
47
|
+
this.touches = indexTouches(mapTouches, points);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
touchmove(e, points, mapTouches) {
|
|
51
|
+
if (this.aborted || !this.centroid) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const newTouches = indexTouches(mapTouches, points);
|
|
55
|
+
for (const id in this.touches) {
|
|
56
|
+
if (this.touches[id]) {
|
|
57
|
+
const prevPos = this.touches[id];
|
|
58
|
+
const pos = newTouches[id];
|
|
59
|
+
if (!pos || pos.dist(prevPos) > MAX_DIST) {
|
|
60
|
+
this.aborted = true;
|
|
77
61
|
}
|
|
78
62
|
}
|
|
79
63
|
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return centroid;
|
|
91
|
-
}
|
|
64
|
+
}
|
|
65
|
+
touchend(e, points, mapTouches) {
|
|
66
|
+
if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) {
|
|
67
|
+
this.aborted = true;
|
|
68
|
+
}
|
|
69
|
+
if (mapTouches.length === 0) {
|
|
70
|
+
const centroid = !this.aborted && this.centroid;
|
|
71
|
+
this.reset();
|
|
72
|
+
if (centroid) {
|
|
73
|
+
return centroid;
|
|
92
74
|
}
|
|
93
75
|
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
}();
|
|
97
|
-
export { SingleTapRecognizer as default };
|
|
76
|
+
}
|
|
77
|
+
}
|