@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,333 @@
|
|
|
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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _lng_lat = _interopRequireDefault(require("../geo/lng_lat"));
|
|
12
|
+
var _util = require("../util");
|
|
13
|
+
var _dom = _interopRequireDefault(require("../utils/dom"));
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
|
|
16
|
+
// deltaY value for mouse scroll wheel identification
|
|
17
|
+
var wheelZoomDelta = 4.000244140625;
|
|
18
|
+
|
|
19
|
+
// These magic numbers control the rate of zoom. Trackpad events fire at a greater
|
|
20
|
+
// frequency than mouse scroll wheel, so reduce the zoom rate per wheel tick
|
|
21
|
+
var defaultZoomRate = 1 / 100;
|
|
22
|
+
var wheelZoomRate = 1 / 450;
|
|
23
|
+
|
|
24
|
+
// upper bound on how much we scale the map in any single render frame; this
|
|
25
|
+
// is used to limit zoom rate in the case of very fast scrolling
|
|
26
|
+
var maxScalePerFrame = 2;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The `ScrollZoomHandler` allows the user to zoom the map by scrolling.
|
|
30
|
+
*/
|
|
31
|
+
var ScrollZoomHandler = /*#__PURE__*/function () {
|
|
32
|
+
// used for delayed-handling of a single wheel movement
|
|
33
|
+
// used to delay final '{move,zoom}end' events
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
function ScrollZoomHandler(map, handler) {
|
|
39
|
+
var _this = this;
|
|
40
|
+
(0, _classCallCheck2.default)(this, ScrollZoomHandler);
|
|
41
|
+
(0, _defineProperty2.default)(this, "onScrollFrame", function () {
|
|
42
|
+
if (!_this.frameId) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
_this.frameId = null;
|
|
46
|
+
if (!_this.isActive()) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
var tr = _this.map.transform;
|
|
50
|
+
|
|
51
|
+
// if we've had scroll events since the last render frame, consume the
|
|
52
|
+
// accumulated delta, and update the target zoom level accordingly
|
|
53
|
+
if (_this.delta !== 0) {
|
|
54
|
+
// For trackpad events and single mouse wheel ticks, use the default zoom rate
|
|
55
|
+
var zoomRate = _this.type === 'wheel' && Math.abs(_this.delta) > wheelZoomDelta ? _this.wheelZoomRate : _this.defaultZoomRate;
|
|
56
|
+
// Scale by sigmoid of scroll wheel delta.
|
|
57
|
+
var scale = maxScalePerFrame / (1 + Math.exp(-Math.abs(_this.delta * zoomRate)));
|
|
58
|
+
if (_this.delta < 0 && scale !== 0) {
|
|
59
|
+
scale = 1 / scale;
|
|
60
|
+
}
|
|
61
|
+
var fromScale = typeof _this.targetZoom === 'number' ? tr.zoomScale(_this.targetZoom) : tr.scale;
|
|
62
|
+
_this.targetZoom = Math.min(tr.maxZoom, Math.max(tr.minZoom, tr.scaleZoom(fromScale * scale)));
|
|
63
|
+
|
|
64
|
+
// if this is a mouse wheel, refresh the starting zoom and easing
|
|
65
|
+
// function we're using to smooth out the zooming between wheel
|
|
66
|
+
// events
|
|
67
|
+
if (_this.type === 'wheel') {
|
|
68
|
+
_this.startZoom = tr.zoom;
|
|
69
|
+
_this.easing = _this.smoothOutEasing(200);
|
|
70
|
+
}
|
|
71
|
+
_this.delta = 0;
|
|
72
|
+
}
|
|
73
|
+
var targetZoom = typeof _this.targetZoom === 'number' ? _this.targetZoom : tr.zoom;
|
|
74
|
+
var startZoom = _this.startZoom;
|
|
75
|
+
var easing = _this.easing;
|
|
76
|
+
var finished = false;
|
|
77
|
+
var zoom;
|
|
78
|
+
if (_this.type === 'wheel' && startZoom && easing) {
|
|
79
|
+
var t = Math.min(((0, _util.now)() - _this.lastWheelEventTime) / 200, 1);
|
|
80
|
+
var k = easing(t);
|
|
81
|
+
zoom = (0, _util.interpolate)(startZoom, targetZoom, k);
|
|
82
|
+
if (t < 1) {
|
|
83
|
+
if (!_this.frameId) {
|
|
84
|
+
_this.frameId = true;
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
finished = true;
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
zoom = targetZoom;
|
|
91
|
+
finished = true;
|
|
92
|
+
}
|
|
93
|
+
_this.active = true;
|
|
94
|
+
if (finished) {
|
|
95
|
+
_this.active = false;
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
_this.finishTimeout = setTimeout(function () {
|
|
98
|
+
_this.zooming = false;
|
|
99
|
+
_this.handler.triggerRenderFrame();
|
|
100
|
+
// @ts-ignore
|
|
101
|
+
delete _this.targetZoom;
|
|
102
|
+
// @ts-ignore
|
|
103
|
+
delete _this.finishTimeout;
|
|
104
|
+
}, 200);
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
noInertia: true,
|
|
108
|
+
needsRenderFrame: !finished,
|
|
109
|
+
zoomDelta: zoom - tr.zoom,
|
|
110
|
+
around: _this.aroundPoint,
|
|
111
|
+
originalEvent: _this.lastWheelEvent
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
this.map = map;
|
|
115
|
+
this.el = map.getCanvasContainer();
|
|
116
|
+
this.handler = handler;
|
|
117
|
+
this.delta = 0;
|
|
118
|
+
this.defaultZoomRate = defaultZoomRate;
|
|
119
|
+
this.wheelZoomRate = wheelZoomRate;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Set the zoom rate of a trackpad
|
|
124
|
+
* @param {number} [zoomRate=1/100] The rate used to scale trackpad movement to a zoom value.
|
|
125
|
+
* @example
|
|
126
|
+
* // Speed up trackpad zoom
|
|
127
|
+
* map.scrollZoom.setZoomRate(1/25);
|
|
128
|
+
*/
|
|
129
|
+
(0, _createClass2.default)(ScrollZoomHandler, [{
|
|
130
|
+
key: "setZoomRate",
|
|
131
|
+
value: function setZoomRate(zoomRate) {
|
|
132
|
+
this.defaultZoomRate = zoomRate;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Set the zoom rate of a mouse wheel
|
|
137
|
+
* @param {number} [wheelZoomRate=1/450] The rate used to scale mouse wheel movement to a zoom value.
|
|
138
|
+
* @example
|
|
139
|
+
* // Slow down zoom of mouse wheel
|
|
140
|
+
* map.scrollZoom.setWheelZoomRate(1/600);
|
|
141
|
+
*/
|
|
142
|
+
}, {
|
|
143
|
+
key: "setWheelZoomRate",
|
|
144
|
+
value: function setWheelZoomRate(zoomRate) {
|
|
145
|
+
this.wheelZoomRate = zoomRate;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Returns a Boolean indicating whether the "scroll to zoom" interaction is enabled.
|
|
150
|
+
*
|
|
151
|
+
* @returns {boolean} `true` if the "scroll to zoom" interaction is enabled.
|
|
152
|
+
*/
|
|
153
|
+
}, {
|
|
154
|
+
key: "isEnabled",
|
|
155
|
+
value: function isEnabled() {
|
|
156
|
+
return !!this.enabled;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/*
|
|
160
|
+
* Active state is turned on and off with every scroll wheel event and is set back to false before the map
|
|
161
|
+
* render is called, so _active is not a good candidate for determining if a scroll zoom animation is in
|
|
162
|
+
* progress.
|
|
163
|
+
*/
|
|
164
|
+
}, {
|
|
165
|
+
key: "isActive",
|
|
166
|
+
value: function isActive() {
|
|
167
|
+
return !!this.active || this.finishTimeout !== undefined;
|
|
168
|
+
}
|
|
169
|
+
}, {
|
|
170
|
+
key: "isZooming",
|
|
171
|
+
value: function isZooming() {
|
|
172
|
+
return !!this.zooming;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Enables the "scroll to zoom" interaction.
|
|
177
|
+
*
|
|
178
|
+
* @param {Object} [options] Options object.
|
|
179
|
+
* @param {string} [options.around] If "center" is passed, map will zoom around center of map
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* map.scrollZoom.enable();
|
|
183
|
+
* @example
|
|
184
|
+
* map.scrollZoom.enable({ around: 'center' })
|
|
185
|
+
*/
|
|
186
|
+
}, {
|
|
187
|
+
key: "enable",
|
|
188
|
+
value: function enable(options) {
|
|
189
|
+
if (this.isEnabled()) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
this.enabled = true;
|
|
193
|
+
this.aroundCenter = options && options.around === 'center';
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Disables the "scroll to zoom" interaction.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* map.scrollZoom.disable();
|
|
201
|
+
*/
|
|
202
|
+
}, {
|
|
203
|
+
key: "disable",
|
|
204
|
+
value: function disable() {
|
|
205
|
+
if (!this.isEnabled()) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
this.enabled = false;
|
|
209
|
+
}
|
|
210
|
+
}, {
|
|
211
|
+
key: "wheel",
|
|
212
|
+
value: function wheel(e) {
|
|
213
|
+
if (!this.isEnabled()) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
// Remove `any` cast when https://github.com/facebook/flow/issues/4879 is fixed.
|
|
217
|
+
var value = e.deltaMode === window.WheelEvent.DOM_DELTA_LINE ? e.deltaY * 40 : e.deltaY;
|
|
218
|
+
var nowTime = (0, _util.now)();
|
|
219
|
+
var timeDelta = nowTime - (this.lastWheelEventTime || 0);
|
|
220
|
+
this.lastWheelEventTime = nowTime;
|
|
221
|
+
if (value !== 0 && value % wheelZoomDelta === 0) {
|
|
222
|
+
// This one is definitely a mouse wheel event.
|
|
223
|
+
this.type = 'wheel';
|
|
224
|
+
} else if (value !== 0 && Math.abs(value) < 4) {
|
|
225
|
+
// This one is definitely a trackpad event because it is so small.
|
|
226
|
+
this.type = 'trackpad';
|
|
227
|
+
} else if (timeDelta > 400) {
|
|
228
|
+
// This is likely a new scroll action.
|
|
229
|
+
this.type = null;
|
|
230
|
+
this.lastValue = value;
|
|
231
|
+
|
|
232
|
+
// Start a timeout in case this was a singular event, and dely it by up to 40ms.
|
|
233
|
+
// @ts-ignore
|
|
234
|
+
this.timeout = setTimeout(this.onTimeout, 40, e);
|
|
235
|
+
} else if (!this.type) {
|
|
236
|
+
// This is a repeating event, but we don't know the type of event just yet.
|
|
237
|
+
// If the delta per time is small, we assume it's a fast trackpad; otherwise we switch into wheel mode.
|
|
238
|
+
this.type = Math.abs(timeDelta * value) < 200 ? 'trackpad' : 'wheel';
|
|
239
|
+
|
|
240
|
+
// Make sure our delayed event isn't fired again, because we accumulate
|
|
241
|
+
// the previous event (which was less than 40ms ago) into this event.
|
|
242
|
+
if (this.timeout) {
|
|
243
|
+
clearTimeout(this.timeout);
|
|
244
|
+
this.timeout = null;
|
|
245
|
+
value += this.lastValue;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Slow down zoom if shift key is held for more precise zooming
|
|
250
|
+
if (e.shiftKey && value) {
|
|
251
|
+
value = value / 4;
|
|
252
|
+
}
|
|
253
|
+
// Only fire the callback if we actually know what type of scrolling device the user uses.
|
|
254
|
+
if (this.type) {
|
|
255
|
+
this.lastWheelEvent = e;
|
|
256
|
+
this.delta -= value;
|
|
257
|
+
if (!this.active) {
|
|
258
|
+
this.start(e);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
e.preventDefault();
|
|
262
|
+
}
|
|
263
|
+
}, {
|
|
264
|
+
key: "renderFrame",
|
|
265
|
+
value: function renderFrame() {
|
|
266
|
+
return this.onScrollFrame();
|
|
267
|
+
}
|
|
268
|
+
}, {
|
|
269
|
+
key: "reset",
|
|
270
|
+
value: function reset() {
|
|
271
|
+
this.active = false;
|
|
272
|
+
}
|
|
273
|
+
}, {
|
|
274
|
+
key: "onTimeout",
|
|
275
|
+
value: function onTimeout(initialEvent) {
|
|
276
|
+
this.type = 'wheel';
|
|
277
|
+
this.delta -= this.lastValue;
|
|
278
|
+
if (!this.active && this.start) {
|
|
279
|
+
this.start(initialEvent);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}, {
|
|
283
|
+
key: "start",
|
|
284
|
+
value: function start(e) {
|
|
285
|
+
if (!this.delta) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
if (this.frameId) {
|
|
289
|
+
this.frameId = null;
|
|
290
|
+
}
|
|
291
|
+
this.active = true;
|
|
292
|
+
if (!this.isZooming()) {
|
|
293
|
+
this.zooming = true;
|
|
294
|
+
}
|
|
295
|
+
if (this.finishTimeout) {
|
|
296
|
+
clearTimeout(this.finishTimeout);
|
|
297
|
+
// @ts-ignore
|
|
298
|
+
delete this.finishTimeout;
|
|
299
|
+
}
|
|
300
|
+
var pos = _dom.default.mousePos(this.el, e);
|
|
301
|
+
this.around = _lng_lat.default.convert(this.aroundCenter ? this.map.getCenter() : this.map.unproject(pos));
|
|
302
|
+
this.aroundPoint = this.map.transform.locationPoint(this.around);
|
|
303
|
+
if (!this.frameId) {
|
|
304
|
+
this.frameId = true;
|
|
305
|
+
this.handler.triggerRenderFrame();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}, {
|
|
309
|
+
key: "smoothOutEasing",
|
|
310
|
+
value: function smoothOutEasing(duration) {
|
|
311
|
+
var easing = _util.ease;
|
|
312
|
+
if (this.prevEase) {
|
|
313
|
+
var preEase = this.prevEase;
|
|
314
|
+
var t = ((0, _util.now)() - preEase.start) / preEase.duration;
|
|
315
|
+
var speed = preEase.easing(t + 0.01) - preEase.easing(t);
|
|
316
|
+
|
|
317
|
+
// Quick hack to make new bezier that is continuous with last
|
|
318
|
+
var x = 0.27 / Math.sqrt(speed * speed + 0.0001) * 0.01;
|
|
319
|
+
var y = Math.sqrt(0.27 * 0.27 - x * x);
|
|
320
|
+
easing = (0, _util.bezier)(x, y, 0.25, 1);
|
|
321
|
+
}
|
|
322
|
+
this.prevEase = {
|
|
323
|
+
start: (0, _util.now)(),
|
|
324
|
+
duration: duration,
|
|
325
|
+
easing: easing
|
|
326
|
+
};
|
|
327
|
+
return easing;
|
|
328
|
+
}
|
|
329
|
+
}]);
|
|
330
|
+
return ScrollZoomHandler;
|
|
331
|
+
}();
|
|
332
|
+
var _default = ScrollZoomHandler;
|
|
333
|
+
exports.default = _default;
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* The `DoubleClickZoomHandler` allows the user to zoom the map at a point by
|
|
12
|
+
* double clicking or double tapping.
|
|
13
|
+
*/
|
|
14
|
+
var DoubleClickZoomHandler = /*#__PURE__*/function () {
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
function DoubleClickZoomHandler(clickZoom, TapZoom) {
|
|
19
|
+
(0, _classCallCheck2.default)(this, DoubleClickZoomHandler);
|
|
20
|
+
this.clickZoom = clickZoom;
|
|
21
|
+
this.tapZoom = TapZoom;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Enables the "double click to zoom" interaction.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* map.doubleClickZoom.enable();
|
|
29
|
+
*/
|
|
30
|
+
(0, _createClass2.default)(DoubleClickZoomHandler, [{
|
|
31
|
+
key: "enable",
|
|
32
|
+
value: function enable() {
|
|
33
|
+
this.clickZoom.enable();
|
|
34
|
+
this.tapZoom.enable();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Disables the "double click to zoom" interaction.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* map.doubleClickZoom.disable();
|
|
42
|
+
*/
|
|
43
|
+
}, {
|
|
44
|
+
key: "disable",
|
|
45
|
+
value: function disable() {
|
|
46
|
+
this.clickZoom.disable();
|
|
47
|
+
this.tapZoom.disable();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns a Boolean indicating whether the "double click to zoom" interaction is enabled.
|
|
52
|
+
*
|
|
53
|
+
* @returns {boolean} `true` if the "double click to zoom" interaction is enabled.
|
|
54
|
+
*/
|
|
55
|
+
}, {
|
|
56
|
+
key: "isEnabled",
|
|
57
|
+
value: function isEnabled() {
|
|
58
|
+
return this.clickZoom.isEnabled() && this.tapZoom.isEnabled();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Returns a Boolean indicating whether the "double click to zoom" interaction is active, i.e. currently being used.
|
|
63
|
+
*
|
|
64
|
+
* @returns {boolean} `true` if the "double click to zoom" interaction is active.
|
|
65
|
+
*/
|
|
66
|
+
}, {
|
|
67
|
+
key: "isActive",
|
|
68
|
+
value: function isActive() {
|
|
69
|
+
return this.clickZoom.isActive() || this.tapZoom.isActive();
|
|
70
|
+
}
|
|
71
|
+
}]);
|
|
72
|
+
return DoubleClickZoomHandler;
|
|
73
|
+
}();
|
|
74
|
+
exports.default = DoubleClickZoomHandler;
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* The `DragPanHandler` allows the user to pan the map by clicking and dragging
|
|
12
|
+
* the cursor.
|
|
13
|
+
*/
|
|
14
|
+
var DragPanHandler = /*#__PURE__*/function () {
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
function DragPanHandler(el, mousePan, touchPan) {
|
|
19
|
+
(0, _classCallCheck2.default)(this, DragPanHandler);
|
|
20
|
+
this.el = el;
|
|
21
|
+
this.mousePan = mousePan;
|
|
22
|
+
this.touchPan = touchPan;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Enables the "drag to pan" interaction.
|
|
27
|
+
*
|
|
28
|
+
* @param {Object} [options] Options object
|
|
29
|
+
* @param {number} [options.linearity=0] factor used to scale the drag velocity
|
|
30
|
+
* @param {Function} [options.easing=bezier(0, 0, 0.3, 1)] easing function applled to `map.panTo` when applying the drag.
|
|
31
|
+
* @param {number} [options.maxSpeed=1400] the maximum value of the drag velocity.
|
|
32
|
+
* @param {number} [options.deceleration=2500] the rate at which the speed reduces after the pan ends.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* map.dragPan.enable();
|
|
36
|
+
* @example
|
|
37
|
+
* map.dragPan.enable({
|
|
38
|
+
* linearity: 0.3,
|
|
39
|
+
* easing: bezier(0, 0, 0.3, 1),
|
|
40
|
+
* maxSpeed: 1400,
|
|
41
|
+
* deceleration: 2500,
|
|
42
|
+
* });
|
|
43
|
+
*/
|
|
44
|
+
(0, _createClass2.default)(DragPanHandler, [{
|
|
45
|
+
key: "enable",
|
|
46
|
+
value: function enable(options) {
|
|
47
|
+
this.inertiaOptions = options || {};
|
|
48
|
+
this.mousePan.enable();
|
|
49
|
+
this.touchPan.enable();
|
|
50
|
+
this.el.classList.add('l7-touch-drag-pan');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Disables the "drag to pan" interaction.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* map.dragPan.disable();
|
|
58
|
+
*/
|
|
59
|
+
}, {
|
|
60
|
+
key: "disable",
|
|
61
|
+
value: function disable() {
|
|
62
|
+
this.mousePan.disable();
|
|
63
|
+
this.touchPan.disable();
|
|
64
|
+
this.el.classList.remove('l7-touch-drag-pan');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Returns a Boolean indicating whether the "drag to pan" interaction is enabled.
|
|
69
|
+
*
|
|
70
|
+
* @returns {boolean} `true` if the "drag to pan" interaction is enabled.
|
|
71
|
+
*/
|
|
72
|
+
}, {
|
|
73
|
+
key: "isEnabled",
|
|
74
|
+
value: function isEnabled() {
|
|
75
|
+
return this.mousePan.isEnabled() && this.touchPan.isEnabled();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Returns a Boolean indicating whether the "drag to pan" interaction is active, i.e. currently being used.
|
|
80
|
+
*
|
|
81
|
+
* @returns {boolean} `true` if the "drag to pan" interaction is active.
|
|
82
|
+
*/
|
|
83
|
+
}, {
|
|
84
|
+
key: "isActive",
|
|
85
|
+
value: function isActive() {
|
|
86
|
+
return this.mousePan.isActive() || this.touchPan.isActive();
|
|
87
|
+
}
|
|
88
|
+
}]);
|
|
89
|
+
return DragPanHandler;
|
|
90
|
+
}();
|
|
91
|
+
exports.default = DragPanHandler;
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* The `DragRotateHandler` allows the user to rotate the map by clicking and
|
|
12
|
+
* dragging the cursor while holding the right mouse button or `ctrl` key.
|
|
13
|
+
*/
|
|
14
|
+
var DragRotateHandler = /*#__PURE__*/function () {
|
|
15
|
+
/**
|
|
16
|
+
* @param {Object} [options]
|
|
17
|
+
* @param {number} [options.bearingSnap] The threshold, measured in degrees, that determines when the map's
|
|
18
|
+
* bearing will snap to north.
|
|
19
|
+
* @param {bool} [options.pitchWithRotate=true] Control the map pitch in addition to the bearing
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
function DragRotateHandler(options, mouseRotate, mousePitch) {
|
|
23
|
+
(0, _classCallCheck2.default)(this, DragRotateHandler);
|
|
24
|
+
this.pitchWithRotate = options.pitchWithRotate;
|
|
25
|
+
this.mouseRotate = mouseRotate;
|
|
26
|
+
this.mousePitch = mousePitch;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Enables the "drag to rotate" interaction.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* map.dragRotate.enable();
|
|
34
|
+
*/
|
|
35
|
+
(0, _createClass2.default)(DragRotateHandler, [{
|
|
36
|
+
key: "enable",
|
|
37
|
+
value: function enable() {
|
|
38
|
+
this.mouseRotate.enable();
|
|
39
|
+
if (this.pitchWithRotate) {
|
|
40
|
+
this.mousePitch.enable();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Disables the "drag to rotate" interaction.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* map.dragRotate.disable();
|
|
49
|
+
*/
|
|
50
|
+
}, {
|
|
51
|
+
key: "disable",
|
|
52
|
+
value: function disable() {
|
|
53
|
+
this.mouseRotate.disable();
|
|
54
|
+
this.mousePitch.disable();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns a Boolean indicating whether the "drag to rotate" interaction is enabled.
|
|
59
|
+
*
|
|
60
|
+
* @returns {boolean} `true` if the "drag to rotate" interaction is enabled.
|
|
61
|
+
*/
|
|
62
|
+
}, {
|
|
63
|
+
key: "isEnabled",
|
|
64
|
+
value: function isEnabled() {
|
|
65
|
+
return this.mouseRotate.isEnabled() && (!this.pitchWithRotate || this.mousePitch.isEnabled());
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Returns a Boolean indicating whether the "drag to rotate" interaction is active, i.e. currently being used.
|
|
70
|
+
*
|
|
71
|
+
* @returns {boolean} `true` if the "drag to rotate" interaction is active.
|
|
72
|
+
*/
|
|
73
|
+
}, {
|
|
74
|
+
key: "isActive",
|
|
75
|
+
value: function isActive() {
|
|
76
|
+
return this.mouseRotate.isActive() || this.mousePitch.isActive();
|
|
77
|
+
}
|
|
78
|
+
}]);
|
|
79
|
+
return DragRotateHandler;
|
|
80
|
+
}();
|
|
81
|
+
exports.default = DragRotateHandler;
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* The `TouchZoomRotateHandler` allows the user to zoom and rotate the map by
|
|
12
|
+
* pinching on a touchscreen.
|
|
13
|
+
*
|
|
14
|
+
* They can zoom with one finger by double tapping and dragging. On the second tap,
|
|
15
|
+
* hold the finger down and drag up or down to zoom in or out.
|
|
16
|
+
*/
|
|
17
|
+
var TouchZoomRotateHandler = /*#__PURE__*/function () {
|
|
18
|
+
/**
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
function TouchZoomRotateHandler(el, touchZoom, touchRotate, tapDragZoom) {
|
|
22
|
+
(0, _classCallCheck2.default)(this, TouchZoomRotateHandler);
|
|
23
|
+
this.el = el;
|
|
24
|
+
this.touchZoom = touchZoom;
|
|
25
|
+
this.touchRotate = touchRotate;
|
|
26
|
+
this.tapDragZoom = tapDragZoom;
|
|
27
|
+
this.rotationDisabled = false;
|
|
28
|
+
this.enabled = true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Enables the "pinch to rotate and zoom" interaction.
|
|
33
|
+
*
|
|
34
|
+
* @param {Object} [options] Options object.
|
|
35
|
+
* @param {string} [options.around] If "center" is passed, map will zoom around the center
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* map.touchZoomRotate.enable();
|
|
39
|
+
* @example
|
|
40
|
+
* map.touchZoomRotate.enable({ around: 'center' });
|
|
41
|
+
*/
|
|
42
|
+
(0, _createClass2.default)(TouchZoomRotateHandler, [{
|
|
43
|
+
key: "enable",
|
|
44
|
+
value: function enable(options) {
|
|
45
|
+
this.touchZoom.enable(options);
|
|
46
|
+
if (!this.rotationDisabled) {
|
|
47
|
+
this.touchRotate.enable(options);
|
|
48
|
+
}
|
|
49
|
+
this.tapDragZoom.enable();
|
|
50
|
+
this.el.classList.add('l7-touch-zoom-rotate');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Disables the "pinch to rotate and zoom" interaction.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* map.touchZoomRotate.disable();
|
|
58
|
+
*/
|
|
59
|
+
}, {
|
|
60
|
+
key: "disable",
|
|
61
|
+
value: function disable() {
|
|
62
|
+
this.touchZoom.disable();
|
|
63
|
+
this.touchRotate.disable();
|
|
64
|
+
this.tapDragZoom.disable();
|
|
65
|
+
this.el.classList.remove('l7-touch-zoom-rotate');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Returns a Boolean indicating whether the "pinch to rotate and zoom" interaction is enabled.
|
|
70
|
+
*
|
|
71
|
+
* @returns {boolean} `true` if the "pinch to rotate and zoom" interaction is enabled.
|
|
72
|
+
*/
|
|
73
|
+
}, {
|
|
74
|
+
key: "isEnabled",
|
|
75
|
+
value: function isEnabled() {
|
|
76
|
+
return this.touchZoom.isEnabled() && (this.rotationDisabled || this.touchRotate.isEnabled()) && this.tapDragZoom.isEnabled();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Returns true if the handler is enabled and has detected the start of a zoom/rotate gesture.
|
|
81
|
+
*
|
|
82
|
+
* @returns {boolean} //eslint-disable-line
|
|
83
|
+
*/
|
|
84
|
+
}, {
|
|
85
|
+
key: "isActive",
|
|
86
|
+
value: function isActive() {
|
|
87
|
+
return this.touchZoom.isActive() || this.touchRotate.isActive() || this.tapDragZoom.isActive();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Disables the "pinch to rotate" interaction, leaving the "pinch to zoom"
|
|
92
|
+
* interaction enabled.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* map.touchZoomRotate.disableRotation();
|
|
96
|
+
*/
|
|
97
|
+
}, {
|
|
98
|
+
key: "disableRotation",
|
|
99
|
+
value: function disableRotation() {
|
|
100
|
+
this.rotationDisabled = true;
|
|
101
|
+
this.touchRotate.disable();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Enables the "pinch to rotate" interaction.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* map.touchZoomRotate.enable();
|
|
109
|
+
* map.touchZoomRotate.enableRotation();
|
|
110
|
+
*/
|
|
111
|
+
}, {
|
|
112
|
+
key: "enableRotation",
|
|
113
|
+
value: function enableRotation() {
|
|
114
|
+
this.rotationDisabled = false;
|
|
115
|
+
if (this.touchZoom.isEnabled()) {
|
|
116
|
+
this.touchRotate.enable();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}]);
|
|
120
|
+
return TouchZoomRotateHandler;
|
|
121
|
+
}();
|
|
122
|
+
exports.default = TouchZoomRotateHandler;
|