@antv/l7-map 2.16.1 → 2.16.2

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.
Files changed (103) hide show
  1. package/es/camera.js +90 -148
  2. package/es/earthmap.js +13 -65
  3. package/es/geo/edge_insets.js +4 -14
  4. package/es/geo/lng_lat.js +5 -13
  5. package/es/geo/lng_lat_bounds.js +4 -17
  6. package/es/geo/mercator.js +2 -10
  7. package/es/geo/point.js +0 -7
  8. package/es/geo/simple.js +6 -11
  9. package/es/geo/transform.js +123 -132
  10. package/es/handler/blockable_map_event.js +7 -12
  11. package/es/handler/box_zoom.js +10 -30
  12. package/es/handler/click_zoom.js +0 -5
  13. package/es/handler/events/event.js +0 -2
  14. package/es/handler/events/map_mouse_event.js +0 -12
  15. package/es/handler/events/map_touch_event.js +2 -12
  16. package/es/handler/events/map_wheel_event.js +1 -12
  17. package/es/handler/events/render_event.js +0 -13
  18. package/es/handler/handler_inertia.js +6 -34
  19. package/es/handler/handler_manager.js +55 -147
  20. package/es/handler/handler_util.js +1 -2
  21. package/es/handler/keyboard.js +1 -20
  22. package/es/handler/map_event.js +3 -9
  23. package/es/handler/mouse/mouse_handler.js +11 -24
  24. package/es/handler/mouse/mousepan_handler.js +1 -11
  25. package/es/handler/mouse/mousepitch_hander.js +1 -11
  26. package/es/handler/mouse/mouserotate_hander.js +1 -11
  27. package/es/handler/mouse/util.js +2 -3
  28. package/es/handler/scroll_zoom.js +43 -71
  29. package/es/handler/shim/dblclick_zoom.js +4 -9
  30. package/es/handler/shim/drag_pan.js +4 -11
  31. package/es/handler/shim/drag_rotate.js +4 -10
  32. package/es/handler/shim/touch_zoom_rotate.js +6 -16
  33. package/es/handler/tap/single_tap_recognizer.js +8 -31
  34. package/es/handler/tap/tap_drag_zoom.js +7 -15
  35. package/es/handler/tap/tap_recognizer.js +3 -11
  36. package/es/handler/tap/tap_zoom.js +1 -7
  37. package/es/handler/touch/touch_pan.js +4 -22
  38. package/es/handler/touch/touch_pitch.js +10 -27
  39. package/es/handler/touch/touch_rotate.js +8 -19
  40. package/es/handler/touch/touch_zoom.js +5 -18
  41. package/es/handler/touch/two_touch.js +19 -32
  42. package/es/hash.js +9 -31
  43. package/es/map.js +16 -78
  44. package/es/util.js +18 -23
  45. package/es/utils/Aabb.js +10 -31
  46. package/es/utils/dom.js +24 -58
  47. package/es/utils/performance.js +8 -7
  48. package/es/utils/primitives.js +13 -11
  49. package/es/utils/task_queue.js +6 -23
  50. package/lib/camera.js +90 -168
  51. package/lib/earthmap.js +11 -79
  52. package/lib/geo/edge_insets.js +3 -18
  53. package/lib/geo/lng_lat.js +5 -18
  54. package/lib/geo/lng_lat_bounds.js +4 -20
  55. package/lib/geo/mercator.js +1 -22
  56. package/lib/geo/point.js +0 -8
  57. package/lib/geo/simple.js +5 -24
  58. package/lib/geo/transform.js +123 -164
  59. package/lib/handler/blockable_map_event.js +6 -14
  60. package/lib/handler/box_zoom.js +8 -39
  61. package/lib/handler/click_zoom.js +0 -6
  62. package/lib/handler/events/event.js +0 -5
  63. package/lib/handler/events/index.js +0 -4
  64. package/lib/handler/events/map_mouse_event.js +0 -19
  65. package/lib/handler/events/map_touch_event.js +1 -20
  66. package/lib/handler/events/map_wheel_event.js +1 -16
  67. package/lib/handler/events/render_event.js +0 -19
  68. package/lib/handler/handler_inertia.js +4 -37
  69. package/lib/handler/handler_manager.js +55 -171
  70. package/lib/handler/handler_util.js +1 -3
  71. package/lib/handler/keyboard.js +1 -22
  72. package/lib/handler/map_event.js +2 -11
  73. package/lib/handler/mouse/index.js +0 -4
  74. package/lib/handler/mouse/mouse_handler.js +10 -27
  75. package/lib/handler/mouse/mousepan_handler.js +0 -17
  76. package/lib/handler/mouse/mousepitch_hander.js +0 -16
  77. package/lib/handler/mouse/mouserotate_hander.js +0 -16
  78. package/lib/handler/mouse/util.js +2 -6
  79. package/lib/handler/scroll_zoom.js +43 -77
  80. package/lib/handler/shim/dblclick_zoom.js +4 -10
  81. package/lib/handler/shim/drag_pan.js +4 -13
  82. package/lib/handler/shim/drag_rotate.js +4 -11
  83. package/lib/handler/shim/touch_zoom_rotate.js +6 -18
  84. package/lib/handler/tap/single_tap_recognizer.js +8 -33
  85. package/lib/handler/tap/tap_drag_zoom.js +6 -18
  86. package/lib/handler/tap/tap_recognizer.js +2 -17
  87. package/lib/handler/tap/tap_zoom.js +0 -9
  88. package/lib/handler/touch/index.js +0 -5
  89. package/lib/handler/touch/touch_pan.js +4 -25
  90. package/lib/handler/touch/touch_pitch.js +9 -31
  91. package/lib/handler/touch/touch_rotate.js +7 -24
  92. package/lib/handler/touch/touch_zoom.js +4 -23
  93. package/lib/handler/touch/two_touch.js +18 -35
  94. package/lib/hash.js +8 -35
  95. package/lib/index.js +0 -8
  96. package/lib/map.js +14 -94
  97. package/lib/util.js +16 -34
  98. package/lib/utils/Aabb.js +10 -34
  99. package/lib/utils/dom.js +22 -64
  100. package/lib/utils/performance.js +8 -9
  101. package/lib/utils/primitives.js +13 -16
  102. package/lib/utils/task_queue.js +6 -24
  103. package/package.json +3 -3
package/lib/map.js CHANGED
@@ -1,98 +1,66 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.Map = void 0;
9
-
10
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
11
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
-
18
12
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
-
20
13
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
-
22
14
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
-
24
15
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
-
26
16
  var _l7Utils = require("@antv/l7-utils");
27
-
28
17
  var _lodash = require("lodash");
29
-
30
18
  var _camera = _interopRequireDefault(require("./camera"));
31
-
32
19
  var _lng_lat = _interopRequireDefault(require("./geo/lng_lat"));
33
-
34
20
  var _lng_lat_bounds = _interopRequireDefault(require("./geo/lng_lat_bounds"));
35
-
36
21
  var _point = _interopRequireDefault(require("./geo/point"));
37
-
38
22
  var _handler_manager = _interopRequireDefault(require("./handler/handler_manager"));
39
-
40
23
  var _hash = _interopRequireDefault(require("./hash"));
41
-
42
24
  var _util = require("./util");
43
-
44
25
  var _performance = require("./utils/performance");
45
-
46
26
  var _task_queue = _interopRequireDefault(require("./utils/task_queue"));
47
-
48
27
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
49
-
50
28
  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; } }
51
-
52
29
  function loadStyles(css, doc) {
53
30
  var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
54
31
  var isWeChatMiniProgram = typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
55
-
56
32
  if (isMiniAli || isWeChatMiniProgram) {
57
33
  return;
58
34
  }
59
-
60
35
  if (!doc) doc = document;
61
-
62
36
  if (!doc) {
63
37
  return;
64
38
  }
65
-
66
39
  var head = doc.head || doc.getElementsByTagName('head')[0];
67
-
68
40
  if (!head) {
69
41
  head = doc.createElement('head');
70
42
  var body = doc.body || doc.getElementsByTagName('body')[0];
71
-
72
43
  if (body) {
73
44
  body.parentNode.insertBefore(head, body);
74
45
  } else {
75
46
  doc.documentElement.appendChild(head);
76
47
  }
77
48
  }
78
-
79
49
  var style = doc.createElement('style');
80
50
  style.type = 'text/css';
81
-
82
51
  if (style.styleSheet) {
83
52
  style.styleSheet.cssText = css;
84
53
  } else {
85
54
  style.appendChild(doc.createTextNode(css));
86
55
  }
87
-
88
56
  head.appendChild(style);
89
57
  return style;
90
58
  }
91
-
92
59
  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");
93
60
  var defaultMinZoom = -2;
94
- var defaultMaxZoom = 22; // the default values, but also the valid range
61
+ var defaultMaxZoom = 22;
95
62
 
63
+ // the default values, but also the valid range
96
64
  var defaultMinPitch = 0;
97
65
  var defaultMaxPitch = 60;
98
66
  var DefaultOptions = {
@@ -122,15 +90,11 @@ var DefaultOptions = {
122
90
  pitchEnabled: true,
123
91
  rotateEnabled: true
124
92
  };
125
-
126
93
  var Map = /*#__PURE__*/function (_Camera) {
127
94
  (0, _inherits2.default)(Map, _Camera);
128
-
129
95
  var _super = _createSuper(Map);
130
-
131
96
  function Map(options) {
132
97
  var _this;
133
-
134
98
  (0, _classCallCheck2.default)(this, Map);
135
99
  _this = _super.call(this, (0, _lodash.merge)({}, DefaultOptions, options));
136
100
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderTaskQueue", new _task_queue.default());
@@ -145,32 +109,26 @@ var Map = /*#__PURE__*/function (_Camera) {
145
109
  }).update();
146
110
  }
147
111
  });
148
-
149
112
  if (_l7Utils.isMini) {
150
113
  _this.initMiniContainer();
151
114
  } else {
152
115
  _this.initContainer();
153
116
  }
154
-
155
117
  _this.resize();
156
-
157
118
  _this.handlers = new _handler_manager.default((0, _assertThisInitialized2.default)(_this), _this.options);
158
-
159
119
  if (typeof window !== 'undefined') {
160
120
  window.addEventListener('online', _this.onWindowOnline, false);
161
121
  window.addEventListener('resize', _this.onWindowResize, false);
162
122
  window.addEventListener('orientationchange', _this.onWindowResize, false);
163
123
  }
164
-
165
124
  if (!_l7Utils.isMini) {
166
125
  var hashName = typeof options.hash === 'string' && options.hash || undefined;
167
-
168
126
  if (options.hash) {
169
127
  _this.hash = new _hash.default(hashName).addTo((0, _assertThisInitialized2.default)(_this));
170
128
  }
171
- } // don't set position from options if set through hash
172
-
129
+ }
173
130
 
131
+ // don't set position from options if set through hash
174
132
  if (!_this.hash || !_this.hash.onHashChange()) {
175
133
  _this.jumpTo({
176
134
  center: options.center,
@@ -178,47 +136,37 @@ var Map = /*#__PURE__*/function (_Camera) {
178
136
  bearing: options.bearing,
179
137
  pitch: options.pitch
180
138
  });
181
-
182
139
  if (options.bounds) {
183
140
  _this.resize();
184
-
185
141
  _this.fitBounds(options.bounds, (0, _lodash.merge)({}, options.fitBoundsOptions, {
186
142
  duration: 0
187
143
  }));
188
144
  }
189
145
  }
190
-
191
146
  return _this;
192
147
  }
193
-
194
148
  (0, _createClass2.default)(Map, [{
195
149
  key: "resize",
196
150
  value: function resize(eventData) {
197
151
  var _this$containerDimens = this.containerDimensions(),
198
- _this$containerDimens2 = (0, _slicedToArray2.default)(_this$containerDimens, 2),
199
- width = _this$containerDimens2[0],
200
- height = _this$containerDimens2[1];
201
-
202
- this.transform.resize(width, height); // 小程序环境不需要执行后续动作
203
-
152
+ _this$containerDimens2 = (0, _slicedToArray2.default)(_this$containerDimens, 2),
153
+ width = _this$containerDimens2[0],
154
+ height = _this$containerDimens2[1];
155
+ this.transform.resize(width, height);
156
+ // 小程序环境不需要执行后续动作
204
157
  if (_l7Utils.isMini) {
205
158
  return this;
206
159
  }
207
-
208
160
  var fireMoving = !this.moving;
209
-
210
161
  if (fireMoving) {
211
162
  this.stop();
212
163
  this.emit('movestart', new _l7Utils.$window.Event('movestart', eventData));
213
164
  this.emit('move', new _l7Utils.$window.Event('move', eventData));
214
165
  }
215
-
216
166
  this.emit('resize', new _l7Utils.$window.Event('resize', eventData));
217
-
218
167
  if (fireMoving) {
219
168
  this.emit('moveend', new _l7Utils.$window.Event('moveend', eventData));
220
169
  }
221
-
222
170
  return this;
223
171
  }
224
172
  }, {
@@ -260,8 +208,9 @@ var Map = /*#__PURE__*/function (_Camera) {
260
208
  key: "setMaxBounds",
261
209
  value: function setMaxBounds(bounds) {
262
210
  this.transform.setMaxBounds(_lng_lat_bounds.default.convert(bounds));
263
- } // eslint-disable-next-line @typescript-eslint/no-unused-vars
211
+ }
264
212
 
213
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
265
214
  }, {
266
215
  key: "setStyle",
267
216
  value: function setStyle(style) {
@@ -271,14 +220,11 @@ var Map = /*#__PURE__*/function (_Camera) {
271
220
  key: "setMinZoom",
272
221
  value: function setMinZoom(minZoom) {
273
222
  minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
274
-
275
223
  if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
276
224
  this.transform.minZoom = minZoom;
277
-
278
225
  if (this.getZoom() < minZoom) {
279
226
  this.setZoom(minZoom);
280
227
  }
281
-
282
228
  return this;
283
229
  } else {
284
230
  throw new Error("minZoom must be between ".concat(defaultMinZoom, " and the current maxZoom, inclusive"));
@@ -293,14 +239,11 @@ var Map = /*#__PURE__*/function (_Camera) {
293
239
  key: "setMaxZoom",
294
240
  value: function setMaxZoom(maxZoom) {
295
241
  maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
296
-
297
242
  if (maxZoom >= this.transform.minZoom) {
298
243
  this.transform.maxZoom = maxZoom;
299
-
300
244
  if (this.getZoom() > maxZoom) {
301
245
  this.setZoom(maxZoom);
302
246
  }
303
-
304
247
  return this;
305
248
  } else {
306
249
  throw new Error('maxZoom must be greater than the current minZoom');
@@ -315,18 +258,14 @@ var Map = /*#__PURE__*/function (_Camera) {
315
258
  key: "setMinPitch",
316
259
  value: function setMinPitch(minPitch) {
317
260
  minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
318
-
319
261
  if (minPitch < defaultMinPitch) {
320
262
  throw new Error("minPitch must be greater than or equal to ".concat(defaultMinPitch));
321
263
  }
322
-
323
264
  if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
324
265
  this.transform.minPitch = minPitch;
325
-
326
266
  if (this.getPitch() < minPitch) {
327
267
  this.setPitch(minPitch);
328
268
  }
329
-
330
269
  return this;
331
270
  } else {
332
271
  throw new Error("minPitch must be between ".concat(defaultMinPitch, " and the current maxPitch, inclusive"));
@@ -341,18 +280,14 @@ var Map = /*#__PURE__*/function (_Camera) {
341
280
  key: "setMaxPitch",
342
281
  value: function setMaxPitch(maxPitch) {
343
282
  maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
344
-
345
283
  if (maxPitch > defaultMaxPitch) {
346
284
  throw new Error("maxPitch must be less than or equal to ".concat(defaultMaxPitch));
347
285
  }
348
-
349
286
  if (maxPitch >= this.transform.minPitch) {
350
287
  this.transform.maxPitch = maxPitch;
351
-
352
288
  if (this.getPitch() > maxPitch) {
353
289
  this.setPitch(maxPitch);
354
290
  }
355
-
356
291
  return this;
357
292
  } else {
358
293
  throw new Error('maxPitch must be greater than the current minPitch');
@@ -376,15 +311,13 @@ var Map = /*#__PURE__*/function (_Camera) {
376
311
  }, {
377
312
  key: "remove",
378
313
  value: function remove() {
379
- this.container.removeChild(this.canvasContainer); // @ts-ignore
380
-
314
+ this.container.removeChild(this.canvasContainer);
315
+ // @ts-ignore
381
316
  this.canvasContainer = null;
382
-
383
317
  if (this.frame) {
384
318
  this.frame.cancel();
385
319
  this.frame = null;
386
320
  }
387
-
388
321
  this.renderTaskQueue.clear();
389
322
  }
390
323
  }, {
@@ -402,13 +335,10 @@ var Map = /*#__PURE__*/function (_Camera) {
402
335
  key: "triggerRepaint",
403
336
  value: function triggerRepaint() {
404
337
  var _this2 = this;
405
-
406
338
  if (!this.frame) {
407
339
  this.frame = (0, _util.renderframe)(function (paintStartTimeStamp) {
408
340
  _performance.PerformanceUtils.frame(paintStartTimeStamp);
409
-
410
341
  _this2.frame = null;
411
-
412
342
  _this2.update(paintStartTimeStamp);
413
343
  });
414
344
  }
@@ -417,13 +347,10 @@ var Map = /*#__PURE__*/function (_Camera) {
417
347
  key: "update",
418
348
  value: function update(time) {
419
349
  var _this3 = this;
420
-
421
350
  if (!this.frame) {
422
351
  this.frame = (0, _util.renderframe)(function (paintStartTimeStamp) {
423
352
  _performance.PerformanceUtils.frame(paintStartTimeStamp);
424
-
425
353
  _this3.frame = null;
426
-
427
354
  _this3.renderTaskQueue.run(time);
428
355
  });
429
356
  }
@@ -433,7 +360,6 @@ var Map = /*#__PURE__*/function (_Camera) {
433
360
  value: function initContainer() {
434
361
  if (typeof this.options.container === 'string') {
435
362
  this.container = window.document.getElementById(this.options.container);
436
-
437
363
  if (!this.container) {
438
364
  throw new Error("Container '".concat(this.options.container, "' not found."));
439
365
  }
@@ -442,20 +368,17 @@ var Map = /*#__PURE__*/function (_Camera) {
442
368
  } else {
443
369
  throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
444
370
  }
445
-
446
371
  var container = this.container;
447
372
  container.classList.add('l7-map');
448
-
449
373
  var canvasContainer = this.canvasContainer = _l7Utils.DOM.create('div', 'l7-canvas-container', container);
450
-
451
374
  if (this.options.interactive) {
452
375
  canvasContainer.classList.add('l7-interactive');
453
376
  }
454
377
  }
378
+
455
379
  /**
456
380
  * 小程序环境构建容器
457
381
  */
458
-
459
382
  }, {
460
383
  key: "initMiniContainer",
461
384
  value: function initMiniContainer() {
@@ -467,7 +390,6 @@ var Map = /*#__PURE__*/function (_Camera) {
467
390
  value: function containerDimensions() {
468
391
  var width = 0;
469
392
  var height = 0;
470
-
471
393
  if (this.container) {
472
394
  if (_l7Utils.isMini) {
473
395
  width = this.container.width / _l7Utils.$window.devicePixelRatio;
@@ -479,11 +401,9 @@ var Map = /*#__PURE__*/function (_Camera) {
479
401
  height = height === 0 ? 300 : height;
480
402
  }
481
403
  }
482
-
483
404
  return [width, height];
484
405
  }
485
406
  }]);
486
407
  return Map;
487
408
  }(_camera.default);
488
-
489
409
  exports.Map = Map;
package/lib/util.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -16,68 +15,50 @@ exports.prefersReducedMotion = prefersReducedMotion;
16
15
  exports.raf = void 0;
17
16
  exports.renderframe = renderframe;
18
17
  exports.wrap = wrap;
19
-
20
18
  var _l7Utils = require("@antv/l7-utils");
21
-
22
19
  var _unitbezier = _interopRequireDefault(require("@mapbox/unitbezier"));
23
-
24
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; } } }; }
25
-
26
21
  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); }
27
-
28
- 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; }
29
-
22
+ 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; }
30
23
  var reducedMotionQuery;
31
-
32
24
  function wrap(n, min, max) {
33
25
  var d = max - min;
34
26
  var w = ((n - min) % d + d) % d + min;
35
27
  return w === min ? max : w;
36
28
  }
37
-
38
29
  function clamp(n, min, max) {
39
30
  return Math.min(max, Math.max(min, n));
40
31
  }
41
-
42
32
  function interpolate(a, b, t) {
43
33
  return a * (1 - t) + b * t;
44
34
  }
45
-
46
35
  function bezier(p1x, p1y, p2x, p2y) {
47
36
  var bez = new _unitbezier.default(p1x, p1y, p2x, p2y);
48
37
  return function (t) {
49
38
  return bez.solve(t);
50
39
  };
51
40
  }
52
-
53
41
  var ease = bezier(0.25, 0.1, 0.25, 1);
54
42
  exports.ease = ease;
55
-
56
43
  function prefersReducedMotion() {
57
44
  // @ts-ignore
58
45
  if (_l7Utils.isMini || !_l7Utils.$window.matchMedia) {
59
46
  return false;
60
- } // Lazily initialize media query
61
-
62
-
47
+ }
48
+ // Lazily initialize media query
63
49
  if (reducedMotionQuery == null) {
64
50
  // @ts-ignore
65
51
  reducedMotionQuery = _l7Utils.$window.matchMedia('(prefers-reduced-motion: reduce)');
66
52
  }
67
-
68
53
  return reducedMotionQuery.matches;
69
54
  }
70
-
71
55
  function pick(src, properties) {
72
56
  var result = {};
73
-
74
57
  var _iterator = _createForOfIteratorHelper(properties),
75
- _step;
76
-
58
+ _step;
77
59
  try {
78
60
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
79
61
  var name = _step.value;
80
-
81
62
  if (name in src) {
82
63
  result[name] = src[name];
83
64
  }
@@ -87,25 +68,26 @@ function pick(src, properties) {
87
68
  } finally {
88
69
  _iterator.f();
89
70
  }
90
-
91
71
  return result;
92
72
  }
93
-
94
73
  var now = _l7Utils.isMini ? Date.now.bind(Date) : _l7Utils.$window.performance && _l7Utils.$window.performance.now ? _l7Utils.$window.performance.now.bind(_l7Utils.$window.performance) : Date.now.bind(Date);
95
74
  exports.now = now;
96
- var raf = _l7Utils.$window.requestAnimationFrame || // @ts-ignore
97
- _l7Utils.$window.mozRequestAnimationFrame || // @ts-ignore
98
- _l7Utils.$window.webkitRequestAnimationFrame || // @ts-ignore
75
+ var raf = _l7Utils.$window.requestAnimationFrame ||
76
+ // @ts-ignore
77
+ _l7Utils.$window.mozRequestAnimationFrame ||
78
+ // @ts-ignore
79
+ _l7Utils.$window.webkitRequestAnimationFrame ||
80
+ // @ts-ignore
99
81
  _l7Utils.$window.msRequestAnimationFrame;
100
82
  exports.raf = raf;
101
-
102
- var _cancel = _l7Utils.$window.cancelAnimationFrame || // @ts-ignore
103
- _l7Utils.$window.mozCancelAnimationFrame || // @ts-ignore
104
- _l7Utils.$window.webkitCancelAnimationFrame || // @ts-ignore
83
+ var _cancel = _l7Utils.$window.cancelAnimationFrame ||
84
+ // @ts-ignore
85
+ _l7Utils.$window.mozCancelAnimationFrame ||
86
+ // @ts-ignore
87
+ _l7Utils.$window.webkitCancelAnimationFrame ||
88
+ // @ts-ignore
105
89
  _l7Utils.$window.msCancelAnimationFrame;
106
-
107
90
  exports.cancel = _cancel;
108
-
109
91
  function renderframe(fn) {
110
92
  var frame = raf(fn);
111
93
  return {
package/lib/utils/Aabb.js CHANGED
@@ -1,24 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
10
  var _glMatrix = require("gl-matrix");
15
-
16
11
  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; } } }; }
17
-
18
12
  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); }
19
-
20
- 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; }
21
-
13
+ 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; }
22
14
  var Aabb = /*#__PURE__*/function () {
23
15
  function Aabb(min, max) {
24
16
  (0, _classCallCheck2.default)(this, Aabb);
@@ -26,22 +18,17 @@ var Aabb = /*#__PURE__*/function () {
26
18
  this.max = max;
27
19
  this.center = _glMatrix.vec3.scale(new Float32Array(3), _glMatrix.vec3.add(new Float32Array(3), this.min, this.max), 0.5);
28
20
  }
29
-
30
21
  (0, _createClass2.default)(Aabb, [{
31
22
  key: "quadrant",
32
23
  value: function quadrant(index) {
33
24
  var split = [index % 2 === 0, index < 2];
34
-
35
25
  var qMin = _glMatrix.vec3.clone(this.min);
36
-
37
26
  var qMax = _glMatrix.vec3.clone(this.max);
38
-
39
27
  for (var axis = 0; axis < split.length; axis++) {
40
28
  qMin[axis] = split[axis] ? this.min[axis] : this.center[axis];
41
29
  qMax[axis] = split[axis] ? this.center[axis] : this.max[axis];
42
- } // Elevation is always constant, hence quadrant.max.z = this.max.z
43
-
44
-
30
+ }
31
+ // Elevation is always constant, hence quadrant.max.z = this.max.z
45
32
  qMax[2] = this.max[2];
46
33
  return new Aabb(qMin, qMax);
47
34
  }
@@ -56,29 +43,27 @@ var Aabb = /*#__PURE__*/function () {
56
43
  value: function distanceY(point) {
57
44
  var pointOnAabb = Math.max(Math.min(this.max[1], point[1]), this.min[1]);
58
45
  return pointOnAabb - point[1];
59
- } // Performs a frustum-aabb intersection test. Returns 0 if there's no intersection,
60
- // 1 if shapes are intersecting and 2 if the aabb if fully inside the frustum.
46
+ }
61
47
 
48
+ // Performs a frustum-aabb intersection test. Returns 0 if there's no intersection,
49
+ // 1 if shapes are intersecting and 2 if the aabb if fully inside the frustum.
62
50
  }, {
63
51
  key: "intersects",
64
52
  value: function intersects(frustum) {
65
53
  // Execute separating axis test between two convex objects to find intersections
66
54
  // Each frustum plane together with 3 major axes define the separating axes
67
55
  // Note: test only 4 points as both min and max points have equal elevation
56
+
68
57
  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]];
69
58
  var fullyInside = true;
70
-
71
59
  var _iterator = _createForOfIteratorHelper(frustum.planes),
72
- _step;
73
-
60
+ _step;
74
61
  try {
75
62
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
76
63
  var plane = _step.value;
77
64
  var pointsInside = 0;
78
-
79
65
  var _iterator3 = _createForOfIteratorHelper(aabbPoints),
80
- _step3;
81
-
66
+ _step3;
82
67
  try {
83
68
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
84
69
  var i = _step3.value;
@@ -90,11 +75,9 @@ var Aabb = /*#__PURE__*/function () {
90
75
  } finally {
91
76
  _iterator3.f();
92
77
  }
93
-
94
78
  if (pointsInside === 0) {
95
79
  return 0;
96
80
  }
97
-
98
81
  if (pointsInside !== aabbPoints.length) {
99
82
  fullyInside = false;
100
83
  }
@@ -104,18 +87,14 @@ var Aabb = /*#__PURE__*/function () {
104
87
  } finally {
105
88
  _iterator.f();
106
89
  }
107
-
108
90
  if (fullyInside) {
109
91
  return 2;
110
92
  }
111
-
112
93
  for (var axis = 0; axis < 3; axis++) {
113
94
  var projMin = Number.MAX_VALUE;
114
95
  var projMax = -Number.MAX_VALUE;
115
-
116
96
  var _iterator2 = _createForOfIteratorHelper(frustum.points),
117
- _step2;
118
-
97
+ _step2;
119
98
  try {
120
99
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
121
100
  var p = _step2.value;
@@ -128,16 +107,13 @@ var Aabb = /*#__PURE__*/function () {
128
107
  } finally {
129
108
  _iterator2.f();
130
109
  }
131
-
132
110
  if (projMax < 0 || projMin > this.max[axis] - this.min[axis]) {
133
111
  return 0;
134
112
  }
135
113
  }
136
-
137
114
  return 1;
138
115
  }
139
116
  }]);
140
117
  return Aabb;
141
118
  }();
142
-
143
119
  exports.default = Aabb;