@antv/l7-map 2.17.11 → 2.17.12

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 +148 -90
  2. package/es/earthmap.js +65 -13
  3. package/es/geo/edge_insets.js +14 -4
  4. package/es/geo/lng_lat.js +13 -5
  5. package/es/geo/lng_lat_bounds.js +17 -4
  6. package/es/geo/mercator.js +10 -2
  7. package/es/geo/point.js +7 -0
  8. package/es/geo/simple.js +11 -6
  9. package/es/geo/transform.js +132 -127
  10. package/es/handler/blockable_map_event.js +12 -7
  11. package/es/handler/box_zoom.js +30 -10
  12. package/es/handler/click_zoom.js +5 -0
  13. package/es/handler/events/event.js +2 -0
  14. package/es/handler/events/map_mouse_event.js +12 -0
  15. package/es/handler/events/map_touch_event.js +12 -2
  16. package/es/handler/events/map_wheel_event.js +12 -1
  17. package/es/handler/events/render_event.js +13 -0
  18. package/es/handler/handler_inertia.js +34 -6
  19. package/es/handler/handler_manager.js +147 -55
  20. package/es/handler/handler_util.js +2 -1
  21. package/es/handler/keyboard.js +20 -1
  22. package/es/handler/map_event.js +9 -3
  23. package/es/handler/mouse/mouse_handler.js +24 -11
  24. package/es/handler/mouse/mousepan_handler.js +11 -1
  25. package/es/handler/mouse/mousepitch_hander.js +11 -1
  26. package/es/handler/mouse/mouserotate_hander.js +11 -1
  27. package/es/handler/mouse/util.js +3 -2
  28. package/es/handler/scroll_zoom.js +71 -43
  29. package/es/handler/shim/dblclick_zoom.js +9 -4
  30. package/es/handler/shim/drag_pan.js +11 -4
  31. package/es/handler/shim/drag_rotate.js +10 -4
  32. package/es/handler/shim/touch_zoom_rotate.js +16 -6
  33. package/es/handler/tap/single_tap_recognizer.js +31 -8
  34. package/es/handler/tap/tap_drag_zoom.js +15 -7
  35. package/es/handler/tap/tap_recognizer.js +11 -3
  36. package/es/handler/tap/tap_zoom.js +7 -1
  37. package/es/handler/touch/touch_pan.js +22 -4
  38. package/es/handler/touch/touch_pitch.js +27 -10
  39. package/es/handler/touch/touch_rotate.js +19 -8
  40. package/es/handler/touch/touch_zoom.js +18 -5
  41. package/es/handler/touch/two_touch.js +32 -19
  42. package/es/hash.js +31 -9
  43. package/es/map.js +78 -16
  44. package/es/util.js +26 -18
  45. package/es/utils/Aabb.js +31 -10
  46. package/es/utils/dom.js +58 -24
  47. package/es/utils/performance.js +7 -8
  48. package/es/utils/primitives.js +11 -13
  49. package/es/utils/task_queue.js +23 -6
  50. package/lib/camera.js +169 -91
  51. package/lib/earthmap.js +80 -12
  52. package/lib/geo/edge_insets.js +18 -3
  53. package/lib/geo/lng_lat.js +18 -5
  54. package/lib/geo/lng_lat_bounds.js +20 -4
  55. package/lib/geo/mercator.js +22 -1
  56. package/lib/geo/point.js +8 -0
  57. package/lib/geo/simple.js +24 -5
  58. package/lib/geo/transform.js +164 -127
  59. package/lib/handler/blockable_map_event.js +14 -6
  60. package/lib/handler/box_zoom.js +39 -8
  61. package/lib/handler/click_zoom.js +6 -0
  62. package/lib/handler/events/event.js +5 -0
  63. package/lib/handler/events/index.js +4 -0
  64. package/lib/handler/events/map_mouse_event.js +20 -2
  65. package/lib/handler/events/map_touch_event.js +21 -2
  66. package/lib/handler/events/map_wheel_event.js +16 -1
  67. package/lib/handler/events/render_event.js +19 -0
  68. package/lib/handler/handler_inertia.js +37 -5
  69. package/lib/handler/handler_manager.js +171 -56
  70. package/lib/handler/handler_util.js +3 -1
  71. package/lib/handler/keyboard.js +22 -1
  72. package/lib/handler/map_event.js +11 -2
  73. package/lib/handler/mouse/index.js +4 -0
  74. package/lib/handler/mouse/mouse_handler.js +27 -10
  75. package/lib/handler/mouse/mousepan_handler.js +18 -1
  76. package/lib/handler/mouse/mousepitch_hander.js +17 -1
  77. package/lib/handler/mouse/mouserotate_hander.js +17 -1
  78. package/lib/handler/mouse/util.js +6 -2
  79. package/lib/handler/scroll_zoom.js +77 -43
  80. package/lib/handler/shim/dblclick_zoom.js +10 -4
  81. package/lib/handler/shim/drag_pan.js +13 -4
  82. package/lib/handler/shim/drag_rotate.js +11 -4
  83. package/lib/handler/shim/touch_zoom_rotate.js +18 -6
  84. package/lib/handler/tap/single_tap_recognizer.js +33 -8
  85. package/lib/handler/tap/tap_drag_zoom.js +18 -6
  86. package/lib/handler/tap/tap_recognizer.js +17 -2
  87. package/lib/handler/tap/tap_zoom.js +9 -0
  88. package/lib/handler/touch/index.js +5 -0
  89. package/lib/handler/touch/touch_pan.js +25 -4
  90. package/lib/handler/touch/touch_pitch.js +32 -10
  91. package/lib/handler/touch/touch_rotate.js +25 -8
  92. package/lib/handler/touch/touch_zoom.js +24 -5
  93. package/lib/handler/touch/two_touch.js +35 -18
  94. package/lib/hash.js +35 -8
  95. package/lib/index.js +8 -0
  96. package/lib/map.js +95 -15
  97. package/lib/util.js +38 -16
  98. package/lib/utils/Aabb.js +34 -10
  99. package/lib/utils/dom.js +64 -22
  100. package/lib/utils/performance.js +9 -8
  101. package/lib/utils/primitives.js +16 -13
  102. package/lib/utils/task_queue.js +24 -6
  103. package/package.json +3 -3
package/lib/earthmap.js CHANGED
@@ -1,64 +1,94 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.EarthMap = void 0;
9
+
8
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
9
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
10
14
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
11
16
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
12
18
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
13
20
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
14
22
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
+
15
24
  var _l7Utils = require("@antv/l7-utils");
25
+
16
26
  var _lodash = require("lodash");
27
+
17
28
  var _camera = _interopRequireDefault(require("./camera"));
29
+
18
30
  var _lng_lat = _interopRequireDefault(require("./geo/lng_lat"));
31
+
19
32
  var _lng_lat_bounds = _interopRequireDefault(require("./geo/lng_lat_bounds"));
33
+
20
34
  var _point = _interopRequireDefault(require("./geo/point"));
35
+
21
36
  var _handler_manager = _interopRequireDefault(require("./handler/handler_manager"));
37
+
22
38
  var _util = require("./util");
39
+
23
40
  var _performance = require("./utils/performance");
41
+
24
42
  var _task_queue = _interopRequireDefault(require("./utils/task_queue"));
43
+
25
44
  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); }; }
45
+
26
46
  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; } }
47
+
27
48
  function loadStyles(css, doc) {
28
49
  var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
29
50
  var isWeChatMiniProgram = typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
51
+
30
52
  if (isMiniAli || isWeChatMiniProgram) {
31
53
  return;
32
54
  }
55
+
33
56
  if (!doc) doc = document;
57
+
34
58
  if (!doc) {
35
59
  return;
36
60
  }
61
+
37
62
  var head = doc.head || doc.getElementsByTagName('head')[0];
63
+
38
64
  if (!head) {
39
65
  head = doc.createElement('head');
40
66
  var body = doc.body || doc.getElementsByTagName('body')[0];
67
+
41
68
  if (body) {
42
69
  body.parentNode.insertBefore(head, body);
43
70
  } else {
44
71
  doc.documentElement.appendChild(head);
45
72
  }
46
73
  }
74
+
47
75
  var style = doc.createElement('style');
48
76
  style.type = 'text/css';
77
+
49
78
  if (style.styleSheet) {
50
79
  style.styleSheet.cssText = css;
51
80
  } else {
52
81
  style.appendChild(doc.createTextNode(css));
53
82
  }
83
+
54
84
  head.appendChild(style);
55
85
  return style;
56
86
  }
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"); // @ts-ignore
87
+
88
+ 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
89
  var defaultMinZoom = -2;
59
- var defaultMaxZoom = 22;
90
+ var defaultMaxZoom = 22; // the default values, but also the valid range
60
91
 
61
- // the default values, but also the valid range
62
92
  var defaultMinPitch = 0;
63
93
  var defaultMaxPitch = 60;
64
94
  var DefaultOptions = {
@@ -88,11 +118,15 @@ var DefaultOptions = {
88
118
  pitchEnabled: true,
89
119
  rotateEnabled: true
90
120
  };
121
+
91
122
  var EarthMap = /*#__PURE__*/function (_Camera) {
92
123
  (0, _inherits2.default)(EarthMap, _Camera);
124
+
93
125
  var _super = _createSuper(EarthMap);
126
+
94
127
  function EarthMap(options) {
95
128
  var _this;
129
+
96
130
  (0, _classCallCheck2.default)(this, EarthMap);
97
131
  _this = _super.call(this, (0, _lodash.merge)({}, DefaultOptions, options));
98
132
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderTaskQueue", new _task_queue.default());
@@ -107,35 +141,44 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
107
141
  }).update();
108
142
  }
109
143
  });
144
+
110
145
  _this.initContainer();
146
+
111
147
  _this.resize();
148
+
112
149
  _this.handlers = new _handler_manager.default((0, _assertThisInitialized2.default)(_this), _this.options);
150
+
113
151
  if (typeof window !== 'undefined') {
114
152
  window.addEventListener('online', _this.onWindowOnline, false);
115
153
  window.addEventListener('resize', _this.onWindowResize, false);
116
154
  window.addEventListener('orientationchange', _this.onWindowResize, false);
117
155
  }
156
+
118
157
  return _this;
119
158
  }
159
+
120
160
  (0, _createClass2.default)(EarthMap, [{
121
161
  key: "resize",
122
162
  value: function resize(eventData) {
123
163
  var dimensions = this.containerDimensions();
124
164
  var width = dimensions[0];
125
- var height = dimensions[1];
165
+ var height = dimensions[1]; // this.resizeCanvas(width, height);
126
166
 
127
- // this.resizeCanvas(width, height);
128
167
  this.transform.resize(width, height);
129
168
  var fireMoving = !this.moving;
169
+
130
170
  if (fireMoving) {
131
171
  this.stop();
132
172
  this.emit('movestart', new Event('movestart', eventData));
133
173
  this.emit('move', new Event('move', eventData));
134
174
  }
175
+
135
176
  this.emit('resize', new Event('resize', eventData));
177
+
136
178
  if (fireMoving) {
137
179
  this.emit('moveend', new Event('moveend', eventData));
138
180
  }
181
+
139
182
  return this;
140
183
  }
141
184
  }, {
@@ -177,9 +220,8 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
177
220
  key: "setMaxBounds",
178
221
  value: function setMaxBounds(bounds) {
179
222
  this.transform.setMaxBounds(_lng_lat_bounds.default.convert(bounds));
180
- }
223
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
181
224
 
182
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
183
225
  }, {
184
226
  key: "setStyle",
185
227
  value: function setStyle(style) {
@@ -189,11 +231,14 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
189
231
  key: "setMinZoom",
190
232
  value: function setMinZoom(minZoom) {
191
233
  minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
234
+
192
235
  if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
193
236
  this.transform.minZoom = minZoom;
237
+
194
238
  if (this.getZoom() < minZoom) {
195
239
  this.setZoom(minZoom);
196
240
  }
241
+
197
242
  return this;
198
243
  } else {
199
244
  throw new Error("minZoom must be between ".concat(defaultMinZoom, " and the current maxZoom, inclusive"));
@@ -208,11 +253,14 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
208
253
  key: "setMaxZoom",
209
254
  value: function setMaxZoom(maxZoom) {
210
255
  maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
256
+
211
257
  if (maxZoom >= this.transform.minZoom) {
212
258
  this.transform.maxZoom = maxZoom;
259
+
213
260
  if (this.getZoom() > maxZoom) {
214
261
  this.setZoom(maxZoom);
215
262
  }
263
+
216
264
  return this;
217
265
  } else {
218
266
  throw new Error('maxZoom must be greater than the current minZoom');
@@ -227,14 +275,18 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
227
275
  key: "setMinPitch",
228
276
  value: function setMinPitch(minPitch) {
229
277
  minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
278
+
230
279
  if (minPitch < defaultMinPitch) {
231
280
  throw new Error("minPitch must be greater than or equal to ".concat(defaultMinPitch));
232
281
  }
282
+
233
283
  if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
234
284
  this.transform.minPitch = minPitch;
285
+
235
286
  if (this.getPitch() < minPitch) {
236
287
  this.setPitch(minPitch);
237
288
  }
289
+
238
290
  return this;
239
291
  } else {
240
292
  throw new Error("minPitch must be between ".concat(defaultMinPitch, " and the current maxPitch, inclusive"));
@@ -249,14 +301,18 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
249
301
  key: "setMaxPitch",
250
302
  value: function setMaxPitch(maxPitch) {
251
303
  maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
304
+
252
305
  if (maxPitch > defaultMaxPitch) {
253
306
  throw new Error("maxPitch must be less than or equal to ".concat(defaultMaxPitch));
254
307
  }
308
+
255
309
  if (maxPitch >= this.transform.minPitch) {
256
310
  this.transform.maxPitch = maxPitch;
311
+
257
312
  if (this.getPitch() > maxPitch) {
258
313
  this.setPitch(maxPitch);
259
314
  }
315
+
260
316
  return this;
261
317
  } else {
262
318
  throw new Error('maxPitch must be greater than the current minPitch');
@@ -284,6 +340,7 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
284
340
  this.frame.cancel();
285
341
  this.frame = null;
286
342
  }
343
+
287
344
  this.renderTaskQueue.clear();
288
345
  }
289
346
  }, {
@@ -301,10 +358,13 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
301
358
  key: "triggerRepaint",
302
359
  value: function triggerRepaint() {
303
360
  var _this2 = this;
361
+
304
362
  if (!this.frame) {
305
363
  this.frame = (0, _util.renderframe)(function (paintStartTimeStamp) {
306
364
  _performance.PerformanceUtils.frame(paintStartTimeStamp);
365
+
307
366
  _this2.frame = null;
367
+
308
368
  _this2.update(paintStartTimeStamp);
309
369
  });
310
370
  }
@@ -313,10 +373,13 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
313
373
  key: "update",
314
374
  value: function update(time) {
315
375
  var _this3 = this;
376
+
316
377
  if (!this.frame) {
317
378
  this.frame = (0, _util.renderframe)(function (paintStartTimeStamp) {
318
379
  _performance.PerformanceUtils.frame(paintStartTimeStamp);
380
+
319
381
  _this3.frame = null;
382
+
320
383
  _this3.renderTaskQueue.run(time);
321
384
  });
322
385
  }
@@ -326,6 +389,7 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
326
389
  value: function initContainer() {
327
390
  if (typeof this.options.container === 'string') {
328
391
  this.container = window.document.getElementById(this.options.container);
392
+
329
393
  if (!this.container) {
330
394
  throw new Error("Container '".concat(this.options.container, "' not found."));
331
395
  }
@@ -334,30 +398,34 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
334
398
  } else {
335
399
  throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
336
400
  }
401
+
337
402
  var container = this.container;
338
403
  container.classList.add('l7-map');
404
+
339
405
  var canvasContainer = this.canvasContainer = _l7Utils.DOM.create('div', 'l7-canvas-container', container);
406
+
340
407
  if (this.options.interactive) {
341
408
  canvasContainer.classList.add('l7-interactive');
342
- }
343
-
344
- // this.canvas = DOM.create(
409
+ } // this.canvas = DOM.create(
345
410
  // 'canvas',
346
411
  // 'l7-canvas',
347
412
  // canvasContainer,
348
413
  // ) as HTMLCanvasElement;
349
414
  // this.canvas.setAttribute('tabindex', '-');
350
415
  // this.canvas.setAttribute('aria-label', 'Map');
416
+
351
417
  }
352
418
  }, {
353
419
  key: "containerDimensions",
354
420
  value: function containerDimensions() {
355
421
  var width = 0;
356
422
  var height = 0;
423
+
357
424
  if (this.container) {
358
425
  width = this.container.clientWidth || 400;
359
426
  height = this.container.clientHeight || 300;
360
427
  }
428
+
361
429
  return [width, height];
362
430
  }
363
431
  }, {
@@ -365,13 +433,13 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
365
433
  value: function resizeCanvas(width, height) {
366
434
  var pixelRatio = _l7Utils.DOM.DPR || 1;
367
435
  this.canvas.width = pixelRatio * width;
368
- this.canvas.height = pixelRatio * height;
436
+ this.canvas.height = pixelRatio * height; // Maintain the same canvas size, potentially downscaling it for HiDPI displays
369
437
 
370
- // Maintain the same canvas size, potentially downscaling it for HiDPI displays
371
438
  this.canvas.style.width = "".concat(width, "px");
372
439
  this.canvas.style.height = "".concat(height, "px");
373
440
  }
374
441
  }]);
375
442
  return EarthMap;
376
443
  }(_camera.default);
444
+
377
445
  exports.EarthMap = EarthMap;
@@ -1,15 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
9
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
10
14
  var _util = require("../util");
15
+
11
16
  var _point = _interopRequireDefault(require("./point"));
17
+
12
18
  // @ts-ignore
19
+
13
20
  /**
14
21
  * An `EdgeInset` object represents screen space padding applied to the edges of the viewport.
15
22
  * This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements
@@ -27,15 +34,16 @@ var EdgeInsets = /*#__PURE__*/function () {
27
34
  var left = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
28
35
  var right = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
29
36
  (0, _classCallCheck2.default)(this, EdgeInsets);
37
+
30
38
  if (isNaN(top) || top < 0 || isNaN(bottom) || bottom < 0 || isNaN(left) || left < 0 || isNaN(right) || right < 0) {
31
39
  throw new Error('Invalid value for edge-insets, top, bottom, left and right must all be numbers');
32
40
  }
41
+
33
42
  this.top = top;
34
43
  this.bottom = bottom;
35
44
  this.left = left;
36
45
  this.right = right;
37
46
  }
38
-
39
47
  /**
40
48
  * Interpolates the inset in-place.
41
49
  * This maintains the current inset value for any inset not present in `target`.
@@ -45,24 +53,29 @@ var EdgeInsets = /*#__PURE__*/function () {
45
53
  * @returns {EdgeInsets}
46
54
  * @memberof EdgeInsets
47
55
  */
56
+
57
+
48
58
  (0, _createClass2.default)(EdgeInsets, [{
49
59
  key: "interpolate",
50
60
  value: function interpolate(start, target, t) {
51
61
  if (target.top != null && start.top != null) {
52
62
  this.top = (0, _util.interpolate)(start.top, target.top, t);
53
63
  }
64
+
54
65
  if (target.bottom != null && start.bottom != null) {
55
66
  this.bottom = (0, _util.interpolate)(start.bottom, target.bottom, t);
56
67
  }
68
+
57
69
  if (target.left != null && start.left != null) {
58
70
  this.left = (0, _util.interpolate)(start.left, target.left, t);
59
71
  }
72
+
60
73
  if (target.right != null && start.right != null) {
61
74
  this.right = (0, _util.interpolate)(start.right, target.right, t);
62
75
  }
76
+
63
77
  return this;
64
78
  }
65
-
66
79
  /**
67
80
  * Utility method that computes the new apprent center or vanishing point after applying insets.
68
81
  * This is in pixels and with the top left being (0.0) and +y being downwards.
@@ -72,6 +85,7 @@ var EdgeInsets = /*#__PURE__*/function () {
72
85
  * @returns {Point}
73
86
  * @memberof EdgeInsets
74
87
  */
88
+
75
89
  }, {
76
90
  key: "getCenter",
77
91
  value: function getCenter(width, height) {
@@ -90,7 +104,6 @@ var EdgeInsets = /*#__PURE__*/function () {
90
104
  value: function clone() {
91
105
  return new EdgeInsets(this.top, this.bottom, this.left, this.right);
92
106
  }
93
-
94
107
  /**
95
108
  * Returns the current sdtate as json, useful when you want to have a
96
109
  * read-only representation of the inset.
@@ -98,6 +111,7 @@ var EdgeInsets = /*#__PURE__*/function () {
98
111
  * @returns {PaddingOptions}
99
112
  * @memberof EdgeInsets
100
113
  */
114
+
101
115
  }, {
102
116
  key: "toJSON",
103
117
  value: function toJSON() {
@@ -111,4 +125,5 @@ var EdgeInsets = /*#__PURE__*/function () {
111
125
  }]);
112
126
  return EdgeInsets;
113
127
  }();
128
+
114
129
  exports.default = EdgeInsets;
@@ -1,28 +1,39 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.earthRadius = exports.default = void 0;
9
+
8
10
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
+
9
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
10
14
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
11
16
  var _util = require("../util");
17
+
12
18
  var earthRadius = 6371008.8;
13
19
  exports.earthRadius = earthRadius;
20
+
14
21
  var LngLat = /*#__PURE__*/function () {
15
22
  function LngLat(lng, lat) {
16
23
  (0, _classCallCheck2.default)(this, LngLat);
24
+
17
25
  if (isNaN(lng) || isNaN(lat)) {
18
26
  throw new Error("Invalid LngLat object: (".concat(lng, ", ").concat(lat, ")"));
19
27
  }
28
+
20
29
  this.lng = +lng;
21
30
  this.lat = +lat;
31
+
22
32
  if (this.lat > 90 || this.lat < -90) {
23
33
  throw new Error('Invalid LngLat latitude value: must be between -90 and 90');
24
34
  }
25
35
  }
36
+
26
37
  (0, _createClass2.default)(LngLat, [{
27
38
  key: "wrap",
28
39
  value: function wrap() {
@@ -32,17 +43,16 @@ var LngLat = /*#__PURE__*/function () {
32
43
  key: "toArray",
33
44
  value: function toArray() {
34
45
  return [this.lng, this.lat];
35
- }
36
- // public toBounds(radius: number = 0) {
46
+ } // public toBounds(radius: number = 0) {
37
47
  // const earthCircumferenceInMetersAtEquator = 40075017;
38
48
  // const latAccuracy = (360 * radius) / earthCircumferenceInMetersAtEquator;
39
49
  // const lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);
40
-
41
50
  // return new LngLatBounds(
42
51
  // new LngLat(this.lng - lngAccuracy, this.lat - latAccuracy),
43
52
  // new LngLat(this.lng + lngAccuracy, this.lat + latAccuracy),
44
53
  // );
45
54
  // }
55
+
46
56
  }, {
47
57
  key: "toString",
48
58
  value: function toString() {
@@ -64,18 +74,21 @@ var LngLat = /*#__PURE__*/function () {
64
74
  if (input instanceof LngLat) {
65
75
  return input;
66
76
  }
77
+
67
78
  if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {
68
79
  return new LngLat(Number(input[0]), Number(input[1]));
69
80
  }
81
+
70
82
  if (!Array.isArray(input) && (0, _typeof2.default)(input) === 'object' && input !== null) {
71
83
  var lng = 'lng' in input ? input.lng : input.lon;
72
- return new LngLat(
73
- // flow can't refine this to have one of lng or lat, so we have to cast to any
84
+ return new LngLat( // flow can't refine this to have one of lng or lat, so we have to cast to any
74
85
  Number(lng), Number(input.lat));
75
86
  }
87
+
76
88
  throw new Error('`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]');
77
89
  }
78
90
  }]);
79
91
  return LngLat;
80
92
  }();
93
+
81
94
  exports.default = LngLat;
@@ -1,18 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+
8
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
9
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
10
14
  var _lng_lat = _interopRequireDefault(require("./lng_lat"));
15
+
11
16
  var LngLatBounds = /*#__PURE__*/function () {
12
17
  function LngLatBounds(sw, ne) {
13
18
  (0, _classCallCheck2.default)(this, LngLatBounds);
14
- if (!sw) {
15
- // noop
19
+
20
+ if (!sw) {// noop
16
21
  } else if (ne) {
17
22
  this.setSouthWest(sw).setNorthEast(ne);
18
23
  } else if (sw.length === 4) {
@@ -21,6 +26,7 @@ var LngLatBounds = /*#__PURE__*/function () {
21
26
  this.setSouthWest(sw[0]).setNorthEast(sw[1]);
22
27
  }
23
28
  }
29
+
24
30
  (0, _createClass2.default)(LngLatBounds, [{
25
31
  key: "setNorthEast",
26
32
  value: function setNorthEast(ne) {
@@ -40,12 +46,14 @@ var LngLatBounds = /*#__PURE__*/function () {
40
46
  var ne = this.ne;
41
47
  var sw2;
42
48
  var ne2;
49
+
43
50
  if (obj instanceof _lng_lat.default) {
44
51
  sw2 = obj;
45
52
  ne2 = obj;
46
53
  } else if (obj instanceof LngLatBounds) {
47
54
  sw2 = obj.sw;
48
55
  ne2 = obj.ne;
56
+
49
57
  if (!sw2 || !ne2) {
50
58
  return this;
51
59
  }
@@ -60,8 +68,10 @@ var LngLatBounds = /*#__PURE__*/function () {
60
68
  return this.extend(_lng_lat.default.convert(lngLatObj));
61
69
  }
62
70
  }
71
+
63
72
  return this;
64
73
  }
74
+
65
75
  if (!sw && !ne) {
66
76
  this.sw = new _lng_lat.default(sw2.lng, sw2.lat);
67
77
  this.ne = new _lng_lat.default(ne2.lng, ne2.lat);
@@ -71,6 +81,7 @@ var LngLatBounds = /*#__PURE__*/function () {
71
81
  ne.lng = Math.max(ne2.lng, ne.lng);
72
82
  ne.lat = Math.max(ne2.lat, ne.lat);
73
83
  }
84
+
74
85
  return this;
75
86
  }
76
87
  }, {
@@ -137,14 +148,17 @@ var LngLatBounds = /*#__PURE__*/function () {
137
148
  key: "contains",
138
149
  value: function contains(lnglat) {
139
150
  var _LngLat$convert = _lng_lat.default.convert(lnglat),
140
- lng = _LngLat$convert.lng,
141
- lat = _LngLat$convert.lat;
151
+ lng = _LngLat$convert.lng,
152
+ lat = _LngLat$convert.lat;
153
+
142
154
  var containsLatitude = this.sw.lat <= lat && lat <= this.ne.lat;
143
155
  var containsLongitude = this.sw.lng <= lng && lng <= this.ne.lng;
156
+
144
157
  if (this.sw.lng > this.ne.lng) {
145
158
  // wrapped coordinates
146
159
  containsLongitude = this.sw.lng >= lng && lng >= this.ne.lng;
147
160
  }
161
+
148
162
  return containsLatitude && containsLongitude;
149
163
  }
150
164
  }], [{
@@ -153,9 +167,11 @@ var LngLatBounds = /*#__PURE__*/function () {
153
167
  if (input instanceof LngLatBounds) {
154
168
  return input;
155
169
  }
170
+
156
171
  return new LngLatBounds(input);
157
172
  }
158
173
  }]);
159
174
  return LngLatBounds;
160
175
  }();
176
+
161
177
  exports.default = LngLatBounds;