@antv/l7-map 2.9.33 → 2.9.34
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/lib/camera.js +766 -508
- package/lib/earthmap.js +389 -223
- package/lib/geo/edge_insets.js +117 -64
- package/lib/geo/lng_lat.js +86 -65
- package/lib/geo/lng_lat_bounds.js +162 -123
- package/lib/geo/mercator.js +91 -62
- package/lib/geo/point.js +234 -171
- package/lib/geo/simple.js +93 -61
- package/lib/geo/transform.js +982 -472
- package/lib/handler/IHandler.js +4 -16
- package/lib/handler/blockable_map_event.js +84 -63
- package/lib/handler/box_zoom.js +201 -123
- package/lib/handler/click_zoom.js +63 -55
- package/lib/handler/events/event.js +20 -35
- package/lib/handler/events/index.js +28 -35
- package/lib/handler/events/map_mouse_event.js +85 -42
- package/lib/handler/events/map_touch_event.js +116 -45
- package/lib/handler/events/map_wheel_event.js +70 -34
- package/lib/handler/events/render_event.js +50 -31
- package/lib/handler/handler_inertia.js +158 -114
- package/lib/handler/handler_manager.js +640 -381
- package/lib/handler/handler_util.js +11 -29
- package/lib/handler/keyboard.js +155 -114
- package/lib/handler/map_event.js +133 -84
- package/lib/handler/mouse/index.js +28 -35
- package/lib/handler/mouse/mouse_handler.js +126 -90
- package/lib/handler/mouse/mousepan_handler.js +64 -46
- package/lib/handler/mouse/mousepitch_hander.js +64 -44
- package/lib/handler/mouse/mouserotate_hander.js +64 -44
- package/lib/handler/mouse/util.js +22 -40
- package/lib/handler/scroll_zoom.js +318 -176
- package/lib/handler/shim/dblclick_zoom.js +76 -42
- package/lib/handler/shim/drag_pan.js +98 -48
- package/lib/handler/shim/drag_rotate.js +82 -43
- package/lib/handler/shim/touch_zoom_rotate.js +127 -59
- package/lib/handler/tap/single_tap_recognizer.js +113 -84
- package/lib/handler/tap/tap_drag_zoom.js +111 -93
- package/lib/handler/tap/tap_recognizer.js +72 -60
- package/lib/handler/tap/tap_zoom.js +113 -88
- package/lib/handler/touch/index.js +36 -38
- package/lib/handler/touch/touch_pan.js +126 -98
- package/lib/handler/touch/touch_pitch.js +108 -74
- package/lib/handler/touch/touch_rotate.js +93 -59
- package/lib/handler/touch/touch_zoom.js +71 -49
- package/lib/handler/touch/two_touch.js +129 -90
- package/lib/hash.js +149 -100
- package/lib/index.js +43 -20
- package/lib/interface.js +4 -16
- package/lib/map.js +420 -240
- package/lib/util.js +88 -69
- package/lib/utils/Aabb.js +134 -81
- package/lib/utils/dom.js +162 -88
- package/lib/utils/performance.js +46 -54
- package/lib/utils/primitives.js +53 -59
- package/lib/utils/task_queue.js +104 -61
- package/package.json +3 -3
|
@@ -1,149 +1,193 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
21
4
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
__export(handler_inertia_exports, {
|
|
25
|
-
default: () => HandlerInertia
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
26
7
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _point = _interopRequireDefault(require("../geo/point"));
|
|
15
|
+
|
|
16
|
+
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
17
|
+
|
|
18
|
+
var _util = require("../util");
|
|
19
|
+
|
|
20
|
+
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; } } }; }
|
|
21
|
+
|
|
22
|
+
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); }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
31
26
|
var defaultInertiaOptions = {
|
|
32
27
|
linearity: 0.3,
|
|
33
|
-
easing: (0,
|
|
28
|
+
easing: (0, _util.bezier)(0, 0, 0.3, 1)
|
|
34
29
|
};
|
|
35
|
-
var defaultPanInertiaOptions = (0,
|
|
30
|
+
var defaultPanInertiaOptions = (0, _merge.default)({
|
|
36
31
|
deceleration: 2500,
|
|
37
32
|
maxSpeed: 1400
|
|
38
33
|
}, defaultInertiaOptions);
|
|
39
|
-
var defaultZoomInertiaOptions = (0,
|
|
34
|
+
var defaultZoomInertiaOptions = (0, _merge.default)({
|
|
40
35
|
deceleration: 20,
|
|
41
36
|
maxSpeed: 1400
|
|
42
37
|
}, defaultInertiaOptions);
|
|
43
|
-
var defaultBearingInertiaOptions = (0,
|
|
44
|
-
deceleration:
|
|
38
|
+
var defaultBearingInertiaOptions = (0, _merge.default)({
|
|
39
|
+
deceleration: 1000,
|
|
45
40
|
maxSpeed: 360
|
|
46
41
|
}, defaultInertiaOptions);
|
|
47
|
-
var defaultPitchInertiaOptions = (0,
|
|
48
|
-
deceleration:
|
|
42
|
+
var defaultPitchInertiaOptions = (0, _merge.default)({
|
|
43
|
+
deceleration: 1000,
|
|
49
44
|
maxSpeed: 90
|
|
50
45
|
}, defaultInertiaOptions);
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
|
|
47
|
+
var HandlerInertia = /*#__PURE__*/function () {
|
|
48
|
+
function HandlerInertia(map) {
|
|
49
|
+
(0, _classCallCheck2.default)(this, HandlerInertia);
|
|
53
50
|
this.map = map;
|
|
54
51
|
this.clear();
|
|
55
52
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.inertiaBuffer.push({ time: (0, import_util.now)(), settings });
|
|
62
|
-
}
|
|
63
|
-
drainInertiaBuffer() {
|
|
64
|
-
const inertia = this.inertiaBuffer;
|
|
65
|
-
const nowTime = (0, import_util.now)();
|
|
66
|
-
const cutoff = 160;
|
|
67
|
-
while (inertia.length > 0 && nowTime - inertia[0].time > cutoff) {
|
|
68
|
-
inertia.shift();
|
|
53
|
+
|
|
54
|
+
(0, _createClass2.default)(HandlerInertia, [{
|
|
55
|
+
key: "clear",
|
|
56
|
+
value: function clear() {
|
|
57
|
+
this.inertiaBuffer = [];
|
|
69
58
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
59
|
+
}, {
|
|
60
|
+
key: "record",
|
|
61
|
+
value: function record(settings) {
|
|
62
|
+
this.drainInertiaBuffer();
|
|
63
|
+
this.inertiaBuffer.push({
|
|
64
|
+
time: (0, _util.now)(),
|
|
65
|
+
settings: settings
|
|
66
|
+
});
|
|
75
67
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
deltas.zoom += settings.zoomDelta || 0;
|
|
86
|
-
deltas.bearing += settings.bearingDelta || 0;
|
|
87
|
-
deltas.pitch += settings.pitchDelta || 0;
|
|
88
|
-
if (settings.panDelta) {
|
|
89
|
-
deltas.pan._add(settings.panDelta);
|
|
68
|
+
}, {
|
|
69
|
+
key: "drainInertiaBuffer",
|
|
70
|
+
value: function drainInertiaBuffer() {
|
|
71
|
+
var inertia = this.inertiaBuffer;
|
|
72
|
+
var nowTime = (0, _util.now)();
|
|
73
|
+
var cutoff = 160; // msec
|
|
74
|
+
|
|
75
|
+
while (inertia.length > 0 && nowTime - inertia[0].time > cutoff) {
|
|
76
|
+
inertia.shift();
|
|
90
77
|
}
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "onMoveEnd",
|
|
81
|
+
value: function onMoveEnd(panInertiaOptions) {
|
|
82
|
+
this.drainInertiaBuffer();
|
|
83
|
+
|
|
84
|
+
if (this.inertiaBuffer.length < 2) {
|
|
85
|
+
return;
|
|
93
86
|
}
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
|
|
88
|
+
var deltas = {
|
|
89
|
+
zoom: 0,
|
|
90
|
+
bearing: 0,
|
|
91
|
+
pitch: 0,
|
|
92
|
+
pan: new _point.default(0, 0),
|
|
93
|
+
pinchAround: undefined,
|
|
94
|
+
around: undefined
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
var _iterator = _createForOfIteratorHelper(this.inertiaBuffer),
|
|
98
|
+
_step;
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
102
|
+
var settings = _step.value.settings;
|
|
103
|
+
deltas.zoom += settings.zoomDelta || 0;
|
|
104
|
+
deltas.bearing += settings.bearingDelta || 0;
|
|
105
|
+
deltas.pitch += settings.pitchDelta || 0;
|
|
106
|
+
|
|
107
|
+
if (settings.panDelta) {
|
|
108
|
+
deltas.pan._add(settings.panDelta);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (settings.around) {
|
|
112
|
+
deltas.around = settings.around;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (settings.pinchAround) {
|
|
116
|
+
deltas.pinchAround = settings.pinchAround;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} catch (err) {
|
|
120
|
+
_iterator.e(err);
|
|
121
|
+
} finally {
|
|
122
|
+
_iterator.f();
|
|
96
123
|
}
|
|
124
|
+
|
|
125
|
+
var lastEntry = this.inertiaBuffer[this.inertiaBuffer.length - 1];
|
|
126
|
+
var duration = lastEntry.time - this.inertiaBuffer[0].time;
|
|
127
|
+
var easeOptions = {};
|
|
128
|
+
|
|
129
|
+
if (deltas.pan.mag()) {
|
|
130
|
+
var result = calculateEasing(deltas.pan.mag(), duration, (0, _merge.default)({}, defaultPanInertiaOptions, panInertiaOptions || {}));
|
|
131
|
+
easeOptions.offset = deltas.pan.mult(result.amount / deltas.pan.mag());
|
|
132
|
+
easeOptions.center = this.map.transform.center;
|
|
133
|
+
extendDuration(easeOptions, result);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (deltas.zoom) {
|
|
137
|
+
var _result = calculateEasing(deltas.zoom, duration, defaultZoomInertiaOptions);
|
|
138
|
+
|
|
139
|
+
easeOptions.zoom = this.map.transform.zoom + _result.amount;
|
|
140
|
+
extendDuration(easeOptions, _result);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (deltas.bearing) {
|
|
144
|
+
var _result2 = calculateEasing(deltas.bearing, duration, defaultBearingInertiaOptions);
|
|
145
|
+
|
|
146
|
+
easeOptions.bearing = this.map.transform.bearing + (0, _util.clamp)(_result2.amount, -179, 179);
|
|
147
|
+
extendDuration(easeOptions, _result2);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (deltas.pitch) {
|
|
151
|
+
var _result3 = calculateEasing(deltas.pitch, duration, defaultPitchInertiaOptions);
|
|
152
|
+
|
|
153
|
+
easeOptions.pitch = this.map.transform.pitch + _result3.amount;
|
|
154
|
+
extendDuration(easeOptions, _result3);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (easeOptions.zoom || easeOptions.bearing) {
|
|
158
|
+
var last = deltas.pinchAround === undefined ? deltas.around : deltas.pinchAround;
|
|
159
|
+
easeOptions.around = last ? this.map.unproject(last) : this.map.getCenter();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
this.clear();
|
|
163
|
+
return (0, _merge.default)(easeOptions, {
|
|
164
|
+
noMoveStart: true
|
|
165
|
+
});
|
|
97
166
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
if (deltas.zoom) {
|
|
108
|
-
const result = calculateEasing(deltas.zoom, duration, defaultZoomInertiaOptions);
|
|
109
|
-
easeOptions.zoom = this.map.transform.zoom + result.amount;
|
|
110
|
-
extendDuration(easeOptions, result);
|
|
111
|
-
}
|
|
112
|
-
if (deltas.bearing) {
|
|
113
|
-
const result = calculateEasing(deltas.bearing, duration, defaultBearingInertiaOptions);
|
|
114
|
-
easeOptions.bearing = this.map.transform.bearing + (0, import_util.clamp)(result.amount, -179, 179);
|
|
115
|
-
extendDuration(easeOptions, result);
|
|
116
|
-
}
|
|
117
|
-
if (deltas.pitch) {
|
|
118
|
-
const result = calculateEasing(deltas.pitch, duration, defaultPitchInertiaOptions);
|
|
119
|
-
easeOptions.pitch = this.map.transform.pitch + result.amount;
|
|
120
|
-
extendDuration(easeOptions, result);
|
|
121
|
-
}
|
|
122
|
-
if (easeOptions.zoom || easeOptions.bearing) {
|
|
123
|
-
const last = deltas.pinchAround === void 0 ? deltas.around : deltas.pinchAround;
|
|
124
|
-
easeOptions.around = last ? this.map.unproject(last) : this.map.getCenter();
|
|
125
|
-
}
|
|
126
|
-
this.clear();
|
|
127
|
-
return (0, import_merge.default)(easeOptions, {
|
|
128
|
-
noMoveStart: true
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
};
|
|
167
|
+
}]);
|
|
168
|
+
return HandlerInertia;
|
|
169
|
+
}(); // Unfortunately zoom, bearing, etc can't have different durations and easings so
|
|
170
|
+
// we need to choose one. We use the longest duration and it's corresponding easing.
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
exports.default = HandlerInertia;
|
|
174
|
+
|
|
132
175
|
function extendDuration(easeOptions, result) {
|
|
133
176
|
if (!easeOptions.duration || easeOptions.duration < result.duration) {
|
|
134
177
|
easeOptions.duration = result.duration;
|
|
135
178
|
easeOptions.easing = result.easing;
|
|
136
179
|
}
|
|
137
180
|
}
|
|
181
|
+
|
|
138
182
|
function calculateEasing(amount, inertiaDuration, inertiaOptions) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
183
|
+
var maxSpeed = inertiaOptions.maxSpeed,
|
|
184
|
+
linearity = inertiaOptions.linearity,
|
|
185
|
+
deceleration = inertiaOptions.deceleration;
|
|
186
|
+
var speed = (0, _util.clamp)(amount * linearity / (inertiaDuration / 1000), -maxSpeed, maxSpeed);
|
|
187
|
+
var duration = Math.abs(speed) / (deceleration * linearity);
|
|
142
188
|
return {
|
|
143
189
|
easing: inertiaOptions.easing,
|
|
144
|
-
duration: duration *
|
|
190
|
+
duration: duration * 1000,
|
|
145
191
|
amount: speed * (duration / 2)
|
|
146
192
|
};
|
|
147
|
-
}
|
|
148
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
149
|
-
0 && (module.exports = {});
|
|
193
|
+
}
|