@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
|
@@ -1,78 +1,58 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
// @ts-ignore
|
|
4
3
|
|
|
5
4
|
import { MapMouseEvent } from "./events";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export default class BlockableMapEventHandler {
|
|
6
|
+
constructor(map) {
|
|
7
|
+
_defineProperty(this, "map", void 0);
|
|
8
|
+
_defineProperty(this, "delayContextMenu", void 0);
|
|
9
|
+
_defineProperty(this, "contextMenuEvent", void 0);
|
|
9
10
|
this.map = map;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
reset() {
|
|
13
|
+
this.delayContextMenu = false;
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
delete this.contextMenuEvent;
|
|
16
|
+
}
|
|
17
|
+
mousemove(e) {
|
|
18
|
+
// mousemove map events should not be fired when interaction handlers (pan, rotate, etc) are active
|
|
19
|
+
this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
|
|
20
|
+
}
|
|
21
|
+
mousedown() {
|
|
22
|
+
this.delayContextMenu = true;
|
|
23
|
+
}
|
|
24
|
+
mouseup() {
|
|
25
|
+
this.delayContextMenu = false;
|
|
26
|
+
if (this.contextMenuEvent) {
|
|
27
|
+
this.map.emit('contextmenu', new MapMouseEvent('contextmenu', this.map, this.contextMenuEvent));
|
|
15
28
|
// @ts-ignore
|
|
16
29
|
delete this.contextMenuEvent;
|
|
17
30
|
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
//
|
|
31
|
+
}
|
|
32
|
+
contextmenu(e) {
|
|
33
|
+
if (this.delayContextMenu) {
|
|
34
|
+
// Mac: contextmenu fired on mousedown; we save it until mouseup for consistency's sake
|
|
35
|
+
this.contextMenuEvent = e;
|
|
36
|
+
} else {
|
|
37
|
+
// Windows: contextmenu fired on mouseup, so fire event now
|
|
22
38
|
this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
|
|
23
39
|
}
|
|
24
|
-
}, {
|
|
25
|
-
key: "mousedown",
|
|
26
|
-
value: function mousedown() {
|
|
27
|
-
this.delayContextMenu = true;
|
|
28
|
-
}
|
|
29
|
-
}, {
|
|
30
|
-
key: "mouseup",
|
|
31
|
-
value: function mouseup() {
|
|
32
|
-
this.delayContextMenu = false;
|
|
33
|
-
if (this.contextMenuEvent) {
|
|
34
|
-
this.map.emit('contextmenu', new MapMouseEvent('contextmenu', this.map, this.contextMenuEvent));
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
delete this.contextMenuEvent;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}, {
|
|
40
|
-
key: "contextmenu",
|
|
41
|
-
value: function contextmenu(e) {
|
|
42
|
-
if (this.delayContextMenu) {
|
|
43
|
-
// Mac: contextmenu fired on mousedown; we save it until mouseup for consistency's sake
|
|
44
|
-
this.contextMenuEvent = e;
|
|
45
|
-
} else {
|
|
46
|
-
// Windows: contextmenu fired on mouseup, so fire event now
|
|
47
|
-
this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
|
|
48
|
-
}
|
|
49
40
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}, {
|
|
56
|
-
key: "isEnabled",
|
|
57
|
-
value: function isEnabled() {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
}, {
|
|
61
|
-
key: "isActive",
|
|
62
|
-
value: function isActive() {
|
|
63
|
-
return false;
|
|
41
|
+
// prevent browser context menu when necessary
|
|
42
|
+
if (this.map.listeners('contextmenu')) {
|
|
43
|
+
e.preventDefault();
|
|
64
44
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
45
|
+
}
|
|
46
|
+
isEnabled() {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
isActive() {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
enable() {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
disable() {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
package/es/handler/box_zoom.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
// @ts-ignore
|
|
4
3
|
|
|
5
4
|
import DOM from "../utils/dom";
|
|
@@ -9,12 +8,20 @@ import { Event } from "./events/event";
|
|
|
9
8
|
* The `BoxZoomHandler` allows the user to zoom the map to fit within a bounding box.
|
|
10
9
|
* The bounding box is defined by clicking and holding `shift` while dragging the cursor.
|
|
11
10
|
*/
|
|
12
|
-
|
|
11
|
+
class BoxZoomHandler {
|
|
13
12
|
/**
|
|
14
13
|
* @private
|
|
15
14
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
constructor(map, options) {
|
|
16
|
+
_defineProperty(this, "map", void 0);
|
|
17
|
+
_defineProperty(this, "el", void 0);
|
|
18
|
+
_defineProperty(this, "container", void 0);
|
|
19
|
+
_defineProperty(this, "enabled", void 0);
|
|
20
|
+
_defineProperty(this, "active", void 0);
|
|
21
|
+
_defineProperty(this, "startPos", void 0);
|
|
22
|
+
_defineProperty(this, "lastPos", void 0);
|
|
23
|
+
_defineProperty(this, "box", void 0);
|
|
24
|
+
_defineProperty(this, "clickTolerance", void 0);
|
|
18
25
|
this.map = map;
|
|
19
26
|
this.el = map.getCanvasContainer();
|
|
20
27
|
this.container = map.getContainer();
|
|
@@ -26,155 +33,130 @@ var BoxZoomHandler = /*#__PURE__*/function () {
|
|
|
26
33
|
*
|
|
27
34
|
* @returns {boolean} `true` if the "box zoom" interaction is enabled.
|
|
28
35
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return !!this.enabled;
|
|
33
|
-
}
|
|
36
|
+
isEnabled() {
|
|
37
|
+
return !!this.enabled;
|
|
38
|
+
}
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return !!this.active;
|
|
44
|
-
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns a Boolean indicating whether the "box zoom" interaction is active, i.e. currently being used.
|
|
42
|
+
*
|
|
43
|
+
* @returns {boolean} `true` if the "box zoom" interaction is active.
|
|
44
|
+
*/
|
|
45
|
+
isActive() {
|
|
46
|
+
return !!this.active;
|
|
47
|
+
}
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (this.isEnabled()) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
this.enabled = true;
|
|
49
|
+
/**
|
|
50
|
+
* Enables the "box zoom" interaction.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* map.boxZoom.enable();
|
|
54
|
+
*/
|
|
55
|
+
enable() {
|
|
56
|
+
if (this.isEnabled()) {
|
|
57
|
+
return;
|
|
59
58
|
}
|
|
59
|
+
this.enabled = true;
|
|
60
|
+
}
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (!this.isEnabled()) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
this.enabled = false;
|
|
62
|
+
/**
|
|
63
|
+
* Disables the "box zoom" interaction.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* map.boxZoom.disable();
|
|
67
|
+
*/
|
|
68
|
+
disable() {
|
|
69
|
+
if (!this.isEnabled()) {
|
|
70
|
+
return;
|
|
74
71
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
if (!(e.shiftKey && e.button === 0)) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
DOM.disableDrag();
|
|
85
|
-
this.startPos = this.lastPos = point;
|
|
86
|
-
this.active = true;
|
|
72
|
+
this.enabled = false;
|
|
73
|
+
}
|
|
74
|
+
mousedown(e, point) {
|
|
75
|
+
if (!this.isEnabled()) {
|
|
76
|
+
return;
|
|
87
77
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
value: function mousemoveWindow(e, point) {
|
|
91
|
-
if (!this.active) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
var pos = point;
|
|
95
|
-
if (this.lastPos.equals(pos) || !this.box && pos.dist(this.startPos) < this.clickTolerance) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
var p0 = this.startPos;
|
|
99
|
-
this.lastPos = pos;
|
|
100
|
-
if (!this.box) {
|
|
101
|
-
this.box = DOM.create('div', 'l7-boxzoom', this.container);
|
|
102
|
-
this.container.classList.add('l7-crosshair');
|
|
103
|
-
this.fireEvent('boxzoomstart', e);
|
|
104
|
-
}
|
|
105
|
-
var minX = Math.min(p0.x, pos.x);
|
|
106
|
-
var maxX = Math.max(p0.x, pos.x);
|
|
107
|
-
var minY = Math.min(p0.y, pos.y);
|
|
108
|
-
var maxY = Math.max(p0.y, pos.y);
|
|
109
|
-
DOM.setTransform(this.box, "translate(".concat(minX, "px,").concat(minY, "px)"));
|
|
110
|
-
if (this.box) {
|
|
111
|
-
this.box.style.width = "".concat(maxX - minX, "px");
|
|
112
|
-
this.box.style.height = "".concat(maxY - minY, "px");
|
|
113
|
-
}
|
|
78
|
+
if (!(e.shiftKey && e.button === 0)) {
|
|
79
|
+
return;
|
|
114
80
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (e.button !== 0) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
var p0 = this.startPos;
|
|
126
|
-
var p1 = point;
|
|
127
|
-
this.reset();
|
|
128
|
-
DOM.suppressClick();
|
|
129
|
-
if (p0.x === p1.x && p0.y === p1.y) {
|
|
130
|
-
this.fireEvent('boxzoomcancel', e);
|
|
131
|
-
} else {
|
|
132
|
-
this.map.emit('boxzoomend', new Event('boxzoomend', {
|
|
133
|
-
originalEvent: e
|
|
134
|
-
}));
|
|
135
|
-
return {
|
|
136
|
-
cameraAnimation: function cameraAnimation(map) {
|
|
137
|
-
return map.fitScreenCoordinates(p0, p1, _this.map.getBearing(), {
|
|
138
|
-
linear: true
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
}
|
|
81
|
+
DOM.disableDrag();
|
|
82
|
+
this.startPos = this.lastPos = point;
|
|
83
|
+
this.active = true;
|
|
84
|
+
}
|
|
85
|
+
mousemoveWindow(e, point) {
|
|
86
|
+
if (!this.active) {
|
|
87
|
+
return;
|
|
143
88
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (!this.active) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
if (e.keyCode === 27) {
|
|
151
|
-
this.reset();
|
|
152
|
-
this.fireEvent('boxzoomcancel', e);
|
|
153
|
-
}
|
|
89
|
+
const pos = point;
|
|
90
|
+
if (this.lastPos.equals(pos) || !this.box && pos.dist(this.startPos) < this.clickTolerance) {
|
|
91
|
+
return;
|
|
154
92
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
this.
|
|
159
|
-
this.container.classList.
|
|
160
|
-
|
|
161
|
-
DOM.remove(this.box);
|
|
162
|
-
this.box = null;
|
|
163
|
-
}
|
|
164
|
-
DOM.enableDrag();
|
|
165
|
-
// @ts-ignore
|
|
166
|
-
delete this.startPos;
|
|
167
|
-
// @ts-ignore
|
|
168
|
-
delete this.lastPos;
|
|
93
|
+
const p0 = this.startPos;
|
|
94
|
+
this.lastPos = pos;
|
|
95
|
+
if (!this.box) {
|
|
96
|
+
this.box = DOM.create('div', 'l7-boxzoom', this.container);
|
|
97
|
+
this.container.classList.add('l7-crosshair');
|
|
98
|
+
this.fireEvent('boxzoomstart', e);
|
|
169
99
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
100
|
+
const minX = Math.min(p0.x, pos.x);
|
|
101
|
+
const maxX = Math.max(p0.x, pos.x);
|
|
102
|
+
const minY = Math.min(p0.y, pos.y);
|
|
103
|
+
const maxY = Math.max(p0.y, pos.y);
|
|
104
|
+
DOM.setTransform(this.box, `translate(${minX}px,${minY}px)`);
|
|
105
|
+
if (this.box) {
|
|
106
|
+
this.box.style.width = `${maxX - minX}px`;
|
|
107
|
+
this.box.style.height = `${maxY - minY}px`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
mouseupWindow(e, point) {
|
|
111
|
+
if (!this.active) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (e.button !== 0) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const p0 = this.startPos;
|
|
118
|
+
const p1 = point;
|
|
119
|
+
this.reset();
|
|
120
|
+
DOM.suppressClick();
|
|
121
|
+
if (p0.x === p1.x && p0.y === p1.y) {
|
|
122
|
+
this.fireEvent('boxzoomcancel', e);
|
|
123
|
+
} else {
|
|
124
|
+
this.map.emit('boxzoomend', new Event('boxzoomend', {
|
|
174
125
|
originalEvent: e
|
|
175
126
|
}));
|
|
127
|
+
return {
|
|
128
|
+
cameraAnimation: map => map.fitScreenCoordinates(p0, p1, this.map.getBearing(), {
|
|
129
|
+
linear: true
|
|
130
|
+
})
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
keydown(e) {
|
|
135
|
+
if (!this.active) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (e.keyCode === 27) {
|
|
139
|
+
this.reset();
|
|
140
|
+
this.fireEvent('boxzoomcancel', e);
|
|
176
141
|
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
142
|
+
}
|
|
143
|
+
reset() {
|
|
144
|
+
this.active = false;
|
|
145
|
+
this.container.classList.remove('l7-crosshair');
|
|
146
|
+
if (this.box) {
|
|
147
|
+
DOM.remove(this.box);
|
|
148
|
+
this.box = null;
|
|
149
|
+
}
|
|
150
|
+
DOM.enableDrag();
|
|
151
|
+
// @ts-ignore
|
|
152
|
+
delete this.startPos;
|
|
153
|
+
// @ts-ignore
|
|
154
|
+
delete this.lastPos;
|
|
155
|
+
}
|
|
156
|
+
fireEvent(type, e) {
|
|
157
|
+
return this.map.emit(type, new Event(type, {
|
|
158
|
+
originalEvent: e
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
180
162
|
export default BoxZoomHandler;
|
package/es/handler/click_zoom.js
CHANGED
|
@@ -1,54 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
// @ts-ignore
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
|
|
4
|
+
export default class ClickZoomHandler {
|
|
5
|
+
constructor() {
|
|
6
|
+
_defineProperty(this, "enabled", void 0);
|
|
7
|
+
_defineProperty(this, "active", void 0);
|
|
7
8
|
this.reset();
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
key: "isEnabled",
|
|
43
|
-
value: function isEnabled() {
|
|
44
|
-
return this.enabled;
|
|
45
|
-
}
|
|
46
|
-
}, {
|
|
47
|
-
key: "isActive",
|
|
48
|
-
value: function isActive() {
|
|
49
|
-
return this.active;
|
|
50
|
-
}
|
|
51
|
-
}]);
|
|
52
|
-
return ClickZoomHandler;
|
|
53
|
-
}();
|
|
54
|
-
export { ClickZoomHandler as default };
|
|
10
|
+
reset() {
|
|
11
|
+
this.active = false;
|
|
12
|
+
}
|
|
13
|
+
dblclick(e, point) {
|
|
14
|
+
e.preventDefault();
|
|
15
|
+
return {
|
|
16
|
+
cameraAnimation: map => {
|
|
17
|
+
map.easeTo({
|
|
18
|
+
duration: 300,
|
|
19
|
+
zoom: map.getZoom() + (e.shiftKey ? -1 : 1),
|
|
20
|
+
around: map.unproject(point)
|
|
21
|
+
}, {
|
|
22
|
+
originalEvent: e
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
enable() {
|
|
28
|
+
this.enabled = true;
|
|
29
|
+
}
|
|
30
|
+
disable() {
|
|
31
|
+
this.enabled = false;
|
|
32
|
+
this.reset();
|
|
33
|
+
}
|
|
34
|
+
isEnabled() {
|
|
35
|
+
return this.enabled;
|
|
36
|
+
}
|
|
37
|
+
isActive() {
|
|
38
|
+
return this.active;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
// tslint:disable-next-line:no-submodule-imports
|
|
4
3
|
import { lodashUtil } from '@antv/l7-utils';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const {
|
|
5
|
+
merge
|
|
6
|
+
} = lodashUtil;
|
|
7
|
+
export class Event {
|
|
8
|
+
constructor(type, data = {}) {
|
|
9
|
+
_defineProperty(this, "type", void 0);
|
|
10
|
+
merge(this, data);
|
|
11
|
+
this.type = type;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,64 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
5
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
6
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
7
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
2
|
// @ts-ignore
|
|
9
3
|
// tslint:disable-next-line:no-submodule-imports
|
|
10
4
|
import { lodashUtil } from '@antv/l7-utils';
|
|
11
5
|
import DOM from "../../utils/dom";
|
|
12
6
|
import { Event } from "./event";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
const {
|
|
8
|
+
merge
|
|
9
|
+
} = lodashUtil;
|
|
10
|
+
export default class MapMouseEvent extends Event {
|
|
17
11
|
/**
|
|
18
|
-
* `true` if `preventDefault` has been called.
|
|
19
12
|
* @private
|
|
20
13
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* The geographic location on the map of the mouse cursor.
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @private
|
|
40
|
-
*/
|
|
41
|
-
function MapMouseEvent(type, map, originalEvent) {
|
|
42
|
-
var _this;
|
|
43
|
-
var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
44
|
-
_classCallCheck(this, MapMouseEvent);
|
|
45
|
-
var point = DOM.mousePos(map.getCanvasContainer(), originalEvent);
|
|
46
|
-
var lngLat = map.unproject(point);
|
|
47
|
-
_this = _super.call(this, type, merge({
|
|
48
|
-
point: point,
|
|
49
|
-
lngLat: lngLat,
|
|
50
|
-
originalEvent: originalEvent
|
|
14
|
+
constructor(type, map, originalEvent, data = {}) {
|
|
15
|
+
const point = DOM.mousePos(map.getCanvasContainer(), originalEvent);
|
|
16
|
+
const lngLat = map.unproject(point);
|
|
17
|
+
super(type, merge({
|
|
18
|
+
point,
|
|
19
|
+
lngLat,
|
|
20
|
+
originalEvent
|
|
51
21
|
}, data));
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
22
|
+
/**
|
|
23
|
+
* `true` if `preventDefault` has been called.
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* The `Map` object that fired the event.
|
|
28
|
+
*/
|
|
29
|
+
_defineProperty(this, "target", void 0);
|
|
30
|
+
/**
|
|
31
|
+
* The DOM event which caused the map event.
|
|
32
|
+
*/
|
|
33
|
+
_defineProperty(this, "originalEvent", void 0);
|
|
34
|
+
/**
|
|
35
|
+
* The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner.
|
|
36
|
+
*/
|
|
37
|
+
_defineProperty(this, "point", void 0);
|
|
38
|
+
/**
|
|
39
|
+
* The geographic location on the map of the mouse cursor.
|
|
40
|
+
*/
|
|
41
|
+
_defineProperty(this, "lngLat", void 0);
|
|
42
|
+
_defineProperty(this, "defaultPrevented", void 0);
|
|
43
|
+
this.defaultPrevented = false;
|
|
44
|
+
this.target = map;
|
|
45
|
+
}
|
|
46
|
+
preventDefault() {
|
|
47
|
+
this.defaultPrevented = true;
|
|
55
48
|
}
|
|
56
|
-
|
|
57
|
-
key: "preventDefault",
|
|
58
|
-
value: function preventDefault() {
|
|
59
|
-
this.defaultPrevented = true;
|
|
60
|
-
}
|
|
61
|
-
}]);
|
|
62
|
-
return MapMouseEvent;
|
|
63
|
-
}(Event);
|
|
64
|
-
export { MapMouseEvent as default };
|
|
49
|
+
}
|