@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
|
@@ -7,8 +7,8 @@ exports.indexTouches = indexTouches;
|
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
|
|
9
9
|
function indexTouches(touches, points) {
|
|
10
|
-
|
|
11
|
-
for (
|
|
10
|
+
const obj = {};
|
|
11
|
+
for (let i = 0; i < touches.length; i++) {
|
|
12
12
|
obj[touches[i].identifier] = points[i];
|
|
13
13
|
}
|
|
14
14
|
return obj;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { EarthMap } from '../earthmap';
|
|
2
|
+
import type { Map } from '../map';
|
|
3
|
+
/**
|
|
4
|
+
* The `KeyboardHandler` allows the user to zoom, rotate, and pan the map using
|
|
5
|
+
* the following keyboard shortcuts:
|
|
6
|
+
*
|
|
7
|
+
* - `=` / `+`: Increase the zoom level by 1.
|
|
8
|
+
* - `Shift-=` / `Shift-+`: Increase the zoom level by 2.
|
|
9
|
+
* - `-`: Decrease the zoom level by 1.
|
|
10
|
+
* - `Shift--`: Decrease the zoom level by 2.
|
|
11
|
+
* - Arrow keys: Pan by 100 pixels.
|
|
12
|
+
* - `Shift+⇢`: Increase the rotation by 15 degrees.
|
|
13
|
+
* - `Shift+⇠`: Decrease the rotation by 15 degrees.
|
|
14
|
+
* - `Shift+⇡`: Increase the pitch by 10 degrees.
|
|
15
|
+
* - `Shift+⇣`: Decrease the pitch by 10 degrees.
|
|
16
|
+
*/
|
|
17
|
+
declare class KeyboardHandler {
|
|
18
|
+
private enabled;
|
|
19
|
+
private active;
|
|
20
|
+
private panStep;
|
|
21
|
+
private bearingStep;
|
|
22
|
+
private pitchStep;
|
|
23
|
+
/**
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
constructor();
|
|
27
|
+
reset(): void;
|
|
28
|
+
keydown(e: KeyboardEvent): {
|
|
29
|
+
cameraAnimation: (map: Map | EarthMap) => void;
|
|
30
|
+
} | undefined;
|
|
31
|
+
enable(): void;
|
|
32
|
+
disable(): void;
|
|
33
|
+
isEnabled(): boolean;
|
|
34
|
+
isActive(): boolean;
|
|
35
|
+
}
|
|
36
|
+
export default KeyboardHandler;
|
package/lib/handler/keyboard.js
CHANGED
|
@@ -5,9 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
var defaultOptions = {
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
const defaultOptions = {
|
|
11
10
|
panStep: 100,
|
|
12
11
|
bearingStep: 15,
|
|
13
12
|
pitchStep: 10
|
|
@@ -27,123 +26,112 @@ var defaultOptions = {
|
|
|
27
26
|
* - `Shift+⇡`: Increase the pitch by 10 degrees.
|
|
28
27
|
* - `Shift+⇣`: Decrease the pitch by 10 degrees.
|
|
29
28
|
*/
|
|
30
|
-
|
|
29
|
+
class KeyboardHandler {
|
|
31
30
|
/**
|
|
32
31
|
* @private
|
|
33
32
|
*/
|
|
34
|
-
|
|
35
|
-
(0,
|
|
36
|
-
|
|
33
|
+
constructor() {
|
|
34
|
+
(0, _defineProperty2.default)(this, "enabled", void 0);
|
|
35
|
+
(0, _defineProperty2.default)(this, "active", void 0);
|
|
36
|
+
(0, _defineProperty2.default)(this, "panStep", void 0);
|
|
37
|
+
(0, _defineProperty2.default)(this, "bearingStep", void 0);
|
|
38
|
+
(0, _defineProperty2.default)(this, "pitchStep", void 0);
|
|
39
|
+
const stepOptions = defaultOptions;
|
|
37
40
|
this.panStep = stepOptions.panStep;
|
|
38
41
|
this.bearingStep = stepOptions.bearingStep;
|
|
39
42
|
this.pitchStep = stepOptions.pitchStep;
|
|
40
43
|
}
|
|
41
|
-
(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
reset() {
|
|
45
|
+
this.active = false;
|
|
46
|
+
}
|
|
47
|
+
keydown(e) {
|
|
48
|
+
if (e.altKey || e.ctrlKey || e.metaKey) {
|
|
49
|
+
return;
|
|
45
50
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
break;
|
|
70
|
-
case 37:
|
|
71
|
-
if (e.shiftKey) {
|
|
72
|
-
bearingDir = -1;
|
|
73
|
-
} else {
|
|
74
|
-
e.preventDefault();
|
|
75
|
-
xDir = -1;
|
|
76
|
-
}
|
|
77
|
-
break;
|
|
78
|
-
case 39:
|
|
79
|
-
if (e.shiftKey) {
|
|
80
|
-
bearingDir = 1;
|
|
81
|
-
} else {
|
|
82
|
-
e.preventDefault();
|
|
83
|
-
xDir = 1;
|
|
84
|
-
}
|
|
85
|
-
break;
|
|
86
|
-
case 38:
|
|
87
|
-
if (e.shiftKey) {
|
|
88
|
-
pitchDir = 1;
|
|
89
|
-
} else {
|
|
90
|
-
e.preventDefault();
|
|
91
|
-
yDir = -1;
|
|
92
|
-
}
|
|
93
|
-
break;
|
|
94
|
-
case 40:
|
|
95
|
-
if (e.shiftKey) {
|
|
96
|
-
pitchDir = -1;
|
|
97
|
-
} else {
|
|
98
|
-
e.preventDefault();
|
|
99
|
-
yDir = 1;
|
|
100
|
-
}
|
|
101
|
-
break;
|
|
102
|
-
default:
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
cameraAnimation: function cameraAnimation(map) {
|
|
107
|
-
var zoom = map.getZoom();
|
|
108
|
-
map.easeTo({
|
|
109
|
-
duration: 300,
|
|
110
|
-
easeId: 'keyboardHandler',
|
|
111
|
-
easing: easeOut,
|
|
112
|
-
zoom: zoomDir ? Math.round(zoom) + zoomDir * (e.shiftKey ? 2 : 1) : zoom,
|
|
113
|
-
bearing: map.getBearing() + bearingDir * _this.bearingStep,
|
|
114
|
-
pitch: map.getPitch() + pitchDir * _this.pitchStep,
|
|
115
|
-
offset: [-xDir * _this.panStep, -yDir * _this.panStep],
|
|
116
|
-
center: map.getCenter()
|
|
117
|
-
}, {
|
|
118
|
-
originalEvent: e
|
|
119
|
-
});
|
|
51
|
+
let zoomDir = 0;
|
|
52
|
+
let bearingDir = 0;
|
|
53
|
+
let pitchDir = 0;
|
|
54
|
+
let xDir = 0;
|
|
55
|
+
let yDir = 0;
|
|
56
|
+
switch (e.keyCode) {
|
|
57
|
+
case 61:
|
|
58
|
+
case 107:
|
|
59
|
+
case 171:
|
|
60
|
+
case 187:
|
|
61
|
+
zoomDir = 1;
|
|
62
|
+
break;
|
|
63
|
+
case 189:
|
|
64
|
+
case 109:
|
|
65
|
+
case 173:
|
|
66
|
+
zoomDir = -1;
|
|
67
|
+
break;
|
|
68
|
+
case 37:
|
|
69
|
+
if (e.shiftKey) {
|
|
70
|
+
bearingDir = -1;
|
|
71
|
+
} else {
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
xDir = -1;
|
|
120
74
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
75
|
+
break;
|
|
76
|
+
case 39:
|
|
77
|
+
if (e.shiftKey) {
|
|
78
|
+
bearingDir = 1;
|
|
79
|
+
} else {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
xDir = 1;
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case 38:
|
|
85
|
+
if (e.shiftKey) {
|
|
86
|
+
pitchDir = 1;
|
|
87
|
+
} else {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
yDir = -1;
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
case 40:
|
|
93
|
+
if (e.shiftKey) {
|
|
94
|
+
pitchDir = -1;
|
|
95
|
+
} else {
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
yDir = 1;
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
default:
|
|
101
|
+
return;
|
|
143
102
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
103
|
+
return {
|
|
104
|
+
cameraAnimation: map => {
|
|
105
|
+
const zoom = map.getZoom();
|
|
106
|
+
map.easeTo({
|
|
107
|
+
duration: 300,
|
|
108
|
+
easeId: 'keyboardHandler',
|
|
109
|
+
easing: easeOut,
|
|
110
|
+
zoom: zoomDir ? Math.round(zoom) + zoomDir * (e.shiftKey ? 2 : 1) : zoom,
|
|
111
|
+
bearing: map.getBearing() + bearingDir * this.bearingStep,
|
|
112
|
+
pitch: map.getPitch() + pitchDir * this.pitchStep,
|
|
113
|
+
offset: [-xDir * this.panStep, -yDir * this.panStep],
|
|
114
|
+
center: map.getCenter()
|
|
115
|
+
}, {
|
|
116
|
+
originalEvent: e
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
enable() {
|
|
122
|
+
this.enabled = true;
|
|
123
|
+
}
|
|
124
|
+
disable() {
|
|
125
|
+
this.enabled = false;
|
|
126
|
+
this.reset();
|
|
127
|
+
}
|
|
128
|
+
isEnabled() {
|
|
129
|
+
return this.enabled;
|
|
130
|
+
}
|
|
131
|
+
isActive() {
|
|
132
|
+
return this.active;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
147
135
|
function easeOut(t) {
|
|
148
136
|
return t * (2 - t);
|
|
149
137
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { EarthMap } from '../earthmap';
|
|
2
|
+
import type Point from '../geo/point';
|
|
3
|
+
import type { Map } from '../map';
|
|
4
|
+
import { MapMouseEvent, MapTouchEvent, MapWheelEvent } from './events';
|
|
5
|
+
export default class MapEventHandler {
|
|
6
|
+
private mousedownPos;
|
|
7
|
+
private clickTolerance;
|
|
8
|
+
private map;
|
|
9
|
+
constructor(map: Map | EarthMap, options: {
|
|
10
|
+
clickTolerance: number;
|
|
11
|
+
});
|
|
12
|
+
reset(): void;
|
|
13
|
+
wheel(e: WheelEvent): {} | undefined;
|
|
14
|
+
mousedown(e: MouseEvent, point: Point): {} | undefined;
|
|
15
|
+
mouseup(e: MouseEvent): void;
|
|
16
|
+
click(e: MouseEvent, point: Point): void;
|
|
17
|
+
dblclick(e: MouseEvent): {} | undefined;
|
|
18
|
+
mouseover(e: MouseEvent): void;
|
|
19
|
+
mouseout(e: MouseEvent): void;
|
|
20
|
+
touchstart(e: TouchEvent): {} | undefined;
|
|
21
|
+
touchmove(e: TouchEvent): void;
|
|
22
|
+
touchend(e: TouchEvent): void;
|
|
23
|
+
touchcancel(e: TouchEvent): void;
|
|
24
|
+
firePreventable(mapEvent: MapMouseEvent | MapTouchEvent | MapWheelEvent): {} | undefined;
|
|
25
|
+
isEnabled(): boolean;
|
|
26
|
+
isActive(): boolean;
|
|
27
|
+
enable(): boolean;
|
|
28
|
+
disable(): boolean;
|
|
29
|
+
}
|
package/lib/handler/map_event.js
CHANGED
|
@@ -5,126 +5,93 @@ 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 _events = require("./events");
|
|
11
10
|
// @ts-ignore
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
|
|
12
|
+
class MapEventHandler {
|
|
13
|
+
constructor(map, options) {
|
|
14
|
+
(0, _defineProperty2.default)(this, "mousedownPos", void 0);
|
|
15
|
+
(0, _defineProperty2.default)(this, "clickTolerance", void 0);
|
|
16
|
+
(0, _defineProperty2.default)(this, "map", void 0);
|
|
15
17
|
this.map = map;
|
|
16
18
|
this.clickTolerance = options.clickTolerance;
|
|
17
19
|
}
|
|
18
|
-
(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, {
|
|
43
|
-
key: "mouseup",
|
|
44
|
-
value: function mouseup(e) {
|
|
45
|
-
this.map.emit(e.type, new _events.MapMouseEvent(e.type, this.map, e));
|
|
46
|
-
}
|
|
47
|
-
}, {
|
|
48
|
-
key: "click",
|
|
49
|
-
value: function click(e, point) {
|
|
50
|
-
if (this.mousedownPos && this.mousedownPos.dist(point) >= this.clickTolerance) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
this.map.emit(e.type, new _events.MapMouseEvent(e.type, this.map, e));
|
|
54
|
-
}
|
|
55
|
-
}, {
|
|
56
|
-
key: "dblclick",
|
|
57
|
-
value: function dblclick(e) {
|
|
58
|
-
// If mapEvent.preventDefault() is called by the user, prevent handlers such as:
|
|
59
|
-
// - DblClickZoom
|
|
60
|
-
return this.firePreventable(new _events.MapMouseEvent(e.type, this.map, e));
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
key: "mouseover",
|
|
64
|
-
value: function mouseover(e) {
|
|
65
|
-
this.map.emit(e.type, new _events.MapMouseEvent(e.type, this.map, e));
|
|
66
|
-
}
|
|
67
|
-
}, {
|
|
68
|
-
key: "mouseout",
|
|
69
|
-
value: function mouseout(e) {
|
|
70
|
-
this.map.emit(e.type, new _events.MapMouseEvent(e.type, this.map, e));
|
|
71
|
-
}
|
|
72
|
-
}, {
|
|
73
|
-
key: "touchstart",
|
|
74
|
-
value: function touchstart(e) {
|
|
75
|
-
// If mapEvent.preventDefault() is called by the user, prevent handlers such as:
|
|
76
|
-
// - TouchPan
|
|
77
|
-
// - TouchZoom
|
|
78
|
-
// - TouchRotate
|
|
79
|
-
// - TouchPitch
|
|
80
|
-
// - TapZoom
|
|
81
|
-
// - SwipeZoom
|
|
82
|
-
return this.firePreventable(new _events.MapTouchEvent(e.type, this.map, e));
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
key: "touchmove",
|
|
86
|
-
value: function touchmove(e) {
|
|
87
|
-
this.map.emit(e.type, new _events.MapTouchEvent(e.type, this.map, e));
|
|
88
|
-
}
|
|
89
|
-
}, {
|
|
90
|
-
key: "touchend",
|
|
91
|
-
value: function touchend(e) {
|
|
92
|
-
this.map.emit(e.type, new _events.MapTouchEvent(e.type, this.map, e));
|
|
93
|
-
}
|
|
94
|
-
}, {
|
|
95
|
-
key: "touchcancel",
|
|
96
|
-
value: function touchcancel(e) {
|
|
97
|
-
this.map.emit(e.type, new _events.MapTouchEvent(e.type, this.map, e));
|
|
98
|
-
}
|
|
99
|
-
}, {
|
|
100
|
-
key: "firePreventable",
|
|
101
|
-
value: function firePreventable(mapEvent) {
|
|
102
|
-
this.map.emit(mapEvent.type, mapEvent);
|
|
103
|
-
if (mapEvent.defaultPrevented) {
|
|
104
|
-
// returning an object marks the handler as active and resets other handlers
|
|
105
|
-
return {};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}, {
|
|
109
|
-
key: "isEnabled",
|
|
110
|
-
value: function isEnabled() {
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
}, {
|
|
114
|
-
key: "isActive",
|
|
115
|
-
value: function isActive() {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
}, {
|
|
119
|
-
key: "enable",
|
|
120
|
-
value: function enable() {
|
|
121
|
-
return false;
|
|
20
|
+
reset() {
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
delete this.mousedownPos;
|
|
23
|
+
}
|
|
24
|
+
wheel(e) {
|
|
25
|
+
// If mapEvent.preventDefault() is called by the user, prevent handlers such as:
|
|
26
|
+
// - ScrollZoom
|
|
27
|
+
return this.firePreventable(new _events.MapWheelEvent(e.type, this.map, e));
|
|
28
|
+
}
|
|
29
|
+
mousedown(e, point) {
|
|
30
|
+
this.mousedownPos = point;
|
|
31
|
+
// If mapEvent.preventDefault() is called by the user, prevent handlers such as:
|
|
32
|
+
// - MousePan
|
|
33
|
+
// - MouseRotate
|
|
34
|
+
// - MousePitch
|
|
35
|
+
// - DblclickHandler
|
|
36
|
+
return this.firePreventable(new _events.MapMouseEvent(e.type, this.map, e));
|
|
37
|
+
}
|
|
38
|
+
mouseup(e) {
|
|
39
|
+
this.map.emit(e.type, new _events.MapMouseEvent(e.type, this.map, e));
|
|
40
|
+
}
|
|
41
|
+
click(e, point) {
|
|
42
|
+
if (this.mousedownPos && this.mousedownPos.dist(point) >= this.clickTolerance) {
|
|
43
|
+
return;
|
|
122
44
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
45
|
+
this.map.emit(e.type, new _events.MapMouseEvent(e.type, this.map, e));
|
|
46
|
+
}
|
|
47
|
+
dblclick(e) {
|
|
48
|
+
// If mapEvent.preventDefault() is called by the user, prevent handlers such as:
|
|
49
|
+
// - DblClickZoom
|
|
50
|
+
return this.firePreventable(new _events.MapMouseEvent(e.type, this.map, e));
|
|
51
|
+
}
|
|
52
|
+
mouseover(e) {
|
|
53
|
+
this.map.emit(e.type, new _events.MapMouseEvent(e.type, this.map, e));
|
|
54
|
+
}
|
|
55
|
+
mouseout(e) {
|
|
56
|
+
this.map.emit(e.type, new _events.MapMouseEvent(e.type, this.map, e));
|
|
57
|
+
}
|
|
58
|
+
touchstart(e) {
|
|
59
|
+
// If mapEvent.preventDefault() is called by the user, prevent handlers such as:
|
|
60
|
+
// - TouchPan
|
|
61
|
+
// - TouchZoom
|
|
62
|
+
// - TouchRotate
|
|
63
|
+
// - TouchPitch
|
|
64
|
+
// - TapZoom
|
|
65
|
+
// - SwipeZoom
|
|
66
|
+
return this.firePreventable(new _events.MapTouchEvent(e.type, this.map, e));
|
|
67
|
+
}
|
|
68
|
+
touchmove(e) {
|
|
69
|
+
this.map.emit(e.type, new _events.MapTouchEvent(e.type, this.map, e));
|
|
70
|
+
}
|
|
71
|
+
touchend(e) {
|
|
72
|
+
this.map.emit(e.type, new _events.MapTouchEvent(e.type, this.map, e));
|
|
73
|
+
}
|
|
74
|
+
touchcancel(e) {
|
|
75
|
+
this.map.emit(e.type, new _events.MapTouchEvent(e.type, this.map, e));
|
|
76
|
+
}
|
|
77
|
+
firePreventable(mapEvent) {
|
|
78
|
+
this.map.emit(mapEvent.type, mapEvent);
|
|
79
|
+
if (mapEvent.defaultPrevented) {
|
|
80
|
+
// returning an object marks the handler as active and resets other handlers
|
|
81
|
+
return {};
|
|
127
82
|
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
83
|
+
}
|
|
84
|
+
isEnabled() {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
isActive() {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
enable() {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
disable() {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.default = MapEventHandler;
|
|
@@ -6,19 +6,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
Object.defineProperty(exports, "MousePanHandler", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function
|
|
9
|
+
get: function () {
|
|
10
10
|
return _mousepan_handler.default;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "MousePitchHandler", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function
|
|
15
|
+
get: function () {
|
|
16
16
|
return _mouserotate_hander.default;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "MouseRotateHandler", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function
|
|
21
|
+
get: function () {
|
|
22
22
|
return _mousepitch_hander.default;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type Point from '../../geo/point';
|
|
2
|
+
export default class MouseHandler {
|
|
3
|
+
protected enabled: boolean;
|
|
4
|
+
protected active: boolean;
|
|
5
|
+
protected lastPoint: Point;
|
|
6
|
+
protected eventButton: 1 | 2;
|
|
7
|
+
protected moved: boolean;
|
|
8
|
+
protected clickTolerance: number;
|
|
9
|
+
constructor(options: {
|
|
10
|
+
clickTolerance: number;
|
|
11
|
+
});
|
|
12
|
+
reset(): void;
|
|
13
|
+
mousedown(e: MouseEvent, point: Point): void;
|
|
14
|
+
mousemoveWindow(e: MouseEvent, point: Point): void;
|
|
15
|
+
mouseupWindow(e: MouseEvent): void;
|
|
16
|
+
enable(): void;
|
|
17
|
+
disable(): void;
|
|
18
|
+
isEnabled(): boolean;
|
|
19
|
+
isActive(): boolean;
|
|
20
|
+
protected correctButton(e: MouseEvent, button: number): boolean;
|
|
21
|
+
protected move(lastPoint: Point, point: Point): void;
|
|
22
|
+
}
|