@antv/l7-map 2.18.2 → 2.18.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.d.ts +85 -0
- package/es/camera.js +718 -0
- package/es/css/l7.css +98 -0
- package/es/earthmap.d.ts +66 -0
- package/es/earthmap.js +369 -0
- package/es/geo/edge_insets.d.ts +54 -0
- package/es/geo/edge_insets.js +108 -0
- package/es/geo/lng_lat.d.ts +18 -0
- package/es/geo/lng_lat.js +73 -0
- package/es/geo/lng_lat_bounds.d.ts +24 -0
- package/es/geo/lng_lat_bounds.js +154 -0
- package/es/geo/mercator.d.ts +29 -0
- package/es/geo/mercator.js +84 -0
- package/es/geo/point.d.ts +40 -0
- package/es/geo/point.js +224 -0
- package/es/geo/simple.d.ts +29 -0
- package/es/geo/simple.js +87 -0
- package/es/geo/transform.d.ts +198 -0
- package/es/geo/transform.js +961 -0
- package/es/handler/IHandler.d.ts +34 -0
- package/es/handler/IHandler.js +1 -0
- package/es/handler/blockable_map_event.d.ts +17 -0
- package/es/handler/blockable_map_event.js +78 -0
- package/es/handler/box_zoom.d.ts +59 -0
- package/es/handler/box_zoom.js +180 -0
- package/es/handler/click_zoom.d.ts +16 -0
- package/es/handler/click_zoom.js +54 -0
- package/es/handler/events/event.d.ts +4 -0
- package/es/handler/events/event.js +11 -0
- package/es/handler/events/index.d.ts +4 -0
- package/es/handler/events/index.js +4 -0
- package/es/handler/events/map_mouse_event.d.ts +34 -0
- package/es/handler/events/map_mouse_event.js +64 -0
- package/es/handler/events/map_touch_event.d.ts +57 -0
- package/es/handler/events/map_touch_event.js +95 -0
- package/es/handler/events/map_wheel_event.d.ts +33 -0
- package/es/handler/events/map_wheel_event.js +50 -0
- package/es/handler/events/render_event.d.ts +5 -0
- package/es/handler/events/render_event.js +26 -0
- package/es/handler/handler_inertia.d.ts +23 -0
- package/es/handler/handler_inertia.js +157 -0
- package/es/handler/handler_manager.d.ts +61 -0
- package/es/handler/handler_manager.js +577 -0
- package/es/handler/handler_util.d.ts +4 -0
- package/es/handler/handler_util.js +9 -0
- package/es/handler/keyboard.d.ts +36 -0
- package/es/handler/keyboard.js +143 -0
- package/es/handler/map_event.d.ts +29 -0
- package/es/handler/map_event.js +125 -0
- package/es/handler/mouse/index.d.ts +4 -0
- package/es/handler/mouse/index.js +4 -0
- package/es/handler/mouse/mouse_handler.d.ts +22 -0
- package/es/handler/mouse/mouse_handler.js +118 -0
- package/es/handler/mouse/mousepan_handler.d.ts +10 -0
- package/es/handler/mouse/mousepan_handler.js +44 -0
- package/es/handler/mouse/mousepitch_hander.d.ts +9 -0
- package/es/handler/mouse/mousepitch_hander.js +46 -0
- package/es/handler/mouse/mouserotate_hander.d.ts +9 -0
- package/es/handler/mouse/mouserotate_hander.js +46 -0
- package/es/handler/mouse/util.d.ts +6 -0
- package/es/handler/mouse/util.js +11 -0
- package/es/handler/scroll_zoom.d.ts +93 -0
- package/es/handler/scroll_zoom.js +325 -0
- package/es/handler/shim/dblclick_zoom.d.ts +40 -0
- package/es/handler/shim/dblclick_zoom.js +67 -0
- package/es/handler/shim/drag_pan.d.ts +61 -0
- package/es/handler/shim/drag_pan.js +84 -0
- package/es/handler/shim/drag_rotate.d.ts +46 -0
- package/es/handler/shim/drag_rotate.js +74 -0
- package/es/handler/shim/touch_zoom_rotate.d.ts +70 -0
- package/es/handler/shim/touch_zoom_rotate.js +115 -0
- package/es/handler/tap/single_tap_recognizer.d.ts +20 -0
- package/es/handler/tap/single_tap_recognizer.js +97 -0
- package/es/handler/tap/tap_drag_zoom.d.ts +22 -0
- package/es/handler/tap/tap_drag_zoom.js +106 -0
- package/es/handler/tap/tap_recognizer.d.ts +17 -0
- package/es/handler/tap/tap_recognizer.js +54 -0
- package/es/handler/tap/tap_zoom.d.ts +22 -0
- package/es/handler/tap/tap_zoom.js +109 -0
- package/es/handler/touch/index.d.ts +5 -0
- package/es/handler/touch/index.js +5 -0
- package/es/handler/touch/touch_pan.d.ts +30 -0
- package/es/handler/touch/touch_pan.js +110 -0
- package/es/handler/touch/touch_pitch.d.ts +13 -0
- package/es/handler/touch/touch_pitch.js +93 -0
- package/es/handler/touch/touch_rotate.d.ts +12 -0
- package/es/handler/touch/touch_rotate.js +77 -0
- package/es/handler/touch/touch_zoom.d.ts +12 -0
- package/es/handler/touch/touch_zoom.js +54 -0
- package/es/handler/touch/two_touch.d.ts +23 -0
- package/es/handler/touch/two_touch.js +125 -0
- package/es/hash.d.ts +14 -0
- package/es/hash.js +134 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +4 -0
- package/es/interface.d.ts +34 -0
- package/es/interface.js +1 -0
- package/es/map.d.ts +70 -0
- package/es/map.js +387 -0
- package/es/util.d.ts +25 -0
- package/es/util.js +88 -0
- package/es/utils/Aabb.d.ts +12 -0
- package/es/utils/Aabb.js +112 -0
- package/es/utils/dom.d.ts +4 -0
- package/es/utils/dom.js +140 -0
- package/es/utils/performance.d.ts +17 -0
- package/es/utils/performance.js +62 -0
- package/es/utils/primitives.d.ts +6 -0
- package/es/utils/primitives.js +47 -0
- package/es/utils/task_queue.d.ts +13 -0
- package/es/utils/task_queue.js +89 -0
- package/lib/camera.js +724 -0
- package/lib/css/l7.css +98 -0
- package/lib/earthmap.js +376 -0
- package/lib/geo/edge_insets.js +114 -0
- package/lib/geo/lng_lat.js +81 -0
- package/lib/geo/lng_lat_bounds.js +161 -0
- package/lib/geo/mercator.js +100 -0
- package/lib/geo/point.js +231 -0
- package/lib/geo/simple.js +104 -0
- package/lib/geo/transform.js +971 -0
- package/lib/handler/IHandler.js +5 -0
- package/lib/handler/blockable_map_event.js +84 -0
- package/lib/handler/box_zoom.js +186 -0
- package/lib/handler/click_zoom.js +61 -0
- package/lib/handler/events/event.js +20 -0
- package/lib/handler/events/index.js +27 -0
- package/lib/handler/events/map_mouse_event.js +70 -0
- package/lib/handler/events/map_touch_event.js +100 -0
- package/lib/handler/events/map_wheel_event.js +57 -0
- package/lib/handler/events/render_event.js +33 -0
- package/lib/handler/handler_inertia.js +162 -0
- package/lib/handler/handler_manager.js +584 -0
- package/lib/handler/handler_util.js +15 -0
- package/lib/handler/keyboard.js +151 -0
- package/lib/handler/map_event.js +131 -0
- package/lib/handler/mouse/index.js +27 -0
- package/lib/handler/mouse/mouse_handler.js +124 -0
- package/lib/handler/mouse/mousepan_handler.js +49 -0
- package/lib/handler/mouse/mousepitch_hander.js +51 -0
- package/lib/handler/mouse/mouserotate_hander.js +51 -0
- package/lib/handler/mouse/util.js +22 -0
- package/lib/handler/scroll_zoom.js +333 -0
- package/lib/handler/shim/dblclick_zoom.js +74 -0
- package/lib/handler/shim/drag_pan.js +91 -0
- package/lib/handler/shim/drag_rotate.js +81 -0
- package/lib/handler/shim/touch_zoom_rotate.js +122 -0
- package/lib/handler/tap/single_tap_recognizer.js +106 -0
- package/lib/handler/tap/tap_drag_zoom.js +112 -0
- package/lib/handler/tap/tap_recognizer.js +63 -0
- package/lib/handler/tap/tap_zoom.js +115 -0
- package/lib/handler/touch/index.js +34 -0
- package/lib/handler/touch/touch_pan.js +117 -0
- package/lib/handler/touch/touch_pitch.js +98 -0
- package/lib/handler/touch/touch_rotate.js +82 -0
- package/lib/handler/touch/touch_zoom.js +59 -0
- package/lib/handler/touch/two_touch.js +131 -0
- package/lib/hash.js +143 -0
- package/lib/index.js +49 -0
- package/lib/interface.js +5 -0
- package/lib/map.js +394 -0
- package/lib/util.js +108 -0
- package/lib/utils/Aabb.js +119 -0
- package/lib/utils/dom.js +147 -0
- package/lib/utils/performance.js +70 -0
- package/lib/utils/primitives.js +54 -0
- package/lib/utils/task_queue.js +97 -0
- package/package.json +3 -3
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _point = _interopRequireDefault(require("../geo/point"));
|
|
11
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
12
|
+
var _util = require("../util");
|
|
13
|
+
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; } } }; }
|
|
14
|
+
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); }
|
|
15
|
+
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; } // @ts-ignore
|
|
16
|
+
// tslint:disable-next-line:no-submodule-imports
|
|
17
|
+
var merge = _l7Utils.lodashUtil.merge;
|
|
18
|
+
var defaultInertiaOptions = {
|
|
19
|
+
linearity: 0.3,
|
|
20
|
+
easing: (0, _util.bezier)(0, 0, 0.3, 1)
|
|
21
|
+
};
|
|
22
|
+
var defaultPanInertiaOptions = merge({
|
|
23
|
+
deceleration: 2500,
|
|
24
|
+
maxSpeed: 1400
|
|
25
|
+
}, defaultInertiaOptions);
|
|
26
|
+
var defaultZoomInertiaOptions = merge({
|
|
27
|
+
deceleration: 20,
|
|
28
|
+
maxSpeed: 1400
|
|
29
|
+
}, defaultInertiaOptions);
|
|
30
|
+
var defaultBearingInertiaOptions = merge({
|
|
31
|
+
deceleration: 1000,
|
|
32
|
+
maxSpeed: 360
|
|
33
|
+
}, defaultInertiaOptions);
|
|
34
|
+
var defaultPitchInertiaOptions = merge({
|
|
35
|
+
deceleration: 1000,
|
|
36
|
+
maxSpeed: 90
|
|
37
|
+
}, defaultInertiaOptions);
|
|
38
|
+
var HandlerInertia = /*#__PURE__*/function () {
|
|
39
|
+
function HandlerInertia(map) {
|
|
40
|
+
(0, _classCallCheck2.default)(this, HandlerInertia);
|
|
41
|
+
this.map = map;
|
|
42
|
+
this.clear();
|
|
43
|
+
}
|
|
44
|
+
(0, _createClass2.default)(HandlerInertia, [{
|
|
45
|
+
key: "clear",
|
|
46
|
+
value: function clear() {
|
|
47
|
+
this.inertiaBuffer = [];
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
key: "record",
|
|
51
|
+
value: function record(settings) {
|
|
52
|
+
this.drainInertiaBuffer();
|
|
53
|
+
this.inertiaBuffer.push({
|
|
54
|
+
time: (0, _util.now)(),
|
|
55
|
+
settings: settings
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "drainInertiaBuffer",
|
|
60
|
+
value: function drainInertiaBuffer() {
|
|
61
|
+
var inertia = this.inertiaBuffer;
|
|
62
|
+
var nowTime = (0, _util.now)();
|
|
63
|
+
var cutoff = 160; // msec
|
|
64
|
+
|
|
65
|
+
while (inertia.length > 0 && nowTime - inertia[0].time > cutoff) {
|
|
66
|
+
inertia.shift();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "onMoveEnd",
|
|
71
|
+
value: function onMoveEnd(panInertiaOptions) {
|
|
72
|
+
this.drainInertiaBuffer();
|
|
73
|
+
if (this.inertiaBuffer.length < 2) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
var deltas = {
|
|
77
|
+
zoom: 0,
|
|
78
|
+
bearing: 0,
|
|
79
|
+
pitch: 0,
|
|
80
|
+
pan: new _point.default(0, 0),
|
|
81
|
+
pinchAround: undefined,
|
|
82
|
+
around: undefined
|
|
83
|
+
};
|
|
84
|
+
var _iterator = _createForOfIteratorHelper(this.inertiaBuffer),
|
|
85
|
+
_step;
|
|
86
|
+
try {
|
|
87
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
88
|
+
var settings = _step.value.settings;
|
|
89
|
+
deltas.zoom += settings.zoomDelta || 0;
|
|
90
|
+
deltas.bearing += settings.bearingDelta || 0;
|
|
91
|
+
deltas.pitch += settings.pitchDelta || 0;
|
|
92
|
+
if (settings.panDelta) {
|
|
93
|
+
deltas.pan._add(settings.panDelta);
|
|
94
|
+
}
|
|
95
|
+
if (settings.around) {
|
|
96
|
+
deltas.around = settings.around;
|
|
97
|
+
}
|
|
98
|
+
if (settings.pinchAround) {
|
|
99
|
+
deltas.pinchAround = settings.pinchAround;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
} catch (err) {
|
|
103
|
+
_iterator.e(err);
|
|
104
|
+
} finally {
|
|
105
|
+
_iterator.f();
|
|
106
|
+
}
|
|
107
|
+
var lastEntry = this.inertiaBuffer[this.inertiaBuffer.length - 1];
|
|
108
|
+
var duration = lastEntry.time - this.inertiaBuffer[0].time;
|
|
109
|
+
var easeOptions = {};
|
|
110
|
+
if (deltas.pan.mag()) {
|
|
111
|
+
var result = calculateEasing(deltas.pan.mag(), duration, merge({}, defaultPanInertiaOptions, panInertiaOptions || {}));
|
|
112
|
+
easeOptions.offset = deltas.pan.mult(result.amount / deltas.pan.mag());
|
|
113
|
+
easeOptions.center = this.map.transform.center;
|
|
114
|
+
extendDuration(easeOptions, result);
|
|
115
|
+
}
|
|
116
|
+
if (deltas.zoom) {
|
|
117
|
+
var _result = calculateEasing(deltas.zoom, duration, defaultZoomInertiaOptions);
|
|
118
|
+
easeOptions.zoom = this.map.transform.zoom + _result.amount;
|
|
119
|
+
extendDuration(easeOptions, _result);
|
|
120
|
+
}
|
|
121
|
+
if (deltas.bearing) {
|
|
122
|
+
var _result2 = calculateEasing(deltas.bearing, duration, defaultBearingInertiaOptions);
|
|
123
|
+
easeOptions.bearing = this.map.transform.bearing + (0, _util.clamp)(_result2.amount, -179, 179);
|
|
124
|
+
extendDuration(easeOptions, _result2);
|
|
125
|
+
}
|
|
126
|
+
if (deltas.pitch) {
|
|
127
|
+
var _result3 = calculateEasing(deltas.pitch, duration, defaultPitchInertiaOptions);
|
|
128
|
+
easeOptions.pitch = this.map.transform.pitch + _result3.amount;
|
|
129
|
+
extendDuration(easeOptions, _result3);
|
|
130
|
+
}
|
|
131
|
+
if (easeOptions.zoom || easeOptions.bearing) {
|
|
132
|
+
var last = deltas.pinchAround === undefined ? deltas.around : deltas.pinchAround;
|
|
133
|
+
easeOptions.around = last ? this.map.unproject(last) : this.map.getCenter();
|
|
134
|
+
}
|
|
135
|
+
this.clear();
|
|
136
|
+
return merge(easeOptions, {
|
|
137
|
+
noMoveStart: true
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}]);
|
|
141
|
+
return HandlerInertia;
|
|
142
|
+
}(); // Unfortunately zoom, bearing, etc can't have different durations and easings so
|
|
143
|
+
// we need to choose one. We use the longest duration and it's corresponding easing.
|
|
144
|
+
exports.default = HandlerInertia;
|
|
145
|
+
function extendDuration(easeOptions, result) {
|
|
146
|
+
if (!easeOptions.duration || easeOptions.duration < result.duration) {
|
|
147
|
+
easeOptions.duration = result.duration;
|
|
148
|
+
easeOptions.easing = result.easing;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function calculateEasing(amount, inertiaDuration, inertiaOptions) {
|
|
152
|
+
var maxSpeed = inertiaOptions.maxSpeed,
|
|
153
|
+
linearity = inertiaOptions.linearity,
|
|
154
|
+
deceleration = inertiaOptions.deceleration;
|
|
155
|
+
var speed = (0, _util.clamp)(amount * linearity / (inertiaDuration / 1000), -maxSpeed, maxSpeed);
|
|
156
|
+
var duration = Math.abs(speed) / (deceleration * linearity);
|
|
157
|
+
return {
|
|
158
|
+
easing: inertiaOptions.easing,
|
|
159
|
+
duration: duration * 1000,
|
|
160
|
+
amount: speed * (duration / 2)
|
|
161
|
+
};
|
|
162
|
+
}
|