@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
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { EarthMap } from '../earthmap';
|
|
2
|
+
import type Point from '../geo/point';
|
|
3
|
+
import type { Map } from '../map';
|
|
4
|
+
export interface IHandlerResult {
|
|
5
|
+
panDelta?: Point;
|
|
6
|
+
zoomDelta?: number;
|
|
7
|
+
bearingDelta?: number;
|
|
8
|
+
pitchDelta?: number;
|
|
9
|
+
around?: Point | null;
|
|
10
|
+
pinchAround?: Point | null;
|
|
11
|
+
cameraAnimation?: (map: Map | EarthMap) => any;
|
|
12
|
+
originalEvent?: any;
|
|
13
|
+
needsRenderFrame?: boolean;
|
|
14
|
+
noInertia?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface IHandler {
|
|
17
|
+
touchstart?: (e: TouchEvent, points: Point[], mapTouches: Touch[]) => IHandlerResult | void;
|
|
18
|
+
touchmove?: (e: TouchEvent, points: Point[], mapTouches: Touch[]) => IHandlerResult | void;
|
|
19
|
+
touchend?: (e: TouchEvent, points: Point[], mapTouches: Touch[]) => IHandlerResult | void;
|
|
20
|
+
touchcancel?: (e: TouchEvent, points: Point[], mapTouches: Touch[]) => IHandlerResult | void;
|
|
21
|
+
mousedown?: (e: MouseEvent, point: Point) => IHandlerResult | void;
|
|
22
|
+
mousemove?: (e: MouseEvent, point: Point) => IHandlerResult | void;
|
|
23
|
+
mouseup?: (e: MouseEvent, point: Point) => IHandlerResult | void;
|
|
24
|
+
dblclick?: (e: MouseEvent, point: Point) => IHandlerResult | void;
|
|
25
|
+
wheel?: (e: WheelEvent, point: Point) => IHandlerResult | void;
|
|
26
|
+
keydown?: (e: KeyboardEvent) => IHandlerResult | void;
|
|
27
|
+
keyup?: (e: KeyboardEvent) => IHandlerResult | void;
|
|
28
|
+
renderFrame?: () => IHandlerResult | void;
|
|
29
|
+
enable(options?: any): void;
|
|
30
|
+
disable(): void;
|
|
31
|
+
isEnabled(): boolean;
|
|
32
|
+
isActive(): boolean;
|
|
33
|
+
reset(): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { EarthMap } from '../earthmap';
|
|
2
|
+
import type { Map } from '../map';
|
|
3
|
+
export default class BlockableMapEventHandler {
|
|
4
|
+
private map;
|
|
5
|
+
private delayContextMenu;
|
|
6
|
+
private contextMenuEvent;
|
|
7
|
+
constructor(map: Map | EarthMap);
|
|
8
|
+
reset(): void;
|
|
9
|
+
mousemove(e: MouseEvent): void;
|
|
10
|
+
mousedown(): void;
|
|
11
|
+
mouseup(): void;
|
|
12
|
+
contextmenu(e: MouseEvent): void;
|
|
13
|
+
isEnabled(): boolean;
|
|
14
|
+
isActive(): boolean;
|
|
15
|
+
enable(): boolean;
|
|
16
|
+
disable(): boolean;
|
|
17
|
+
}
|
|
@@ -5,79 +5,62 @@ 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 BlockableMapEventHandler {
|
|
13
|
+
constructor(map) {
|
|
14
|
+
(0, _defineProperty2.default)(this, "map", void 0);
|
|
15
|
+
(0, _defineProperty2.default)(this, "delayContextMenu", void 0);
|
|
16
|
+
(0, _defineProperty2.default)(this, "contextMenuEvent", void 0);
|
|
15
17
|
this.map = map;
|
|
16
18
|
}
|
|
17
|
-
(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
reset() {
|
|
20
|
+
this.delayContextMenu = false;
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
delete this.contextMenuEvent;
|
|
23
|
+
}
|
|
24
|
+
mousemove(e) {
|
|
25
|
+
// mousemove map events should not be fired when interaction handlers (pan, rotate, etc) are active
|
|
26
|
+
this.map.emit(e.type, new _events.MapMouseEvent(e.type, this.map, e));
|
|
27
|
+
}
|
|
28
|
+
mousedown() {
|
|
29
|
+
this.delayContextMenu = true;
|
|
30
|
+
}
|
|
31
|
+
mouseup() {
|
|
32
|
+
this.delayContextMenu = false;
|
|
33
|
+
if (this.contextMenuEvent) {
|
|
34
|
+
this.map.emit('contextmenu', new _events.MapMouseEvent('contextmenu', this.map, this.contextMenuEvent));
|
|
21
35
|
// @ts-ignore
|
|
22
36
|
delete this.contextMenuEvent;
|
|
23
37
|
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//
|
|
38
|
+
}
|
|
39
|
+
contextmenu(e) {
|
|
40
|
+
if (this.delayContextMenu) {
|
|
41
|
+
// Mac: contextmenu fired on mousedown; we save it until mouseup for consistency's sake
|
|
42
|
+
this.contextMenuEvent = e;
|
|
43
|
+
} else {
|
|
44
|
+
// Windows: contextmenu fired on mouseup, so fire event now
|
|
28
45
|
this.map.emit(e.type, new _events.MapMouseEvent(e.type, this.map, e));
|
|
29
46
|
}
|
|
30
|
-
}, {
|
|
31
|
-
key: "mousedown",
|
|
32
|
-
value: function mousedown() {
|
|
33
|
-
this.delayContextMenu = true;
|
|
34
|
-
}
|
|
35
|
-
}, {
|
|
36
|
-
key: "mouseup",
|
|
37
|
-
value: function mouseup() {
|
|
38
|
-
this.delayContextMenu = false;
|
|
39
|
-
if (this.contextMenuEvent) {
|
|
40
|
-
this.map.emit('contextmenu', new _events.MapMouseEvent('contextmenu', this.map, this.contextMenuEvent));
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
delete this.contextMenuEvent;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}, {
|
|
46
|
-
key: "contextmenu",
|
|
47
|
-
value: function contextmenu(e) {
|
|
48
|
-
if (this.delayContextMenu) {
|
|
49
|
-
// Mac: contextmenu fired on mousedown; we save it until mouseup for consistency's sake
|
|
50
|
-
this.contextMenuEvent = e;
|
|
51
|
-
} else {
|
|
52
|
-
// Windows: contextmenu fired on mouseup, so fire event now
|
|
53
|
-
this.map.emit(e.type, new _events.MapMouseEvent(e.type, this.map, e));
|
|
54
|
-
}
|
|
55
47
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}, {
|
|
62
|
-
key: "isEnabled",
|
|
63
|
-
value: function isEnabled() {
|
|
64
|
-
return true;
|
|
48
|
+
// prevent browser context menu when necessary
|
|
49
|
+
if (this.map.listeners('contextmenu')) {
|
|
50
|
+
e.preventDefault();
|
|
65
51
|
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}]);
|
|
82
|
-
return BlockableMapEventHandler;
|
|
83
|
-
}();
|
|
52
|
+
}
|
|
53
|
+
isEnabled() {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
isActive() {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
enable() {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
disable() {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.default = BlockableMapEventHandler;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { EarthMap } from '../earthmap';
|
|
2
|
+
import type Point from '../geo/point';
|
|
3
|
+
import type { Map } from '../map';
|
|
4
|
+
/**
|
|
5
|
+
* The `BoxZoomHandler` allows the user to zoom the map to fit within a bounding box.
|
|
6
|
+
* The bounding box is defined by clicking and holding `shift` while dragging the cursor.
|
|
7
|
+
*/
|
|
8
|
+
declare class BoxZoomHandler {
|
|
9
|
+
private map;
|
|
10
|
+
private el;
|
|
11
|
+
private container;
|
|
12
|
+
private enabled;
|
|
13
|
+
private active;
|
|
14
|
+
private startPos;
|
|
15
|
+
private lastPos;
|
|
16
|
+
private box;
|
|
17
|
+
private clickTolerance;
|
|
18
|
+
/**
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
constructor(map: Map | EarthMap, options: {
|
|
22
|
+
clickTolerance: number;
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Returns a Boolean indicating whether the "box zoom" interaction is enabled.
|
|
26
|
+
*
|
|
27
|
+
* @returns {boolean} `true` if the "box zoom" interaction is enabled.
|
|
28
|
+
*/
|
|
29
|
+
isEnabled(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Returns a Boolean indicating whether the "box zoom" interaction is active, i.e. currently being used.
|
|
32
|
+
*
|
|
33
|
+
* @returns {boolean} `true` if the "box zoom" interaction is active.
|
|
34
|
+
*/
|
|
35
|
+
isActive(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Enables the "box zoom" interaction.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* map.boxZoom.enable();
|
|
41
|
+
*/
|
|
42
|
+
enable(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Disables the "box zoom" interaction.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* map.boxZoom.disable();
|
|
48
|
+
*/
|
|
49
|
+
disable(): void;
|
|
50
|
+
mousedown(e: MouseEvent, point: Point): void;
|
|
51
|
+
mousemoveWindow(e: MouseEvent, point: Point): void;
|
|
52
|
+
mouseupWindow(e: MouseEvent, point: Point): {
|
|
53
|
+
cameraAnimation: (map: Map) => boolean | Map;
|
|
54
|
+
} | undefined;
|
|
55
|
+
keydown(e: KeyboardEvent): void;
|
|
56
|
+
reset(): void;
|
|
57
|
+
fireEvent(type: string, e: any): boolean;
|
|
58
|
+
}
|
|
59
|
+
export default BoxZoomHandler;
|
package/lib/handler/box_zoom.js
CHANGED
|
@@ -5,21 +5,29 @@ 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 _event = require("./events/event");
|
|
12
11
|
// @ts-ignore
|
|
12
|
+
|
|
13
13
|
/**
|
|
14
14
|
* The `BoxZoomHandler` allows the user to zoom the map to fit within a bounding box.
|
|
15
15
|
* The bounding box is defined by clicking and holding `shift` while dragging the cursor.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
class BoxZoomHandler {
|
|
18
18
|
/**
|
|
19
19
|
* @private
|
|
20
20
|
*/
|
|
21
|
-
|
|
22
|
-
(0,
|
|
21
|
+
constructor(map, options) {
|
|
22
|
+
(0, _defineProperty2.default)(this, "map", void 0);
|
|
23
|
+
(0, _defineProperty2.default)(this, "el", void 0);
|
|
24
|
+
(0, _defineProperty2.default)(this, "container", void 0);
|
|
25
|
+
(0, _defineProperty2.default)(this, "enabled", void 0);
|
|
26
|
+
(0, _defineProperty2.default)(this, "active", void 0);
|
|
27
|
+
(0, _defineProperty2.default)(this, "startPos", void 0);
|
|
28
|
+
(0, _defineProperty2.default)(this, "lastPos", void 0);
|
|
29
|
+
(0, _defineProperty2.default)(this, "box", void 0);
|
|
30
|
+
(0, _defineProperty2.default)(this, "clickTolerance", void 0);
|
|
23
31
|
this.map = map;
|
|
24
32
|
this.el = map.getCanvasContainer();
|
|
25
33
|
this.container = map.getContainer();
|
|
@@ -31,155 +39,130 @@ var BoxZoomHandler = /*#__PURE__*/function () {
|
|
|
31
39
|
*
|
|
32
40
|
* @returns {boolean} `true` if the "box zoom" interaction is enabled.
|
|
33
41
|
*/
|
|
34
|
-
(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return !!this.enabled;
|
|
38
|
-
}
|
|
42
|
+
isEnabled() {
|
|
43
|
+
return !!this.enabled;
|
|
44
|
+
}
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return !!this.active;
|
|
49
|
-
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns a Boolean indicating whether the "box zoom" interaction is active, i.e. currently being used.
|
|
48
|
+
*
|
|
49
|
+
* @returns {boolean} `true` if the "box zoom" interaction is active.
|
|
50
|
+
*/
|
|
51
|
+
isActive() {
|
|
52
|
+
return !!this.active;
|
|
53
|
+
}
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (this.isEnabled()) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
this.enabled = true;
|
|
55
|
+
/**
|
|
56
|
+
* Enables the "box zoom" interaction.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* map.boxZoom.enable();
|
|
60
|
+
*/
|
|
61
|
+
enable() {
|
|
62
|
+
if (this.isEnabled()) {
|
|
63
|
+
return;
|
|
64
64
|
}
|
|
65
|
+
this.enabled = true;
|
|
66
|
+
}
|
|
65
67
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (!this.isEnabled()) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
this.enabled = false;
|
|
68
|
+
/**
|
|
69
|
+
* Disables the "box zoom" interaction.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* map.boxZoom.disable();
|
|
73
|
+
*/
|
|
74
|
+
disable() {
|
|
75
|
+
if (!this.isEnabled()) {
|
|
76
|
+
return;
|
|
79
77
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
if (!(e.shiftKey && e.button === 0)) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
_dom.default.disableDrag();
|
|
90
|
-
this.startPos = this.lastPos = point;
|
|
91
|
-
this.active = true;
|
|
78
|
+
this.enabled = false;
|
|
79
|
+
}
|
|
80
|
+
mousedown(e, point) {
|
|
81
|
+
if (!this.isEnabled()) {
|
|
82
|
+
return;
|
|
92
83
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
value: function mousemoveWindow(e, point) {
|
|
96
|
-
if (!this.active) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
var pos = point;
|
|
100
|
-
if (this.lastPos.equals(pos) || !this.box && pos.dist(this.startPos) < this.clickTolerance) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
var p0 = this.startPos;
|
|
104
|
-
this.lastPos = pos;
|
|
105
|
-
if (!this.box) {
|
|
106
|
-
this.box = _dom.default.create('div', 'l7-boxzoom', this.container);
|
|
107
|
-
this.container.classList.add('l7-crosshair');
|
|
108
|
-
this.fireEvent('boxzoomstart', e);
|
|
109
|
-
}
|
|
110
|
-
var minX = Math.min(p0.x, pos.x);
|
|
111
|
-
var maxX = Math.max(p0.x, pos.x);
|
|
112
|
-
var minY = Math.min(p0.y, pos.y);
|
|
113
|
-
var maxY = Math.max(p0.y, pos.y);
|
|
114
|
-
_dom.default.setTransform(this.box, "translate(".concat(minX, "px,").concat(minY, "px)"));
|
|
115
|
-
if (this.box) {
|
|
116
|
-
this.box.style.width = "".concat(maxX - minX, "px");
|
|
117
|
-
this.box.style.height = "".concat(maxY - minY, "px");
|
|
118
|
-
}
|
|
84
|
+
if (!(e.shiftKey && e.button === 0)) {
|
|
85
|
+
return;
|
|
119
86
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
var p1 = point;
|
|
132
|
-
this.reset();
|
|
133
|
-
_dom.default.suppressClick();
|
|
134
|
-
if (p0.x === p1.x && p0.y === p1.y) {
|
|
135
|
-
this.fireEvent('boxzoomcancel', e);
|
|
136
|
-
} else {
|
|
137
|
-
this.map.emit('boxzoomend', new _event.Event('boxzoomend', {
|
|
138
|
-
originalEvent: e
|
|
139
|
-
}));
|
|
140
|
-
return {
|
|
141
|
-
cameraAnimation: function cameraAnimation(map) {
|
|
142
|
-
return map.fitScreenCoordinates(p0, p1, _this.map.getBearing(), {
|
|
143
|
-
linear: true
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
}
|
|
87
|
+
_dom.default.disableDrag();
|
|
88
|
+
this.startPos = this.lastPos = point;
|
|
89
|
+
this.active = true;
|
|
90
|
+
}
|
|
91
|
+
mousemoveWindow(e, point) {
|
|
92
|
+
if (!this.active) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const pos = point;
|
|
96
|
+
if (this.lastPos.equals(pos) || !this.box && pos.dist(this.startPos) < this.clickTolerance) {
|
|
97
|
+
return;
|
|
148
98
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (e.keyCode === 27) {
|
|
156
|
-
this.reset();
|
|
157
|
-
this.fireEvent('boxzoomcancel', e);
|
|
158
|
-
}
|
|
99
|
+
const p0 = this.startPos;
|
|
100
|
+
this.lastPos = pos;
|
|
101
|
+
if (!this.box) {
|
|
102
|
+
this.box = _dom.default.create('div', 'l7-boxzoom', this.container);
|
|
103
|
+
this.container.classList.add('l7-crosshair');
|
|
104
|
+
this.fireEvent('boxzoomstart', e);
|
|
159
105
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
_dom.default.enableDrag();
|
|
170
|
-
// @ts-ignore
|
|
171
|
-
delete this.startPos;
|
|
172
|
-
// @ts-ignore
|
|
173
|
-
delete this.lastPos;
|
|
106
|
+
const minX = Math.min(p0.x, pos.x);
|
|
107
|
+
const maxX = Math.max(p0.x, pos.x);
|
|
108
|
+
const minY = Math.min(p0.y, pos.y);
|
|
109
|
+
const maxY = Math.max(p0.y, pos.y);
|
|
110
|
+
_dom.default.setTransform(this.box, `translate(${minX}px,${minY}px)`);
|
|
111
|
+
if (this.box) {
|
|
112
|
+
this.box.style.width = `${maxX - minX}px`;
|
|
113
|
+
this.box.style.height = `${maxY - minY}px`;
|
|
174
114
|
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return
|
|
115
|
+
}
|
|
116
|
+
mouseupWindow(e, point) {
|
|
117
|
+
if (!this.active) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (e.button !== 0) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const p0 = this.startPos;
|
|
124
|
+
const p1 = point;
|
|
125
|
+
this.reset();
|
|
126
|
+
_dom.default.suppressClick();
|
|
127
|
+
if (p0.x === p1.x && p0.y === p1.y) {
|
|
128
|
+
this.fireEvent('boxzoomcancel', e);
|
|
129
|
+
} else {
|
|
130
|
+
this.map.emit('boxzoomend', new _event.Event('boxzoomend', {
|
|
179
131
|
originalEvent: e
|
|
180
132
|
}));
|
|
133
|
+
return {
|
|
134
|
+
cameraAnimation: map => map.fitScreenCoordinates(p0, p1, this.map.getBearing(), {
|
|
135
|
+
linear: true
|
|
136
|
+
})
|
|
137
|
+
};
|
|
181
138
|
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
139
|
+
}
|
|
140
|
+
keydown(e) {
|
|
141
|
+
if (!this.active) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (e.keyCode === 27) {
|
|
145
|
+
this.reset();
|
|
146
|
+
this.fireEvent('boxzoomcancel', e);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
reset() {
|
|
150
|
+
this.active = false;
|
|
151
|
+
this.container.classList.remove('l7-crosshair');
|
|
152
|
+
if (this.box) {
|
|
153
|
+
_dom.default.remove(this.box);
|
|
154
|
+
this.box = null;
|
|
155
|
+
}
|
|
156
|
+
_dom.default.enableDrag();
|
|
157
|
+
// @ts-ignore
|
|
158
|
+
delete this.startPos;
|
|
159
|
+
// @ts-ignore
|
|
160
|
+
delete this.lastPos;
|
|
161
|
+
}
|
|
162
|
+
fireEvent(type, e) {
|
|
163
|
+
return this.map.emit(type, new _event.Event(type, {
|
|
164
|
+
originalEvent: e
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
185
168
|
var _default = exports.default = BoxZoomHandler;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { EarthMap } from '../earthmap';
|
|
2
|
+
import type Point from '../geo/point';
|
|
3
|
+
import type { Map } from '../map';
|
|
4
|
+
export default class ClickZoomHandler {
|
|
5
|
+
private enabled;
|
|
6
|
+
private active;
|
|
7
|
+
constructor();
|
|
8
|
+
reset(): void;
|
|
9
|
+
dblclick(e: MouseEvent, point: Point): {
|
|
10
|
+
cameraAnimation: (map: Map | EarthMap) => void;
|
|
11
|
+
};
|
|
12
|
+
enable(): void;
|
|
13
|
+
disable(): void;
|
|
14
|
+
isEnabled(): boolean;
|
|
15
|
+
isActive(): boolean;
|
|
16
|
+
}
|
|
@@ -5,56 +5,44 @@ 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
|
// @ts-ignore
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
|
|
11
|
+
class ClickZoomHandler {
|
|
12
|
+
constructor() {
|
|
13
|
+
(0, _defineProperty2.default)(this, "enabled", void 0);
|
|
14
|
+
(0, _defineProperty2.default)(this, "active", void 0);
|
|
15
|
+
this.reset();
|
|
16
|
+
}
|
|
17
|
+
reset() {
|
|
18
|
+
this.active = false;
|
|
19
|
+
}
|
|
20
|
+
dblclick(e, point) {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
return {
|
|
23
|
+
cameraAnimation: map => {
|
|
24
|
+
map.easeTo({
|
|
25
|
+
duration: 300,
|
|
26
|
+
zoom: map.getZoom() + (e.shiftKey ? -1 : 1),
|
|
27
|
+
around: map.unproject(point)
|
|
28
|
+
}, {
|
|
29
|
+
originalEvent: e
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
enable() {
|
|
35
|
+
this.enabled = true;
|
|
36
|
+
}
|
|
37
|
+
disable() {
|
|
38
|
+
this.enabled = false;
|
|
14
39
|
this.reset();
|
|
15
40
|
}
|
|
16
|
-
(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
e.preventDefault();
|
|
25
|
-
return {
|
|
26
|
-
cameraAnimation: function cameraAnimation(map) {
|
|
27
|
-
map.easeTo({
|
|
28
|
-
duration: 300,
|
|
29
|
-
zoom: map.getZoom() + (e.shiftKey ? -1 : 1),
|
|
30
|
-
around: map.unproject(point)
|
|
31
|
-
}, {
|
|
32
|
-
originalEvent: e
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}, {
|
|
38
|
-
key: "enable",
|
|
39
|
-
value: function enable() {
|
|
40
|
-
this.enabled = true;
|
|
41
|
-
}
|
|
42
|
-
}, {
|
|
43
|
-
key: "disable",
|
|
44
|
-
value: function disable() {
|
|
45
|
-
this.enabled = false;
|
|
46
|
-
this.reset();
|
|
47
|
-
}
|
|
48
|
-
}, {
|
|
49
|
-
key: "isEnabled",
|
|
50
|
-
value: function isEnabled() {
|
|
51
|
-
return this.enabled;
|
|
52
|
-
}
|
|
53
|
-
}, {
|
|
54
|
-
key: "isActive",
|
|
55
|
-
value: function isActive() {
|
|
56
|
-
return this.active;
|
|
57
|
-
}
|
|
58
|
-
}]);
|
|
59
|
-
return ClickZoomHandler;
|
|
60
|
-
}();
|
|
41
|
+
isEnabled() {
|
|
42
|
+
return this.enabled;
|
|
43
|
+
}
|
|
44
|
+
isActive() {
|
|
45
|
+
return this.active;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.default = ClickZoomHandler;
|