@antv/l7-map 2.17.12 → 2.18.0
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 +92 -149
- package/es/earthmap.js +15 -68
- 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 +128 -138
- 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 +2 -3
- package/es/handler/events/map_mouse_event.js +2 -13
- 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 +8 -35
- package/es/handler/handler_manager.js +90 -197
- 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 +6 -18
- package/es/handler/shim/drag_rotate.js +4 -10
- package/es/handler/shim/touch_zoom_rotate.js +8 -23
- 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 +13 -35
- package/es/map.js +30 -107
- package/es/util.d.ts +3 -3
- package/es/util.js +20 -33
- package/es/utils/Aabb.js +10 -31
- package/es/utils/dom.js +33 -111
- package/es/utils/performance.js +9 -9
- package/es/utils/primitives.js +13 -11
- package/es/utils/task_queue.js +6 -23
- package/lib/camera.js +102 -179
- package/lib/earthmap.js +14 -83
- 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 +128 -170
- 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 +4 -7
- package/lib/handler/events/index.js +0 -4
- package/lib/handler/events/map_mouse_event.js +5 -22
- package/lib/handler/events/map_touch_event.js +2 -21
- 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 +13 -44
- package/lib/handler/handler_manager.js +92 -222
- 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 +1 -18
- package/lib/handler/mouse/mousepitch_hander.js +1 -17
- package/lib/handler/mouse/mouserotate_hander.js +1 -17
- 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 +6 -20
- package/lib/handler/shim/drag_rotate.js +4 -11
- package/lib/handler/shim/touch_zoom_rotate.js +8 -25
- 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 +10 -32
- package/lib/handler/touch/touch_rotate.js +8 -25
- package/lib/handler/touch/touch_zoom.js +5 -24
- package/lib/handler/touch/two_touch.js +18 -35
- package/lib/hash.js +12 -38
- package/lib/index.js +0 -8
- package/lib/map.js +30 -125
- package/lib/util.js +19 -46
- package/lib/utils/Aabb.js +10 -34
- package/lib/utils/dom.js +32 -118
- package/lib/utils/performance.js +9 -11
- package/lib/utils/primitives.js +13 -16
- package/lib/utils/task_queue.js +6 -24
- package/package.json +4 -4
package/es/map.js
CHANGED
|
@@ -6,59 +6,44 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
-
|
|
10
9
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
-
|
|
12
10
|
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; } }
|
|
13
|
-
|
|
14
|
-
import { $window, DOM, isMini } from '@antv/l7-utils';
|
|
15
|
-
import { merge } from 'lodash';
|
|
11
|
+
import { DOM, lodashUtil } from '@antv/l7-utils';
|
|
16
12
|
import Camera from "./camera";
|
|
17
|
-
|
|
18
13
|
function loadStyles(css, doc) {
|
|
19
14
|
var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
|
|
20
15
|
var isWeChatMiniProgram = typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
|
|
21
|
-
|
|
22
16
|
if (isMiniAli || isWeChatMiniProgram) {
|
|
23
17
|
return;
|
|
24
18
|
}
|
|
25
|
-
|
|
26
19
|
if (!doc) doc = document;
|
|
27
|
-
|
|
28
20
|
if (!doc) {
|
|
29
21
|
return;
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
var head = doc.head || doc.getElementsByTagName('head')[0];
|
|
33
|
-
|
|
34
24
|
if (!head) {
|
|
35
25
|
head = doc.createElement('head');
|
|
36
26
|
var body = doc.body || doc.getElementsByTagName('body')[0];
|
|
37
|
-
|
|
38
27
|
if (body) {
|
|
39
28
|
body.parentNode.insertBefore(head, body);
|
|
40
29
|
} else {
|
|
41
30
|
doc.documentElement.appendChild(head);
|
|
42
31
|
}
|
|
43
32
|
}
|
|
44
|
-
|
|
45
33
|
var style = doc.createElement('style');
|
|
46
34
|
style.type = 'text/css';
|
|
47
|
-
|
|
48
35
|
if (style.styleSheet) {
|
|
49
36
|
style.styleSheet.cssText = css;
|
|
50
37
|
} else {
|
|
51
38
|
style.appendChild(doc.createTextNode(css));
|
|
52
39
|
}
|
|
53
|
-
|
|
54
40
|
head.appendChild(style);
|
|
55
41
|
return style;
|
|
56
42
|
}
|
|
57
|
-
|
|
58
43
|
loadStyles(".l7-map {\n font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;\n overflow: hidden;\n position: relative;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n\n.l7-canvas {\n position: absolute;\n left: 0;\n top: 0;\n}\n\n.l7-map:-webkit-full-screen {\n width: 100%;\n height: 100%;\n}\n\n.l7-canary {\n background-color: salmon;\n}\n\n.l7-canvas-container.l7-interactive,\n.l7-ctrl-group button.l7-ctrl-compass {\n cursor: -webkit-grab;\n cursor: grab;\n -moz-user-select: none;\n -webkit-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n.l7-canvas-container.l7-interactive.l7-track-pointer {\n cursor: pointer;\n}\n\n.l7-canvas-container.l7-interactive:active,\n.l7-ctrl-group button.l7-ctrl-compass:active {\n cursor: -webkit-grabbing;\n cursor: grabbing;\n}\n\n.l7-canvas-container.l7-touch-zoom-rotate,\n.l7-canvas-container.l7-touch-zoom-rotate .l7-canvas {\n -ms-touch-action: pan-x pan-y;\n touch-action: pan-x pan-y;\n}\n\n.l7-canvas-container.l7-touch-drag-pan,\n.l7-canvas-container.l7-touch-drag-pan .l7-canvas {\n -ms-touch-action: pinch-zoom;\n touch-action: pinch-zoom;\n}\n\n.l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan,\n.l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan .l7-canvas {\n -ms-touch-action: none;\n touch-action: none;\n}\n\n.l7-ctrl-top-left,\n.l7-ctrl-top-right,\n.l7-ctrl-bottom-left,\n.l7-ctrl-bottom-right { position: absolute; pointer-events: none; z-index: 2; }\n.l7-ctrl-top-left { top: 0; left: 0; }\n.l7-ctrl-top-right { top: 0; right: 0; }\n.l7-ctrl-bottom-left { bottom: 0; left: 0; }\n.l7-ctrl-bottom-right { right: 0; bottom: 0; }\n\n.l7-ctrl {\n clear: both;\n pointer-events: auto;\n\n /* workaround for a Safari bug https://github.com/mapbox/mapbox-gl-js/issues/8185 */\n -webkit-transform: translate(0, 0);\n transform: translate(0, 0);\n}\n.l7-ctrl-top-left .l7-ctrl { margin: 10px 0 0 10px; float: left; }\n.l7-ctrl-top-right .l7-ctrl { margin: 10px 10px 0 0; float: right; }\n.l7-ctrl-bottom-left .l7-ctrl { margin: 0 0 10px 10px; float: left; }\n.l7-ctrl-bottom-right .l7-ctrl { margin: 0 10px 10px 0; float: right; }\n\n\n.l7-crosshair,\n.l7-crosshair .l7-interactive,\n.l7-crosshair .l7-interactive:active {\n cursor: crosshair;\n}\n\n.l7-boxzoom {\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 0;\n background: #fff;\n border: 2px dotted #202020;\n opacity: 0.5;\n z-index: 10;\n}\n");
|
|
59
44
|
import LngLat from "./geo/lng_lat";
|
|
60
|
-
import LngLatBounds from "./geo/lng_lat_bounds";
|
|
61
|
-
|
|
45
|
+
import LngLatBounds from "./geo/lng_lat_bounds";
|
|
46
|
+
// @ts-ignore
|
|
62
47
|
import Point from "./geo/point";
|
|
63
48
|
import HandlerManager from "./handler/handler_manager";
|
|
64
49
|
import Hash from "./hash";
|
|
@@ -66,8 +51,9 @@ import { renderframe } from "./util";
|
|
|
66
51
|
import { PerformanceUtils } from "./utils/performance";
|
|
67
52
|
import TaskQueue from "./utils/task_queue";
|
|
68
53
|
var defaultMinZoom = -2;
|
|
69
|
-
var defaultMaxZoom = 22;
|
|
70
|
-
|
|
54
|
+
var defaultMaxZoom = 22;
|
|
55
|
+
var merge = lodashUtil.merge;
|
|
56
|
+
// the default values, but also the valid range
|
|
71
57
|
var defaultMinPitch = 0;
|
|
72
58
|
var defaultMaxPitch = 60;
|
|
73
59
|
var DefaultOptions = {
|
|
@@ -99,24 +85,16 @@ var DefaultOptions = {
|
|
|
99
85
|
};
|
|
100
86
|
export var Map = /*#__PURE__*/function (_Camera) {
|
|
101
87
|
_inherits(Map, _Camera);
|
|
102
|
-
|
|
103
88
|
var _super = _createSuper(Map);
|
|
104
|
-
|
|
105
89
|
function Map(options) {
|
|
106
90
|
var _this;
|
|
107
|
-
|
|
108
91
|
_classCallCheck(this, Map);
|
|
109
|
-
|
|
110
92
|
_this = _super.call(this, merge({}, DefaultOptions, options));
|
|
111
|
-
|
|
112
93
|
_defineProperty(_assertThisInitialized(_this), "renderTaskQueue", new TaskQueue());
|
|
113
|
-
|
|
114
94
|
_defineProperty(_assertThisInitialized(_this), "trackResize", true);
|
|
115
|
-
|
|
116
95
|
_defineProperty(_assertThisInitialized(_this), "onWindowOnline", function () {
|
|
117
96
|
_this.update();
|
|
118
97
|
});
|
|
119
|
-
|
|
120
98
|
_defineProperty(_assertThisInitialized(_this), "onWindowResize", function (event) {
|
|
121
99
|
if (_this.trackResize) {
|
|
122
100
|
_this.resize({
|
|
@@ -124,32 +102,20 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
124
102
|
}).update();
|
|
125
103
|
}
|
|
126
104
|
});
|
|
127
|
-
|
|
128
|
-
if (isMini) {
|
|
129
|
-
_this.initMiniContainer();
|
|
130
|
-
} else {
|
|
131
|
-
_this.initContainer();
|
|
132
|
-
}
|
|
133
|
-
|
|
105
|
+
_this.initContainer();
|
|
134
106
|
_this.resize();
|
|
135
|
-
|
|
136
107
|
_this.handlers = new HandlerManager(_assertThisInitialized(_this), _this.options);
|
|
137
|
-
|
|
138
108
|
if (typeof window !== 'undefined') {
|
|
139
109
|
window.addEventListener('online', _this.onWindowOnline, false);
|
|
140
110
|
window.addEventListener('resize', _this.onWindowResize, false);
|
|
141
111
|
window.addEventListener('orientationchange', _this.onWindowResize, false);
|
|
142
112
|
}
|
|
113
|
+
var hashName = typeof options.hash === 'string' && options.hash || undefined;
|
|
114
|
+
if (options.hash) {
|
|
115
|
+
_this.hash = new Hash(hashName).addTo(_assertThisInitialized(_this));
|
|
116
|
+
}
|
|
143
117
|
|
|
144
|
-
if
|
|
145
|
-
var hashName = typeof options.hash === 'string' && options.hash || undefined;
|
|
146
|
-
|
|
147
|
-
if (options.hash) {
|
|
148
|
-
_this.hash = new Hash(hashName).addTo(_assertThisInitialized(_this));
|
|
149
|
-
}
|
|
150
|
-
} // don't set position from options if set through hash
|
|
151
|
-
|
|
152
|
-
|
|
118
|
+
// don't set position from options if set through hash
|
|
153
119
|
if (!_this.hash || !_this.hash.onHashChange()) {
|
|
154
120
|
_this.jumpTo({
|
|
155
121
|
center: options.center,
|
|
@@ -157,47 +123,34 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
157
123
|
bearing: options.bearing,
|
|
158
124
|
pitch: options.pitch
|
|
159
125
|
});
|
|
160
|
-
|
|
161
126
|
if (options.bounds) {
|
|
162
127
|
_this.resize();
|
|
163
|
-
|
|
164
128
|
_this.fitBounds(options.bounds, merge({}, options.fitBoundsOptions, {
|
|
165
129
|
duration: 0
|
|
166
130
|
}));
|
|
167
131
|
}
|
|
168
132
|
}
|
|
169
|
-
|
|
170
133
|
return _this;
|
|
171
134
|
}
|
|
172
|
-
|
|
173
135
|
_createClass(Map, [{
|
|
174
136
|
key: "resize",
|
|
175
137
|
value: function resize(eventData) {
|
|
176
138
|
var _this$containerDimens = this.containerDimensions(),
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (isMini) {
|
|
184
|
-
return this;
|
|
185
|
-
}
|
|
186
|
-
|
|
139
|
+
_this$containerDimens2 = _slicedToArray(_this$containerDimens, 2),
|
|
140
|
+
width = _this$containerDimens2[0],
|
|
141
|
+
height = _this$containerDimens2[1];
|
|
142
|
+
this.transform.resize(width, height);
|
|
143
|
+
// 小程序环境不需要执行后续动作
|
|
187
144
|
var fireMoving = !this.moving;
|
|
188
|
-
|
|
189
145
|
if (fireMoving) {
|
|
190
146
|
this.stop();
|
|
191
|
-
this.emit('movestart', new
|
|
192
|
-
this.emit('move', new
|
|
147
|
+
this.emit('movestart', new window.Event('movestart', eventData));
|
|
148
|
+
this.emit('move', new window.Event('move', eventData));
|
|
193
149
|
}
|
|
194
|
-
|
|
195
|
-
this.emit('resize', new $window.Event('resize', eventData));
|
|
196
|
-
|
|
150
|
+
this.emit('resize', new window.Event('resize', eventData));
|
|
197
151
|
if (fireMoving) {
|
|
198
|
-
this.emit('moveend', new
|
|
152
|
+
this.emit('moveend', new window.Event('moveend', eventData));
|
|
199
153
|
}
|
|
200
|
-
|
|
201
154
|
return this;
|
|
202
155
|
}
|
|
203
156
|
}, {
|
|
@@ -239,8 +192,9 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
239
192
|
key: "setMaxBounds",
|
|
240
193
|
value: function setMaxBounds(bounds) {
|
|
241
194
|
this.transform.setMaxBounds(LngLatBounds.convert(bounds));
|
|
242
|
-
}
|
|
195
|
+
}
|
|
243
196
|
|
|
197
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
244
198
|
}, {
|
|
245
199
|
key: "setStyle",
|
|
246
200
|
value: function setStyle(style) {
|
|
@@ -250,14 +204,11 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
250
204
|
key: "setMinZoom",
|
|
251
205
|
value: function setMinZoom(minZoom) {
|
|
252
206
|
minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
|
|
253
|
-
|
|
254
207
|
if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
|
|
255
208
|
this.transform.minZoom = minZoom;
|
|
256
|
-
|
|
257
209
|
if (this.getZoom() < minZoom) {
|
|
258
210
|
this.setZoom(minZoom);
|
|
259
211
|
}
|
|
260
|
-
|
|
261
212
|
return this;
|
|
262
213
|
} else {
|
|
263
214
|
throw new Error("minZoom must be between ".concat(defaultMinZoom, " and the current maxZoom, inclusive"));
|
|
@@ -272,14 +223,11 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
272
223
|
key: "setMaxZoom",
|
|
273
224
|
value: function setMaxZoom(maxZoom) {
|
|
274
225
|
maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
|
|
275
|
-
|
|
276
226
|
if (maxZoom >= this.transform.minZoom) {
|
|
277
227
|
this.transform.maxZoom = maxZoom;
|
|
278
|
-
|
|
279
228
|
if (this.getZoom() > maxZoom) {
|
|
280
229
|
this.setZoom(maxZoom);
|
|
281
230
|
}
|
|
282
|
-
|
|
283
231
|
return this;
|
|
284
232
|
} else {
|
|
285
233
|
throw new Error('maxZoom must be greater than the current minZoom');
|
|
@@ -294,18 +242,14 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
294
242
|
key: "setMinPitch",
|
|
295
243
|
value: function setMinPitch(minPitch) {
|
|
296
244
|
minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
|
|
297
|
-
|
|
298
245
|
if (minPitch < defaultMinPitch) {
|
|
299
246
|
throw new Error("minPitch must be greater than or equal to ".concat(defaultMinPitch));
|
|
300
247
|
}
|
|
301
|
-
|
|
302
248
|
if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
|
|
303
249
|
this.transform.minPitch = minPitch;
|
|
304
|
-
|
|
305
250
|
if (this.getPitch() < minPitch) {
|
|
306
251
|
this.setPitch(minPitch);
|
|
307
252
|
}
|
|
308
|
-
|
|
309
253
|
return this;
|
|
310
254
|
} else {
|
|
311
255
|
throw new Error("minPitch must be between ".concat(defaultMinPitch, " and the current maxPitch, inclusive"));
|
|
@@ -320,18 +264,14 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
320
264
|
key: "setMaxPitch",
|
|
321
265
|
value: function setMaxPitch(maxPitch) {
|
|
322
266
|
maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
|
|
323
|
-
|
|
324
267
|
if (maxPitch > defaultMaxPitch) {
|
|
325
268
|
throw new Error("maxPitch must be less than or equal to ".concat(defaultMaxPitch));
|
|
326
269
|
}
|
|
327
|
-
|
|
328
270
|
if (maxPitch >= this.transform.minPitch) {
|
|
329
271
|
this.transform.maxPitch = maxPitch;
|
|
330
|
-
|
|
331
272
|
if (this.getPitch() > maxPitch) {
|
|
332
273
|
this.setPitch(maxPitch);
|
|
333
274
|
}
|
|
334
|
-
|
|
335
275
|
return this;
|
|
336
276
|
} else {
|
|
337
277
|
throw new Error('maxPitch must be greater than the current minPitch');
|
|
@@ -355,15 +295,13 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
355
295
|
}, {
|
|
356
296
|
key: "remove",
|
|
357
297
|
value: function remove() {
|
|
358
|
-
this.container.removeChild(this.canvasContainer);
|
|
359
|
-
|
|
298
|
+
this.container.removeChild(this.canvasContainer);
|
|
299
|
+
// @ts-ignore
|
|
360
300
|
this.canvasContainer = null;
|
|
361
|
-
|
|
362
301
|
if (this.frame) {
|
|
363
302
|
this.frame.cancel();
|
|
364
303
|
this.frame = null;
|
|
365
304
|
}
|
|
366
|
-
|
|
367
305
|
this.renderTaskQueue.clear();
|
|
368
306
|
}
|
|
369
307
|
}, {
|
|
@@ -381,12 +319,10 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
381
319
|
key: "triggerRepaint",
|
|
382
320
|
value: function triggerRepaint() {
|
|
383
321
|
var _this2 = this;
|
|
384
|
-
|
|
385
322
|
if (!this.frame) {
|
|
386
323
|
this.frame = renderframe(function (paintStartTimeStamp) {
|
|
387
324
|
PerformanceUtils.frame(paintStartTimeStamp);
|
|
388
325
|
_this2.frame = null;
|
|
389
|
-
|
|
390
326
|
_this2.update(paintStartTimeStamp);
|
|
391
327
|
});
|
|
392
328
|
}
|
|
@@ -395,12 +331,10 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
395
331
|
key: "update",
|
|
396
332
|
value: function update(time) {
|
|
397
333
|
var _this3 = this;
|
|
398
|
-
|
|
399
334
|
if (!this.frame) {
|
|
400
335
|
this.frame = renderframe(function (paintStartTimeStamp) {
|
|
401
336
|
PerformanceUtils.frame(paintStartTimeStamp);
|
|
402
337
|
_this3.frame = null;
|
|
403
|
-
|
|
404
338
|
_this3.renderTaskQueue.run(time);
|
|
405
339
|
});
|
|
406
340
|
}
|
|
@@ -410,7 +344,6 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
410
344
|
value: function initContainer() {
|
|
411
345
|
if (typeof this.options.container === 'string') {
|
|
412
346
|
this.container = window.document.getElementById(this.options.container);
|
|
413
|
-
|
|
414
347
|
if (!this.container) {
|
|
415
348
|
throw new Error("Container '".concat(this.options.container, "' not found."));
|
|
416
349
|
}
|
|
@@ -419,19 +352,17 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
419
352
|
} else {
|
|
420
353
|
throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
|
|
421
354
|
}
|
|
422
|
-
|
|
423
355
|
var container = this.container;
|
|
424
356
|
container.classList.add('l7-map');
|
|
425
357
|
var canvasContainer = this.canvasContainer = DOM.create('div', 'l7-canvas-container', container);
|
|
426
|
-
|
|
427
358
|
if (this.options.interactive) {
|
|
428
359
|
canvasContainer.classList.add('l7-interactive');
|
|
429
360
|
}
|
|
430
361
|
}
|
|
362
|
+
|
|
431
363
|
/**
|
|
432
364
|
* 小程序环境构建容器
|
|
433
365
|
*/
|
|
434
|
-
|
|
435
366
|
}, {
|
|
436
367
|
key: "initMiniContainer",
|
|
437
368
|
value: function initMiniContainer() {
|
|
@@ -443,22 +374,14 @@ export var Map = /*#__PURE__*/function (_Camera) {
|
|
|
443
374
|
value: function containerDimensions() {
|
|
444
375
|
var width = 0;
|
|
445
376
|
var height = 0;
|
|
446
|
-
|
|
447
377
|
if (this.container) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
width = this.container.clientWidth;
|
|
453
|
-
height = this.container.clientHeight;
|
|
454
|
-
width = width === 0 ? 400 : width;
|
|
455
|
-
height = height === 0 ? 300 : height;
|
|
456
|
-
}
|
|
378
|
+
width = this.container.clientWidth;
|
|
379
|
+
height = this.container.clientHeight;
|
|
380
|
+
width = width === 0 ? 400 : width;
|
|
381
|
+
height = height === 0 ? 300 : height;
|
|
457
382
|
}
|
|
458
|
-
|
|
459
383
|
return [width, height];
|
|
460
384
|
}
|
|
461
385
|
}]);
|
|
462
|
-
|
|
463
386
|
return Map;
|
|
464
387
|
}(Camera);
|
package/es/util.d.ts
CHANGED
|
@@ -12,9 +12,9 @@ export declare function pick(src: {
|
|
|
12
12
|
}, properties: string[]): {
|
|
13
13
|
[key: string]: any;
|
|
14
14
|
};
|
|
15
|
-
export declare const now:
|
|
16
|
-
export declare const raf:
|
|
17
|
-
export declare const cancel:
|
|
15
|
+
export declare const now: () => number;
|
|
16
|
+
export declare const raf: ((callback: FrameRequestCallback) => number) & typeof requestAnimationFrame;
|
|
17
|
+
export declare const cancel: ((handle: number) => void) & typeof cancelAnimationFrame;
|
|
18
18
|
export declare function renderframe(fn: (paintStartTimestamp: number) => void): ICancelable;
|
|
19
19
|
export declare function extend(dest: {
|
|
20
20
|
[key: string]: any;
|
package/es/util.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
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; } } }; }
|
|
2
|
-
|
|
3
2
|
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); }
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { $window, isMini } from '@antv/l7-utils'; // @ts-ignore
|
|
8
|
-
|
|
3
|
+
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; }
|
|
4
|
+
// @ts-ignore
|
|
9
5
|
import UnitBezier from '@mapbox/unitbezier';
|
|
10
6
|
var reducedMotionQuery;
|
|
11
7
|
export function wrap(n, min, max) {
|
|
@@ -27,29 +23,20 @@ export function bezier(p1x, p1y, p2x, p2y) {
|
|
|
27
23
|
}
|
|
28
24
|
export var ease = bezier(0.25, 0.1, 0.25, 1);
|
|
29
25
|
export function prefersReducedMotion() {
|
|
30
|
-
//
|
|
31
|
-
if (isMini || !$window.matchMedia) {
|
|
32
|
-
return false;
|
|
33
|
-
} // Lazily initialize media query
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
// Lazily initialize media query
|
|
36
27
|
if (reducedMotionQuery == null) {
|
|
37
28
|
// @ts-ignore
|
|
38
|
-
reducedMotionQuery =
|
|
29
|
+
reducedMotionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
39
30
|
}
|
|
40
|
-
|
|
41
31
|
return reducedMotionQuery.matches;
|
|
42
32
|
}
|
|
43
33
|
export function pick(src, properties) {
|
|
44
34
|
var result = {};
|
|
45
|
-
|
|
46
35
|
var _iterator = _createForOfIteratorHelper(properties),
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
_step;
|
|
49
37
|
try {
|
|
50
38
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
51
39
|
var name = _step.value;
|
|
52
|
-
|
|
53
40
|
if (name in src) {
|
|
54
41
|
result[name] = src[name];
|
|
55
42
|
}
|
|
@@ -59,20 +46,23 @@ export function pick(src, properties) {
|
|
|
59
46
|
} finally {
|
|
60
47
|
_iterator.f();
|
|
61
48
|
}
|
|
62
|
-
|
|
63
49
|
return result;
|
|
64
50
|
}
|
|
65
|
-
export var now =
|
|
66
|
-
export var raf =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
51
|
+
export var now = window.performance && window.performance.now ? window.performance.now.bind(window.performance) : Date.now.bind(Date);
|
|
52
|
+
export var raf = window.requestAnimationFrame ||
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
window.mozRequestAnimationFrame ||
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
window.webkitRequestAnimationFrame ||
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
window.msRequestAnimationFrame;
|
|
59
|
+
var _cancel = window.cancelAnimationFrame ||
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
window.mozCancelAnimationFrame ||
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
window.webkitCancelAnimationFrame ||
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
window.msCancelAnimationFrame;
|
|
76
66
|
export { _cancel as cancel };
|
|
77
67
|
export function renderframe(fn) {
|
|
78
68
|
var frame = raf(fn);
|
|
@@ -86,16 +76,13 @@ export function extend(dest) {
|
|
|
86
76
|
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
87
77
|
sources[_key - 1] = arguments[_key];
|
|
88
78
|
}
|
|
89
|
-
|
|
90
79
|
for (var _i = 0, _sources = sources; _i < _sources.length; _i++) {
|
|
91
80
|
var src = _sources[_i];
|
|
92
|
-
|
|
93
81
|
for (var k in src) {
|
|
94
82
|
if (src[k] !== undefined) {
|
|
95
83
|
dest[k] = src[k];
|
|
96
84
|
}
|
|
97
85
|
}
|
|
98
86
|
}
|
|
99
|
-
|
|
100
87
|
return dest;
|
|
101
88
|
}
|
package/es/utils/Aabb.js
CHANGED
|
@@ -1,36 +1,27 @@
|
|
|
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
|
import { vec3, vec4 } from 'gl-matrix';
|
|
11
|
-
|
|
12
7
|
var Aabb = /*#__PURE__*/function () {
|
|
13
8
|
function Aabb(min, max) {
|
|
14
9
|
_classCallCheck(this, Aabb);
|
|
15
|
-
|
|
16
10
|
this.min = min;
|
|
17
11
|
this.max = max;
|
|
18
12
|
this.center = vec3.scale(new Float32Array(3), vec3.add(new Float32Array(3), this.min, this.max), 0.5);
|
|
19
13
|
}
|
|
20
|
-
|
|
21
14
|
_createClass(Aabb, [{
|
|
22
15
|
key: "quadrant",
|
|
23
16
|
value: function quadrant(index) {
|
|
24
17
|
var split = [index % 2 === 0, index < 2];
|
|
25
18
|
var qMin = vec3.clone(this.min);
|
|
26
19
|
var qMax = vec3.clone(this.max);
|
|
27
|
-
|
|
28
20
|
for (var axis = 0; axis < split.length; axis++) {
|
|
29
21
|
qMin[axis] = split[axis] ? this.min[axis] : this.center[axis];
|
|
30
22
|
qMax[axis] = split[axis] ? this.center[axis] : this.max[axis];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
}
|
|
24
|
+
// Elevation is always constant, hence quadrant.max.z = this.max.z
|
|
34
25
|
qMax[2] = this.max[2];
|
|
35
26
|
return new Aabb(qMin, qMax);
|
|
36
27
|
}
|
|
@@ -45,29 +36,27 @@ var Aabb = /*#__PURE__*/function () {
|
|
|
45
36
|
value: function distanceY(point) {
|
|
46
37
|
var pointOnAabb = Math.max(Math.min(this.max[1], point[1]), this.min[1]);
|
|
47
38
|
return pointOnAabb - point[1];
|
|
48
|
-
}
|
|
49
|
-
// 1 if shapes are intersecting and 2 if the aabb if fully inside the frustum.
|
|
39
|
+
}
|
|
50
40
|
|
|
41
|
+
// Performs a frustum-aabb intersection test. Returns 0 if there's no intersection,
|
|
42
|
+
// 1 if shapes are intersecting and 2 if the aabb if fully inside the frustum.
|
|
51
43
|
}, {
|
|
52
44
|
key: "intersects",
|
|
53
45
|
value: function intersects(frustum) {
|
|
54
46
|
// Execute separating axis test between two convex objects to find intersections
|
|
55
47
|
// Each frustum plane together with 3 major axes define the separating axes
|
|
56
48
|
// Note: test only 4 points as both min and max points have equal elevation
|
|
49
|
+
|
|
57
50
|
var aabbPoints = [[this.min[0], this.min[1], 0.0, 1], [this.max[0], this.min[1], 0.0, 1], [this.max[0], this.max[1], 0.0, 1], [this.min[0], this.max[1], 0.0, 1]];
|
|
58
51
|
var fullyInside = true;
|
|
59
|
-
|
|
60
52
|
var _iterator = _createForOfIteratorHelper(frustum.planes),
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
_step;
|
|
63
54
|
try {
|
|
64
55
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
65
56
|
var plane = _step.value;
|
|
66
57
|
var pointsInside = 0;
|
|
67
|
-
|
|
68
58
|
var _iterator3 = _createForOfIteratorHelper(aabbPoints),
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
_step3;
|
|
71
60
|
try {
|
|
72
61
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
73
62
|
var i = _step3.value;
|
|
@@ -79,11 +68,9 @@ var Aabb = /*#__PURE__*/function () {
|
|
|
79
68
|
} finally {
|
|
80
69
|
_iterator3.f();
|
|
81
70
|
}
|
|
82
|
-
|
|
83
71
|
if (pointsInside === 0) {
|
|
84
72
|
return 0;
|
|
85
73
|
}
|
|
86
|
-
|
|
87
74
|
if (pointsInside !== aabbPoints.length) {
|
|
88
75
|
fullyInside = false;
|
|
89
76
|
}
|
|
@@ -93,18 +80,14 @@ var Aabb = /*#__PURE__*/function () {
|
|
|
93
80
|
} finally {
|
|
94
81
|
_iterator.f();
|
|
95
82
|
}
|
|
96
|
-
|
|
97
83
|
if (fullyInside) {
|
|
98
84
|
return 2;
|
|
99
85
|
}
|
|
100
|
-
|
|
101
86
|
for (var axis = 0; axis < 3; axis++) {
|
|
102
87
|
var projMin = Number.MAX_VALUE;
|
|
103
88
|
var projMax = -Number.MAX_VALUE;
|
|
104
|
-
|
|
105
89
|
var _iterator2 = _createForOfIteratorHelper(frustum.points),
|
|
106
|
-
|
|
107
|
-
|
|
90
|
+
_step2;
|
|
108
91
|
try {
|
|
109
92
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
110
93
|
var p = _step2.value;
|
|
@@ -117,17 +100,13 @@ var Aabb = /*#__PURE__*/function () {
|
|
|
117
100
|
} finally {
|
|
118
101
|
_iterator2.f();
|
|
119
102
|
}
|
|
120
|
-
|
|
121
103
|
if (projMax < 0 || projMin > this.max[axis] - this.min[axis]) {
|
|
122
104
|
return 0;
|
|
123
105
|
}
|
|
124
106
|
}
|
|
125
|
-
|
|
126
107
|
return 1;
|
|
127
108
|
}
|
|
128
109
|
}]);
|
|
129
|
-
|
|
130
110
|
return Aabb;
|
|
131
111
|
}();
|
|
132
|
-
|
|
133
112
|
export { Aabb as default };
|