@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,106 +1,89 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
// @ts-ignore
|
|
4
3
|
|
|
5
4
|
import { MAX_TAP_INTERVAL } from "./single_tap_recognizer";
|
|
6
5
|
import TapRecognizer from "./tap_recognizer";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export default class TapDragZoomHandler {
|
|
7
|
+
constructor() {
|
|
8
|
+
_defineProperty(this, "enabled", void 0);
|
|
9
|
+
_defineProperty(this, "active", void 0);
|
|
10
|
+
_defineProperty(this, "swipePoint", void 0);
|
|
11
|
+
_defineProperty(this, "swipeTouch", void 0);
|
|
12
|
+
_defineProperty(this, "tapTime", void 0);
|
|
13
|
+
_defineProperty(this, "tap", void 0);
|
|
10
14
|
this.tap = new TapRecognizer({
|
|
11
15
|
numTouches: 1,
|
|
12
16
|
numTaps: 1
|
|
13
17
|
});
|
|
14
18
|
this.reset();
|
|
15
19
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
reset() {
|
|
21
|
+
this.active = false;
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
delete this.swipePoint;
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
delete this.swipeTouch;
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
delete this.tapTime;
|
|
28
|
+
this.tap.reset();
|
|
29
|
+
}
|
|
30
|
+
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;
|
|
27
42
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
}
|
|
44
|
+
touchmove(e, points, mapTouches) {
|
|
45
|
+
if (!this.tapTime) {
|
|
46
|
+
this.tap.touchmove(e, points, mapTouches);
|
|
47
|
+
} else if (this.swipePoint) {
|
|
48
|
+
if (mapTouches[0].identifier !== this.swipeTouch) {
|
|
32
49
|
return;
|
|
33
50
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
51
|
+
const newSwipePoint = points[0];
|
|
52
|
+
const dist = newSwipePoint.y - this.swipePoint.y;
|
|
53
|
+
this.swipePoint = newSwipePoint;
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
this.active = true;
|
|
56
|
+
return {
|
|
57
|
+
zoomDelta: dist / 128
|
|
58
|
+
};
|
|
43
59
|
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
};
|
|
60
|
+
}
|
|
61
|
+
touchend(e, points, mapTouches) {
|
|
62
|
+
if (!this.tapTime) {
|
|
63
|
+
const point = this.tap.touchend(e, points, mapTouches);
|
|
64
|
+
if (point) {
|
|
65
|
+
this.tapTime = e.timeStamp;
|
|
61
66
|
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
}
|
|
67
|
+
} else if (this.swipePoint) {
|
|
68
|
+
if (mapTouches.length === 0) {
|
|
69
|
+
this.reset();
|
|
75
70
|
}
|
|
76
71
|
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
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 };
|
|
72
|
+
}
|
|
73
|
+
touchcancel() {
|
|
74
|
+
this.reset();
|
|
75
|
+
}
|
|
76
|
+
enable() {
|
|
77
|
+
this.enabled = true;
|
|
78
|
+
}
|
|
79
|
+
disable() {
|
|
80
|
+
this.enabled = false;
|
|
81
|
+
this.reset();
|
|
82
|
+
}
|
|
83
|
+
isEnabled() {
|
|
84
|
+
return this.enabled;
|
|
85
|
+
}
|
|
86
|
+
isActive() {
|
|
87
|
+
return this.active;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -1,54 +1,46 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
// @ts-ignore
|
|
4
3
|
|
|
5
4
|
import SingleTapRecognizer, { MAX_DIST, MAX_TAP_INTERVAL } from "./single_tap_recognizer";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export default class TapRecognizer {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
_defineProperty(this, "singleTap", void 0);
|
|
8
|
+
_defineProperty(this, "numTaps", void 0);
|
|
9
|
+
_defineProperty(this, "lastTime", void 0);
|
|
10
|
+
_defineProperty(this, "lastTap", void 0);
|
|
11
|
+
_defineProperty(this, "count", void 0);
|
|
9
12
|
this.singleTap = new SingleTapRecognizer(options);
|
|
10
13
|
this.numTaps = options.numTaps;
|
|
11
14
|
this.reset();
|
|
12
15
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
}
|
|
16
|
+
reset() {
|
|
17
|
+
this.lastTime = Infinity;
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
delete this.lastTap;
|
|
20
|
+
this.count = 0;
|
|
21
|
+
this.singleTap.reset();
|
|
22
|
+
}
|
|
23
|
+
touchstart(e, points, mapTouches) {
|
|
24
|
+
this.singleTap.touchstart(e, points, mapTouches);
|
|
25
|
+
}
|
|
26
|
+
touchmove(e, points, mapTouches) {
|
|
27
|
+
this.singleTap.touchmove(e, points, mapTouches);
|
|
28
|
+
}
|
|
29
|
+
touchend(e, points, mapTouches) {
|
|
30
|
+
const tap = this.singleTap.touchend(e, points, mapTouches);
|
|
31
|
+
if (tap) {
|
|
32
|
+
const soonEnough = e.timeStamp - this.lastTime < MAX_TAP_INTERVAL;
|
|
33
|
+
const closeEnough = !this.lastTap || this.lastTap.dist(tap) < MAX_DIST;
|
|
34
|
+
if (!soonEnough || !closeEnough) {
|
|
35
|
+
this.reset();
|
|
36
|
+
}
|
|
37
|
+
this.count++;
|
|
38
|
+
this.lastTime = e.timeStamp;
|
|
39
|
+
this.lastTap = tap;
|
|
40
|
+
if (this.count === this.numTaps) {
|
|
41
|
+
this.reset();
|
|
42
|
+
return tap;
|
|
49
43
|
}
|
|
50
44
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
}();
|
|
54
|
-
export { TapRecognizer as default };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
// @ts-ignore
|
|
4
3
|
|
|
5
4
|
import TapRecognizer from "./tap_recognizer";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export default class TapZoomHandler {
|
|
6
|
+
constructor() {
|
|
7
|
+
_defineProperty(this, "enabled", void 0);
|
|
8
|
+
_defineProperty(this, "active", void 0);
|
|
9
|
+
_defineProperty(this, "zoomIn", void 0);
|
|
10
|
+
_defineProperty(this, "zoomOut", void 0);
|
|
9
11
|
this.zoomIn = new TapRecognizer({
|
|
10
12
|
numTouches: 1,
|
|
11
13
|
numTaps: 2
|
|
@@ -16,94 +18,64 @@ var TapZoomHandler = /*#__PURE__*/function () {
|
|
|
16
18
|
});
|
|
17
19
|
this.reset();
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
} else if (zoomOutPoint) {
|
|
62
|
-
this.active = true;
|
|
63
|
-
e.preventDefault();
|
|
64
|
-
setTimeout(function () {
|
|
65
|
-
return _this.reset();
|
|
66
|
-
}, 0);
|
|
67
|
-
return {
|
|
68
|
-
cameraAnimation: function cameraAnimation(map) {
|
|
69
|
-
return map.easeTo({
|
|
70
|
-
duration: 300,
|
|
71
|
-
zoom: map.getZoom() - 1,
|
|
72
|
-
around: map.unproject(zoomOutPoint)
|
|
73
|
-
}, {
|
|
74
|
-
originalEvent: e
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}, {
|
|
81
|
-
key: "touchcancel",
|
|
82
|
-
value: function touchcancel() {
|
|
83
|
-
this.reset();
|
|
84
|
-
}
|
|
85
|
-
}, {
|
|
86
|
-
key: "enable",
|
|
87
|
-
value: function enable() {
|
|
88
|
-
this.enabled = true;
|
|
89
|
-
}
|
|
90
|
-
}, {
|
|
91
|
-
key: "disable",
|
|
92
|
-
value: function disable() {
|
|
93
|
-
this.enabled = false;
|
|
94
|
-
this.reset();
|
|
95
|
-
}
|
|
96
|
-
}, {
|
|
97
|
-
key: "isEnabled",
|
|
98
|
-
value: function isEnabled() {
|
|
99
|
-
return this.enabled;
|
|
100
|
-
}
|
|
101
|
-
}, {
|
|
102
|
-
key: "isActive",
|
|
103
|
-
value: function isActive() {
|
|
104
|
-
return this.active;
|
|
21
|
+
reset() {
|
|
22
|
+
this.active = false;
|
|
23
|
+
this.zoomIn.reset();
|
|
24
|
+
this.zoomOut.reset();
|
|
25
|
+
}
|
|
26
|
+
touchstart(e, points, mapTouches) {
|
|
27
|
+
this.zoomIn.touchstart(e, points, mapTouches);
|
|
28
|
+
this.zoomOut.touchstart(e, points, mapTouches);
|
|
29
|
+
}
|
|
30
|
+
touchmove(e, points, mapTouches) {
|
|
31
|
+
this.zoomIn.touchmove(e, points, mapTouches);
|
|
32
|
+
this.zoomOut.touchmove(e, points, mapTouches);
|
|
33
|
+
}
|
|
34
|
+
touchend(e, points, mapTouches) {
|
|
35
|
+
const zoomInPoint = this.zoomIn.touchend(e, points, mapTouches);
|
|
36
|
+
const zoomOutPoint = this.zoomOut.touchend(e, points, mapTouches);
|
|
37
|
+
if (zoomInPoint) {
|
|
38
|
+
this.active = true;
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
setTimeout(() => this.reset(), 0);
|
|
41
|
+
return {
|
|
42
|
+
cameraAnimation: map => map.easeTo({
|
|
43
|
+
duration: 300,
|
|
44
|
+
zoom: map.getZoom() + 1,
|
|
45
|
+
around: map.unproject(zoomInPoint)
|
|
46
|
+
}, {
|
|
47
|
+
originalEvent: e
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
} else if (zoomOutPoint) {
|
|
51
|
+
this.active = true;
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
setTimeout(() => this.reset(), 0);
|
|
54
|
+
return {
|
|
55
|
+
cameraAnimation: map => map.easeTo({
|
|
56
|
+
duration: 300,
|
|
57
|
+
zoom: map.getZoom() - 1,
|
|
58
|
+
around: map.unproject(zoomOutPoint)
|
|
59
|
+
}, {
|
|
60
|
+
originalEvent: e
|
|
61
|
+
})
|
|
62
|
+
};
|
|
105
63
|
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
64
|
+
}
|
|
65
|
+
touchcancel() {
|
|
66
|
+
this.reset();
|
|
67
|
+
}
|
|
68
|
+
enable() {
|
|
69
|
+
this.enabled = true;
|
|
70
|
+
}
|
|
71
|
+
disable() {
|
|
72
|
+
this.enabled = false;
|
|
73
|
+
this.reset();
|
|
74
|
+
}
|
|
75
|
+
isEnabled() {
|
|
76
|
+
return this.enabled;
|
|
77
|
+
}
|
|
78
|
+
isActive() {
|
|
79
|
+
return this.active;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -1,110 +1,91 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
// @ts-ignore
|
|
4
3
|
import Point from "../../geo/point";
|
|
5
4
|
import { indexTouches } from "../handler_util";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export default class TouchPanHandler {
|
|
6
|
+
constructor(options) {
|
|
7
|
+
_defineProperty(this, "enabled", void 0);
|
|
8
|
+
_defineProperty(this, "active", void 0);
|
|
9
|
+
_defineProperty(this, "touches", void 0);
|
|
10
|
+
_defineProperty(this, "minTouches", void 0);
|
|
11
|
+
_defineProperty(this, "clickTolerance", void 0);
|
|
12
|
+
_defineProperty(this, "sum", void 0);
|
|
9
13
|
this.minTouches = 1;
|
|
10
14
|
this.clickTolerance = options.clickTolerance || 1;
|
|
11
15
|
this.reset();
|
|
12
16
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return
|
|
24
|
-
}
|
|
25
|
-
}, {
|
|
26
|
-
key: "touchmove",
|
|
27
|
-
value: function touchmove(e, points, mapTouches) {
|
|
28
|
-
if (!this.active) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
e.preventDefault();
|
|
32
|
-
return this.calculateTransform(e, points, mapTouches);
|
|
33
|
-
}
|
|
34
|
-
}, {
|
|
35
|
-
key: "touchend",
|
|
36
|
-
value: function touchend(e, points, mapTouches) {
|
|
37
|
-
this.calculateTransform(e, points, mapTouches);
|
|
38
|
-
if (this.active && mapTouches.length < this.minTouches) {
|
|
39
|
-
this.reset();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}, {
|
|
43
|
-
key: "touchcancel",
|
|
44
|
-
value: function touchcancel() {
|
|
45
|
-
this.reset();
|
|
46
|
-
}
|
|
47
|
-
}, {
|
|
48
|
-
key: "enable",
|
|
49
|
-
value: function enable() {
|
|
50
|
-
this.enabled = true;
|
|
17
|
+
reset() {
|
|
18
|
+
this.active = false;
|
|
19
|
+
this.touches = {};
|
|
20
|
+
this.sum = new Point(0, 0);
|
|
21
|
+
}
|
|
22
|
+
touchstart(e, points, mapTouches) {
|
|
23
|
+
return this.calculateTransform(e, points, mapTouches);
|
|
24
|
+
}
|
|
25
|
+
touchmove(e, points, mapTouches) {
|
|
26
|
+
if (!this.active) {
|
|
27
|
+
return;
|
|
51
28
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
return this.calculateTransform(e, points, mapTouches);
|
|
31
|
+
}
|
|
32
|
+
touchend(e, points, mapTouches) {
|
|
33
|
+
this.calculateTransform(e, points, mapTouches);
|
|
34
|
+
if (this.active && mapTouches.length < this.minTouches) {
|
|
56
35
|
this.reset();
|
|
57
36
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
37
|
+
}
|
|
38
|
+
touchcancel() {
|
|
39
|
+
this.reset();
|
|
40
|
+
}
|
|
41
|
+
enable() {
|
|
42
|
+
this.enabled = true;
|
|
43
|
+
}
|
|
44
|
+
disable() {
|
|
45
|
+
this.enabled = false;
|
|
46
|
+
this.reset();
|
|
47
|
+
}
|
|
48
|
+
isEnabled() {
|
|
49
|
+
return this.enabled;
|
|
50
|
+
}
|
|
51
|
+
isActive() {
|
|
52
|
+
return this.active;
|
|
53
|
+
}
|
|
54
|
+
calculateTransform(e, points, mapTouches) {
|
|
55
|
+
if (mapTouches.length > 0) {
|
|
56
|
+
this.active = true;
|
|
67
57
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var prevPoint = this.touches[identifier];
|
|
82
|
-
if (prevPoint) {
|
|
83
|
-
touchPointSum._add(point);
|
|
84
|
-
touchDeltaSum._add(point.sub(prevPoint));
|
|
85
|
-
touchDeltaCount++;
|
|
86
|
-
touches[identifier] = point;
|
|
87
|
-
}
|
|
58
|
+
const touches = indexTouches(mapTouches, points);
|
|
59
|
+
const touchPointSum = new Point(0, 0);
|
|
60
|
+
const touchDeltaSum = new Point(0, 0);
|
|
61
|
+
let touchDeltaCount = 0;
|
|
62
|
+
for (const identifier in touches) {
|
|
63
|
+
if (touches[identifier]) {
|
|
64
|
+
const point = touches[identifier];
|
|
65
|
+
const prevPoint = this.touches[identifier];
|
|
66
|
+
if (prevPoint) {
|
|
67
|
+
touchPointSum._add(point);
|
|
68
|
+
touchDeltaSum._add(point.sub(prevPoint));
|
|
69
|
+
touchDeltaCount++;
|
|
70
|
+
touches[identifier] = point;
|
|
88
71
|
}
|
|
89
72
|
}
|
|
90
|
-
this.touches = touches;
|
|
91
|
-
if (touchDeltaCount < this.minTouches || !touchDeltaSum.mag()) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
var panDelta = touchDeltaSum.div(touchDeltaCount);
|
|
96
|
-
this.sum._add(panDelta);
|
|
97
|
-
if (this.sum.mag() < this.clickTolerance) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
// @ts-ignore
|
|
101
|
-
var around = touchPointSum.div(touchDeltaCount);
|
|
102
|
-
return {
|
|
103
|
-
around: around,
|
|
104
|
-
panDelta: panDelta
|
|
105
|
-
};
|
|
106
73
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
74
|
+
this.touches = touches;
|
|
75
|
+
if (touchDeltaCount < this.minTouches || !touchDeltaSum.mag()) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
// @ts-ignore
|
|
79
|
+
const panDelta = touchDeltaSum.div(touchDeltaCount);
|
|
80
|
+
this.sum._add(panDelta);
|
|
81
|
+
if (this.sum.mag() < this.clickTolerance) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
const around = touchPointSum.div(touchDeltaCount);
|
|
86
|
+
return {
|
|
87
|
+
around,
|
|
88
|
+
panDelta
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|