@antv/l7-map 2.9.21 → 2.9.22-alpha.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.
Files changed (223) hide show
  1. package/es/camera.js +115 -85
  2. package/es/css/l7.css +98 -0
  3. package/es/earthmap.js +27 -43
  4. package/es/geo/edge_insets.js +44 -14
  5. package/es/geo/lng_lat.js +15 -11
  6. package/es/geo/lng_lat_bounds.js +6 -10
  7. package/es/geo/mercator.js +24 -12
  8. package/es/geo/point.js +2 -8
  9. package/es/geo/simple.js +24 -12
  10. package/es/geo/transform.js +421 -120
  11. package/es/handler/IHandler.js +1 -2
  12. package/es/handler/blockable_map_event.js +13 -14
  13. package/es/handler/box_zoom.js +43 -27
  14. package/es/handler/click_zoom.js +3 -8
  15. package/es/handler/events/event.js +3 -6
  16. package/es/handler/events/index.js +4 -5
  17. package/es/handler/events/map_mouse_event.js +30 -20
  18. package/es/handler/events/map_touch_event.js +55 -25
  19. package/es/handler/events/map_wheel_event.js +24 -15
  20. package/es/handler/events/render_event.js +3 -6
  21. package/es/handler/handler_inertia.js +10 -12
  22. package/es/handler/handler_manager.js +75 -72
  23. package/es/handler/handler_util.js +2 -2
  24. package/es/handler/keyboard.js +20 -15
  25. package/es/handler/map_event.js +23 -12
  26. package/es/handler/mouse/index.js +4 -5
  27. package/es/handler/mouse/mouse_handler.js +17 -21
  28. package/es/handler/mouse/mousepan_handler.js +5 -5
  29. package/es/handler/mouse/mousepitch_hander.js +7 -5
  30. package/es/handler/mouse/mouserotate_hander.js +7 -5
  31. package/es/handler/mouse/util.js +3 -3
  32. package/es/handler/scroll_zoom.js +103 -67
  33. package/es/handler/shim/dblclick_zoom.js +35 -8
  34. package/es/handler/shim/drag_pan.js +48 -12
  35. package/es/handler/shim/drag_rotate.js +39 -10
  36. package/es/handler/shim/touch_zoom_rotate.js +59 -16
  37. package/es/handler/tap/single_tap_recognizer.js +7 -17
  38. package/es/handler/tap/tap_drag_zoom.js +5 -18
  39. package/es/handler/tap/tap_recognizer.js +4 -15
  40. package/es/handler/tap/tap_zoom.js +4 -13
  41. package/es/handler/touch/index.js +5 -6
  42. package/es/handler/touch/touch_pan.js +9 -20
  43. package/es/handler/touch/touch_pitch.js +11 -23
  44. package/es/handler/touch/touch_rotate.js +15 -18
  45. package/es/handler/touch/touch_zoom.js +5 -19
  46. package/es/handler/touch/two_touch.js +14 -21
  47. package/es/hash.js +28 -16
  48. package/es/index.js +2 -3
  49. package/es/interface.js +1 -2
  50. package/es/map.js +26 -47
  51. package/es/util.js +15 -6
  52. package/es/utils/Aabb.js +11 -12
  53. package/es/utils/dom.js +30 -11
  54. package/es/utils/performance.js +10 -6
  55. package/es/utils/primitives.js +11 -10
  56. package/es/utils/task_queue.js +6 -13
  57. package/lib/camera.js +508 -721
  58. package/lib/css/l7.css +98 -0
  59. package/lib/earthmap.js +222 -392
  60. package/lib/geo/edge_insets.js +64 -83
  61. package/lib/geo/lng_lat.js +65 -81
  62. package/lib/geo/lng_lat_bounds.js +124 -165
  63. package/lib/geo/mercator.js +62 -78
  64. package/lib/geo/point.js +171 -239
  65. package/lib/geo/simple.js +61 -80
  66. package/lib/geo/transform.js +470 -653
  67. package/lib/handler/IHandler.js +17 -2
  68. package/lib/handler/blockable_map_event.js +63 -83
  69. package/lib/handler/box_zoom.js +123 -176
  70. package/lib/handler/click_zoom.js +56 -68
  71. package/lib/handler/events/event.js +35 -23
  72. package/lib/handler/events/index.js +35 -29
  73. package/lib/handler/events/map_mouse_event.js +42 -72
  74. package/lib/handler/events/map_touch_event.js +45 -80
  75. package/lib/handler/events/map_wheel_event.js +34 -58
  76. package/lib/handler/events/render_event.js +31 -52
  77. package/lib/handler/handler_inertia.js +113 -160
  78. package/lib/handler/handler_manager.js +379 -620
  79. package/lib/handler/handler_util.js +28 -10
  80. package/lib/handler/keyboard.js +114 -146
  81. package/lib/handler/map_event.js +84 -120
  82. package/lib/handler/mouse/index.js +35 -29
  83. package/lib/handler/mouse/mouse_handler.js +90 -123
  84. package/lib/handler/mouse/mousepan_handler.js +46 -65
  85. package/lib/handler/mouse/mousepitch_hander.js +44 -63
  86. package/lib/handler/mouse/mouserotate_hander.js +44 -63
  87. package/lib/handler/mouse/util.js +38 -20
  88. package/lib/handler/scroll_zoom.js +175 -258
  89. package/lib/handler/shim/dblclick_zoom.js +42 -48
  90. package/lib/handler/shim/drag_pan.js +48 -59
  91. package/lib/handler/shim/drag_rotate.js +43 -51
  92. package/lib/handler/shim/touch_zoom_rotate.js +58 -78
  93. package/lib/handler/tap/single_tap_recognizer.js +84 -117
  94. package/lib/handler/tap/tap_drag_zoom.js +92 -115
  95. package/lib/handler/tap/tap_recognizer.js +60 -78
  96. package/lib/handler/tap/tap_zoom.js +88 -119
  97. package/lib/handler/touch/index.js +38 -37
  98. package/lib/handler/touch/touch_pan.js +98 -132
  99. package/lib/handler/touch/touch_pitch.js +73 -117
  100. package/lib/handler/touch/touch_rotate.js +58 -94
  101. package/lib/handler/touch/touch_zoom.js +49 -84
  102. package/lib/handler/touch/two_touch.js +88 -128
  103. package/lib/hash.js +100 -133
  104. package/lib/index.js +19 -31
  105. package/lib/interface.js +17 -2
  106. package/lib/map.js +238 -420
  107. package/lib/util.js +67 -78
  108. package/lib/utils/Aabb.js +80 -132
  109. package/lib/utils/dom.js +84 -141
  110. package/lib/utils/performance.js +54 -42
  111. package/lib/utils/primitives.js +59 -51
  112. package/lib/utils/task_queue.js +61 -108
  113. package/package.json +11 -8
  114. package/es/camera.js.map +0 -1
  115. package/es/earthmap.js.map +0 -1
  116. package/es/geo/edge_insets.js.map +0 -1
  117. package/es/geo/lng_lat.js.map +0 -1
  118. package/es/geo/lng_lat_bounds.js.map +0 -1
  119. package/es/geo/mercator.js.map +0 -1
  120. package/es/geo/point.js.map +0 -1
  121. package/es/geo/simple.js.map +0 -1
  122. package/es/geo/transform.js.map +0 -1
  123. package/es/handler/IHandler.js.map +0 -1
  124. package/es/handler/blockable_map_event.js.map +0 -1
  125. package/es/handler/box_zoom.js.map +0 -1
  126. package/es/handler/click_zoom.js.map +0 -1
  127. package/es/handler/events/event.js.map +0 -1
  128. package/es/handler/events/index.js.map +0 -1
  129. package/es/handler/events/map_mouse_event.js.map +0 -1
  130. package/es/handler/events/map_touch_event.js.map +0 -1
  131. package/es/handler/events/map_wheel_event.js.map +0 -1
  132. package/es/handler/events/render_event.js.map +0 -1
  133. package/es/handler/handler_inertia.js.map +0 -1
  134. package/es/handler/handler_manager.js.map +0 -1
  135. package/es/handler/handler_util.js.map +0 -1
  136. package/es/handler/keyboard.js.map +0 -1
  137. package/es/handler/map_event.js.map +0 -1
  138. package/es/handler/mouse/index.js.map +0 -1
  139. package/es/handler/mouse/mouse_handler.js.map +0 -1
  140. package/es/handler/mouse/mousepan_handler.js.map +0 -1
  141. package/es/handler/mouse/mousepitch_hander.js.map +0 -1
  142. package/es/handler/mouse/mouserotate_hander.js.map +0 -1
  143. package/es/handler/mouse/util.js.map +0 -1
  144. package/es/handler/scroll_zoom.js.map +0 -1
  145. package/es/handler/shim/dblclick_zoom.js.map +0 -1
  146. package/es/handler/shim/drag_pan.js.map +0 -1
  147. package/es/handler/shim/drag_rotate.js.map +0 -1
  148. package/es/handler/shim/touch_zoom_rotate.js.map +0 -1
  149. package/es/handler/tap/single_tap_recognizer.js.map +0 -1
  150. package/es/handler/tap/tap_drag_zoom.js.map +0 -1
  151. package/es/handler/tap/tap_recognizer.js.map +0 -1
  152. package/es/handler/tap/tap_zoom.js.map +0 -1
  153. package/es/handler/touch/index.js.map +0 -1
  154. package/es/handler/touch/touch_pan.js.map +0 -1
  155. package/es/handler/touch/touch_pitch.js.map +0 -1
  156. package/es/handler/touch/touch_rotate.js.map +0 -1
  157. package/es/handler/touch/touch_zoom.js.map +0 -1
  158. package/es/handler/touch/two_touch.js.map +0 -1
  159. package/es/hash.js.map +0 -1
  160. package/es/index.js.map +0 -1
  161. package/es/interface.js.map +0 -1
  162. package/es/map.js.map +0 -1
  163. package/es/util.js.map +0 -1
  164. package/es/utils/Aabb.js.map +0 -1
  165. package/es/utils/dom.js.map +0 -1
  166. package/es/utils/performance.js.map +0 -1
  167. package/es/utils/primitives.js.map +0 -1
  168. package/es/utils/task_queue.js.map +0 -1
  169. package/lib/camera.js.map +0 -1
  170. package/lib/earthmap.js.map +0 -1
  171. package/lib/geo/edge_insets.js.map +0 -1
  172. package/lib/geo/lng_lat.js.map +0 -1
  173. package/lib/geo/lng_lat_bounds.js.map +0 -1
  174. package/lib/geo/mercator.js.map +0 -1
  175. package/lib/geo/point.js.map +0 -1
  176. package/lib/geo/simple.js.map +0 -1
  177. package/lib/geo/transform.js.map +0 -1
  178. package/lib/handler/IHandler.js.map +0 -1
  179. package/lib/handler/blockable_map_event.js.map +0 -1
  180. package/lib/handler/box_zoom.js.map +0 -1
  181. package/lib/handler/click_zoom.js.map +0 -1
  182. package/lib/handler/events/event.js.map +0 -1
  183. package/lib/handler/events/index.js.map +0 -1
  184. package/lib/handler/events/map_mouse_event.js.map +0 -1
  185. package/lib/handler/events/map_touch_event.js.map +0 -1
  186. package/lib/handler/events/map_wheel_event.js.map +0 -1
  187. package/lib/handler/events/render_event.js.map +0 -1
  188. package/lib/handler/handler_inertia.js.map +0 -1
  189. package/lib/handler/handler_manager.js.map +0 -1
  190. package/lib/handler/handler_util.js.map +0 -1
  191. package/lib/handler/keyboard.js.map +0 -1
  192. package/lib/handler/map_event.js.map +0 -1
  193. package/lib/handler/mouse/index.js.map +0 -1
  194. package/lib/handler/mouse/mouse_handler.js.map +0 -1
  195. package/lib/handler/mouse/mousepan_handler.js.map +0 -1
  196. package/lib/handler/mouse/mousepitch_hander.js.map +0 -1
  197. package/lib/handler/mouse/mouserotate_hander.js.map +0 -1
  198. package/lib/handler/mouse/util.js.map +0 -1
  199. package/lib/handler/scroll_zoom.js.map +0 -1
  200. package/lib/handler/shim/dblclick_zoom.js.map +0 -1
  201. package/lib/handler/shim/drag_pan.js.map +0 -1
  202. package/lib/handler/shim/drag_rotate.js.map +0 -1
  203. package/lib/handler/shim/touch_zoom_rotate.js.map +0 -1
  204. package/lib/handler/tap/single_tap_recognizer.js.map +0 -1
  205. package/lib/handler/tap/tap_drag_zoom.js.map +0 -1
  206. package/lib/handler/tap/tap_recognizer.js.map +0 -1
  207. package/lib/handler/tap/tap_zoom.js.map +0 -1
  208. package/lib/handler/touch/index.js.map +0 -1
  209. package/lib/handler/touch/touch_pan.js.map +0 -1
  210. package/lib/handler/touch/touch_pitch.js.map +0 -1
  211. package/lib/handler/touch/touch_rotate.js.map +0 -1
  212. package/lib/handler/touch/touch_zoom.js.map +0 -1
  213. package/lib/handler/touch/two_touch.js.map +0 -1
  214. package/lib/hash.js.map +0 -1
  215. package/lib/index.js.map +0 -1
  216. package/lib/interface.js.map +0 -1
  217. package/lib/map.js.map +0 -1
  218. package/lib/util.js.map +0 -1
  219. package/lib/utils/Aabb.js.map +0 -1
  220. package/lib/utils/dom.js.map +0 -1
  221. package/lib/utils/performance.js.map +0 -1
  222. package/lib/utils/primitives.js.map +0 -1
  223. package/lib/utils/task_queue.js.map +0 -1
package/es/map.js CHANGED
@@ -5,14 +5,14 @@ import _inherits from "@babel/runtime/helpers/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- import _merge from "lodash/merge";
9
8
 
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
10
 
12
11
  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
12
 
14
13
  import { $window, DOM, isMini } from '@antv/l7-utils';
15
- import Camera from './camera';
14
+ import { merge } from 'lodash';
15
+ import Camera from "./camera";
16
16
 
17
17
  function loadStyles(css, doc) {
18
18
  var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
@@ -55,16 +55,18 @@ function loadStyles(css, doc) {
55
55
  }
56
56
 
57
57
  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");
58
- import LngLat from './geo/lng_lat';
59
- import LngLatBounds from './geo/lng_lat_bounds';
60
- import Point from './geo/point';
61
- import HandlerManager from './handler/handler_manager';
62
- import Hash from './hash';
63
- import { renderframe } from './util';
64
- import { PerformanceUtils } from './utils/performance';
65
- import TaskQueue from './utils/task_queue';
58
+ import LngLat from "./geo/lng_lat";
59
+ import LngLatBounds from "./geo/lng_lat_bounds"; // @ts-ignore
60
+
61
+ import Point from "./geo/point";
62
+ import HandlerManager from "./handler/handler_manager";
63
+ import Hash from "./hash";
64
+ import { renderframe } from "./util";
65
+ import { PerformanceUtils } from "./utils/performance";
66
+ import TaskQueue from "./utils/task_queue";
66
67
  var defaultMinZoom = -2;
67
- var defaultMaxZoom = 22;
68
+ var defaultMaxZoom = 22; // the default values, but also the valid range
69
+
68
70
  var defaultMinPitch = 0;
69
71
  var defaultMaxPitch = 60;
70
72
  var DefaultOptions = {
@@ -94,7 +96,7 @@ var DefaultOptions = {
94
96
  pitchEnabled: true,
95
97
  rotateEnabled: true
96
98
  };
97
- export var Map = function (_Camera) {
99
+ export var Map = /*#__PURE__*/function (_Camera) {
98
100
  _inherits(Map, _Camera);
99
101
 
100
102
  var _super = _createSuper(Map);
@@ -104,40 +106,12 @@ export var Map = function (_Camera) {
104
106
 
105
107
  _classCallCheck(this, Map);
106
108
 
107
- _this = _super.call(this, _merge({}, DefaultOptions, options));
108
-
109
- _defineProperty(_assertThisInitialized(_this), "doubleClickZoom", void 0);
110
-
111
- _defineProperty(_assertThisInitialized(_this), "dragRotate", void 0);
112
-
113
- _defineProperty(_assertThisInitialized(_this), "dragPan", void 0);
114
-
115
- _defineProperty(_assertThisInitialized(_this), "touchZoomRotate", void 0);
116
-
117
- _defineProperty(_assertThisInitialized(_this), "scrollZoom", void 0);
118
-
119
- _defineProperty(_assertThisInitialized(_this), "keyboard", void 0);
120
-
121
- _defineProperty(_assertThisInitialized(_this), "touchPitch", void 0);
122
-
123
- _defineProperty(_assertThisInitialized(_this), "boxZoom", void 0);
124
-
125
- _defineProperty(_assertThisInitialized(_this), "handlers", void 0);
126
-
127
- _defineProperty(_assertThisInitialized(_this), "container", void 0);
128
-
129
- _defineProperty(_assertThisInitialized(_this), "canvas", void 0);
130
-
131
- _defineProperty(_assertThisInitialized(_this), "canvasContainer", void 0);
109
+ _this = _super.call(this, merge({}, DefaultOptions, options));
132
110
 
133
111
  _defineProperty(_assertThisInitialized(_this), "renderTaskQueue", new TaskQueue());
134
112
 
135
- _defineProperty(_assertThisInitialized(_this), "frame", void 0);
136
-
137
113
  _defineProperty(_assertThisInitialized(_this), "trackResize", true);
138
114
 
139
- _defineProperty(_assertThisInitialized(_this), "hash", void 0);
140
-
141
115
  _defineProperty(_assertThisInitialized(_this), "onWindowOnline", function () {
142
116
  _this.update();
143
117
  });
@@ -172,7 +146,8 @@ export var Map = function (_Camera) {
172
146
  if (options.hash) {
173
147
  _this.hash = new Hash(hashName).addTo(_assertThisInitialized(_this));
174
148
  }
175
- }
149
+ } // don't set position from options if set through hash
150
+
176
151
 
177
152
  if (!_this.hash || !_this.hash.onHashChange()) {
178
153
  _this.jumpTo({
@@ -185,7 +160,7 @@ export var Map = function (_Camera) {
185
160
  if (options.bounds) {
186
161
  _this.resize();
187
162
 
188
- _this.fitBounds(options.bounds, _merge({}, options.fitBoundsOptions, {
163
+ _this.fitBounds(options.bounds, merge({}, options.fitBoundsOptions, {
189
164
  duration: 0
190
165
  }));
191
166
  }
@@ -200,7 +175,7 @@ export var Map = function (_Camera) {
200
175
  var dimensions = this.containerDimensions();
201
176
  var width = dimensions[0];
202
177
  var height = dimensions[1];
203
- this.transform.resize(width, height);
178
+ this.transform.resize(width, height); // TODO: 小程序环境不需要执行后续动作
204
179
 
205
180
  if (isMini) {
206
181
  return this;
@@ -376,7 +351,8 @@ export var Map = function (_Camera) {
376
351
  }, {
377
352
  key: "remove",
378
353
  value: function remove() {
379
- this.container.removeChild(this.canvasContainer);
354
+ this.container.removeChild(this.canvasContainer); // @ts-ignore
355
+
380
356
  this.canvasContainer = null;
381
357
 
382
358
  if (this.frame) {
@@ -448,6 +424,10 @@ export var Map = function (_Camera) {
448
424
  canvasContainer.classList.add('l7-interactive');
449
425
  }
450
426
  }
427
+ /**
428
+ * 小程序环境构建容器
429
+ */
430
+
451
431
  }, {
452
432
  key: "initMiniContainer",
453
433
  value: function initMiniContainer() {
@@ -475,5 +455,4 @@ export var Map = function (_Camera) {
475
455
  }]);
476
456
 
477
457
  return Map;
478
- }(Camera);
479
- //# sourceMappingURL=map.js.map
458
+ }(Camera);
package/es/util.js CHANGED
@@ -4,7 +4,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
 
5
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; }
6
6
 
7
- import { $window, isMini } from '@antv/l7-utils';
7
+ import { $window, isMini } from '@antv/l7-utils'; // @ts-ignore
8
+
8
9
  import UnitBezier from '@mapbox/unitbezier';
9
10
  var reducedMotionQuery;
10
11
  export function wrap(n, min, max) {
@@ -26,11 +27,14 @@ export function bezier(p1x, p1y, p2x, p2y) {
26
27
  }
27
28
  export var ease = bezier(0.25, 0.1, 0.25, 1);
28
29
  export function prefersReducedMotion() {
30
+ // @ts-ignore
29
31
  if (isMini || !$window.matchMedia) {
30
32
  return false;
31
- }
33
+ } // Lazily initialize media query
34
+
32
35
 
33
36
  if (reducedMotionQuery == null) {
37
+ // @ts-ignore
34
38
  reducedMotionQuery = $window.matchMedia('(prefers-reduced-motion: reduce)');
35
39
  }
36
40
 
@@ -59,9 +63,15 @@ export function pick(src, properties) {
59
63
  return result;
60
64
  }
61
65
  export var now = isMini ? Date.now.bind(Date) : $window.performance && $window.performance.now ? $window.performance.now.bind($window.performance) : Date.now.bind(Date);
62
- export var raf = $window.requestAnimationFrame || $window.mozRequestAnimationFrame || $window.webkitRequestAnimationFrame || $window.msRequestAnimationFrame;
66
+ export var raf = $window.requestAnimationFrame || // @ts-ignore
67
+ $window.mozRequestAnimationFrame || // @ts-ignore
68
+ $window.webkitRequestAnimationFrame || // @ts-ignore
69
+ $window.msRequestAnimationFrame;
63
70
 
64
- var _cancel = $window.cancelAnimationFrame || $window.mozCancelAnimationFrame || $window.webkitCancelAnimationFrame || $window.msCancelAnimationFrame;
71
+ var _cancel = $window.cancelAnimationFrame || // @ts-ignore
72
+ $window.mozCancelAnimationFrame || // @ts-ignore
73
+ $window.webkitCancelAnimationFrame || // @ts-ignore
74
+ $window.msCancelAnimationFrame;
65
75
 
66
76
  export { _cancel as cancel };
67
77
  export function renderframe(fn) {
@@ -71,5 +81,4 @@ export function renderframe(fn) {
71
81
  return _cancel(frame);
72
82
  }
73
83
  };
74
- }
75
- //# sourceMappingURL=util.js.map
84
+ }
package/es/utils/Aabb.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
3
 
5
4
  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; } } }; }
6
5
 
@@ -10,16 +9,10 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
10
9
 
11
10
  import { vec3, vec4 } from 'gl-matrix';
12
11
 
13
- var Aabb = function () {
12
+ var Aabb = /*#__PURE__*/function () {
14
13
  function Aabb(min, max) {
15
14
  _classCallCheck(this, Aabb);
16
15
 
17
- _defineProperty(this, "min", void 0);
18
-
19
- _defineProperty(this, "max", void 0);
20
-
21
- _defineProperty(this, "center", void 0);
22
-
23
16
  this.min = min;
24
17
  this.max = max;
25
18
  this.center = vec3.scale(new Float32Array(3), vec3.add(new Float32Array(3), this.min, this.max), 0.5);
@@ -35,7 +28,8 @@ var Aabb = function () {
35
28
  for (var axis = 0; axis < split.length; axis++) {
36
29
  qMin[axis] = split[axis] ? this.min[axis] : this.center[axis];
37
30
  qMax[axis] = split[axis] ? this.center[axis] : this.max[axis];
38
- }
31
+ } // Elevation is always constant, hence quadrant.max.z = this.max.z
32
+
39
33
 
40
34
  qMax[2] = this.max[2];
41
35
  return new Aabb(qMin, qMax);
@@ -51,10 +45,15 @@ var Aabb = function () {
51
45
  value: function distanceY(point) {
52
46
  var pointOnAabb = Math.max(Math.min(this.max[1], point[1]), this.min[1]);
53
47
  return pointOnAabb - point[1];
54
- }
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.
50
+
55
51
  }, {
56
52
  key: "intersects",
57
53
  value: function intersects(frustum) {
54
+ // Execute separating axis test between two convex objects to find intersections
55
+ // Each frustum plane together with 3 major axes define the separating axes
56
+ // Note: test only 4 points as both min and max points have equal elevation
58
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]];
59
58
  var fullyInside = true;
60
59
 
@@ -72,6 +71,7 @@ var Aabb = function () {
72
71
  try {
73
72
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
74
73
  var i = _step3.value;
74
+ // @ts-ignore
75
75
  pointsInside += vec4.dot(plane, i) >= 0;
76
76
  }
77
77
  } catch (err) {
@@ -130,5 +130,4 @@ var Aabb = function () {
130
130
  return Aabb;
131
131
  }();
132
132
 
133
- export { Aabb as default };
134
- //# sourceMappingURL=Aabb.js.map
133
+ export { Aabb as default };
package/es/utils/dom.js CHANGED
@@ -4,8 +4,9 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
 
5
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; }
6
6
 
7
- import { $window, isMini } from '@antv/l7-utils';
8
- import Point from '../geo/point';
7
+ import { $window, isMini } from '@antv/l7-utils'; // @ts-ignore
8
+
9
+ import Point from "../geo/point";
9
10
  var DOM = {};
10
11
  export default DOM;
11
12
 
@@ -74,18 +75,26 @@ DOM.enableDrag = function () {
74
75
  var transformProp = testProp(['transform', 'WebkitTransform']);
75
76
 
76
77
  DOM.setTransform = function (el, value) {
78
+ // https://github.com/facebook/flow/issues/7754
79
+ // $FlowFixMe
77
80
  el.style[transformProp] = value;
78
- };
81
+ }; // Feature detection for {passive: false} support in add/removeEventListener.
82
+
79
83
 
80
84
  var passiveSupported = false;
81
85
 
82
86
  try {
87
+ // https://github.com/facebook/flow/issues/285
88
+ // $FlowFixMe
83
89
  var options = Object.defineProperty({}, 'passive', {
84
90
  get: function get() {
91
+ // eslint-disable-line
85
92
  passiveSupported = true;
86
93
  }
87
- });
88
- $window.addEventListener('test', options, options);
94
+ }); // @ts-ignore
95
+
96
+ $window.addEventListener('test', options, options); // @ts-ignore
97
+
89
98
  $window.removeEventListener('test', options, options);
90
99
  } catch (err) {
91
100
  passiveSupported = false;
@@ -109,7 +118,8 @@ DOM.removeEventListener = function (target, type, callback) {
109
118
  } else {
110
119
  target.removeEventListener(type, callback, options.capture);
111
120
  }
112
- };
121
+ }; // Suppress the next click, but only if it's immediate.
122
+
113
123
 
114
124
  var suppressClick = function suppressClick(e) {
115
125
  e.preventDefault();
@@ -129,15 +139,19 @@ DOM.suppressClick = function () {
129
139
  };
130
140
 
131
141
  DOM.mousePos = function (el, e) {
142
+ // 暂时从 el 上获取 top/left, 后面需要动态获取
132
143
  if (!isMini) {
133
144
  var rect = el.getBoundingClientRect();
134
145
  return new Point(e.clientX - rect.left - el.clientLeft, e.clientY - rect.top - el.clientTop);
135
146
  } else {
136
- return new Point(e.clientX - el.left - 0, e.clientY - el.top - 0);
147
+ return new Point( // @ts-ignore
148
+ e.clientX - el.left - 0, // @ts-ignore
149
+ e.clientY - el.top - 0);
137
150
  }
138
151
  };
139
152
 
140
153
  DOM.touchPos = function (el, touches) {
154
+ // 暂时从 el 上获取 top/left, 后面需要动态获取
141
155
  if (!isMini) {
142
156
  var rect = el.getBoundingClientRect();
143
157
  var points = [];
@@ -167,7 +181,9 @@ DOM.touchPos = function (el, touches) {
167
181
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
168
182
  var _touche = _step3.value;
169
183
 
170
- _points.push(new Point(_touche.clientX - el.left, _touche.clientY - el.top));
184
+ _points.push(new Point( // @ts-ignore
185
+ _touche.clientX - el.left, // @ts-ignore
186
+ _touche.clientY - el.top));
171
187
  }
172
188
  } catch (err) {
173
189
  _iterator3.e(err);
@@ -184,7 +200,11 @@ DOM.mouseButton = function (e) {
184
200
  return e.button;
185
201
  }
186
202
 
187
- if (typeof $window.InstallTrigger !== 'undefined' && e.button === 2 && e.ctrlKey && $window.navigator.platform.toUpperCase().indexOf('MAC') >= 0) {
203
+ if ( // @ts-ignore
204
+ typeof $window.InstallTrigger !== 'undefined' && e.button === 2 && e.ctrlKey && $window.navigator.platform.toUpperCase().indexOf('MAC') >= 0) {
205
+ // Fix for https://github.com/mapbox/mapbox-gl-js/issues/3131:
206
+ // Firefox (detected by InstallTrigger) on Mac determines e.button = 2 when
207
+ // using Control + left click
188
208
  return 0;
189
209
  }
190
210
 
@@ -195,5 +215,4 @@ DOM.remove = function (node) {
195
215
  if (node.parentNode) {
196
216
  node.parentNode.removeChild(node);
197
217
  }
198
- };
199
- //# sourceMappingURL=dom.js.map
218
+ };
@@ -27,20 +27,25 @@ export var PerformanceUtils = {
27
27
  lastFrameTime = null;
28
28
  frameTimes = [];
29
29
  performance.clearMeasures('loadTime');
30
- performance.clearMeasures('fullLoadTime');
30
+ performance.clearMeasures('fullLoadTime'); // @ts-ignore
31
+ // tslint:disable-next-line:forin
31
32
 
32
33
  for (var marker in PerformanceMarkers) {
34
+ // @ts-ignore
33
35
  performance.clearMarks(PerformanceMarkers[marker]);
34
36
  }
35
37
  },
36
38
  getPerformanceMetrics: function getPerformanceMetrics() {
37
- var loadTime = performance.measure('loadTime', PerformanceMarkers.create, PerformanceMarkers.load).duration;
38
- var fullLoadTime = performance.measure('fullLoadTime', PerformanceMarkers.create, PerformanceMarkers.fullLoad).duration;
39
+ var loadTime = performance.measure('loadTime', PerformanceMarkers.create, PerformanceMarkers.load // @ts-ignore
40
+ ).duration;
41
+ var fullLoadTime = performance.measure('fullLoadTime', PerformanceMarkers.create, PerformanceMarkers.fullLoad // @ts-ignore
42
+ ).duration;
39
43
  var totalFrames = frameTimes.length;
40
44
  var avgFrameTime = frameTimes.reduce(function (prev, curr) {
41
45
  return prev + curr;
42
46
  }, 0) / totalFrames / 1000;
43
- var fps = 1 / avgFrameTime;
47
+ var fps = 1 / avgFrameTime; // count frames that missed our framerate target
48
+
44
49
  var droppedFrames = frameTimes.filter(function (frameTime) {
45
50
  return frameTime > frameTimeTarget;
46
51
  }).reduce(function (acc, curr) {
@@ -54,5 +59,4 @@ export var PerformanceUtils = {
54
59
  percentDroppedFrames: percentDroppedFrames
55
60
  };
56
61
  }
57
- };
58
- //# sourceMappingURL=performance.js.map
62
+ };
@@ -1,16 +1,11 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
3
  import { vec3, vec4 } from 'gl-matrix';
5
4
 
6
- var Frustum = function () {
5
+ var Frustum = /*#__PURE__*/function () {
7
6
  function Frustum(points, planes) {
8
7
  _classCallCheck(this, Frustum);
9
8
 
10
- _defineProperty(this, "points", void 0);
11
-
12
- _defineProperty(this, "planes", void 0);
13
-
14
9
  this.points = points;
15
10
  this.planes = planes;
16
11
  }
@@ -19,13 +14,20 @@ var Frustum = function () {
19
14
  key: "fromInvProjectionMatrix",
20
15
  value: function fromInvProjectionMatrix(invProj, worldSize, zoom) {
21
16
  var clipSpaceCorners = [[-1, 1, -1, 1], [1, 1, -1, 1], [1, -1, -1, 1], [-1, -1, -1, 1], [-1, 1, 1, 1], [1, 1, 1, 1], [1, -1, 1, 1], [-1, -1, 1, 1]];
22
- var scale = Math.pow(2, zoom);
17
+ var scale = Math.pow(2, zoom); // Transform frustum corner points from clip space to tile space
18
+
23
19
  var frustumCoords = clipSpaceCorners.map(function (v) {
24
20
  return vec4.transformMat4(new Float32Array([]), v, invProj);
25
21
  }).map(function (v) {
26
22
  return vec4.scale(new Float32Array([]), v, 1.0 / v[3] / worldSize * scale);
27
23
  });
28
- var frustumPlanePointIndices = [[0, 1, 2], [6, 5, 4], [0, 3, 7], [2, 1, 5], [3, 2, 6], [0, 4, 5]];
24
+ var frustumPlanePointIndices = [[0, 1, 2], // near
25
+ [6, 5, 4], // far
26
+ [0, 3, 7], // left
27
+ [2, 1, 5], // right
28
+ [3, 2, 6], // bottom
29
+ [0, 4, 5] // top
30
+ ];
29
31
  var frustumPlanes = frustumPlanePointIndices.map(function (p) {
30
32
  var a = vec3.sub(new Float32Array(3), new Float32Array(frustumCoords[p[0]]), new Float32Array(frustumCoords[p[1]]));
31
33
  var b = vec3.sub(new Float32Array(3), new Float32Array(frustumCoords[p[2]]), new Float32Array(frustumCoords[p[1]]));
@@ -40,5 +42,4 @@ var Frustum = function () {
40
42
  return Frustum;
41
43
  }();
42
44
 
43
- export { Frustum as default };
44
- //# sourceMappingURL=primitives.js.map
45
+ export { Frustum as default };
@@ -1,6 +1,5 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
3
 
5
4
  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; } } }; }
6
5
 
@@ -8,18 +7,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
8
7
 
9
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; }
10
9
 
11
- var TaskQueue = function () {
10
+ // can't mark opaque due to https://github.com/flowtype/flow-remove-types/pull/61
11
+ var TaskQueue = /*#__PURE__*/function () {
12
12
  function TaskQueue() {
13
13
  _classCallCheck(this, TaskQueue);
14
14
 
15
- _defineProperty(this, "queue", void 0);
16
-
17
- _defineProperty(this, "id", void 0);
18
-
19
- _defineProperty(this, "cleared", void 0);
20
-
21
- _defineProperty(this, "currentlyRunning", void 0);
22
-
23
15
  this.queue = [];
24
16
  this.id = 0;
25
17
  this.cleared = false;
@@ -66,7 +58,9 @@ var TaskQueue = function () {
66
58
  key: "run",
67
59
  value: function run() {
68
60
  var timeStamp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
69
- var queue = this.currentlyRunning = this.queue;
61
+ var queue = this.currentlyRunning = this.queue; // Tasks queued by callbacks in the current queue should be executed
62
+ // on the next run, not the current run.
63
+
70
64
  this.queue = [];
71
65
 
72
66
  var _iterator2 = _createForOfIteratorHelper(queue),
@@ -109,5 +103,4 @@ var TaskQueue = function () {
109
103
  return TaskQueue;
110
104
  }();
111
105
 
112
- export default TaskQueue;
113
- //# sourceMappingURL=task_queue.js.map
106
+ export default TaskQueue;