@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
|
@@ -5,93 +5,79 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
11
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
9
|
var _two_touch = _interopRequireDefault(require("./two_touch"));
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
|
|
17
12
|
function isVertical(vector) {
|
|
18
13
|
return Math.abs(vector.y) > Math.abs(vector.x);
|
|
19
14
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(0,
|
|
26
|
-
|
|
15
|
+
const ALLOWED_SINGLE_TOUCH_TIME = 100;
|
|
16
|
+
class TouchPitchHandler extends _two_touch.default {
|
|
17
|
+
constructor(...args) {
|
|
18
|
+
super(...args);
|
|
19
|
+
(0, _defineProperty2.default)(this, "valid", void 0);
|
|
20
|
+
(0, _defineProperty2.default)(this, "firstMove", void 0);
|
|
21
|
+
(0, _defineProperty2.default)(this, "lastPoints", void 0);
|
|
22
|
+
}
|
|
23
|
+
reset() {
|
|
24
|
+
super.reset();
|
|
25
|
+
this.valid = undefined;
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
delete this.firstMove;
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
delete this.lastPoints;
|
|
27
30
|
}
|
|
28
|
-
(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.valid =
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
delete this.firstMove;
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
delete this.lastPoints;
|
|
31
|
+
start(points) {
|
|
32
|
+
this.lastPoints = points;
|
|
33
|
+
if (isVertical(points[0].sub(points[1]))) {
|
|
34
|
+
// fingers are more horizontal than vertical
|
|
35
|
+
this.valid = false;
|
|
37
36
|
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
37
|
+
}
|
|
38
|
+
move(points, center, e) {
|
|
39
|
+
const vectorA = points[0].sub(this.lastPoints[0]);
|
|
40
|
+
const vectorB = points[1].sub(this.lastPoints[1]);
|
|
41
|
+
this.valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);
|
|
42
|
+
if (!this.valid) {
|
|
43
|
+
return;
|
|
46
44
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.
|
|
58
|
-
var yDeltaAverage = (vectorA.y + vectorB.y) / 2;
|
|
59
|
-
var degreesPerPixelMoved = -0.5;
|
|
60
|
-
return {
|
|
61
|
-
pitchDelta: yDeltaAverage * degreesPerPixelMoved
|
|
62
|
-
};
|
|
45
|
+
this.lastPoints = points;
|
|
46
|
+
this.active = true;
|
|
47
|
+
const yDeltaAverage = (vectorA.y + vectorB.y) / 2;
|
|
48
|
+
const degreesPerPixelMoved = -0.5;
|
|
49
|
+
return {
|
|
50
|
+
pitchDelta: yDeltaAverage * degreesPerPixelMoved
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
gestureBeginsVertically(vectorA, vectorB, timeStamp) {
|
|
54
|
+
if (this.valid !== undefined) {
|
|
55
|
+
return this.valid;
|
|
63
56
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (this.valid !== undefined) {
|
|
68
|
-
return this.valid;
|
|
69
|
-
}
|
|
70
|
-
var threshold = 2;
|
|
71
|
-
var movedA = vectorA.mag() >= threshold;
|
|
72
|
-
var movedB = vectorB.mag() >= threshold;
|
|
57
|
+
const threshold = 2;
|
|
58
|
+
const movedA = vectorA.mag() >= threshold;
|
|
59
|
+
const movedB = vectorB.mag() >= threshold;
|
|
73
60
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
61
|
+
// neither finger has moved a meaningful amount, wait
|
|
62
|
+
if (!movedA && !movedB) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
78
65
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
66
|
+
// One finger has moved and the other has not.
|
|
67
|
+
// If enough time has passed, decide it is not a pitch.
|
|
68
|
+
if (!movedA || !movedB) {
|
|
69
|
+
if (this.firstMove === undefined) {
|
|
70
|
+
this.firstMove = timeStamp;
|
|
71
|
+
}
|
|
72
|
+
if (timeStamp - this.firstMove < ALLOWED_SINGLE_TOUCH_TIME) {
|
|
73
|
+
// still waiting for a movement from the second finger
|
|
74
|
+
return undefined;
|
|
75
|
+
} else {
|
|
76
|
+
return false;
|
|
91
77
|
}
|
|
92
|
-
var isSameDirection = vectorA.y > 0 === vectorB.y > 0;
|
|
93
|
-
return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
|
|
94
78
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
79
|
+
const isSameDirection = vectorA.y > 0 === vectorB.y > 0;
|
|
80
|
+
return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.default = TouchPitchHandler;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type Point from '../../geo/point';
|
|
2
|
+
import TwoTouchHandler from './two_touch';
|
|
3
|
+
export default class TouchRotateHandler extends TwoTouchHandler {
|
|
4
|
+
private minDiameter;
|
|
5
|
+
reset(): void;
|
|
6
|
+
start(points: [Point, Point]): void;
|
|
7
|
+
move(points: [Point, Point], pinchAround: Point): {
|
|
8
|
+
bearingDelta: number;
|
|
9
|
+
pinchAround: Point;
|
|
10
|
+
} | undefined;
|
|
11
|
+
private isBelowThreshold;
|
|
12
|
+
}
|
|
@@ -5,77 +5,61 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
11
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
9
|
var _two_touch = _interopRequireDefault(require("./two_touch"));
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
|
|
12
|
+
const ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle
|
|
18
13
|
|
|
19
14
|
function getBearingDelta(a, b) {
|
|
20
15
|
return a.angleWith(b) * 180 / Math.PI;
|
|
21
16
|
}
|
|
22
|
-
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
(0, _classCallCheck2.default)(this, TouchRotateHandler);
|
|
27
|
-
return _super.apply(this, arguments);
|
|
17
|
+
class TouchRotateHandler extends _two_touch.default {
|
|
18
|
+
constructor(...args) {
|
|
19
|
+
super(...args);
|
|
20
|
+
(0, _defineProperty2.default)(this, "minDiameter", void 0);
|
|
28
21
|
}
|
|
29
|
-
(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
key: "move",
|
|
48
|
-
value: function move(points, pinchAround) {
|
|
49
|
-
var lastVector = this.vector;
|
|
50
|
-
this.vector = points[0].sub(points[1]);
|
|
51
|
-
if (!this.active && this.isBelowThreshold(this.vector)) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
this.active = true;
|
|
55
|
-
return {
|
|
56
|
-
bearingDelta: getBearingDelta(this.vector, lastVector),
|
|
57
|
-
pinchAround: pinchAround
|
|
58
|
-
};
|
|
22
|
+
reset() {
|
|
23
|
+
super.reset();
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
delete this.minDiameter;
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
delete this.startVector;
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
delete this.vector;
|
|
30
|
+
}
|
|
31
|
+
start(points) {
|
|
32
|
+
this.startVector = this.vector = points[0].sub(points[1]);
|
|
33
|
+
this.minDiameter = points[0].dist(points[1]);
|
|
34
|
+
}
|
|
35
|
+
move(points, pinchAround) {
|
|
36
|
+
const lastVector = this.vector;
|
|
37
|
+
this.vector = points[0].sub(points[1]);
|
|
38
|
+
if (!this.active && this.isBelowThreshold(this.vector)) {
|
|
39
|
+
return;
|
|
59
40
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
41
|
+
this.active = true;
|
|
42
|
+
return {
|
|
43
|
+
bearingDelta: getBearingDelta(this.vector, lastVector),
|
|
44
|
+
pinchAround
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
isBelowThreshold(vector) {
|
|
48
|
+
/*
|
|
49
|
+
* The threshold before a rotation actually happens is configured in
|
|
50
|
+
* pixels alongth circumference of the circle formed by the two fingers.
|
|
51
|
+
* This makes the threshold in degrees larger when the fingers are close
|
|
52
|
+
* together and smaller when the fingers are far apart.
|
|
53
|
+
*
|
|
54
|
+
* Use the smallest diameter from the whole gesture to reduce sensitivity
|
|
55
|
+
* when pinching in and out.
|
|
56
|
+
*/
|
|
72
57
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}(_two_touch.default);
|
|
58
|
+
this.minDiameter = Math.min(this.minDiameter, vector.mag());
|
|
59
|
+
const circumference = Math.PI * this.minDiameter;
|
|
60
|
+
const threshold = ROTATION_THRESHOLD / circumference * 360;
|
|
61
|
+
const bearingDeltaSinceStart = getBearingDelta(vector, this.startVector);
|
|
62
|
+
return Math.abs(bearingDeltaSinceStart) < threshold;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.default = TouchRotateHandler;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type Point from '../../geo/point';
|
|
2
|
+
import TwoTouchHandler from './two_touch';
|
|
3
|
+
export default class TouchZoomHandler extends TwoTouchHandler {
|
|
4
|
+
private distance;
|
|
5
|
+
private startDistance;
|
|
6
|
+
reset(): void;
|
|
7
|
+
start(points: [Point, Point]): void;
|
|
8
|
+
move(points: [Point, Point], pinchAround: Point): {
|
|
9
|
+
zoomDelta: number;
|
|
10
|
+
pinchAround: Point;
|
|
11
|
+
} | undefined;
|
|
12
|
+
}
|
|
@@ -5,54 +5,41 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
11
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
9
|
var _two_touch = _interopRequireDefault(require("./two_touch"));
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
|
|
12
|
+
const ZOOM_THRESHOLD = 0.1;
|
|
18
13
|
function getZoomDelta(distance, lastDistance) {
|
|
19
14
|
return Math.log(distance / lastDistance) / Math.LN2;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
|
-
(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(0,
|
|
26
|
-
return _super.apply(this, arguments);
|
|
16
|
+
class TouchZoomHandler extends _two_touch.default {
|
|
17
|
+
constructor(...args) {
|
|
18
|
+
super(...args);
|
|
19
|
+
(0, _defineProperty2.default)(this, "distance", void 0);
|
|
20
|
+
(0, _defineProperty2.default)(this, "startDistance", void 0);
|
|
27
21
|
}
|
|
28
|
-
(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
key: "move",
|
|
44
|
-
value: function move(points, pinchAround) {
|
|
45
|
-
var lastDistance = this.distance;
|
|
46
|
-
this.distance = points[0].dist(points[1]);
|
|
47
|
-
if (!this.active && Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
this.active = true;
|
|
51
|
-
return {
|
|
52
|
-
zoomDelta: getZoomDelta(this.distance, lastDistance),
|
|
53
|
-
pinchAround: pinchAround
|
|
54
|
-
};
|
|
22
|
+
reset() {
|
|
23
|
+
super.reset();
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
delete this.distance;
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
delete this.startDistance;
|
|
28
|
+
}
|
|
29
|
+
start(points) {
|
|
30
|
+
this.startDistance = this.distance = points[0].dist(points[1]);
|
|
31
|
+
}
|
|
32
|
+
move(points, pinchAround) {
|
|
33
|
+
const lastDistance = this.distance;
|
|
34
|
+
this.distance = points[0].dist(points[1]);
|
|
35
|
+
if (!this.active && Math.abs(getZoomDelta(this.distance, this.startDistance)) < ZOOM_THRESHOLD) {
|
|
36
|
+
return;
|
|
55
37
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
38
|
+
this.active = true;
|
|
39
|
+
return {
|
|
40
|
+
zoomDelta: getZoomDelta(this.distance, lastDistance),
|
|
41
|
+
pinchAround
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.default = TouchZoomHandler;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type Point from '../../geo/point';
|
|
2
|
+
export default class TwoTouchHandler {
|
|
3
|
+
protected enabled: boolean;
|
|
4
|
+
protected active: boolean;
|
|
5
|
+
protected firstTwoTouches: [number, number];
|
|
6
|
+
protected vector: Point;
|
|
7
|
+
protected startVector: Point;
|
|
8
|
+
protected aroundCenter: boolean;
|
|
9
|
+
constructor();
|
|
10
|
+
reset(): void;
|
|
11
|
+
start(points: [Point, Point]): void;
|
|
12
|
+
move(points: [Point, Point], pinchAround: Point | null, e: TouchEvent): void;
|
|
13
|
+
touchstart(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
|
|
14
|
+
touchmove(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
|
|
15
|
+
touchend(e: TouchEvent, points: Point[], mapTouches: Touch[]): void;
|
|
16
|
+
touchcancel(): void;
|
|
17
|
+
enable(options?: {
|
|
18
|
+
around?: 'center';
|
|
19
|
+
}): void;
|
|
20
|
+
disable(): void;
|
|
21
|
+
isEnabled(): boolean;
|
|
22
|
+
isActive(): boolean;
|
|
23
|
+
}
|
|
@@ -5,122 +5,100 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
9
|
var _dom = _interopRequireDefault(require("../../utils/dom"));
|
|
12
10
|
// @ts-ignore
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
|
|
12
|
+
class TwoTouchHandler {
|
|
13
|
+
constructor() {
|
|
14
|
+
(0, _defineProperty2.default)(this, "enabled", void 0);
|
|
15
|
+
(0, _defineProperty2.default)(this, "active", void 0);
|
|
16
|
+
(0, _defineProperty2.default)(this, "firstTwoTouches", void 0);
|
|
17
|
+
(0, _defineProperty2.default)(this, "vector", void 0);
|
|
18
|
+
(0, _defineProperty2.default)(this, "startVector", void 0);
|
|
19
|
+
(0, _defineProperty2.default)(this, "aroundCenter", void 0);
|
|
16
20
|
this.reset();
|
|
17
21
|
}
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
|
-
pinchAround,
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
39
|
-
e) {
|
|
40
|
-
return;
|
|
41
|
-
} // eslint-disable-line
|
|
42
|
-
}, {
|
|
43
|
-
key: "touchstart",
|
|
44
|
-
value: function touchstart(e, points, mapTouches) {
|
|
45
|
-
if (this.firstTwoTouches || mapTouches.length < 2) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
|
|
22
|
+
reset() {
|
|
23
|
+
this.active = false;
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
delete this.firstTwoTouches;
|
|
26
|
+
}
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
|
+
start(points) {
|
|
29
|
+
return;
|
|
30
|
+
} // eslint-disable-line
|
|
31
|
+
move(
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
+
points,
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
35
|
+
pinchAround,
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
|
+
e) {
|
|
38
|
+
return;
|
|
39
|
+
} // eslint-disable-line
|
|
49
40
|
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
touchstart(e, points, mapTouches) {
|
|
42
|
+
if (this.firstTwoTouches || mapTouches.length < 2) {
|
|
43
|
+
return;
|
|
52
44
|
}
|
|
53
|
-
|
|
54
|
-
key: "touchmove",
|
|
55
|
-
value: function touchmove(e, points, mapTouches) {
|
|
56
|
-
if (!this.firstTwoTouches) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
e.preventDefault();
|
|
60
|
-
var _this$firstTwoTouches = (0, _slicedToArray2.default)(this.firstTwoTouches, 2),
|
|
61
|
-
idA = _this$firstTwoTouches[0],
|
|
62
|
-
idB = _this$firstTwoTouches[1];
|
|
63
|
-
var a = getTouchById(mapTouches, points, idA);
|
|
64
|
-
var b = getTouchById(mapTouches, points, idB);
|
|
65
|
-
if (!a || !b) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
var pinchAround = this.aroundCenter ? null : a.add(b).div(2);
|
|
45
|
+
this.firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
|
|
69
46
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (!this.firstTwoTouches) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
var _this$firstTwoTouches2 = (0, _slicedToArray2.default)(this.firstTwoTouches, 2),
|
|
80
|
-
idA = _this$firstTwoTouches2[0],
|
|
81
|
-
idB = _this$firstTwoTouches2[1];
|
|
82
|
-
var a = getTouchById(mapTouches, points, idA);
|
|
83
|
-
var b = getTouchById(mapTouches, points, idB);
|
|
84
|
-
if (a && b) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (this.active) {
|
|
88
|
-
_dom.default.suppressClick();
|
|
89
|
-
}
|
|
90
|
-
this.reset();
|
|
91
|
-
}
|
|
92
|
-
}, {
|
|
93
|
-
key: "touchcancel",
|
|
94
|
-
value: function touchcancel() {
|
|
95
|
-
this.reset();
|
|
47
|
+
// implemented by child classes
|
|
48
|
+
this.start([points[0], points[1]]);
|
|
49
|
+
}
|
|
50
|
+
touchmove(e, points, mapTouches) {
|
|
51
|
+
if (!this.firstTwoTouches) {
|
|
52
|
+
return;
|
|
96
53
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
const [idA, idB] = this.firstTwoTouches;
|
|
56
|
+
const a = getTouchById(mapTouches, points, idA);
|
|
57
|
+
const b = getTouchById(mapTouches, points, idB);
|
|
58
|
+
if (!a || !b) {
|
|
59
|
+
return;
|
|
102
60
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
61
|
+
const pinchAround = this.aroundCenter ? null : a.add(b).div(2);
|
|
62
|
+
|
|
63
|
+
// implemented by child classes
|
|
64
|
+
return this.move([a, b], pinchAround, e);
|
|
65
|
+
}
|
|
66
|
+
touchend(e, points, mapTouches) {
|
|
67
|
+
if (!this.firstTwoTouches) {
|
|
68
|
+
return;
|
|
108
69
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
70
|
+
const [idA, idB] = this.firstTwoTouches;
|
|
71
|
+
const a = getTouchById(mapTouches, points, idA);
|
|
72
|
+
const b = getTouchById(mapTouches, points, idB);
|
|
73
|
+
if (a && b) {
|
|
74
|
+
return;
|
|
113
75
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
value: function isActive() {
|
|
117
|
-
return this.active;
|
|
76
|
+
if (this.active) {
|
|
77
|
+
_dom.default.suppressClick();
|
|
118
78
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
79
|
+
this.reset();
|
|
80
|
+
}
|
|
81
|
+
touchcancel() {
|
|
82
|
+
this.reset();
|
|
83
|
+
}
|
|
84
|
+
enable(options) {
|
|
85
|
+
this.enabled = true;
|
|
86
|
+
this.aroundCenter = !!options && options.around === 'center';
|
|
87
|
+
}
|
|
88
|
+
disable() {
|
|
89
|
+
this.enabled = false;
|
|
90
|
+
this.reset();
|
|
91
|
+
}
|
|
92
|
+
isEnabled() {
|
|
93
|
+
return this.enabled;
|
|
94
|
+
}
|
|
95
|
+
isActive() {
|
|
96
|
+
return this.active;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.default = TwoTouchHandler;
|
|
122
100
|
function getTouchById(mapTouches, points, identifier) {
|
|
123
|
-
for (
|
|
101
|
+
for (let i = 0; i < mapTouches.length; i++) {
|
|
124
102
|
if (mapTouches[i].identifier === identifier) {
|
|
125
103
|
return points[i];
|
|
126
104
|
}
|
package/lib/hash.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Map } from './map';
|
|
2
|
+
declare class Hash {
|
|
3
|
+
private map;
|
|
4
|
+
private updateHash;
|
|
5
|
+
private hashName?;
|
|
6
|
+
constructor(hashName?: string);
|
|
7
|
+
addTo(map: Map): this;
|
|
8
|
+
remove(): this;
|
|
9
|
+
onHashChange: () => boolean;
|
|
10
|
+
private getCurrentHash;
|
|
11
|
+
private getHashString;
|
|
12
|
+
private updateHashUnthrottled;
|
|
13
|
+
}
|
|
14
|
+
export default Hash;
|