@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.
- package/es/index.d.ts +5 -0
- package/es/index.js +4 -0
- package/es/map/camera.d.ts +690 -0
- package/es/map/camera.js +1138 -0
- package/es/map/css/l7.css +171 -0
- package/es/map/events.d.ts +384 -0
- package/es/map/events.js +231 -0
- package/es/map/geo/edge_insets.d.ts +97 -0
- package/es/map/geo/edge_insets.js +115 -0
- package/es/map/geo/lng_lat.d.ts +116 -0
- package/es/map/geo/lng_lat.js +159 -0
- package/es/map/geo/lng_lat_bounds.d.ts +217 -0
- package/es/map/geo/lng_lat_bounds.js +334 -0
- package/es/map/geo/mercator_coordinate.d.ts +113 -0
- package/es/map/geo/mercator_coordinate.js +142 -0
- package/es/map/geo/transform.d.ts +262 -0
- package/es/map/geo/transform.js +736 -0
- package/es/map/handler/box_zoom.d.ts +65 -0
- package/es/map/handler/box_zoom.js +145 -0
- package/es/map/handler/click_zoom.d.ts +24 -0
- package/es/map/handler/click_zoom.js +47 -0
- package/es/map/handler/cooperative_gestures.d.ts +40 -0
- package/es/map/handler/cooperative_gestures.js +94 -0
- package/es/map/handler/drag_handler.d.ts +88 -0
- package/es/map/handler/drag_handler.js +89 -0
- package/es/map/handler/drag_move_state_manager.d.ts +30 -0
- package/es/map/handler/drag_move_state_manager.js +94 -0
- package/es/map/handler/handler_util.d.ts +3 -0
- package/es/map/handler/handler_util.js +8 -0
- package/es/map/handler/keyboard.d.ts +88 -0
- package/es/map/handler/keyboard.js +197 -0
- package/es/map/handler/map_event.d.ts +46 -0
- package/es/map/handler/map_event.js +131 -0
- package/es/map/handler/mouse.d.ts +30 -0
- package/es/map/handler/mouse.js +85 -0
- package/es/map/handler/one_finger_touch_drag.d.ts +15 -0
- package/es/map/handler/one_finger_touch_drag.js +39 -0
- package/es/map/handler/scroll_zoom.d.ts +102 -0
- package/es/map/handler/scroll_zoom.js +312 -0
- package/es/map/handler/shim/dblclick_zoom.d.ts +44 -0
- package/es/map/handler/shim/dblclick_zoom.js +60 -0
- package/es/map/handler/shim/drag_pan.d.ts +79 -0
- package/es/map/handler/shim/drag_pan.js +77 -0
- package/es/map/handler/shim/drag_rotate.d.ts +54 -0
- package/es/map/handler/shim/drag_rotate.js +66 -0
- package/es/map/handler/shim/two_fingers_touch.d.ts +74 -0
- package/es/map/handler/shim/two_fingers_touch.js +106 -0
- package/es/map/handler/tap_drag_zoom.d.ts +28 -0
- package/es/map/handler/tap_drag_zoom.js +92 -0
- package/es/map/handler/tap_recognizer.d.ts +35 -0
- package/es/map/handler/tap_recognizer.js +107 -0
- package/es/map/handler/tap_zoom.d.ts +28 -0
- package/es/map/handler/tap_zoom.js +87 -0
- package/es/map/handler/touch_pan.d.ts +40 -0
- package/es/map/handler/touch_pan.js +85 -0
- package/es/map/handler/transform-provider.d.ts +23 -0
- package/es/map/handler/transform-provider.js +35 -0
- package/es/map/handler/two_fingers_touch.d.ts +107 -0
- package/es/map/handler/two_fingers_touch.js +289 -0
- package/es/map/handler_inertia.d.ts +20 -0
- package/es/map/handler_inertia.js +128 -0
- package/es/map/handler_manager.d.ts +154 -0
- package/es/map/handler_manager.js +466 -0
- package/es/map/map.d.ts +637 -0
- package/es/map/map.js +984 -0
- package/es/map/util/abort_error.d.ts +15 -0
- package/es/map/util/abort_error.js +21 -0
- package/es/map/util/browser.d.ts +10 -0
- package/es/map/util/browser.js +30 -0
- package/es/map/util/dom.d.ts +30 -0
- package/es/map/util/dom.js +105 -0
- package/es/map/util/evented.d.ts +75 -0
- package/es/map/util/evented.js +158 -0
- package/es/map/util/simpleMapCoord.d.ts +31 -0
- package/es/map/util/simpleMapCoord.js +54 -0
- package/es/map/util/task_queue.d.ts +18 -0
- package/es/map/util/task_queue.js +54 -0
- package/es/map/util/util.d.ts +104 -0
- package/es/map/util/util.js +155 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +33 -0
- package/lib/map/camera.d.ts +690 -0
- package/lib/map/camera.js +1145 -0
- package/lib/map/css/l7.css +171 -0
- package/lib/map/events.d.ts +384 -0
- package/lib/map/events.js +240 -0
- package/lib/map/geo/edge_insets.d.ts +97 -0
- package/lib/map/geo/edge_insets.js +122 -0
- package/lib/map/geo/lng_lat.d.ts +116 -0
- package/lib/map/geo/lng_lat.js +166 -0
- package/lib/map/geo/lng_lat_bounds.d.ts +217 -0
- package/lib/map/geo/lng_lat_bounds.js +341 -0
- package/lib/map/geo/mercator_coordinate.d.ts +113 -0
- package/lib/map/geo/mercator_coordinate.js +157 -0
- package/lib/map/geo/transform.d.ts +262 -0
- package/lib/map/geo/transform.js +744 -0
- package/lib/map/handler/box_zoom.d.ts +65 -0
- package/lib/map/handler/box_zoom.js +153 -0
- package/lib/map/handler/click_zoom.d.ts +24 -0
- package/lib/map/handler/click_zoom.js +54 -0
- package/lib/map/handler/cooperative_gestures.d.ts +40 -0
- package/lib/map/handler/cooperative_gestures.js +101 -0
- package/lib/map/handler/drag_handler.d.ts +88 -0
- package/lib/map/handler/drag_handler.js +97 -0
- package/lib/map/handler/drag_move_state_manager.d.ts +30 -0
- package/lib/map/handler/drag_move_state_manager.js +103 -0
- package/lib/map/handler/handler_util.d.ts +3 -0
- package/lib/map/handler/handler_util.js +14 -0
- package/lib/map/handler/keyboard.d.ts +88 -0
- package/lib/map/handler/keyboard.js +205 -0
- package/lib/map/handler/map_event.d.ts +46 -0
- package/lib/map/handler/map_event.js +140 -0
- package/lib/map/handler/mouse.d.ts +30 -0
- package/lib/map/handler/mouse.js +93 -0
- package/lib/map/handler/one_finger_touch_drag.d.ts +15 -0
- package/lib/map/handler/one_finger_touch_drag.js +47 -0
- package/lib/map/handler/scroll_zoom.d.ts +102 -0
- package/lib/map/handler/scroll_zoom.js +320 -0
- package/lib/map/handler/shim/dblclick_zoom.d.ts +44 -0
- package/lib/map/handler/shim/dblclick_zoom.js +68 -0
- package/lib/map/handler/shim/drag_pan.d.ts +79 -0
- package/lib/map/handler/shim/drag_pan.js +85 -0
- package/lib/map/handler/shim/drag_rotate.d.ts +54 -0
- package/lib/map/handler/shim/drag_rotate.js +74 -0
- package/lib/map/handler/shim/two_fingers_touch.d.ts +74 -0
- package/lib/map/handler/shim/two_fingers_touch.js +114 -0
- package/lib/map/handler/tap_drag_zoom.d.ts +28 -0
- package/lib/map/handler/tap_drag_zoom.js +99 -0
- package/lib/map/handler/tap_recognizer.d.ts +35 -0
- package/lib/map/handler/tap_recognizer.js +116 -0
- package/lib/map/handler/tap_zoom.d.ts +28 -0
- package/lib/map/handler/tap_zoom.js +94 -0
- package/lib/map/handler/touch_pan.d.ts +40 -0
- package/lib/map/handler/touch_pan.js +92 -0
- package/lib/map/handler/transform-provider.d.ts +23 -0
- package/lib/map/handler/transform-provider.js +43 -0
- package/lib/map/handler/two_fingers_touch.d.ts +107 -0
- package/lib/map/handler/two_fingers_touch.js +296 -0
- package/lib/map/handler_inertia.d.ts +20 -0
- package/lib/map/handler_inertia.js +136 -0
- package/lib/map/handler_manager.d.ts +154 -0
- package/lib/map/handler_manager.js +474 -0
- package/lib/map/map.d.ts +637 -0
- package/lib/map/map.js +991 -0
- package/lib/map/util/abort_error.d.ts +15 -0
- package/lib/map/util/abort_error.js +29 -0
- package/lib/map/util/browser.d.ts +10 -0
- package/lib/map/util/browser.js +36 -0
- package/lib/map/util/dom.d.ts +30 -0
- package/lib/map/util/dom.js +113 -0
- package/lib/map/util/evented.d.ts +75 -0
- package/lib/map/util/evented.js +167 -0
- package/lib/map/util/simpleMapCoord.d.ts +31 -0
- package/lib/map/util/simpleMapCoord.js +62 -0
- package/lib/map/util/task_queue.d.ts +18 -0
- package/lib/map/util/task_queue.js +62 -0
- package/lib/map/util/util.d.ts +104 -0
- package/lib/map/util/util.js +171 -0
- package/package.json +2 -2
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.TapRecognizer = exports.SingleTapRecognizer = exports.MAX_TAP_INTERVAL = exports.MAX_DIST = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _pointGeometry = _interopRequireDefault(require("@mapbox/point-geometry"));
|
|
10
|
+
var _handler_util = require("./handler_util");
|
|
11
|
+
function getCentroid(points) {
|
|
12
|
+
const sum = new _pointGeometry.default(0, 0);
|
|
13
|
+
for (const point of points) {
|
|
14
|
+
sum._add(point);
|
|
15
|
+
}
|
|
16
|
+
return sum.div(points.length);
|
|
17
|
+
}
|
|
18
|
+
const MAX_TAP_INTERVAL = exports.MAX_TAP_INTERVAL = 500;
|
|
19
|
+
const MAX_TOUCH_TIME = 500;
|
|
20
|
+
const MAX_DIST = exports.MAX_DIST = 30;
|
|
21
|
+
class SingleTapRecognizer {
|
|
22
|
+
constructor(options) {
|
|
23
|
+
(0, _defineProperty2.default)(this, "numTouches", void 0);
|
|
24
|
+
(0, _defineProperty2.default)(this, "centroid", void 0);
|
|
25
|
+
(0, _defineProperty2.default)(this, "startTime", void 0);
|
|
26
|
+
(0, _defineProperty2.default)(this, "aborted", void 0);
|
|
27
|
+
(0, _defineProperty2.default)(this, "touches", void 0);
|
|
28
|
+
this.reset();
|
|
29
|
+
this.numTouches = options.numTouches;
|
|
30
|
+
}
|
|
31
|
+
reset() {
|
|
32
|
+
delete this.centroid;
|
|
33
|
+
delete this.startTime;
|
|
34
|
+
delete this.touches;
|
|
35
|
+
this.aborted = false;
|
|
36
|
+
}
|
|
37
|
+
touchstart(e, points, mapTouches) {
|
|
38
|
+
if (this.centroid || mapTouches.length > this.numTouches) {
|
|
39
|
+
this.aborted = true;
|
|
40
|
+
}
|
|
41
|
+
if (this.aborted) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (this.startTime === undefined) {
|
|
45
|
+
this.startTime = e.timeStamp;
|
|
46
|
+
}
|
|
47
|
+
if (mapTouches.length === this.numTouches) {
|
|
48
|
+
this.centroid = getCentroid(points);
|
|
49
|
+
this.touches = (0, _handler_util.indexTouches)(mapTouches, points);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
touchmove(e, points, mapTouches) {
|
|
53
|
+
if (this.aborted || !this.centroid) return;
|
|
54
|
+
const newTouches = (0, _handler_util.indexTouches)(mapTouches, points);
|
|
55
|
+
for (const id in this.touches) {
|
|
56
|
+
const prevPos = this.touches[id];
|
|
57
|
+
const pos = newTouches[id];
|
|
58
|
+
if (!pos || pos.dist(prevPos) > MAX_DIST) {
|
|
59
|
+
this.aborted = true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
touchend(e, points, mapTouches) {
|
|
64
|
+
if (!this.centroid || e.timeStamp - this.startTime > MAX_TOUCH_TIME) {
|
|
65
|
+
this.aborted = true;
|
|
66
|
+
}
|
|
67
|
+
if (mapTouches.length === 0) {
|
|
68
|
+
const centroid = !this.aborted && this.centroid;
|
|
69
|
+
this.reset();
|
|
70
|
+
if (centroid) return centroid;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.SingleTapRecognizer = SingleTapRecognizer;
|
|
75
|
+
class TapRecognizer {
|
|
76
|
+
constructor(options) {
|
|
77
|
+
(0, _defineProperty2.default)(this, "singleTap", void 0);
|
|
78
|
+
(0, _defineProperty2.default)(this, "numTaps", void 0);
|
|
79
|
+
(0, _defineProperty2.default)(this, "lastTime", void 0);
|
|
80
|
+
(0, _defineProperty2.default)(this, "lastTap", void 0);
|
|
81
|
+
(0, _defineProperty2.default)(this, "count", void 0);
|
|
82
|
+
this.singleTap = new SingleTapRecognizer(options);
|
|
83
|
+
this.numTaps = options.numTaps;
|
|
84
|
+
this.reset();
|
|
85
|
+
}
|
|
86
|
+
reset() {
|
|
87
|
+
this.lastTime = Infinity;
|
|
88
|
+
delete this.lastTap;
|
|
89
|
+
this.count = 0;
|
|
90
|
+
this.singleTap.reset();
|
|
91
|
+
}
|
|
92
|
+
touchstart(e, points, mapTouches) {
|
|
93
|
+
this.singleTap.touchstart(e, points, mapTouches);
|
|
94
|
+
}
|
|
95
|
+
touchmove(e, points, mapTouches) {
|
|
96
|
+
this.singleTap.touchmove(e, points, mapTouches);
|
|
97
|
+
}
|
|
98
|
+
touchend(e, points, mapTouches) {
|
|
99
|
+
const tap = this.singleTap.touchend(e, points, mapTouches);
|
|
100
|
+
if (tap) {
|
|
101
|
+
const soonEnough = e.timeStamp - this.lastTime < MAX_TAP_INTERVAL;
|
|
102
|
+
const closeEnough = !this.lastTap || this.lastTap.dist(tap) < MAX_DIST;
|
|
103
|
+
if (!soonEnough || !closeEnough) {
|
|
104
|
+
this.reset();
|
|
105
|
+
}
|
|
106
|
+
this.count++;
|
|
107
|
+
this.lastTime = e.timeStamp;
|
|
108
|
+
this.lastTap = tap;
|
|
109
|
+
if (this.count === this.numTaps) {
|
|
110
|
+
this.reset();
|
|
111
|
+
return tap;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.TapRecognizer = TapRecognizer;
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.TapZoomHandler = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _tap_recognizer = require("./tap_recognizer");
|
|
10
|
+
var _transformProvider = require("./transform-provider");
|
|
11
|
+
/**
|
|
12
|
+
* A `TapZoomHandler` allows the user to zoom the map at a point by double tapping
|
|
13
|
+
*/
|
|
14
|
+
class TapZoomHandler {
|
|
15
|
+
constructor(map) {
|
|
16
|
+
(0, _defineProperty2.default)(this, "_tr", void 0);
|
|
17
|
+
(0, _defineProperty2.default)(this, "_enabled", void 0);
|
|
18
|
+
(0, _defineProperty2.default)(this, "_active", void 0);
|
|
19
|
+
(0, _defineProperty2.default)(this, "_zoomIn", void 0);
|
|
20
|
+
(0, _defineProperty2.default)(this, "_zoomOut", void 0);
|
|
21
|
+
this._tr = new _transformProvider.TransformProvider(map);
|
|
22
|
+
this._zoomIn = new _tap_recognizer.TapRecognizer({
|
|
23
|
+
numTouches: 1,
|
|
24
|
+
numTaps: 2
|
|
25
|
+
});
|
|
26
|
+
this._zoomOut = new _tap_recognizer.TapRecognizer({
|
|
27
|
+
numTouches: 2,
|
|
28
|
+
numTaps: 1
|
|
29
|
+
});
|
|
30
|
+
this.reset();
|
|
31
|
+
}
|
|
32
|
+
reset() {
|
|
33
|
+
this._active = false;
|
|
34
|
+
this._zoomIn.reset();
|
|
35
|
+
this._zoomOut.reset();
|
|
36
|
+
}
|
|
37
|
+
touchstart(e, points, mapTouches) {
|
|
38
|
+
this._zoomIn.touchstart(e, points, mapTouches);
|
|
39
|
+
this._zoomOut.touchstart(e, points, mapTouches);
|
|
40
|
+
}
|
|
41
|
+
touchmove(e, points, mapTouches) {
|
|
42
|
+
this._zoomIn.touchmove(e, points, mapTouches);
|
|
43
|
+
this._zoomOut.touchmove(e, points, mapTouches);
|
|
44
|
+
}
|
|
45
|
+
touchend(e, points, mapTouches) {
|
|
46
|
+
const zoomInPoint = this._zoomIn.touchend(e, points, mapTouches);
|
|
47
|
+
const zoomOutPoint = this._zoomOut.touchend(e, points, mapTouches);
|
|
48
|
+
const tr = this._tr;
|
|
49
|
+
if (zoomInPoint) {
|
|
50
|
+
this._active = true;
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
setTimeout(() => this.reset(), 0);
|
|
53
|
+
return {
|
|
54
|
+
cameraAnimation: map => map.easeTo({
|
|
55
|
+
duration: 300,
|
|
56
|
+
zoom: tr.zoom + 1,
|
|
57
|
+
around: tr.unproject(zoomInPoint)
|
|
58
|
+
}, {
|
|
59
|
+
originalEvent: e
|
|
60
|
+
})
|
|
61
|
+
};
|
|
62
|
+
} else if (zoomOutPoint) {
|
|
63
|
+
this._active = true;
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
setTimeout(() => this.reset(), 0);
|
|
66
|
+
return {
|
|
67
|
+
cameraAnimation: map => map.easeTo({
|
|
68
|
+
duration: 300,
|
|
69
|
+
zoom: tr.zoom - 1,
|
|
70
|
+
around: tr.unproject(zoomOutPoint)
|
|
71
|
+
}, {
|
|
72
|
+
originalEvent: e
|
|
73
|
+
})
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
touchcancel() {
|
|
78
|
+
this.reset();
|
|
79
|
+
}
|
|
80
|
+
enable() {
|
|
81
|
+
this._enabled = true;
|
|
82
|
+
}
|
|
83
|
+
disable() {
|
|
84
|
+
this._enabled = false;
|
|
85
|
+
this.reset();
|
|
86
|
+
}
|
|
87
|
+
isEnabled() {
|
|
88
|
+
return this._enabled;
|
|
89
|
+
}
|
|
90
|
+
isActive() {
|
|
91
|
+
return this._active;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.TapZoomHandler = TapZoomHandler;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="mapbox__point-geometry" />
|
|
2
|
+
import Point from '@mapbox/point-geometry';
|
|
3
|
+
import type { Handler } from '../handler_manager';
|
|
4
|
+
import type { Map } from '../map';
|
|
5
|
+
/**
|
|
6
|
+
* A `TouchPanHandler` allows the user to pan the map using touch gestures.
|
|
7
|
+
*/
|
|
8
|
+
export declare class TouchPanHandler implements Handler {
|
|
9
|
+
_enabled: boolean;
|
|
10
|
+
_active: boolean;
|
|
11
|
+
_touches: {
|
|
12
|
+
[k in string | number]: Point;
|
|
13
|
+
};
|
|
14
|
+
_clickTolerance: number;
|
|
15
|
+
_sum: Point;
|
|
16
|
+
_map: Map;
|
|
17
|
+
constructor(options: {
|
|
18
|
+
clickTolerance: number;
|
|
19
|
+
}, map: Map);
|
|
20
|
+
reset(): void;
|
|
21
|
+
minTouchs(): 1 | 2;
|
|
22
|
+
touchstart(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): {
|
|
23
|
+
around: Point;
|
|
24
|
+
panDelta: Point;
|
|
25
|
+
};
|
|
26
|
+
touchmove(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): {
|
|
27
|
+
around: Point;
|
|
28
|
+
panDelta: Point;
|
|
29
|
+
};
|
|
30
|
+
touchend(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): void;
|
|
31
|
+
touchcancel(): void;
|
|
32
|
+
_calculateTransform(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): {
|
|
33
|
+
around: Point;
|
|
34
|
+
panDelta: Point;
|
|
35
|
+
};
|
|
36
|
+
enable(): void;
|
|
37
|
+
disable(): void;
|
|
38
|
+
isEnabled(): boolean;
|
|
39
|
+
isActive(): boolean;
|
|
40
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.TouchPanHandler = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _pointGeometry = _interopRequireDefault(require("@mapbox/point-geometry"));
|
|
10
|
+
var _handler_util = require("./handler_util");
|
|
11
|
+
/**
|
|
12
|
+
* A `TouchPanHandler` allows the user to pan the map using touch gestures.
|
|
13
|
+
*/
|
|
14
|
+
class TouchPanHandler {
|
|
15
|
+
constructor(options, map) {
|
|
16
|
+
(0, _defineProperty2.default)(this, "_enabled", void 0);
|
|
17
|
+
(0, _defineProperty2.default)(this, "_active", void 0);
|
|
18
|
+
(0, _defineProperty2.default)(this, "_touches", void 0);
|
|
19
|
+
(0, _defineProperty2.default)(this, "_clickTolerance", void 0);
|
|
20
|
+
(0, _defineProperty2.default)(this, "_sum", void 0);
|
|
21
|
+
(0, _defineProperty2.default)(this, "_map", void 0);
|
|
22
|
+
this._clickTolerance = options.clickTolerance || 1;
|
|
23
|
+
this._map = map;
|
|
24
|
+
this.reset();
|
|
25
|
+
}
|
|
26
|
+
reset() {
|
|
27
|
+
this._active = false;
|
|
28
|
+
this._touches = {};
|
|
29
|
+
this._sum = new _pointGeometry.default(0, 0);
|
|
30
|
+
}
|
|
31
|
+
minTouchs() {
|
|
32
|
+
return this._map.cooperativeGestures.isEnabled() ? 2 : 1;
|
|
33
|
+
}
|
|
34
|
+
touchstart(e, points, mapTouches) {
|
|
35
|
+
return this._calculateTransform(e, points, mapTouches);
|
|
36
|
+
}
|
|
37
|
+
touchmove(e, points, mapTouches) {
|
|
38
|
+
if (!this._active || mapTouches.length < this.minTouchs()) return;
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
return this._calculateTransform(e, points, mapTouches);
|
|
41
|
+
}
|
|
42
|
+
touchend(e, points, mapTouches) {
|
|
43
|
+
this._calculateTransform(e, points, mapTouches);
|
|
44
|
+
if (this._active && mapTouches.length < this.minTouchs()) {
|
|
45
|
+
this.reset();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
touchcancel() {
|
|
49
|
+
this.reset();
|
|
50
|
+
}
|
|
51
|
+
_calculateTransform(e, points, mapTouches) {
|
|
52
|
+
if (mapTouches.length > 0) this._active = true;
|
|
53
|
+
const touches = (0, _handler_util.indexTouches)(mapTouches, points);
|
|
54
|
+
const touchPointSum = new _pointGeometry.default(0, 0);
|
|
55
|
+
const touchDeltaSum = new _pointGeometry.default(0, 0);
|
|
56
|
+
let touchDeltaCount = 0;
|
|
57
|
+
for (const identifier in touches) {
|
|
58
|
+
const point = touches[identifier];
|
|
59
|
+
const prevPoint = this._touches[identifier];
|
|
60
|
+
if (prevPoint) {
|
|
61
|
+
touchPointSum._add(point);
|
|
62
|
+
touchDeltaSum._add(point.sub(prevPoint));
|
|
63
|
+
touchDeltaCount++;
|
|
64
|
+
touches[identifier] = point;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
this._touches = touches;
|
|
68
|
+
if (touchDeltaCount < this.minTouchs() || !touchDeltaSum.mag()) return;
|
|
69
|
+
const panDelta = touchDeltaSum.div(touchDeltaCount);
|
|
70
|
+
this._sum._add(panDelta);
|
|
71
|
+
if (this._sum.mag() < this._clickTolerance) return;
|
|
72
|
+
const around = touchPointSum.div(touchDeltaCount);
|
|
73
|
+
return {
|
|
74
|
+
around,
|
|
75
|
+
panDelta
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
enable() {
|
|
79
|
+
this._enabled = true;
|
|
80
|
+
}
|
|
81
|
+
disable() {
|
|
82
|
+
this._enabled = false;
|
|
83
|
+
this.reset();
|
|
84
|
+
}
|
|
85
|
+
isEnabled() {
|
|
86
|
+
return this._enabled;
|
|
87
|
+
}
|
|
88
|
+
isActive() {
|
|
89
|
+
return this._active;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.TouchPanHandler = TouchPanHandler;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PointLike } from '../camera';
|
|
2
|
+
import type { LngLat } from '../geo/lng_lat';
|
|
3
|
+
import type { Transform } from '../geo/transform';
|
|
4
|
+
import type { Map } from '../map';
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
* Shared utilities for the Handler classes to access the correct camera state.
|
|
8
|
+
* If Camera.transformCameraUpdate is specified, the "desired state" of camera may differ from the state used for rendering.
|
|
9
|
+
* The handlers need the "desired state" to track accumulated changes.
|
|
10
|
+
*/
|
|
11
|
+
export declare class TransformProvider {
|
|
12
|
+
_map: Map;
|
|
13
|
+
constructor(map: Map);
|
|
14
|
+
get transform(): Transform;
|
|
15
|
+
get center(): {
|
|
16
|
+
lng: number;
|
|
17
|
+
lat: number;
|
|
18
|
+
};
|
|
19
|
+
get zoom(): number;
|
|
20
|
+
get pitch(): number;
|
|
21
|
+
get bearing(): number;
|
|
22
|
+
unproject(point: PointLike): LngLat;
|
|
23
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.TransformProvider = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _pointGeometry = _interopRequireDefault(require("@mapbox/point-geometry"));
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
* Shared utilities for the Handler classes to access the correct camera state.
|
|
13
|
+
* If Camera.transformCameraUpdate is specified, the "desired state" of camera may differ from the state used for rendering.
|
|
14
|
+
* The handlers need the "desired state" to track accumulated changes.
|
|
15
|
+
*/
|
|
16
|
+
class TransformProvider {
|
|
17
|
+
constructor(map) {
|
|
18
|
+
(0, _defineProperty2.default)(this, "_map", void 0);
|
|
19
|
+
this._map = map;
|
|
20
|
+
}
|
|
21
|
+
get transform() {
|
|
22
|
+
return this._map._requestedCameraState || this._map.transform;
|
|
23
|
+
}
|
|
24
|
+
get center() {
|
|
25
|
+
return {
|
|
26
|
+
lng: this.transform.center.lng,
|
|
27
|
+
lat: this.transform.center.lat
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
get zoom() {
|
|
31
|
+
return this.transform.zoom;
|
|
32
|
+
}
|
|
33
|
+
get pitch() {
|
|
34
|
+
return this.transform.pitch;
|
|
35
|
+
}
|
|
36
|
+
get bearing() {
|
|
37
|
+
return this.transform.bearing;
|
|
38
|
+
}
|
|
39
|
+
unproject(point) {
|
|
40
|
+
return this.transform.pointLocation(_pointGeometry.default.convert(point));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.TransformProvider = TransformProvider;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/// <reference types="mapbox__point-geometry" />
|
|
2
|
+
import type Point from '@mapbox/point-geometry';
|
|
3
|
+
import type { Handler, HandlerResult } from '../handler_manager';
|
|
4
|
+
import type { Map } from '../map';
|
|
5
|
+
/**
|
|
6
|
+
* An options object sent to the enable function of some of the handlers
|
|
7
|
+
*/
|
|
8
|
+
export type AroundCenterOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* If "center" is passed, map will zoom around the center of map
|
|
11
|
+
*/
|
|
12
|
+
around: 'center';
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The `TwoFingersTouchHandler`s allows the user to zoom, pitch and rotate the map using two fingers
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
declare abstract class TwoFingersTouchHandler implements Handler {
|
|
19
|
+
_enabled?: boolean;
|
|
20
|
+
_active?: boolean;
|
|
21
|
+
_firstTwoTouches?: [number, number];
|
|
22
|
+
_vector?: Point;
|
|
23
|
+
_startVector?: Point;
|
|
24
|
+
_aroundCenter?: boolean;
|
|
25
|
+
/** @internal */
|
|
26
|
+
constructor();
|
|
27
|
+
reset(): void;
|
|
28
|
+
abstract _start(points: [Point, Point]): void;
|
|
29
|
+
abstract _move(points: [Point, Point], pinchAround: Point | null, e: TouchEvent): HandlerResult | void;
|
|
30
|
+
touchstart(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): void;
|
|
31
|
+
touchmove(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): HandlerResult | void;
|
|
32
|
+
touchend(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): void;
|
|
33
|
+
touchcancel(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Enables the "drag to pitch" interaction.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* map.touchPitch.enable();
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
enable(options?: AroundCenterOptions | boolean | null): void;
|
|
43
|
+
/**
|
|
44
|
+
* Disables the "drag to pitch" interaction.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* map.touchPitch.disable();
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
disable(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Returns a Boolean indicating whether the "drag to pitch" interaction is enabled.
|
|
54
|
+
*
|
|
55
|
+
* @returns `true` if the "drag to pitch" interaction is enabled.
|
|
56
|
+
*/
|
|
57
|
+
isEnabled(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Returns a Boolean indicating whether the "drag to pitch" interaction is active, i.e. currently being used.
|
|
60
|
+
*
|
|
61
|
+
* @returns `true` if the "drag to pitch" interaction is active.
|
|
62
|
+
*/
|
|
63
|
+
isActive(): boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The `TwoFingersTouchHandler`s allows the user to zoom the map two fingers
|
|
67
|
+
*
|
|
68
|
+
* @group Handlers
|
|
69
|
+
*/
|
|
70
|
+
export declare class TwoFingersTouchZoomHandler extends TwoFingersTouchHandler {
|
|
71
|
+
_distance?: number;
|
|
72
|
+
_startDistance?: number;
|
|
73
|
+
reset(): void;
|
|
74
|
+
_start(points: [Point, Point]): void;
|
|
75
|
+
_move(points: [Point, Point], pinchAround: Point | null): HandlerResult | void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The `TwoFingersTouchHandler`s allows the user to rotate the map two fingers
|
|
79
|
+
*
|
|
80
|
+
* @group Handlers
|
|
81
|
+
*/
|
|
82
|
+
export declare class TwoFingersTouchRotateHandler extends TwoFingersTouchHandler {
|
|
83
|
+
_minDiameter?: number;
|
|
84
|
+
reset(): void;
|
|
85
|
+
_start(points: [Point, Point]): void;
|
|
86
|
+
_move(points: [Point, Point], pinchAround: Point | null, _e: TouchEvent): HandlerResult | void;
|
|
87
|
+
_isBelowThreshold(vector: Point): boolean;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The `TwoFingersTouchPitchHandler` allows the user to pitch the map by dragging up and down with two fingers.
|
|
91
|
+
*
|
|
92
|
+
* @group Handlers
|
|
93
|
+
*/
|
|
94
|
+
export declare class TwoFingersTouchPitchHandler extends TwoFingersTouchHandler {
|
|
95
|
+
_valid?: boolean;
|
|
96
|
+
_firstMove?: number;
|
|
97
|
+
_lastPoints?: [Point, Point];
|
|
98
|
+
_map: Map;
|
|
99
|
+
_currentTouchCount: number;
|
|
100
|
+
constructor(map: Map);
|
|
101
|
+
reset(): void;
|
|
102
|
+
touchstart(e: TouchEvent, points: Array<Point>, mapTouches: Array<Touch>): void;
|
|
103
|
+
_start(points: [Point, Point]): void;
|
|
104
|
+
_move(points: [Point, Point], center: Point | null, e: TouchEvent): HandlerResult | void;
|
|
105
|
+
gestureBeginsVertically(vectorA: Point, vectorB: Point, timeStamp: number): boolean | undefined;
|
|
106
|
+
}
|
|
107
|
+
export {};
|