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