@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,119 +5,103 @@ 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"));
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
9
|
var _dom = _interopRequireDefault(require("../../utils/dom"));
|
|
11
10
|
var _util = require("./util");
|
|
12
11
|
// @ts-ignore
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
|
|
13
|
+
class MouseHandler {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
(0, _defineProperty2.default)(this, "enabled", void 0);
|
|
16
|
+
(0, _defineProperty2.default)(this, "active", void 0);
|
|
17
|
+
(0, _defineProperty2.default)(this, "lastPoint", void 0);
|
|
18
|
+
(0, _defineProperty2.default)(this, "eventButton", void 0);
|
|
19
|
+
(0, _defineProperty2.default)(this, "moved", void 0);
|
|
20
|
+
(0, _defineProperty2.default)(this, "clickTolerance", void 0);
|
|
16
21
|
this.reset();
|
|
17
22
|
this.clickTolerance = options.clickTolerance || 1;
|
|
18
23
|
}
|
|
19
|
-
(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
reset() {
|
|
25
|
+
this.active = false;
|
|
26
|
+
this.moved = false;
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
delete this.lastPoint;
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
delete this.eventButton;
|
|
31
|
+
}
|
|
32
|
+
mousedown(e, point) {
|
|
33
|
+
if (this.lastPoint) {
|
|
34
|
+
return;
|
|
28
35
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (this.lastPoint) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
var eventButton = _dom.default.mouseButton(e);
|
|
36
|
-
if (!this.correctButton(e, eventButton)) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
this.lastPoint = point;
|
|
40
|
-
this.eventButton = eventButton;
|
|
36
|
+
const eventButton = _dom.default.mouseButton(e);
|
|
37
|
+
if (!this.correctButton(e, eventButton)) {
|
|
38
|
+
return;
|
|
41
39
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
e.preventDefault();
|
|
50
|
-
if ((0, _util.buttonStillPressed)(e, this.eventButton)) {
|
|
51
|
-
// Some browsers don't fire a `mouseup` when the mouseup occurs outside
|
|
52
|
-
// the window or iframe:
|
|
53
|
-
// https://github.com/mapbox/mapbox-gl-js/issues/4622
|
|
54
|
-
//
|
|
55
|
-
// If the button is no longer pressed during this `mousemove` it may have
|
|
56
|
-
// been released outside of the window or iframe.
|
|
57
|
-
this.reset();
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (!this.moved && point.dist(lastPoint) < this.clickTolerance) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
this.moved = true;
|
|
64
|
-
this.lastPoint = point;
|
|
65
|
-
|
|
66
|
-
// implemented by child class
|
|
67
|
-
return this.move(lastPoint, point);
|
|
40
|
+
this.lastPoint = point;
|
|
41
|
+
this.eventButton = eventButton;
|
|
42
|
+
}
|
|
43
|
+
mousemoveWindow(e, point) {
|
|
44
|
+
const lastPoint = this.lastPoint;
|
|
45
|
+
if (!lastPoint) {
|
|
46
|
+
return;
|
|
68
47
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (this.moved) {
|
|
80
|
-
_dom.default.suppressClick();
|
|
81
|
-
}
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
if ((0, _util.buttonStillPressed)(e, this.eventButton)) {
|
|
50
|
+
// Some browsers don't fire a `mouseup` when the mouseup occurs outside
|
|
51
|
+
// the window or iframe:
|
|
52
|
+
// https://github.com/mapbox/mapbox-gl-js/issues/4622
|
|
53
|
+
//
|
|
54
|
+
// If the button is no longer pressed during this `mousemove` it may have
|
|
55
|
+
// been released outside of the window or iframe.
|
|
82
56
|
this.reset();
|
|
57
|
+
return;
|
|
83
58
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
value: function enable() {
|
|
87
|
-
this.enabled = true;
|
|
59
|
+
if (!this.moved && point.dist(lastPoint) < this.clickTolerance) {
|
|
60
|
+
return;
|
|
88
61
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
62
|
+
this.moved = true;
|
|
63
|
+
this.lastPoint = point;
|
|
64
|
+
|
|
65
|
+
// implemented by child class
|
|
66
|
+
return this.move(lastPoint, point);
|
|
67
|
+
}
|
|
68
|
+
mouseupWindow(e) {
|
|
69
|
+
if (!this.lastPoint) {
|
|
70
|
+
return;
|
|
94
71
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return this.enabled;
|
|
72
|
+
const eventButton = _dom.default.mouseButton(e);
|
|
73
|
+
if (eventButton !== this.eventButton) {
|
|
74
|
+
return;
|
|
99
75
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
value: function isActive() {
|
|
103
|
-
return this.active;
|
|
76
|
+
if (this.moved) {
|
|
77
|
+
_dom.default.suppressClick();
|
|
104
78
|
}
|
|
79
|
+
this.reset();
|
|
80
|
+
}
|
|
81
|
+
enable() {
|
|
82
|
+
this.enabled = true;
|
|
83
|
+
}
|
|
84
|
+
disable() {
|
|
85
|
+
this.enabled = false;
|
|
86
|
+
this.reset();
|
|
87
|
+
}
|
|
88
|
+
isEnabled() {
|
|
89
|
+
return this.enabled;
|
|
90
|
+
}
|
|
91
|
+
isActive() {
|
|
92
|
+
return this.active;
|
|
93
|
+
}
|
|
105
94
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return false; // implemented by child
|
|
112
|
-
}
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
96
|
+
correctButton(e, button) {
|
|
97
|
+
// eslint-disable-line
|
|
98
|
+
return false; // implemented by child
|
|
99
|
+
}
|
|
113
100
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}]);
|
|
122
|
-
return MouseHandler;
|
|
123
|
-
}();
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
102
|
+
move(lastPoint, point) {
|
|
103
|
+
// eslint-disable-line
|
|
104
|
+
return; // implemented by child
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.default = MouseHandler;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type Point from '../../geo/point';
|
|
2
|
+
import MouseHandler from './mouse_handler';
|
|
3
|
+
export default class MousePanHandler extends MouseHandler {
|
|
4
|
+
mousedown(e: MouseEvent, point: Point): void;
|
|
5
|
+
move(lastPoint: Point, point: Point): {
|
|
6
|
+
around: Point;
|
|
7
|
+
panDelta: Point;
|
|
8
|
+
};
|
|
9
|
+
protected correctButton(e: MouseEvent, button: number): boolean;
|
|
10
|
+
}
|
|
@@ -5,44 +5,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
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"));
|
|
14
8
|
var _mouse_handler = _interopRequireDefault(require("./mouse_handler"));
|
|
15
9
|
var _util = require("./util");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return _super.apply(this, arguments);
|
|
24
|
-
}
|
|
25
|
-
(0, _createClass2.default)(MousePanHandler, [{
|
|
26
|
-
key: "mousedown",
|
|
27
|
-
value: function mousedown(e, point) {
|
|
28
|
-
(0, _get2.default)((0, _getPrototypeOf2.default)(MousePanHandler.prototype), "mousedown", this).call(this, e, point);
|
|
29
|
-
if (this.lastPoint) {
|
|
30
|
-
this.active = true;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}, {
|
|
34
|
-
key: "move",
|
|
35
|
-
value: function move(lastPoint, point) {
|
|
36
|
-
return {
|
|
37
|
-
around: point,
|
|
38
|
-
panDelta: point.sub(lastPoint)
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}, {
|
|
42
|
-
key: "correctButton",
|
|
43
|
-
value: function correctButton(e, button) {
|
|
44
|
-
return button === _util.LEFT_BUTTON && !e.ctrlKey;
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
|
|
12
|
+
class MousePanHandler extends _mouse_handler.default {
|
|
13
|
+
mousedown(e, point) {
|
|
14
|
+
super.mousedown(e, point);
|
|
15
|
+
if (this.lastPoint) {
|
|
16
|
+
this.active = true;
|
|
45
17
|
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
18
|
+
}
|
|
19
|
+
move(lastPoint, point) {
|
|
20
|
+
return {
|
|
21
|
+
around: point,
|
|
22
|
+
panDelta: point.sub(lastPoint)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
correctButton(e, button) {
|
|
26
|
+
return button === _util.LEFT_BUTTON && !e.ctrlKey;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = MousePanHandler;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type Point from '../../geo/point';
|
|
2
|
+
import MouseHandler from './mouse_handler';
|
|
3
|
+
export default class MousePitchHandler extends MouseHandler {
|
|
4
|
+
correctButton(e: MouseEvent, button: number): boolean;
|
|
5
|
+
move(lastPoint: Point, point: Point): {
|
|
6
|
+
pitchDelta: number;
|
|
7
|
+
} | undefined;
|
|
8
|
+
contextmenu(e: MouseEvent): void;
|
|
9
|
+
}
|
|
@@ -5,46 +5,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
11
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
12
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
8
|
var _mouse_handler = _interopRequireDefault(require("./mouse_handler"));
|
|
14
9
|
var _util = require("./util");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
function MousePitchHandler() {
|
|
21
|
-
(0, _classCallCheck2.default)(this, MousePitchHandler);
|
|
22
|
-
return _super.apply(this, arguments);
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
|
|
12
|
+
class MousePitchHandler extends _mouse_handler.default {
|
|
13
|
+
correctButton(e, button) {
|
|
14
|
+
return button === _util.LEFT_BUTTON && e.ctrlKey || button === _util.RIGHT_BUTTON;
|
|
23
15
|
}
|
|
24
|
-
(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var degreesPerPixelMoved = -0.5;
|
|
33
|
-
var pitchDelta = (point.y - lastPoint.y) * degreesPerPixelMoved;
|
|
34
|
-
if (pitchDelta) {
|
|
35
|
-
this.active = true;
|
|
36
|
-
return {
|
|
37
|
-
pitchDelta: pitchDelta
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}, {
|
|
42
|
-
key: "contextmenu",
|
|
43
|
-
value: function contextmenu(e) {
|
|
44
|
-
// prevent browser context menu when necessary; we don't allow it with rotation
|
|
45
|
-
// because we can't discern rotation gesture start from contextmenu on Mac
|
|
46
|
-
e.preventDefault();
|
|
16
|
+
move(lastPoint, point) {
|
|
17
|
+
const degreesPerPixelMoved = -0.5;
|
|
18
|
+
const pitchDelta = (point.y - lastPoint.y) * degreesPerPixelMoved;
|
|
19
|
+
if (pitchDelta) {
|
|
20
|
+
this.active = true;
|
|
21
|
+
return {
|
|
22
|
+
pitchDelta
|
|
23
|
+
};
|
|
47
24
|
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
25
|
+
}
|
|
26
|
+
contextmenu(e) {
|
|
27
|
+
// prevent browser context menu when necessary; we don't allow it with rotation
|
|
28
|
+
// because we can't discern rotation gesture start from contextmenu on Mac
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.default = MousePitchHandler;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type Point from '../../geo/point';
|
|
2
|
+
import MouseHandler from './mouse_handler';
|
|
3
|
+
export default class MouseRotateHandler extends MouseHandler {
|
|
4
|
+
contextmenu(e: MouseEvent): void;
|
|
5
|
+
protected correctButton(e: MouseEvent, button: number): boolean;
|
|
6
|
+
protected move(lastPoint: Point, point: Point): {
|
|
7
|
+
bearingDelta: number;
|
|
8
|
+
} | undefined;
|
|
9
|
+
}
|
|
@@ -5,46 +5,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
11
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
12
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
8
|
var _mouse_handler = _interopRequireDefault(require("./mouse_handler"));
|
|
14
9
|
var _util = require("./util");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return _super.apply(this, arguments);
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
|
|
12
|
+
class MouseRotateHandler extends _mouse_handler.default {
|
|
13
|
+
contextmenu(e) {
|
|
14
|
+
// prevent browser context menu when necessary; we don't allow it with rotation
|
|
15
|
+
// because we can't discern rotation gesture start from contextmenu on Mac
|
|
16
|
+
e.preventDefault();
|
|
23
17
|
}
|
|
24
|
-
(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
}, {
|
|
37
|
-
key: "move",
|
|
38
|
-
value: function move(lastPoint, point) {
|
|
39
|
-
var degreesPerPixelMoved = 0.8;
|
|
40
|
-
var bearingDelta = (point.x - lastPoint.x) * degreesPerPixelMoved;
|
|
41
|
-
if (bearingDelta) {
|
|
42
|
-
this.active = true;
|
|
43
|
-
return {
|
|
44
|
-
bearingDelta: bearingDelta
|
|
45
|
-
};
|
|
46
|
-
}
|
|
18
|
+
correctButton(e, button) {
|
|
19
|
+
return button === _util.LEFT_BUTTON && e.ctrlKey || button === _util.RIGHT_BUTTON;
|
|
20
|
+
}
|
|
21
|
+
move(lastPoint, point) {
|
|
22
|
+
const degreesPerPixelMoved = 0.8;
|
|
23
|
+
const bearingDelta = (point.x - lastPoint.x) * degreesPerPixelMoved;
|
|
24
|
+
if (bearingDelta) {
|
|
25
|
+
this.active = true;
|
|
26
|
+
return {
|
|
27
|
+
bearingDelta
|
|
28
|
+
};
|
|
47
29
|
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.default = MouseRotateHandler;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.RIGHT_BUTTON = exports.LEFT_BUTTON = exports.BUTTONS_FLAGS = void 0;
|
|
8
7
|
exports.buttonStillPressed = buttonStillPressed;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var LEFT_BUTTON = exports.LEFT_BUTTON = 0;
|
|
12
|
-
var RIGHT_BUTTON = exports.RIGHT_BUTTON = 2;
|
|
8
|
+
const LEFT_BUTTON = exports.LEFT_BUTTON = 0;
|
|
9
|
+
const RIGHT_BUTTON = exports.RIGHT_BUTTON = 2;
|
|
13
10
|
|
|
14
11
|
// the values for each button in MouseEvent.buttons
|
|
15
|
-
|
|
12
|
+
const BUTTONS_FLAGS = exports.BUTTONS_FLAGS = {
|
|
13
|
+
[LEFT_BUTTON]: 1,
|
|
14
|
+
[RIGHT_BUTTON]: 2
|
|
15
|
+
};
|
|
16
16
|
function buttonStillPressed(e, button) {
|
|
17
|
-
|
|
17
|
+
const flag = BUTTONS_FLAGS[button];
|
|
18
18
|
return e.buttons === undefined || (e.buttons & flag) !== flag;
|
|
19
19
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { EarthMap } from '../earthmap';
|
|
2
|
+
import type Point from '../geo/point';
|
|
3
|
+
import type { Map } from '../map';
|
|
4
|
+
import type HandlerManager from './handler_manager';
|
|
5
|
+
/**
|
|
6
|
+
* The `ScrollZoomHandler` allows the user to zoom the map by scrolling.
|
|
7
|
+
*/
|
|
8
|
+
declare class ScrollZoomHandler {
|
|
9
|
+
private map;
|
|
10
|
+
private el;
|
|
11
|
+
private enabled;
|
|
12
|
+
private active;
|
|
13
|
+
private zooming;
|
|
14
|
+
private aroundCenter;
|
|
15
|
+
private around;
|
|
16
|
+
private aroundPoint;
|
|
17
|
+
private type;
|
|
18
|
+
private lastValue;
|
|
19
|
+
private timeout;
|
|
20
|
+
private finishTimeout;
|
|
21
|
+
private lastWheelEvent;
|
|
22
|
+
private lastWheelEventTime;
|
|
23
|
+
private startZoom;
|
|
24
|
+
private targetZoom;
|
|
25
|
+
private delta;
|
|
26
|
+
private easing;
|
|
27
|
+
private prevEase;
|
|
28
|
+
private frameId;
|
|
29
|
+
private handler;
|
|
30
|
+
private defaultZoomRate;
|
|
31
|
+
private wheelZoomRate;
|
|
32
|
+
/**
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
constructor(map: Map | EarthMap, handler: HandlerManager);
|
|
36
|
+
/**
|
|
37
|
+
* Set the zoom rate of a trackpad
|
|
38
|
+
* @param {number} [zoomRate=1/100] The rate used to scale trackpad movement to a zoom value.
|
|
39
|
+
* @example
|
|
40
|
+
* // Speed up trackpad zoom
|
|
41
|
+
* map.scrollZoom.setZoomRate(1/25);
|
|
42
|
+
*/
|
|
43
|
+
setZoomRate(zoomRate: number): void;
|
|
44
|
+
/**
|
|
45
|
+
* Set the zoom rate of a mouse wheel
|
|
46
|
+
* @param {number} [wheelZoomRate=1/450] The rate used to scale mouse wheel movement to a zoom value.
|
|
47
|
+
* @example
|
|
48
|
+
* // Slow down zoom of mouse wheel
|
|
49
|
+
* map.scrollZoom.setWheelZoomRate(1/600);
|
|
50
|
+
*/
|
|
51
|
+
setWheelZoomRate(zoomRate: number): void;
|
|
52
|
+
/**
|
|
53
|
+
* Returns a Boolean indicating whether the "scroll to zoom" interaction is enabled.
|
|
54
|
+
*
|
|
55
|
+
* @returns {boolean} `true` if the "scroll to zoom" interaction is enabled.
|
|
56
|
+
*/
|
|
57
|
+
isEnabled(): boolean;
|
|
58
|
+
isActive(): boolean;
|
|
59
|
+
isZooming(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Enables the "scroll to zoom" interaction.
|
|
62
|
+
*
|
|
63
|
+
* @param {Object} [options] Options object.
|
|
64
|
+
* @param {string} [options.around] If "center" is passed, map will zoom around center of map
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* map.scrollZoom.enable();
|
|
68
|
+
* @example
|
|
69
|
+
* map.scrollZoom.enable({ around: 'center' })
|
|
70
|
+
*/
|
|
71
|
+
enable(options?: any): void;
|
|
72
|
+
/**
|
|
73
|
+
* Disables the "scroll to zoom" interaction.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* map.scrollZoom.disable();
|
|
77
|
+
*/
|
|
78
|
+
disable(): void;
|
|
79
|
+
wheel(e: WheelEvent): void;
|
|
80
|
+
renderFrame(): {
|
|
81
|
+
noInertia: boolean;
|
|
82
|
+
needsRenderFrame: boolean;
|
|
83
|
+
zoomDelta: number;
|
|
84
|
+
around: Point;
|
|
85
|
+
originalEvent: any;
|
|
86
|
+
} | undefined;
|
|
87
|
+
reset(): void;
|
|
88
|
+
private onScrollFrame;
|
|
89
|
+
private onTimeout;
|
|
90
|
+
private start;
|
|
91
|
+
private smoothOutEasing;
|
|
92
|
+
}
|
|
93
|
+
export default ScrollZoomHandler;
|