@antv/l7-map 2.17.10 → 2.17.12
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 +148 -90
- package/es/earthmap.js +65 -13
- package/es/geo/edge_insets.js +14 -4
- package/es/geo/lng_lat.js +13 -5
- package/es/geo/lng_lat_bounds.js +17 -4
- package/es/geo/mercator.js +10 -2
- package/es/geo/point.js +7 -0
- package/es/geo/simple.js +11 -6
- package/es/geo/transform.js +132 -127
- package/es/handler/blockable_map_event.js +12 -7
- package/es/handler/box_zoom.js +30 -10
- package/es/handler/click_zoom.js +5 -0
- package/es/handler/events/event.js +2 -0
- package/es/handler/events/map_mouse_event.js +12 -0
- package/es/handler/events/map_touch_event.js +12 -2
- package/es/handler/events/map_wheel_event.js +12 -1
- package/es/handler/events/render_event.js +13 -0
- package/es/handler/handler_inertia.js +34 -6
- package/es/handler/handler_manager.js +147 -55
- package/es/handler/handler_util.js +2 -1
- package/es/handler/keyboard.js +20 -1
- package/es/handler/map_event.js +9 -3
- package/es/handler/mouse/mouse_handler.js +24 -11
- package/es/handler/mouse/mousepan_handler.js +11 -1
- package/es/handler/mouse/mousepitch_hander.js +11 -1
- package/es/handler/mouse/mouserotate_hander.js +11 -1
- package/es/handler/mouse/util.js +3 -2
- package/es/handler/scroll_zoom.js +71 -43
- package/es/handler/shim/dblclick_zoom.js +9 -4
- package/es/handler/shim/drag_pan.js +11 -4
- package/es/handler/shim/drag_rotate.js +10 -4
- package/es/handler/shim/touch_zoom_rotate.js +16 -6
- package/es/handler/tap/single_tap_recognizer.js +31 -8
- package/es/handler/tap/tap_drag_zoom.js +15 -7
- package/es/handler/tap/tap_recognizer.js +11 -3
- package/es/handler/tap/tap_zoom.js +7 -1
- package/es/handler/touch/touch_pan.js +22 -4
- package/es/handler/touch/touch_pitch.js +27 -10
- package/es/handler/touch/touch_rotate.js +19 -8
- package/es/handler/touch/touch_zoom.js +18 -5
- package/es/handler/touch/two_touch.js +32 -19
- package/es/hash.js +31 -9
- package/es/map.js +78 -16
- package/es/util.js +26 -18
- package/es/utils/Aabb.js +31 -10
- package/es/utils/dom.js +58 -24
- package/es/utils/performance.js +7 -8
- package/es/utils/primitives.js +11 -13
- package/es/utils/task_queue.js +23 -6
- package/lib/camera.js +169 -91
- package/lib/earthmap.js +80 -12
- package/lib/geo/edge_insets.js +18 -3
- package/lib/geo/lng_lat.js +18 -5
- package/lib/geo/lng_lat_bounds.js +20 -4
- package/lib/geo/mercator.js +22 -1
- package/lib/geo/point.js +8 -0
- package/lib/geo/simple.js +24 -5
- package/lib/geo/transform.js +164 -127
- package/lib/handler/blockable_map_event.js +14 -6
- package/lib/handler/box_zoom.js +39 -8
- package/lib/handler/click_zoom.js +6 -0
- package/lib/handler/events/event.js +5 -0
- package/lib/handler/events/index.js +4 -0
- package/lib/handler/events/map_mouse_event.js +20 -2
- package/lib/handler/events/map_touch_event.js +21 -2
- package/lib/handler/events/map_wheel_event.js +16 -1
- package/lib/handler/events/render_event.js +19 -0
- package/lib/handler/handler_inertia.js +37 -5
- package/lib/handler/handler_manager.js +171 -56
- package/lib/handler/handler_util.js +3 -1
- package/lib/handler/keyboard.js +22 -1
- package/lib/handler/map_event.js +11 -2
- package/lib/handler/mouse/index.js +4 -0
- package/lib/handler/mouse/mouse_handler.js +27 -10
- package/lib/handler/mouse/mousepan_handler.js +18 -1
- package/lib/handler/mouse/mousepitch_hander.js +17 -1
- package/lib/handler/mouse/mouserotate_hander.js +17 -1
- package/lib/handler/mouse/util.js +6 -2
- package/lib/handler/scroll_zoom.js +77 -43
- package/lib/handler/shim/dblclick_zoom.js +10 -4
- package/lib/handler/shim/drag_pan.js +13 -4
- package/lib/handler/shim/drag_rotate.js +11 -4
- package/lib/handler/shim/touch_zoom_rotate.js +18 -6
- package/lib/handler/tap/single_tap_recognizer.js +33 -8
- package/lib/handler/tap/tap_drag_zoom.js +18 -6
- package/lib/handler/tap/tap_recognizer.js +17 -2
- package/lib/handler/tap/tap_zoom.js +9 -0
- package/lib/handler/touch/index.js +5 -0
- package/lib/handler/touch/touch_pan.js +25 -4
- package/lib/handler/touch/touch_pitch.js +32 -10
- package/lib/handler/touch/touch_rotate.js +25 -8
- package/lib/handler/touch/touch_zoom.js +24 -5
- package/lib/handler/touch/two_touch.js +35 -18
- package/lib/hash.js +35 -8
- package/lib/index.js +8 -0
- package/lib/map.js +95 -15
- package/lib/util.js +38 -16
- package/lib/utils/Aabb.js +34 -10
- package/lib/utils/dom.js +64 -22
- package/lib/utils/performance.js +9 -8
- package/lib/utils/primitives.js +16 -13
- package/lib/utils/task_queue.js +24 -6
- package/package.json +3 -3
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
3
|
// @ts-ignore
|
|
4
|
-
|
|
5
4
|
import { MapMouseEvent } from "./events";
|
|
5
|
+
|
|
6
6
|
var BlockableMapEventHandler = /*#__PURE__*/function () {
|
|
7
7
|
function BlockableMapEventHandler(map) {
|
|
8
8
|
_classCallCheck(this, BlockableMapEventHandler);
|
|
9
|
+
|
|
9
10
|
this.map = map;
|
|
10
11
|
}
|
|
12
|
+
|
|
11
13
|
_createClass(BlockableMapEventHandler, [{
|
|
12
14
|
key: "reset",
|
|
13
15
|
value: function reset() {
|
|
14
|
-
this.delayContextMenu = false;
|
|
15
|
-
|
|
16
|
+
this.delayContextMenu = false; // @ts-ignore
|
|
17
|
+
|
|
16
18
|
delete this.contextMenuEvent;
|
|
17
19
|
}
|
|
18
20
|
}, {
|
|
@@ -30,9 +32,10 @@ var BlockableMapEventHandler = /*#__PURE__*/function () {
|
|
|
30
32
|
key: "mouseup",
|
|
31
33
|
value: function mouseup() {
|
|
32
34
|
this.delayContextMenu = false;
|
|
35
|
+
|
|
33
36
|
if (this.contextMenuEvent) {
|
|
34
|
-
this.map.emit('contextmenu', new MapMouseEvent('contextmenu', this.map, this.contextMenuEvent));
|
|
35
|
-
|
|
37
|
+
this.map.emit('contextmenu', new MapMouseEvent('contextmenu', this.map, this.contextMenuEvent)); // @ts-ignore
|
|
38
|
+
|
|
36
39
|
delete this.contextMenuEvent;
|
|
37
40
|
}
|
|
38
41
|
}
|
|
@@ -45,9 +48,9 @@ var BlockableMapEventHandler = /*#__PURE__*/function () {
|
|
|
45
48
|
} else {
|
|
46
49
|
// Windows: contextmenu fired on mouseup, so fire event now
|
|
47
50
|
this.map.emit(e.type, new MapMouseEvent(e.type, this.map, e));
|
|
48
|
-
}
|
|
51
|
+
} // prevent browser context menu when necessary
|
|
52
|
+
|
|
49
53
|
|
|
50
|
-
// prevent browser context menu when necessary
|
|
51
54
|
if (this.map.listeners('contextmenu')) {
|
|
52
55
|
e.preventDefault();
|
|
53
56
|
}
|
|
@@ -73,6 +76,8 @@ var BlockableMapEventHandler = /*#__PURE__*/function () {
|
|
|
73
76
|
return false;
|
|
74
77
|
}
|
|
75
78
|
}]);
|
|
79
|
+
|
|
76
80
|
return BlockableMapEventHandler;
|
|
77
81
|
}();
|
|
82
|
+
|
|
78
83
|
export { BlockableMapEventHandler as default };
|
package/es/handler/box_zoom.js
CHANGED
|
@@ -1,75 +1,78 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
3
|
// @ts-ignore
|
|
4
|
-
|
|
5
4
|
import DOM from "../utils/dom";
|
|
6
5
|
import { Event } from "./events/event";
|
|
7
|
-
|
|
8
6
|
/**
|
|
9
7
|
* The `BoxZoomHandler` allows the user to zoom the map to fit within a bounding box.
|
|
10
8
|
* The bounding box is defined by clicking and holding `shift` while dragging the cursor.
|
|
11
9
|
*/
|
|
10
|
+
|
|
12
11
|
var BoxZoomHandler = /*#__PURE__*/function () {
|
|
13
12
|
/**
|
|
14
13
|
* @private
|
|
15
14
|
*/
|
|
16
15
|
function BoxZoomHandler(map, options) {
|
|
17
16
|
_classCallCheck(this, BoxZoomHandler);
|
|
17
|
+
|
|
18
18
|
this.map = map;
|
|
19
19
|
this.el = map.getCanvasContainer();
|
|
20
20
|
this.container = map.getContainer();
|
|
21
21
|
this.clickTolerance = options.clickTolerance || 1;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
23
|
/**
|
|
25
24
|
* Returns a Boolean indicating whether the "box zoom" interaction is enabled.
|
|
26
25
|
*
|
|
27
26
|
* @returns {boolean} `true` if the "box zoom" interaction is enabled.
|
|
28
27
|
*/
|
|
28
|
+
|
|
29
|
+
|
|
29
30
|
_createClass(BoxZoomHandler, [{
|
|
30
31
|
key: "isEnabled",
|
|
31
32
|
value: function isEnabled() {
|
|
32
33
|
return !!this.enabled;
|
|
33
34
|
}
|
|
34
|
-
|
|
35
35
|
/**
|
|
36
36
|
* Returns a Boolean indicating whether the "box zoom" interaction is active, i.e. currently being used.
|
|
37
37
|
*
|
|
38
38
|
* @returns {boolean} `true` if the "box zoom" interaction is active.
|
|
39
39
|
*/
|
|
40
|
+
|
|
40
41
|
}, {
|
|
41
42
|
key: "isActive",
|
|
42
43
|
value: function isActive() {
|
|
43
44
|
return !!this.active;
|
|
44
45
|
}
|
|
45
|
-
|
|
46
46
|
/**
|
|
47
47
|
* Enables the "box zoom" interaction.
|
|
48
48
|
*
|
|
49
49
|
* @example
|
|
50
50
|
* map.boxZoom.enable();
|
|
51
51
|
*/
|
|
52
|
+
|
|
52
53
|
}, {
|
|
53
54
|
key: "enable",
|
|
54
55
|
value: function enable() {
|
|
55
56
|
if (this.isEnabled()) {
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
59
|
+
|
|
58
60
|
this.enabled = true;
|
|
59
61
|
}
|
|
60
|
-
|
|
61
62
|
/**
|
|
62
63
|
* Disables the "box zoom" interaction.
|
|
63
64
|
*
|
|
64
65
|
* @example
|
|
65
66
|
* map.boxZoom.disable();
|
|
66
67
|
*/
|
|
68
|
+
|
|
67
69
|
}, {
|
|
68
70
|
key: "disable",
|
|
69
71
|
value: function disable() {
|
|
70
72
|
if (!this.isEnabled()) {
|
|
71
73
|
return;
|
|
72
74
|
}
|
|
75
|
+
|
|
73
76
|
this.enabled = false;
|
|
74
77
|
}
|
|
75
78
|
}, {
|
|
@@ -78,9 +81,11 @@ var BoxZoomHandler = /*#__PURE__*/function () {
|
|
|
78
81
|
if (!this.isEnabled()) {
|
|
79
82
|
return;
|
|
80
83
|
}
|
|
84
|
+
|
|
81
85
|
if (!(e.shiftKey && e.button === 0)) {
|
|
82
86
|
return;
|
|
83
87
|
}
|
|
88
|
+
|
|
84
89
|
DOM.disableDrag();
|
|
85
90
|
this.startPos = this.lastPos = point;
|
|
86
91
|
this.active = true;
|
|
@@ -91,22 +96,28 @@ var BoxZoomHandler = /*#__PURE__*/function () {
|
|
|
91
96
|
if (!this.active) {
|
|
92
97
|
return;
|
|
93
98
|
}
|
|
99
|
+
|
|
94
100
|
var pos = point;
|
|
101
|
+
|
|
95
102
|
if (this.lastPos.equals(pos) || !this.box && pos.dist(this.startPos) < this.clickTolerance) {
|
|
96
103
|
return;
|
|
97
104
|
}
|
|
105
|
+
|
|
98
106
|
var p0 = this.startPos;
|
|
99
107
|
this.lastPos = pos;
|
|
108
|
+
|
|
100
109
|
if (!this.box) {
|
|
101
110
|
this.box = DOM.create('div', 'l7-boxzoom', this.container);
|
|
102
111
|
this.container.classList.add('l7-crosshair');
|
|
103
112
|
this.fireEvent('boxzoomstart', e);
|
|
104
113
|
}
|
|
114
|
+
|
|
105
115
|
var minX = Math.min(p0.x, pos.x);
|
|
106
116
|
var maxX = Math.max(p0.x, pos.x);
|
|
107
117
|
var minY = Math.min(p0.y, pos.y);
|
|
108
118
|
var maxY = Math.max(p0.y, pos.y);
|
|
109
119
|
DOM.setTransform(this.box, "translate(".concat(minX, "px,").concat(minY, "px)"));
|
|
120
|
+
|
|
110
121
|
if (this.box) {
|
|
111
122
|
this.box.style.width = "".concat(maxX - minX, "px");
|
|
112
123
|
this.box.style.height = "".concat(maxY - minY, "px");
|
|
@@ -116,16 +127,20 @@ var BoxZoomHandler = /*#__PURE__*/function () {
|
|
|
116
127
|
key: "mouseupWindow",
|
|
117
128
|
value: function mouseupWindow(e, point) {
|
|
118
129
|
var _this = this;
|
|
130
|
+
|
|
119
131
|
if (!this.active) {
|
|
120
132
|
return;
|
|
121
133
|
}
|
|
134
|
+
|
|
122
135
|
if (e.button !== 0) {
|
|
123
136
|
return;
|
|
124
137
|
}
|
|
138
|
+
|
|
125
139
|
var p0 = this.startPos;
|
|
126
140
|
var p1 = point;
|
|
127
141
|
this.reset();
|
|
128
142
|
DOM.suppressClick();
|
|
143
|
+
|
|
129
144
|
if (p0.x === p1.x && p0.y === p1.y) {
|
|
130
145
|
this.fireEvent('boxzoomcancel', e);
|
|
131
146
|
} else {
|
|
@@ -147,6 +162,7 @@ var BoxZoomHandler = /*#__PURE__*/function () {
|
|
|
147
162
|
if (!this.active) {
|
|
148
163
|
return;
|
|
149
164
|
}
|
|
165
|
+
|
|
150
166
|
if (e.keyCode === 27) {
|
|
151
167
|
this.reset();
|
|
152
168
|
this.fireEvent('boxzoomcancel', e);
|
|
@@ -157,14 +173,16 @@ var BoxZoomHandler = /*#__PURE__*/function () {
|
|
|
157
173
|
value: function reset() {
|
|
158
174
|
this.active = false;
|
|
159
175
|
this.container.classList.remove('l7-crosshair');
|
|
176
|
+
|
|
160
177
|
if (this.box) {
|
|
161
178
|
DOM.remove(this.box);
|
|
162
179
|
this.box = null;
|
|
163
180
|
}
|
|
164
|
-
|
|
165
|
-
// @ts-ignore
|
|
166
|
-
|
|
167
|
-
// @ts-ignore
|
|
181
|
+
|
|
182
|
+
DOM.enableDrag(); // @ts-ignore
|
|
183
|
+
|
|
184
|
+
delete this.startPos; // @ts-ignore
|
|
185
|
+
|
|
168
186
|
delete this.lastPos;
|
|
169
187
|
}
|
|
170
188
|
}, {
|
|
@@ -175,6 +193,8 @@ var BoxZoomHandler = /*#__PURE__*/function () {
|
|
|
175
193
|
}));
|
|
176
194
|
}
|
|
177
195
|
}]);
|
|
196
|
+
|
|
178
197
|
return BoxZoomHandler;
|
|
179
198
|
}();
|
|
199
|
+
|
|
180
200
|
export default BoxZoomHandler;
|
package/es/handler/click_zoom.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
|
|
3
4
|
// @ts-ignore
|
|
4
5
|
var ClickZoomHandler = /*#__PURE__*/function () {
|
|
5
6
|
function ClickZoomHandler() {
|
|
6
7
|
_classCallCheck(this, ClickZoomHandler);
|
|
8
|
+
|
|
7
9
|
this.reset();
|
|
8
10
|
}
|
|
11
|
+
|
|
9
12
|
_createClass(ClickZoomHandler, [{
|
|
10
13
|
key: "reset",
|
|
11
14
|
value: function reset() {
|
|
@@ -49,6 +52,8 @@ var ClickZoomHandler = /*#__PURE__*/function () {
|
|
|
49
52
|
return this.active;
|
|
50
53
|
}
|
|
51
54
|
}]);
|
|
55
|
+
|
|
52
56
|
return ClickZoomHandler;
|
|
53
57
|
}();
|
|
58
|
+
|
|
54
59
|
export { ClickZoomHandler as default };
|
|
@@ -4,7 +4,9 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
|
4
4
|
import merge from 'lodash/merge';
|
|
5
5
|
export var Event = /*#__PURE__*/_createClass(function Event(type) {
|
|
6
6
|
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
7
|
+
|
|
7
8
|
_classCallCheck(this, Event);
|
|
9
|
+
|
|
8
10
|
merge(this, data);
|
|
9
11
|
this.type = type;
|
|
10
12
|
});
|
|
@@ -3,16 +3,22 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
5
5
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
6
|
+
|
|
6
7
|
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); }; }
|
|
8
|
+
|
|
7
9
|
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; } }
|
|
10
|
+
|
|
8
11
|
// @ts-ignore
|
|
9
12
|
// tslint:disable-next-line:no-submodule-imports
|
|
10
13
|
import merge from 'lodash/merge';
|
|
11
14
|
import DOM from "../../utils/dom";
|
|
12
15
|
import { Event } from "./event";
|
|
16
|
+
|
|
13
17
|
var MapMouseEvent = /*#__PURE__*/function (_Event) {
|
|
14
18
|
_inherits(MapMouseEvent, _Event);
|
|
19
|
+
|
|
15
20
|
var _super = _createSuper(MapMouseEvent);
|
|
21
|
+
|
|
16
22
|
/**
|
|
17
23
|
* `true` if `preventDefault` has been called.
|
|
18
24
|
* @private
|
|
@@ -39,8 +45,11 @@ var MapMouseEvent = /*#__PURE__*/function (_Event) {
|
|
|
39
45
|
*/
|
|
40
46
|
function MapMouseEvent(type, map, originalEvent) {
|
|
41
47
|
var _this;
|
|
48
|
+
|
|
42
49
|
var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
50
|
+
|
|
43
51
|
_classCallCheck(this, MapMouseEvent);
|
|
52
|
+
|
|
44
53
|
var point = DOM.mousePos(map.getCanvasContainer(), originalEvent);
|
|
45
54
|
var lngLat = map.unproject(point);
|
|
46
55
|
_this = _super.call(this, type, merge({
|
|
@@ -52,12 +61,15 @@ var MapMouseEvent = /*#__PURE__*/function (_Event) {
|
|
|
52
61
|
_this.target = map;
|
|
53
62
|
return _this;
|
|
54
63
|
}
|
|
64
|
+
|
|
55
65
|
_createClass(MapMouseEvent, [{
|
|
56
66
|
key: "preventDefault",
|
|
57
67
|
value: function preventDefault() {
|
|
58
68
|
this.defaultPrevented = true;
|
|
59
69
|
}
|
|
60
70
|
}]);
|
|
71
|
+
|
|
61
72
|
return MapMouseEvent;
|
|
62
73
|
}(Event);
|
|
74
|
+
|
|
63
75
|
export { MapMouseEvent as default };
|
|
@@ -3,16 +3,21 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
5
5
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
6
|
+
|
|
6
7
|
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); }; }
|
|
8
|
+
|
|
7
9
|
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; } }
|
|
8
|
-
// @ts-ignore
|
|
9
10
|
|
|
11
|
+
// @ts-ignore
|
|
10
12
|
import Point from "../../geo/point";
|
|
11
13
|
import DOM from "../../utils/dom";
|
|
12
14
|
import { Event } from "./event";
|
|
15
|
+
|
|
13
16
|
var MapTouchEvent = /*#__PURE__*/function (_Event) {
|
|
14
17
|
_inherits(MapTouchEvent, _Event);
|
|
18
|
+
|
|
15
19
|
var _super = _createSuper(MapTouchEvent);
|
|
20
|
+
|
|
16
21
|
/**
|
|
17
22
|
* The event type.
|
|
18
23
|
*/
|
|
@@ -54,7 +59,9 @@ var MapTouchEvent = /*#__PURE__*/function (_Event) {
|
|
|
54
59
|
*/
|
|
55
60
|
function MapTouchEvent(type, map, originalEvent) {
|
|
56
61
|
var _this;
|
|
62
|
+
|
|
57
63
|
_classCallCheck(this, MapTouchEvent);
|
|
64
|
+
|
|
58
65
|
var touches = type === 'touchend' ? originalEvent.changedTouches : originalEvent.touches;
|
|
59
66
|
var points = DOM.touchPos(map.getCanvasContainer(), touches);
|
|
60
67
|
var lngLats = points.map(function (t) {
|
|
@@ -74,7 +81,6 @@ var MapTouchEvent = /*#__PURE__*/function (_Event) {
|
|
|
74
81
|
_this.defaultPrevented = false;
|
|
75
82
|
return _this;
|
|
76
83
|
}
|
|
77
|
-
|
|
78
84
|
/**
|
|
79
85
|
* Prevents subsequent default processing of the event by the map.
|
|
80
86
|
*
|
|
@@ -84,12 +90,16 @@ var MapTouchEvent = /*#__PURE__*/function (_Event) {
|
|
|
84
90
|
* * On `touchstart` events, the behavior of {@link TouchZoomRotateHandler}
|
|
85
91
|
*
|
|
86
92
|
*/
|
|
93
|
+
|
|
94
|
+
|
|
87
95
|
_createClass(MapTouchEvent, [{
|
|
88
96
|
key: "preventDefault",
|
|
89
97
|
value: function preventDefault() {
|
|
90
98
|
this.defaultPrevented = true;
|
|
91
99
|
}
|
|
92
100
|
}]);
|
|
101
|
+
|
|
93
102
|
return MapTouchEvent;
|
|
94
103
|
}(Event);
|
|
104
|
+
|
|
95
105
|
export { MapTouchEvent as default };
|
|
@@ -3,12 +3,18 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
5
5
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
6
|
+
|
|
6
7
|
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); }; }
|
|
8
|
+
|
|
7
9
|
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; } }
|
|
10
|
+
|
|
8
11
|
import { Event } from "./event";
|
|
12
|
+
|
|
9
13
|
var MapWheelEvent = /*#__PURE__*/function (_Event) {
|
|
10
14
|
_inherits(MapWheelEvent, _Event);
|
|
15
|
+
|
|
11
16
|
var _super = _createSuper(MapWheelEvent);
|
|
17
|
+
|
|
12
18
|
/**
|
|
13
19
|
* The event type.
|
|
14
20
|
*/
|
|
@@ -26,25 +32,30 @@ var MapWheelEvent = /*#__PURE__*/function (_Event) {
|
|
|
26
32
|
*/
|
|
27
33
|
function MapWheelEvent(type, map, originalEvent) {
|
|
28
34
|
var _this;
|
|
35
|
+
|
|
29
36
|
_classCallCheck(this, MapWheelEvent);
|
|
37
|
+
|
|
30
38
|
_this = _super.call(this, type, {
|
|
31
39
|
originalEvent: originalEvent
|
|
32
40
|
});
|
|
33
41
|
_this.defaultPrevented = false;
|
|
34
42
|
return _this;
|
|
35
43
|
}
|
|
36
|
-
|
|
37
44
|
/**
|
|
38
45
|
* Prevents subsequent default processing of the event by the map.
|
|
39
46
|
*
|
|
40
47
|
* Calling this method will prevent the the behavior of {@link ScrollZoomHandler}.
|
|
41
48
|
*/
|
|
49
|
+
|
|
50
|
+
|
|
42
51
|
_createClass(MapWheelEvent, [{
|
|
43
52
|
key: "preventDefault",
|
|
44
53
|
value: function preventDefault() {
|
|
45
54
|
this.defaultPrevented = true;
|
|
46
55
|
}
|
|
47
56
|
}]);
|
|
57
|
+
|
|
48
58
|
return MapWheelEvent;
|
|
49
59
|
}(Event);
|
|
60
|
+
|
|
50
61
|
export { MapWheelEvent as default };
|
|
@@ -5,22 +5,35 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
|
+
|
|
8
9
|
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); }; }
|
|
10
|
+
|
|
9
11
|
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; } }
|
|
12
|
+
|
|
10
13
|
import { Event } from "./event";
|
|
14
|
+
|
|
11
15
|
var RenderFrameEvent = /*#__PURE__*/function (_Event) {
|
|
12
16
|
_inherits(RenderFrameEvent, _Event);
|
|
17
|
+
|
|
13
18
|
var _super = _createSuper(RenderFrameEvent);
|
|
19
|
+
|
|
14
20
|
function RenderFrameEvent() {
|
|
15
21
|
var _this;
|
|
22
|
+
|
|
16
23
|
_classCallCheck(this, RenderFrameEvent);
|
|
24
|
+
|
|
17
25
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
18
26
|
args[_key] = arguments[_key];
|
|
19
27
|
}
|
|
28
|
+
|
|
20
29
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
30
|
+
|
|
21
31
|
_defineProperty(_assertThisInitialized(_this), "type", 'renderFrame');
|
|
32
|
+
|
|
22
33
|
return _this;
|
|
23
34
|
}
|
|
35
|
+
|
|
24
36
|
return _createClass(RenderFrameEvent);
|
|
25
37
|
}(Event);
|
|
38
|
+
|
|
26
39
|
export { RenderFrameEvent as default };
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
|
|
3
4
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
5
|
+
|
|
4
6
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
-
|
|
7
|
+
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
9
|
+
|
|
6
10
|
// @ts-ignore
|
|
7
|
-
import Point from "../geo/point";
|
|
11
|
+
import Point from "../geo/point"; // tslint:disable-next-line:no-submodule-imports
|
|
8
12
|
|
|
9
|
-
// tslint:disable-next-line:no-submodule-imports
|
|
10
13
|
import merge from 'lodash/merge';
|
|
11
14
|
import { bezier, clamp, now } from "../util";
|
|
12
15
|
var defaultInertiaOptions = {
|
|
@@ -29,12 +32,15 @@ var defaultPitchInertiaOptions = merge({
|
|
|
29
32
|
deceleration: 1000,
|
|
30
33
|
maxSpeed: 90
|
|
31
34
|
}, defaultInertiaOptions);
|
|
35
|
+
|
|
32
36
|
var HandlerInertia = /*#__PURE__*/function () {
|
|
33
37
|
function HandlerInertia(map) {
|
|
34
38
|
_classCallCheck(this, HandlerInertia);
|
|
39
|
+
|
|
35
40
|
this.map = map;
|
|
36
41
|
this.clear();
|
|
37
42
|
}
|
|
43
|
+
|
|
38
44
|
_createClass(HandlerInertia, [{
|
|
39
45
|
key: "clear",
|
|
40
46
|
value: function clear() {
|
|
@@ -64,9 +70,11 @@ var HandlerInertia = /*#__PURE__*/function () {
|
|
|
64
70
|
key: "onMoveEnd",
|
|
65
71
|
value: function onMoveEnd(panInertiaOptions) {
|
|
66
72
|
this.drainInertiaBuffer();
|
|
73
|
+
|
|
67
74
|
if (this.inertiaBuffer.length < 2) {
|
|
68
75
|
return;
|
|
69
76
|
}
|
|
77
|
+
|
|
70
78
|
var deltas = {
|
|
71
79
|
zoom: 0,
|
|
72
80
|
bearing: 0,
|
|
@@ -75,20 +83,25 @@ var HandlerInertia = /*#__PURE__*/function () {
|
|
|
75
83
|
pinchAround: undefined,
|
|
76
84
|
around: undefined
|
|
77
85
|
};
|
|
86
|
+
|
|
78
87
|
var _iterator = _createForOfIteratorHelper(this.inertiaBuffer),
|
|
79
|
-
|
|
88
|
+
_step;
|
|
89
|
+
|
|
80
90
|
try {
|
|
81
91
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
82
92
|
var settings = _step.value.settings;
|
|
83
93
|
deltas.zoom += settings.zoomDelta || 0;
|
|
84
94
|
deltas.bearing += settings.bearingDelta || 0;
|
|
85
95
|
deltas.pitch += settings.pitchDelta || 0;
|
|
96
|
+
|
|
86
97
|
if (settings.panDelta) {
|
|
87
98
|
deltas.pan._add(settings.panDelta);
|
|
88
99
|
}
|
|
100
|
+
|
|
89
101
|
if (settings.around) {
|
|
90
102
|
deltas.around = settings.around;
|
|
91
103
|
}
|
|
104
|
+
|
|
92
105
|
if (settings.pinchAround) {
|
|
93
106
|
deltas.pinchAround = settings.pinchAround;
|
|
94
107
|
}
|
|
@@ -98,54 +111,69 @@ var HandlerInertia = /*#__PURE__*/function () {
|
|
|
98
111
|
} finally {
|
|
99
112
|
_iterator.f();
|
|
100
113
|
}
|
|
114
|
+
|
|
101
115
|
var lastEntry = this.inertiaBuffer[this.inertiaBuffer.length - 1];
|
|
102
116
|
var duration = lastEntry.time - this.inertiaBuffer[0].time;
|
|
103
117
|
var easeOptions = {};
|
|
118
|
+
|
|
104
119
|
if (deltas.pan.mag()) {
|
|
105
120
|
var result = calculateEasing(deltas.pan.mag(), duration, merge({}, defaultPanInertiaOptions, panInertiaOptions || {}));
|
|
106
121
|
easeOptions.offset = deltas.pan.mult(result.amount / deltas.pan.mag());
|
|
107
122
|
easeOptions.center = this.map.transform.center;
|
|
108
123
|
extendDuration(easeOptions, result);
|
|
109
124
|
}
|
|
125
|
+
|
|
110
126
|
if (deltas.zoom) {
|
|
111
127
|
var _result = calculateEasing(deltas.zoom, duration, defaultZoomInertiaOptions);
|
|
128
|
+
|
|
112
129
|
easeOptions.zoom = this.map.transform.zoom + _result.amount;
|
|
113
130
|
extendDuration(easeOptions, _result);
|
|
114
131
|
}
|
|
132
|
+
|
|
115
133
|
if (deltas.bearing) {
|
|
116
134
|
var _result2 = calculateEasing(deltas.bearing, duration, defaultBearingInertiaOptions);
|
|
135
|
+
|
|
117
136
|
easeOptions.bearing = this.map.transform.bearing + clamp(_result2.amount, -179, 179);
|
|
118
137
|
extendDuration(easeOptions, _result2);
|
|
119
138
|
}
|
|
139
|
+
|
|
120
140
|
if (deltas.pitch) {
|
|
121
141
|
var _result3 = calculateEasing(deltas.pitch, duration, defaultPitchInertiaOptions);
|
|
142
|
+
|
|
122
143
|
easeOptions.pitch = this.map.transform.pitch + _result3.amount;
|
|
123
144
|
extendDuration(easeOptions, _result3);
|
|
124
145
|
}
|
|
146
|
+
|
|
125
147
|
if (easeOptions.zoom || easeOptions.bearing) {
|
|
126
148
|
var last = deltas.pinchAround === undefined ? deltas.around : deltas.pinchAround;
|
|
127
149
|
easeOptions.around = last ? this.map.unproject(last) : this.map.getCenter();
|
|
128
150
|
}
|
|
151
|
+
|
|
129
152
|
this.clear();
|
|
130
153
|
return merge(easeOptions, {
|
|
131
154
|
noMoveStart: true
|
|
132
155
|
});
|
|
133
156
|
}
|
|
134
157
|
}]);
|
|
158
|
+
|
|
135
159
|
return HandlerInertia;
|
|
136
160
|
}(); // Unfortunately zoom, bearing, etc can't have different durations and easings so
|
|
137
161
|
// we need to choose one. We use the longest duration and it's corresponding easing.
|
|
162
|
+
|
|
163
|
+
|
|
138
164
|
export { HandlerInertia as default };
|
|
165
|
+
|
|
139
166
|
function extendDuration(easeOptions, result) {
|
|
140
167
|
if (!easeOptions.duration || easeOptions.duration < result.duration) {
|
|
141
168
|
easeOptions.duration = result.duration;
|
|
142
169
|
easeOptions.easing = result.easing;
|
|
143
170
|
}
|
|
144
171
|
}
|
|
172
|
+
|
|
145
173
|
function calculateEasing(amount, inertiaDuration, inertiaOptions) {
|
|
146
174
|
var maxSpeed = inertiaOptions.maxSpeed,
|
|
147
|
-
|
|
148
|
-
|
|
175
|
+
linearity = inertiaOptions.linearity,
|
|
176
|
+
deceleration = inertiaOptions.deceleration;
|
|
149
177
|
var speed = clamp(amount * linearity / (inertiaDuration / 1000), -maxSpeed, maxSpeed);
|
|
150
178
|
var duration = Math.abs(speed) / (deceleration * linearity);
|
|
151
179
|
return {
|