@antv/l7-map 2.25.5 → 2.25.7
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/package.json +2 -2
- package/es/index.d.ts +0 -5
- package/es/index.js +0 -4
- package/es/map/camera.d.ts +0 -690
- package/es/map/camera.js +0 -1138
- package/es/map/css/l7.css +0 -171
- package/es/map/events.d.ts +0 -384
- package/es/map/events.js +0 -231
- package/es/map/geo/edge_insets.d.ts +0 -97
- package/es/map/geo/edge_insets.js +0 -115
- package/es/map/geo/lng_lat.d.ts +0 -116
- package/es/map/geo/lng_lat.js +0 -159
- package/es/map/geo/lng_lat_bounds.d.ts +0 -217
- package/es/map/geo/lng_lat_bounds.js +0 -334
- package/es/map/geo/mercator_coordinate.d.ts +0 -113
- package/es/map/geo/mercator_coordinate.js +0 -142
- package/es/map/geo/transform.d.ts +0 -262
- package/es/map/geo/transform.js +0 -736
- package/es/map/handler/box_zoom.d.ts +0 -65
- package/es/map/handler/box_zoom.js +0 -145
- package/es/map/handler/click_zoom.d.ts +0 -24
- package/es/map/handler/click_zoom.js +0 -47
- package/es/map/handler/cooperative_gestures.d.ts +0 -40
- package/es/map/handler/cooperative_gestures.js +0 -94
- package/es/map/handler/drag_handler.d.ts +0 -88
- package/es/map/handler/drag_handler.js +0 -89
- package/es/map/handler/drag_move_state_manager.d.ts +0 -30
- package/es/map/handler/drag_move_state_manager.js +0 -94
- package/es/map/handler/handler_util.d.ts +0 -3
- package/es/map/handler/handler_util.js +0 -8
- package/es/map/handler/keyboard.d.ts +0 -88
- package/es/map/handler/keyboard.js +0 -197
- package/es/map/handler/map_event.d.ts +0 -46
- package/es/map/handler/map_event.js +0 -131
- package/es/map/handler/mouse.d.ts +0 -30
- package/es/map/handler/mouse.js +0 -85
- package/es/map/handler/one_finger_touch_drag.d.ts +0 -15
- package/es/map/handler/one_finger_touch_drag.js +0 -39
- package/es/map/handler/scroll_zoom.d.ts +0 -102
- package/es/map/handler/scroll_zoom.js +0 -312
- package/es/map/handler/shim/dblclick_zoom.d.ts +0 -44
- package/es/map/handler/shim/dblclick_zoom.js +0 -60
- package/es/map/handler/shim/drag_pan.d.ts +0 -79
- package/es/map/handler/shim/drag_pan.js +0 -77
- package/es/map/handler/shim/drag_rotate.d.ts +0 -54
- package/es/map/handler/shim/drag_rotate.js +0 -66
- package/es/map/handler/shim/two_fingers_touch.d.ts +0 -74
- package/es/map/handler/shim/two_fingers_touch.js +0 -106
- package/es/map/handler/tap_drag_zoom.d.ts +0 -28
- package/es/map/handler/tap_drag_zoom.js +0 -92
- package/es/map/handler/tap_recognizer.d.ts +0 -35
- package/es/map/handler/tap_recognizer.js +0 -107
- package/es/map/handler/tap_zoom.d.ts +0 -28
- package/es/map/handler/tap_zoom.js +0 -87
- package/es/map/handler/touch_pan.d.ts +0 -40
- package/es/map/handler/touch_pan.js +0 -85
- package/es/map/handler/transform-provider.d.ts +0 -23
- package/es/map/handler/transform-provider.js +0 -35
- package/es/map/handler/two_fingers_touch.d.ts +0 -107
- package/es/map/handler/two_fingers_touch.js +0 -289
- package/es/map/handler_inertia.d.ts +0 -20
- package/es/map/handler_inertia.js +0 -128
- package/es/map/handler_manager.d.ts +0 -154
- package/es/map/handler_manager.js +0 -466
- package/es/map/map.d.ts +0 -637
- package/es/map/map.js +0 -984
- package/es/map/util/abort_error.d.ts +0 -15
- package/es/map/util/abort_error.js +0 -21
- package/es/map/util/browser.d.ts +0 -10
- package/es/map/util/browser.js +0 -30
- package/es/map/util/dom.d.ts +0 -30
- package/es/map/util/dom.js +0 -105
- package/es/map/util/evented.d.ts +0 -75
- package/es/map/util/evented.js +0 -158
- package/es/map/util/simpleMapCoord.d.ts +0 -31
- package/es/map/util/simpleMapCoord.js +0 -54
- package/es/map/util/task_queue.d.ts +0 -18
- package/es/map/util/task_queue.js +0 -54
- package/es/map/util/util.d.ts +0 -104
- package/es/map/util/util.js +0 -155
- package/lib/index.d.ts +0 -5
- package/lib/index.js +0 -33
- package/lib/map/camera.d.ts +0 -690
- package/lib/map/camera.js +0 -1145
- package/lib/map/css/l7.css +0 -171
- package/lib/map/events.d.ts +0 -384
- package/lib/map/events.js +0 -240
- package/lib/map/geo/edge_insets.d.ts +0 -97
- package/lib/map/geo/edge_insets.js +0 -122
- package/lib/map/geo/lng_lat.d.ts +0 -116
- package/lib/map/geo/lng_lat.js +0 -166
- package/lib/map/geo/lng_lat_bounds.d.ts +0 -217
- package/lib/map/geo/lng_lat_bounds.js +0 -341
- package/lib/map/geo/mercator_coordinate.d.ts +0 -113
- package/lib/map/geo/mercator_coordinate.js +0 -157
- package/lib/map/geo/transform.d.ts +0 -262
- package/lib/map/geo/transform.js +0 -744
- package/lib/map/handler/box_zoom.d.ts +0 -65
- package/lib/map/handler/box_zoom.js +0 -153
- package/lib/map/handler/click_zoom.d.ts +0 -24
- package/lib/map/handler/click_zoom.js +0 -54
- package/lib/map/handler/cooperative_gestures.d.ts +0 -40
- package/lib/map/handler/cooperative_gestures.js +0 -101
- package/lib/map/handler/drag_handler.d.ts +0 -88
- package/lib/map/handler/drag_handler.js +0 -97
- package/lib/map/handler/drag_move_state_manager.d.ts +0 -30
- package/lib/map/handler/drag_move_state_manager.js +0 -103
- package/lib/map/handler/handler_util.d.ts +0 -3
- package/lib/map/handler/handler_util.js +0 -14
- package/lib/map/handler/keyboard.d.ts +0 -88
- package/lib/map/handler/keyboard.js +0 -205
- package/lib/map/handler/map_event.d.ts +0 -46
- package/lib/map/handler/map_event.js +0 -140
- package/lib/map/handler/mouse.d.ts +0 -30
- package/lib/map/handler/mouse.js +0 -93
- package/lib/map/handler/one_finger_touch_drag.d.ts +0 -15
- package/lib/map/handler/one_finger_touch_drag.js +0 -47
- package/lib/map/handler/scroll_zoom.d.ts +0 -102
- package/lib/map/handler/scroll_zoom.js +0 -320
- package/lib/map/handler/shim/dblclick_zoom.d.ts +0 -44
- package/lib/map/handler/shim/dblclick_zoom.js +0 -68
- package/lib/map/handler/shim/drag_pan.d.ts +0 -79
- package/lib/map/handler/shim/drag_pan.js +0 -85
- package/lib/map/handler/shim/drag_rotate.d.ts +0 -54
- package/lib/map/handler/shim/drag_rotate.js +0 -74
- package/lib/map/handler/shim/two_fingers_touch.d.ts +0 -74
- package/lib/map/handler/shim/two_fingers_touch.js +0 -114
- package/lib/map/handler/tap_drag_zoom.d.ts +0 -28
- package/lib/map/handler/tap_drag_zoom.js +0 -99
- package/lib/map/handler/tap_recognizer.d.ts +0 -35
- package/lib/map/handler/tap_recognizer.js +0 -116
- package/lib/map/handler/tap_zoom.d.ts +0 -28
- package/lib/map/handler/tap_zoom.js +0 -94
- package/lib/map/handler/touch_pan.d.ts +0 -40
- package/lib/map/handler/touch_pan.js +0 -92
- package/lib/map/handler/transform-provider.d.ts +0 -23
- package/lib/map/handler/transform-provider.js +0 -43
- package/lib/map/handler/two_fingers_touch.d.ts +0 -107
- package/lib/map/handler/two_fingers_touch.js +0 -296
- package/lib/map/handler_inertia.d.ts +0 -20
- package/lib/map/handler_inertia.js +0 -136
- package/lib/map/handler_manager.d.ts +0 -154
- package/lib/map/handler_manager.js +0 -474
- package/lib/map/map.d.ts +0 -637
- package/lib/map/map.js +0 -991
- package/lib/map/util/abort_error.d.ts +0 -15
- package/lib/map/util/abort_error.js +0 -29
- package/lib/map/util/browser.d.ts +0 -10
- package/lib/map/util/browser.js +0 -36
- package/lib/map/util/dom.d.ts +0 -30
- package/lib/map/util/dom.js +0 -113
- package/lib/map/util/evented.d.ts +0 -75
- package/lib/map/util/evented.js +0 -167
- package/lib/map/util/simpleMapCoord.d.ts +0 -31
- package/lib/map/util/simpleMapCoord.js +0 -62
- package/lib/map/util/task_queue.d.ts +0 -18
- package/lib/map/util/task_queue.js +0 -62
- package/lib/map/util/util.d.ts +0 -104
- package/lib/map/util/util.js +0 -171
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { TapRecognizer } from "./tap_recognizer";
|
|
3
|
-
import { TransformProvider } from "./transform-provider";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A `TapZoomHandler` allows the user to zoom the map at a point by double tapping
|
|
7
|
-
*/
|
|
8
|
-
export class TapZoomHandler {
|
|
9
|
-
constructor(map) {
|
|
10
|
-
_defineProperty(this, "_tr", void 0);
|
|
11
|
-
_defineProperty(this, "_enabled", void 0);
|
|
12
|
-
_defineProperty(this, "_active", void 0);
|
|
13
|
-
_defineProperty(this, "_zoomIn", void 0);
|
|
14
|
-
_defineProperty(this, "_zoomOut", void 0);
|
|
15
|
-
this._tr = new TransformProvider(map);
|
|
16
|
-
this._zoomIn = new TapRecognizer({
|
|
17
|
-
numTouches: 1,
|
|
18
|
-
numTaps: 2
|
|
19
|
-
});
|
|
20
|
-
this._zoomOut = new TapRecognizer({
|
|
21
|
-
numTouches: 2,
|
|
22
|
-
numTaps: 1
|
|
23
|
-
});
|
|
24
|
-
this.reset();
|
|
25
|
-
}
|
|
26
|
-
reset() {
|
|
27
|
-
this._active = false;
|
|
28
|
-
this._zoomIn.reset();
|
|
29
|
-
this._zoomOut.reset();
|
|
30
|
-
}
|
|
31
|
-
touchstart(e, points, mapTouches) {
|
|
32
|
-
this._zoomIn.touchstart(e, points, mapTouches);
|
|
33
|
-
this._zoomOut.touchstart(e, points, mapTouches);
|
|
34
|
-
}
|
|
35
|
-
touchmove(e, points, mapTouches) {
|
|
36
|
-
this._zoomIn.touchmove(e, points, mapTouches);
|
|
37
|
-
this._zoomOut.touchmove(e, points, mapTouches);
|
|
38
|
-
}
|
|
39
|
-
touchend(e, points, mapTouches) {
|
|
40
|
-
const zoomInPoint = this._zoomIn.touchend(e, points, mapTouches);
|
|
41
|
-
const zoomOutPoint = this._zoomOut.touchend(e, points, mapTouches);
|
|
42
|
-
const tr = this._tr;
|
|
43
|
-
if (zoomInPoint) {
|
|
44
|
-
this._active = true;
|
|
45
|
-
e.preventDefault();
|
|
46
|
-
setTimeout(() => this.reset(), 0);
|
|
47
|
-
return {
|
|
48
|
-
cameraAnimation: map => map.easeTo({
|
|
49
|
-
duration: 300,
|
|
50
|
-
zoom: tr.zoom + 1,
|
|
51
|
-
around: tr.unproject(zoomInPoint)
|
|
52
|
-
}, {
|
|
53
|
-
originalEvent: e
|
|
54
|
-
})
|
|
55
|
-
};
|
|
56
|
-
} else if (zoomOutPoint) {
|
|
57
|
-
this._active = true;
|
|
58
|
-
e.preventDefault();
|
|
59
|
-
setTimeout(() => this.reset(), 0);
|
|
60
|
-
return {
|
|
61
|
-
cameraAnimation: map => map.easeTo({
|
|
62
|
-
duration: 300,
|
|
63
|
-
zoom: tr.zoom - 1,
|
|
64
|
-
around: tr.unproject(zoomOutPoint)
|
|
65
|
-
}, {
|
|
66
|
-
originalEvent: e
|
|
67
|
-
})
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
touchcancel() {
|
|
72
|
-
this.reset();
|
|
73
|
-
}
|
|
74
|
-
enable() {
|
|
75
|
-
this._enabled = true;
|
|
76
|
-
}
|
|
77
|
-
disable() {
|
|
78
|
-
this._enabled = false;
|
|
79
|
-
this.reset();
|
|
80
|
-
}
|
|
81
|
-
isEnabled() {
|
|
82
|
-
return this._enabled;
|
|
83
|
-
}
|
|
84
|
-
isActive() {
|
|
85
|
-
return this._active;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import Point from '@mapbox/point-geometry';
|
|
3
|
-
import { indexTouches } from "./handler_util";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A `TouchPanHandler` allows the user to pan the map using touch gestures.
|
|
7
|
-
*/
|
|
8
|
-
export class TouchPanHandler {
|
|
9
|
-
constructor(options, map) {
|
|
10
|
-
_defineProperty(this, "_enabled", void 0);
|
|
11
|
-
_defineProperty(this, "_active", void 0);
|
|
12
|
-
_defineProperty(this, "_touches", void 0);
|
|
13
|
-
_defineProperty(this, "_clickTolerance", void 0);
|
|
14
|
-
_defineProperty(this, "_sum", void 0);
|
|
15
|
-
_defineProperty(this, "_map", void 0);
|
|
16
|
-
this._clickTolerance = options.clickTolerance || 1;
|
|
17
|
-
this._map = map;
|
|
18
|
-
this.reset();
|
|
19
|
-
}
|
|
20
|
-
reset() {
|
|
21
|
-
this._active = false;
|
|
22
|
-
this._touches = {};
|
|
23
|
-
this._sum = new Point(0, 0);
|
|
24
|
-
}
|
|
25
|
-
minTouchs() {
|
|
26
|
-
return this._map.cooperativeGestures.isEnabled() ? 2 : 1;
|
|
27
|
-
}
|
|
28
|
-
touchstart(e, points, mapTouches) {
|
|
29
|
-
return this._calculateTransform(e, points, mapTouches);
|
|
30
|
-
}
|
|
31
|
-
touchmove(e, points, mapTouches) {
|
|
32
|
-
if (!this._active || mapTouches.length < this.minTouchs()) return;
|
|
33
|
-
e.preventDefault();
|
|
34
|
-
return this._calculateTransform(e, points, mapTouches);
|
|
35
|
-
}
|
|
36
|
-
touchend(e, points, mapTouches) {
|
|
37
|
-
this._calculateTransform(e, points, mapTouches);
|
|
38
|
-
if (this._active && mapTouches.length < this.minTouchs()) {
|
|
39
|
-
this.reset();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
touchcancel() {
|
|
43
|
-
this.reset();
|
|
44
|
-
}
|
|
45
|
-
_calculateTransform(e, points, mapTouches) {
|
|
46
|
-
if (mapTouches.length > 0) this._active = true;
|
|
47
|
-
const touches = indexTouches(mapTouches, points);
|
|
48
|
-
const touchPointSum = new Point(0, 0);
|
|
49
|
-
const touchDeltaSum = new Point(0, 0);
|
|
50
|
-
let touchDeltaCount = 0;
|
|
51
|
-
for (const identifier in touches) {
|
|
52
|
-
const point = touches[identifier];
|
|
53
|
-
const prevPoint = this._touches[identifier];
|
|
54
|
-
if (prevPoint) {
|
|
55
|
-
touchPointSum._add(point);
|
|
56
|
-
touchDeltaSum._add(point.sub(prevPoint));
|
|
57
|
-
touchDeltaCount++;
|
|
58
|
-
touches[identifier] = point;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
this._touches = touches;
|
|
62
|
-
if (touchDeltaCount < this.minTouchs() || !touchDeltaSum.mag()) return;
|
|
63
|
-
const panDelta = touchDeltaSum.div(touchDeltaCount);
|
|
64
|
-
this._sum._add(panDelta);
|
|
65
|
-
if (this._sum.mag() < this._clickTolerance) return;
|
|
66
|
-
const around = touchPointSum.div(touchDeltaCount);
|
|
67
|
-
return {
|
|
68
|
-
around,
|
|
69
|
-
panDelta
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
enable() {
|
|
73
|
-
this._enabled = true;
|
|
74
|
-
}
|
|
75
|
-
disable() {
|
|
76
|
-
this._enabled = false;
|
|
77
|
-
this.reset();
|
|
78
|
-
}
|
|
79
|
-
isEnabled() {
|
|
80
|
-
return this._enabled;
|
|
81
|
-
}
|
|
82
|
-
isActive() {
|
|
83
|
-
return this._active;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import Point from '@mapbox/point-geometry';
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
* Shared utilities for the Handler classes to access the correct camera state.
|
|
6
|
-
* If Camera.transformCameraUpdate is specified, the "desired state" of camera may differ from the state used for rendering.
|
|
7
|
-
* The handlers need the "desired state" to track accumulated changes.
|
|
8
|
-
*/
|
|
9
|
-
export class TransformProvider {
|
|
10
|
-
constructor(map) {
|
|
11
|
-
_defineProperty(this, "_map", void 0);
|
|
12
|
-
this._map = map;
|
|
13
|
-
}
|
|
14
|
-
get transform() {
|
|
15
|
-
return this._map._requestedCameraState || this._map.transform;
|
|
16
|
-
}
|
|
17
|
-
get center() {
|
|
18
|
-
return {
|
|
19
|
-
lng: this.transform.center.lng,
|
|
20
|
-
lat: this.transform.center.lat
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
get zoom() {
|
|
24
|
-
return this.transform.zoom;
|
|
25
|
-
}
|
|
26
|
-
get pitch() {
|
|
27
|
-
return this.transform.pitch;
|
|
28
|
-
}
|
|
29
|
-
get bearing() {
|
|
30
|
-
return this.transform.bearing;
|
|
31
|
-
}
|
|
32
|
-
unproject(point) {
|
|
33
|
-
return this.transform.pointLocation(Point.convert(point));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { DOM } from "../util/dom";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* An options object sent to the enable function of some of the handlers
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The `TwoFingersTouchHandler`s allows the user to zoom, pitch and rotate the map using two fingers
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
class TwoFingersTouchHandler {
|
|
13
|
-
/** @internal */
|
|
14
|
-
constructor() {
|
|
15
|
-
_defineProperty(this, "_enabled", void 0);
|
|
16
|
-
_defineProperty(this, "_active", void 0);
|
|
17
|
-
_defineProperty(this, "_firstTwoTouches", void 0);
|
|
18
|
-
_defineProperty(this, "_vector", void 0);
|
|
19
|
-
_defineProperty(this, "_startVector", void 0);
|
|
20
|
-
_defineProperty(this, "_aroundCenter", void 0);
|
|
21
|
-
this.reset();
|
|
22
|
-
}
|
|
23
|
-
reset() {
|
|
24
|
-
this._active = false;
|
|
25
|
-
delete this._firstTwoTouches;
|
|
26
|
-
}
|
|
27
|
-
touchstart(e, points, mapTouches) {
|
|
28
|
-
//log('touchstart', points, e.target.innerHTML, e.targetTouches.length ? e.targetTouches[0].target.innerHTML: undefined);
|
|
29
|
-
if (this._firstTwoTouches || mapTouches.length < 2) return;
|
|
30
|
-
this._firstTwoTouches = [mapTouches[0].identifier, mapTouches[1].identifier];
|
|
31
|
-
|
|
32
|
-
// implemented by child classes
|
|
33
|
-
this._start([points[0], points[1]]);
|
|
34
|
-
}
|
|
35
|
-
touchmove(e, points, mapTouches) {
|
|
36
|
-
if (!this._firstTwoTouches) return;
|
|
37
|
-
e.preventDefault();
|
|
38
|
-
const [idA, idB] = this._firstTwoTouches;
|
|
39
|
-
const a = getTouchById(mapTouches, points, idA);
|
|
40
|
-
const b = getTouchById(mapTouches, points, idB);
|
|
41
|
-
if (!a || !b) return;
|
|
42
|
-
const pinchAround = this._aroundCenter ? null : a.add(b).div(2);
|
|
43
|
-
|
|
44
|
-
// implemented by child classes
|
|
45
|
-
return this._move([a, b], pinchAround, e);
|
|
46
|
-
}
|
|
47
|
-
touchend(e, points, mapTouches) {
|
|
48
|
-
if (!this._firstTwoTouches) return;
|
|
49
|
-
const [idA, idB] = this._firstTwoTouches;
|
|
50
|
-
const a = getTouchById(mapTouches, points, idA);
|
|
51
|
-
const b = getTouchById(mapTouches, points, idB);
|
|
52
|
-
if (a && b) return;
|
|
53
|
-
if (this._active) DOM.suppressClick();
|
|
54
|
-
this.reset();
|
|
55
|
-
}
|
|
56
|
-
touchcancel() {
|
|
57
|
-
this.reset();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Enables the "drag to pitch" interaction.
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```ts
|
|
65
|
-
* map.touchPitch.enable();
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
enable(options) {
|
|
69
|
-
this._enabled = true;
|
|
70
|
-
this._aroundCenter = !!options && options.around === 'center';
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Disables the "drag to pitch" interaction.
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* ```ts
|
|
78
|
-
* map.touchPitch.disable();
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
disable() {
|
|
82
|
-
this._enabled = false;
|
|
83
|
-
this.reset();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Returns a Boolean indicating whether the "drag to pitch" interaction is enabled.
|
|
88
|
-
*
|
|
89
|
-
* @returns `true` if the "drag to pitch" interaction is enabled.
|
|
90
|
-
*/
|
|
91
|
-
isEnabled() {
|
|
92
|
-
return !!this._enabled;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Returns a Boolean indicating whether the "drag to pitch" interaction is active, i.e. currently being used.
|
|
97
|
-
*
|
|
98
|
-
* @returns `true` if the "drag to pitch" interaction is active.
|
|
99
|
-
*/
|
|
100
|
-
isActive() {
|
|
101
|
-
return !!this._active;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function getTouchById(mapTouches, points, identifier) {
|
|
105
|
-
for (let i = 0; i < mapTouches.length; i++) {
|
|
106
|
-
if (mapTouches[i].identifier === identifier) return points[i];
|
|
107
|
-
}
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/* ZOOM */
|
|
112
|
-
|
|
113
|
-
const ZOOM_THRESHOLD = 0.1;
|
|
114
|
-
function getZoomDelta(distance, lastDistance) {
|
|
115
|
-
return Math.log(distance / lastDistance) / Math.LN2;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* The `TwoFingersTouchHandler`s allows the user to zoom the map two fingers
|
|
120
|
-
*
|
|
121
|
-
* @group Handlers
|
|
122
|
-
*/
|
|
123
|
-
export class TwoFingersTouchZoomHandler extends TwoFingersTouchHandler {
|
|
124
|
-
constructor(...args) {
|
|
125
|
-
super(...args);
|
|
126
|
-
_defineProperty(this, "_distance", void 0);
|
|
127
|
-
_defineProperty(this, "_startDistance", void 0);
|
|
128
|
-
}
|
|
129
|
-
reset() {
|
|
130
|
-
super.reset();
|
|
131
|
-
delete this._distance;
|
|
132
|
-
delete this._startDistance;
|
|
133
|
-
}
|
|
134
|
-
_start(points) {
|
|
135
|
-
this._startDistance = this._distance = points[0].dist(points[1]);
|
|
136
|
-
}
|
|
137
|
-
_move(points, pinchAround) {
|
|
138
|
-
const lastDistance = this._distance;
|
|
139
|
-
this._distance = points[0].dist(points[1]);
|
|
140
|
-
if (!this._active && Math.abs(getZoomDelta(this._distance, this._startDistance)) < ZOOM_THRESHOLD) return;
|
|
141
|
-
this._active = true;
|
|
142
|
-
return {
|
|
143
|
-
zoomDelta: getZoomDelta(this._distance, lastDistance),
|
|
144
|
-
pinchAround
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/* ROTATE */
|
|
150
|
-
|
|
151
|
-
const ROTATION_THRESHOLD = 25; // pixels along circumference of touch circle
|
|
152
|
-
|
|
153
|
-
function getBearingDelta(a, b) {
|
|
154
|
-
return a.angleWith(b) * 180 / Math.PI;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* The `TwoFingersTouchHandler`s allows the user to rotate the map two fingers
|
|
159
|
-
*
|
|
160
|
-
* @group Handlers
|
|
161
|
-
*/
|
|
162
|
-
export class TwoFingersTouchRotateHandler extends TwoFingersTouchHandler {
|
|
163
|
-
constructor(...args) {
|
|
164
|
-
super(...args);
|
|
165
|
-
_defineProperty(this, "_minDiameter", void 0);
|
|
166
|
-
}
|
|
167
|
-
reset() {
|
|
168
|
-
super.reset();
|
|
169
|
-
delete this._minDiameter;
|
|
170
|
-
delete this._startVector;
|
|
171
|
-
delete this._vector;
|
|
172
|
-
}
|
|
173
|
-
_start(points) {
|
|
174
|
-
this._startVector = this._vector = points[0].sub(points[1]);
|
|
175
|
-
this._minDiameter = points[0].dist(points[1]);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
179
|
-
_move(points, pinchAround, _e) {
|
|
180
|
-
const lastVector = this._vector;
|
|
181
|
-
this._vector = points[0].sub(points[1]);
|
|
182
|
-
if (!this._active && this._isBelowThreshold(this._vector)) return;
|
|
183
|
-
this._active = true;
|
|
184
|
-
return {
|
|
185
|
-
bearingDelta: getBearingDelta(this._vector, lastVector),
|
|
186
|
-
pinchAround
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
_isBelowThreshold(vector) {
|
|
190
|
-
/*
|
|
191
|
-
* The threshold before a rotation actually happens is configured in
|
|
192
|
-
* pixels along the circumference of the circle formed by the two fingers.
|
|
193
|
-
* This makes the threshold in degrees larger when the fingers are close
|
|
194
|
-
* together and smaller when the fingers are far apart.
|
|
195
|
-
*
|
|
196
|
-
* Use the smallest diameter from the whole gesture to reduce sensitivity
|
|
197
|
-
* when pinching in and out.
|
|
198
|
-
*/
|
|
199
|
-
|
|
200
|
-
this._minDiameter = Math.min(this._minDiameter, vector.mag());
|
|
201
|
-
const circumference = Math.PI * this._minDiameter;
|
|
202
|
-
const threshold = ROTATION_THRESHOLD / circumference * 360;
|
|
203
|
-
const bearingDeltaSinceStart = getBearingDelta(vector, this._startVector);
|
|
204
|
-
return Math.abs(bearingDeltaSinceStart) < threshold;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/* PITCH */
|
|
209
|
-
|
|
210
|
-
function isVertical(vector) {
|
|
211
|
-
return Math.abs(vector.y) > Math.abs(vector.x);
|
|
212
|
-
}
|
|
213
|
-
const ALLOWED_SINGLE_TOUCH_TIME = 100;
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* The `TwoFingersTouchPitchHandler` allows the user to pitch the map by dragging up and down with two fingers.
|
|
217
|
-
*
|
|
218
|
-
* @group Handlers
|
|
219
|
-
*/
|
|
220
|
-
export class TwoFingersTouchPitchHandler extends TwoFingersTouchHandler {
|
|
221
|
-
constructor(map) {
|
|
222
|
-
super();
|
|
223
|
-
_defineProperty(this, "_valid", void 0);
|
|
224
|
-
_defineProperty(this, "_firstMove", void 0);
|
|
225
|
-
_defineProperty(this, "_lastPoints", void 0);
|
|
226
|
-
_defineProperty(this, "_map", void 0);
|
|
227
|
-
_defineProperty(this, "_currentTouchCount", 0);
|
|
228
|
-
this._map = map;
|
|
229
|
-
}
|
|
230
|
-
reset() {
|
|
231
|
-
super.reset();
|
|
232
|
-
this._valid = undefined;
|
|
233
|
-
delete this._firstMove;
|
|
234
|
-
delete this._lastPoints;
|
|
235
|
-
}
|
|
236
|
-
touchstart(e, points, mapTouches) {
|
|
237
|
-
super.touchstart(e, points, mapTouches);
|
|
238
|
-
this._currentTouchCount = mapTouches.length;
|
|
239
|
-
}
|
|
240
|
-
_start(points) {
|
|
241
|
-
this._lastPoints = points;
|
|
242
|
-
if (isVertical(points[0].sub(points[1]))) {
|
|
243
|
-
// fingers are more horizontal than vertical
|
|
244
|
-
this._valid = false;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
_move(points, center, e) {
|
|
248
|
-
// If cooperative gestures is enabled, we need a 3-finger minimum for this gesture to register
|
|
249
|
-
if (this._map.cooperativeGestures.isEnabled() && this._currentTouchCount < 3) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
const vectorA = points[0].sub(this._lastPoints[0]);
|
|
253
|
-
const vectorB = points[1].sub(this._lastPoints[1]);
|
|
254
|
-
this._valid = this.gestureBeginsVertically(vectorA, vectorB, e.timeStamp);
|
|
255
|
-
if (!this._valid) return;
|
|
256
|
-
this._lastPoints = points;
|
|
257
|
-
this._active = true;
|
|
258
|
-
const yDeltaAverage = (vectorA.y + vectorB.y) / 2;
|
|
259
|
-
const degreesPerPixelMoved = -0.5;
|
|
260
|
-
return {
|
|
261
|
-
pitchDelta: yDeltaAverage * degreesPerPixelMoved
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
gestureBeginsVertically(vectorA, vectorB, timeStamp) {
|
|
265
|
-
if (this._valid !== undefined) return this._valid;
|
|
266
|
-
const threshold = 2;
|
|
267
|
-
const movedA = vectorA.mag() >= threshold;
|
|
268
|
-
const movedB = vectorB.mag() >= threshold;
|
|
269
|
-
|
|
270
|
-
// neither finger has moved a meaningful amount, wait
|
|
271
|
-
if (!movedA && !movedB) return;
|
|
272
|
-
|
|
273
|
-
// One finger has moved and the other has not.
|
|
274
|
-
// If enough time has passed, decide it is not a pitch.
|
|
275
|
-
if (!movedA || !movedB) {
|
|
276
|
-
if (this._firstMove === undefined) {
|
|
277
|
-
this._firstMove = timeStamp;
|
|
278
|
-
}
|
|
279
|
-
if (timeStamp - this._firstMove < ALLOWED_SINGLE_TOUCH_TIME) {
|
|
280
|
-
// still waiting for a movement from the second finger
|
|
281
|
-
return undefined;
|
|
282
|
-
} else {
|
|
283
|
-
return false;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
const isSameDirection = vectorA.y > 0 === vectorB.y > 0;
|
|
287
|
-
return isVertical(vectorA) && isVertical(vectorB) && isSameDirection;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { DragPanOptions } from './handler/shim/drag_pan';
|
|
2
|
-
import type { Map } from './map';
|
|
3
|
-
export type InertiaOptions = {
|
|
4
|
-
linearity: number;
|
|
5
|
-
easing: (t: number) => number;
|
|
6
|
-
deceleration: number;
|
|
7
|
-
maxSpeed: number;
|
|
8
|
-
};
|
|
9
|
-
export declare class HandlerInertia {
|
|
10
|
-
_map: Map;
|
|
11
|
-
_inertiaBuffer: Array<{
|
|
12
|
-
time: number;
|
|
13
|
-
settings: any;
|
|
14
|
-
}>;
|
|
15
|
-
constructor(map: Map);
|
|
16
|
-
clear(): void;
|
|
17
|
-
record(settings: any): void;
|
|
18
|
-
_drainInertiaBuffer(): void;
|
|
19
|
-
_onMoveEnd(panInertiaOptions?: DragPanOptions | boolean): any;
|
|
20
|
-
}
|