@antv/l7-map 2.17.4 → 2.17.6

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 -26
  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 -38
  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/es/earthmap.js CHANGED
@@ -5,67 +5,54 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
7
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
-
9
8
  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); }; }
10
-
11
9
  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; } }
12
-
13
10
  import { DOM } from '@antv/l7-utils';
14
11
  import { merge } from 'lodash';
15
12
  import Camera from "./camera";
16
-
17
13
  function loadStyles(css, doc) {
18
14
  var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
19
15
  var isWeChatMiniProgram = typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
20
-
21
16
  if (isMiniAli || isWeChatMiniProgram) {
22
17
  return;
23
18
  }
24
-
25
19
  if (!doc) doc = document;
26
-
27
20
  if (!doc) {
28
21
  return;
29
22
  }
30
-
31
23
  var head = doc.head || doc.getElementsByTagName('head')[0];
32
-
33
24
  if (!head) {
34
25
  head = doc.createElement('head');
35
26
  var body = doc.body || doc.getElementsByTagName('body')[0];
36
-
37
27
  if (body) {
38
28
  body.parentNode.insertBefore(head, body);
39
29
  } else {
40
30
  doc.documentElement.appendChild(head);
41
31
  }
42
32
  }
43
-
44
33
  var style = doc.createElement('style');
45
34
  style.type = 'text/css';
46
-
47
35
  if (style.styleSheet) {
48
36
  style.styleSheet.cssText = css;
49
37
  } else {
50
38
  style.appendChild(doc.createTextNode(css));
51
39
  }
52
-
53
40
  head.appendChild(style);
54
41
  return style;
55
42
  }
56
-
57
43
  loadStyles(".l7-map {\n font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;\n overflow: hidden;\n position: relative;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n\n.l7-canvas {\n position: absolute;\n left: 0;\n top: 0;\n}\n\n.l7-map:-webkit-full-screen {\n width: 100%;\n height: 100%;\n}\n\n.l7-canary {\n background-color: salmon;\n}\n\n.l7-canvas-container.l7-interactive,\n.l7-ctrl-group button.l7-ctrl-compass {\n cursor: -webkit-grab;\n cursor: grab;\n -moz-user-select: none;\n -webkit-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n.l7-canvas-container.l7-interactive.l7-track-pointer {\n cursor: pointer;\n}\n\n.l7-canvas-container.l7-interactive:active,\n.l7-ctrl-group button.l7-ctrl-compass:active {\n cursor: -webkit-grabbing;\n cursor: grabbing;\n}\n\n.l7-canvas-container.l7-touch-zoom-rotate,\n.l7-canvas-container.l7-touch-zoom-rotate .l7-canvas {\n -ms-touch-action: pan-x pan-y;\n touch-action: pan-x pan-y;\n}\n\n.l7-canvas-container.l7-touch-drag-pan,\n.l7-canvas-container.l7-touch-drag-pan .l7-canvas {\n -ms-touch-action: pinch-zoom;\n touch-action: pinch-zoom;\n}\n\n.l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan,\n.l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan .l7-canvas {\n -ms-touch-action: none;\n touch-action: none;\n}\n\n.l7-ctrl-top-left,\n.l7-ctrl-top-right,\n.l7-ctrl-bottom-left,\n.l7-ctrl-bottom-right { position: absolute; pointer-events: none; z-index: 2; }\n.l7-ctrl-top-left { top: 0; left: 0; }\n.l7-ctrl-top-right { top: 0; right: 0; }\n.l7-ctrl-bottom-left { bottom: 0; left: 0; }\n.l7-ctrl-bottom-right { right: 0; bottom: 0; }\n\n.l7-ctrl {\n clear: both;\n pointer-events: auto;\n\n /* workaround for a Safari bug https://github.com/mapbox/mapbox-gl-js/issues/8185 */\n -webkit-transform: translate(0, 0);\n transform: translate(0, 0);\n}\n.l7-ctrl-top-left .l7-ctrl { margin: 10px 0 0 10px; float: left; }\n.l7-ctrl-top-right .l7-ctrl { margin: 10px 10px 0 0; float: right; }\n.l7-ctrl-bottom-left .l7-ctrl { margin: 0 0 10px 10px; float: left; }\n.l7-ctrl-bottom-right .l7-ctrl { margin: 0 10px 10px 0; float: right; }\n\n\n.l7-crosshair,\n.l7-crosshair .l7-interactive,\n.l7-crosshair .l7-interactive:active {\n cursor: crosshair;\n}\n\n.l7-boxzoom {\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 0;\n background: #fff;\n border: 2px dotted #202020;\n opacity: 0.5;\n z-index: 10;\n}\n");
58
44
  import LngLat from "./geo/lng_lat";
59
- import LngLatBounds from "./geo/lng_lat_bounds"; // @ts-ignore
60
-
45
+ import LngLatBounds from "./geo/lng_lat_bounds";
46
+ // @ts-ignore
61
47
  import Point from "./geo/point";
62
48
  import HandlerManager from "./handler/handler_manager";
63
49
  import { renderframe } from "./util";
64
50
  import { PerformanceUtils } from "./utils/performance";
65
51
  import TaskQueue from "./utils/task_queue";
66
52
  var defaultMinZoom = -2;
67
- var defaultMaxZoom = 22; // the default values, but also the valid range
53
+ var defaultMaxZoom = 22;
68
54
 
55
+ // the default values, but also the valid range
69
56
  var defaultMinPitch = 0;
70
57
  var defaultMaxPitch = 60;
71
58
  var DefaultOptions = {
@@ -97,24 +84,16 @@ var DefaultOptions = {
97
84
  };
98
85
  export var EarthMap = /*#__PURE__*/function (_Camera) {
99
86
  _inherits(EarthMap, _Camera);
100
-
101
87
  var _super = _createSuper(EarthMap);
102
-
103
88
  function EarthMap(options) {
104
89
  var _this;
105
-
106
90
  _classCallCheck(this, EarthMap);
107
-
108
91
  _this = _super.call(this, merge({}, DefaultOptions, options));
109
-
110
92
  _defineProperty(_assertThisInitialized(_this), "renderTaskQueue", new TaskQueue());
111
-
112
93
  _defineProperty(_assertThisInitialized(_this), "trackResize", true);
113
-
114
94
  _defineProperty(_assertThisInitialized(_this), "onWindowOnline", function () {
115
95
  _this.update();
116
96
  });
117
-
118
97
  _defineProperty(_assertThisInitialized(_this), "onWindowResize", function (event) {
119
98
  if (_this.trackResize) {
120
99
  _this.resize({
@@ -122,44 +101,35 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
122
101
  }).update();
123
102
  }
124
103
  });
125
-
126
104
  _this.initContainer();
127
-
128
105
  _this.resize();
129
-
130
106
  _this.handlers = new HandlerManager(_assertThisInitialized(_this), _this.options);
131
-
132
107
  if (typeof window !== 'undefined') {
133
108
  window.addEventListener('online', _this.onWindowOnline, false);
134
109
  window.addEventListener('resize', _this.onWindowResize, false);
135
110
  window.addEventListener('orientationchange', _this.onWindowResize, false);
136
111
  }
137
-
138
112
  return _this;
139
113
  }
140
-
141
114
  _createClass(EarthMap, [{
142
115
  key: "resize",
143
116
  value: function resize(eventData) {
144
117
  var dimensions = this.containerDimensions();
145
118
  var width = dimensions[0];
146
- var height = dimensions[1]; // this.resizeCanvas(width, height);
119
+ var height = dimensions[1];
147
120
 
121
+ // this.resizeCanvas(width, height);
148
122
  this.transform.resize(width, height);
149
123
  var fireMoving = !this.moving;
150
-
151
124
  if (fireMoving) {
152
125
  this.stop();
153
126
  this.emit('movestart', new Event('movestart', eventData));
154
127
  this.emit('move', new Event('move', eventData));
155
128
  }
156
-
157
129
  this.emit('resize', new Event('resize', eventData));
158
-
159
130
  if (fireMoving) {
160
131
  this.emit('moveend', new Event('moveend', eventData));
161
132
  }
162
-
163
133
  return this;
164
134
  }
165
135
  }, {
@@ -201,8 +171,9 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
201
171
  key: "setMaxBounds",
202
172
  value: function setMaxBounds(bounds) {
203
173
  this.transform.setMaxBounds(LngLatBounds.convert(bounds));
204
- } // eslint-disable-next-line @typescript-eslint/no-unused-vars
174
+ }
205
175
 
176
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
206
177
  }, {
207
178
  key: "setStyle",
208
179
  value: function setStyle(style) {
@@ -212,14 +183,11 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
212
183
  key: "setMinZoom",
213
184
  value: function setMinZoom(minZoom) {
214
185
  minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
215
-
216
186
  if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
217
187
  this.transform.minZoom = minZoom;
218
-
219
188
  if (this.getZoom() < minZoom) {
220
189
  this.setZoom(minZoom);
221
190
  }
222
-
223
191
  return this;
224
192
  } else {
225
193
  throw new Error("minZoom must be between ".concat(defaultMinZoom, " and the current maxZoom, inclusive"));
@@ -234,14 +202,11 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
234
202
  key: "setMaxZoom",
235
203
  value: function setMaxZoom(maxZoom) {
236
204
  maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
237
-
238
205
  if (maxZoom >= this.transform.minZoom) {
239
206
  this.transform.maxZoom = maxZoom;
240
-
241
207
  if (this.getZoom() > maxZoom) {
242
208
  this.setZoom(maxZoom);
243
209
  }
244
-
245
210
  return this;
246
211
  } else {
247
212
  throw new Error('maxZoom must be greater than the current minZoom');
@@ -256,18 +221,14 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
256
221
  key: "setMinPitch",
257
222
  value: function setMinPitch(minPitch) {
258
223
  minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
259
-
260
224
  if (minPitch < defaultMinPitch) {
261
225
  throw new Error("minPitch must be greater than or equal to ".concat(defaultMinPitch));
262
226
  }
263
-
264
227
  if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
265
228
  this.transform.minPitch = minPitch;
266
-
267
229
  if (this.getPitch() < minPitch) {
268
230
  this.setPitch(minPitch);
269
231
  }
270
-
271
232
  return this;
272
233
  } else {
273
234
  throw new Error("minPitch must be between ".concat(defaultMinPitch, " and the current maxPitch, inclusive"));
@@ -282,18 +243,14 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
282
243
  key: "setMaxPitch",
283
244
  value: function setMaxPitch(maxPitch) {
284
245
  maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
285
-
286
246
  if (maxPitch > defaultMaxPitch) {
287
247
  throw new Error("maxPitch must be less than or equal to ".concat(defaultMaxPitch));
288
248
  }
289
-
290
249
  if (maxPitch >= this.transform.minPitch) {
291
250
  this.transform.maxPitch = maxPitch;
292
-
293
251
  if (this.getPitch() > maxPitch) {
294
252
  this.setPitch(maxPitch);
295
253
  }
296
-
297
254
  return this;
298
255
  } else {
299
256
  throw new Error('maxPitch must be greater than the current minPitch');
@@ -321,7 +278,6 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
321
278
  this.frame.cancel();
322
279
  this.frame = null;
323
280
  }
324
-
325
281
  this.renderTaskQueue.clear();
326
282
  }
327
283
  }, {
@@ -339,12 +295,10 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
339
295
  key: "triggerRepaint",
340
296
  value: function triggerRepaint() {
341
297
  var _this2 = this;
342
-
343
298
  if (!this.frame) {
344
299
  this.frame = renderframe(function (paintStartTimeStamp) {
345
300
  PerformanceUtils.frame(paintStartTimeStamp);
346
301
  _this2.frame = null;
347
-
348
302
  _this2.update(paintStartTimeStamp);
349
303
  });
350
304
  }
@@ -353,12 +307,10 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
353
307
  key: "update",
354
308
  value: function update(time) {
355
309
  var _this3 = this;
356
-
357
310
  if (!this.frame) {
358
311
  this.frame = renderframe(function (paintStartTimeStamp) {
359
312
  PerformanceUtils.frame(paintStartTimeStamp);
360
313
  _this3.frame = null;
361
-
362
314
  _this3.renderTaskQueue.run(time);
363
315
  });
364
316
  }
@@ -368,7 +320,6 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
368
320
  value: function initContainer() {
369
321
  if (typeof this.options.container === 'string') {
370
322
  this.container = window.document.getElementById(this.options.container);
371
-
372
323
  if (!this.container) {
373
324
  throw new Error("Container '".concat(this.options.container, "' not found."));
374
325
  }
@@ -377,33 +328,30 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
377
328
  } else {
378
329
  throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
379
330
  }
380
-
381
331
  var container = this.container;
382
332
  container.classList.add('l7-map');
383
333
  var canvasContainer = this.canvasContainer = DOM.create('div', 'l7-canvas-container', container);
384
-
385
334
  if (this.options.interactive) {
386
335
  canvasContainer.classList.add('l7-interactive');
387
- } // this.canvas = DOM.create(
336
+ }
337
+
338
+ // this.canvas = DOM.create(
388
339
  // 'canvas',
389
340
  // 'l7-canvas',
390
341
  // canvasContainer,
391
342
  // ) as HTMLCanvasElement;
392
343
  // this.canvas.setAttribute('tabindex', '-');
393
344
  // this.canvas.setAttribute('aria-label', 'Map');
394
-
395
345
  }
396
346
  }, {
397
347
  key: "containerDimensions",
398
348
  value: function containerDimensions() {
399
349
  var width = 0;
400
350
  var height = 0;
401
-
402
351
  if (this.container) {
403
352
  width = this.container.clientWidth || 400;
404
353
  height = this.container.clientHeight || 300;
405
354
  }
406
-
407
355
  return [width, height];
408
356
  }
409
357
  }, {
@@ -411,12 +359,12 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
411
359
  value: function resizeCanvas(width, height) {
412
360
  var pixelRatio = DOM.DPR || 1;
413
361
  this.canvas.width = pixelRatio * width;
414
- this.canvas.height = pixelRatio * height; // Maintain the same canvas size, potentially downscaling it for HiDPI displays
362
+ this.canvas.height = pixelRatio * height;
415
363
 
364
+ // Maintain the same canvas size, potentially downscaling it for HiDPI displays
416
365
  this.canvas.style.width = "".concat(width, "px");
417
366
  this.canvas.style.height = "".concat(height, "px");
418
367
  }
419
368
  }]);
420
-
421
369
  return EarthMap;
422
370
  }(Camera);
@@ -3,6 +3,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  // @ts-ignore
4
4
  import { clamp, interpolate as _interpolate } from "../util";
5
5
  import Point from "./point";
6
+
6
7
  /**
7
8
  * An `EdgeInset` object represents screen space padding applied to the edges of the viewport.
8
9
  * This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements
@@ -13,25 +14,22 @@ import Point from "./point";
13
14
  * @param {number} [left=0]
14
15
  * @param {number} [right=0]
15
16
  */
16
-
17
17
  var EdgeInsets = /*#__PURE__*/function () {
18
18
  function EdgeInsets() {
19
19
  var top = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
20
20
  var bottom = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
21
21
  var left = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
22
22
  var right = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
23
-
24
23
  _classCallCheck(this, EdgeInsets);
25
-
26
24
  if (isNaN(top) || top < 0 || isNaN(bottom) || bottom < 0 || isNaN(left) || left < 0 || isNaN(right) || right < 0) {
27
25
  throw new Error('Invalid value for edge-insets, top, bottom, left and right must all be numbers');
28
26
  }
29
-
30
27
  this.top = top;
31
28
  this.bottom = bottom;
32
29
  this.left = left;
33
30
  this.right = right;
34
31
  }
32
+
35
33
  /**
36
34
  * Interpolates the inset in-place.
37
35
  * This maintains the current inset value for any inset not present in `target`.
@@ -41,29 +39,24 @@ var EdgeInsets = /*#__PURE__*/function () {
41
39
  * @returns {EdgeInsets}
42
40
  * @memberof EdgeInsets
43
41
  */
44
-
45
-
46
42
  _createClass(EdgeInsets, [{
47
43
  key: "interpolate",
48
44
  value: function interpolate(start, target, t) {
49
45
  if (target.top != null && start.top != null) {
50
46
  this.top = _interpolate(start.top, target.top, t);
51
47
  }
52
-
53
48
  if (target.bottom != null && start.bottom != null) {
54
49
  this.bottom = _interpolate(start.bottom, target.bottom, t);
55
50
  }
56
-
57
51
  if (target.left != null && start.left != null) {
58
52
  this.left = _interpolate(start.left, target.left, t);
59
53
  }
60
-
61
54
  if (target.right != null && start.right != null) {
62
55
  this.right = _interpolate(start.right, target.right, t);
63
56
  }
64
-
65
57
  return this;
66
58
  }
59
+
67
60
  /**
68
61
  * Utility method that computes the new apprent center or vanishing point after applying insets.
69
62
  * This is in pixels and with the top left being (0.0) and +y being downwards.
@@ -73,7 +66,6 @@ var EdgeInsets = /*#__PURE__*/function () {
73
66
  * @returns {Point}
74
67
  * @memberof EdgeInsets
75
68
  */
76
-
77
69
  }, {
78
70
  key: "getCenter",
79
71
  value: function getCenter(width, height) {
@@ -92,6 +84,7 @@ var EdgeInsets = /*#__PURE__*/function () {
92
84
  value: function clone() {
93
85
  return new EdgeInsets(this.top, this.bottom, this.left, this.right);
94
86
  }
87
+
95
88
  /**
96
89
  * Returns the current sdtate as json, useful when you want to have a
97
90
  * read-only representation of the inset.
@@ -99,7 +92,6 @@ var EdgeInsets = /*#__PURE__*/function () {
99
92
  * @returns {PaddingOptions}
100
93
  * @memberof EdgeInsets
101
94
  */
102
-
103
95
  }, {
104
96
  key: "toJSON",
105
97
  value: function toJSON() {
@@ -111,8 +103,6 @@ var EdgeInsets = /*#__PURE__*/function () {
111
103
  };
112
104
  }
113
105
  }]);
114
-
115
106
  return EdgeInsets;
116
107
  }();
117
-
118
108
  export { EdgeInsets as default };
package/es/geo/lng_lat.js CHANGED
@@ -3,23 +3,18 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
4
  import { wrap as _wrap } from "../util";
5
5
  export var earthRadius = 6371008.8;
6
-
7
6
  var LngLat = /*#__PURE__*/function () {
8
7
  function LngLat(lng, lat) {
9
8
  _classCallCheck(this, LngLat);
10
-
11
9
  if (isNaN(lng) || isNaN(lat)) {
12
10
  throw new Error("Invalid LngLat object: (".concat(lng, ", ").concat(lat, ")"));
13
11
  }
14
-
15
12
  this.lng = +lng;
16
13
  this.lat = +lat;
17
-
18
14
  if (this.lat > 90 || this.lat < -90) {
19
15
  throw new Error('Invalid LngLat latitude value: must be between -90 and 90');
20
16
  }
21
17
  }
22
-
23
18
  _createClass(LngLat, [{
24
19
  key: "wrap",
25
20
  value: function wrap() {
@@ -29,16 +24,17 @@ var LngLat = /*#__PURE__*/function () {
29
24
  key: "toArray",
30
25
  value: function toArray() {
31
26
  return [this.lng, this.lat];
32
- } // public toBounds(radius: number = 0) {
27
+ }
28
+ // public toBounds(radius: number = 0) {
33
29
  // const earthCircumferenceInMetersAtEquator = 40075017;
34
30
  // const latAccuracy = (360 * radius) / earthCircumferenceInMetersAtEquator;
35
31
  // const lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);
32
+
36
33
  // return new LngLatBounds(
37
34
  // new LngLat(this.lng - lngAccuracy, this.lat - latAccuracy),
38
35
  // new LngLat(this.lng + lngAccuracy, this.lat + latAccuracy),
39
36
  // );
40
37
  // }
41
-
42
38
  }, {
43
39
  key: "toString",
44
40
  value: function toString() {
@@ -60,22 +56,18 @@ var LngLat = /*#__PURE__*/function () {
60
56
  if (input instanceof LngLat) {
61
57
  return input;
62
58
  }
63
-
64
59
  if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {
65
60
  return new LngLat(Number(input[0]), Number(input[1]));
66
61
  }
67
-
68
62
  if (!Array.isArray(input) && _typeof(input) === 'object' && input !== null) {
69
63
  var lng = 'lng' in input ? input.lng : input.lon;
70
- return new LngLat( // flow can't refine this to have one of lng or lat, so we have to cast to any
64
+ return new LngLat(
65
+ // flow can't refine this to have one of lng or lat, so we have to cast to any
71
66
  Number(lng), Number(input.lat));
72
67
  }
73
-
74
68
  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>]');
75
69
  }
76
70
  }]);
77
-
78
71
  return LngLat;
79
72
  }();
80
-
81
73
  export { LngLat as default };
@@ -1,12 +1,11 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import LngLat from "./lng_lat";
4
-
5
4
  var LngLatBounds = /*#__PURE__*/function () {
6
5
  function LngLatBounds(sw, ne) {
7
6
  _classCallCheck(this, LngLatBounds);
8
-
9
- if (!sw) {// noop
7
+ if (!sw) {
8
+ // noop
10
9
  } else if (ne) {
11
10
  this.setSouthWest(sw).setNorthEast(ne);
12
11
  } else if (sw.length === 4) {
@@ -15,7 +14,6 @@ var LngLatBounds = /*#__PURE__*/function () {
15
14
  this.setSouthWest(sw[0]).setNorthEast(sw[1]);
16
15
  }
17
16
  }
18
-
19
17
  _createClass(LngLatBounds, [{
20
18
  key: "setNorthEast",
21
19
  value: function setNorthEast(ne) {
@@ -35,14 +33,12 @@ var LngLatBounds = /*#__PURE__*/function () {
35
33
  var ne = this.ne;
36
34
  var sw2;
37
35
  var ne2;
38
-
39
36
  if (obj instanceof LngLat) {
40
37
  sw2 = obj;
41
38
  ne2 = obj;
42
39
  } else if (obj instanceof LngLatBounds) {
43
40
  sw2 = obj.sw;
44
41
  ne2 = obj.ne;
45
-
46
42
  if (!sw2 || !ne2) {
47
43
  return this;
48
44
  }
@@ -57,10 +53,8 @@ var LngLatBounds = /*#__PURE__*/function () {
57
53
  return this.extend(LngLat.convert(lngLatObj));
58
54
  }
59
55
  }
60
-
61
56
  return this;
62
57
  }
63
-
64
58
  if (!sw && !ne) {
65
59
  this.sw = new LngLat(sw2.lng, sw2.lat);
66
60
  this.ne = new LngLat(ne2.lng, ne2.lat);
@@ -70,7 +64,6 @@ var LngLatBounds = /*#__PURE__*/function () {
70
64
  ne.lng = Math.max(ne2.lng, ne.lng);
71
65
  ne.lat = Math.max(ne2.lat, ne.lat);
72
66
  }
73
-
74
67
  return this;
75
68
  }
76
69
  }, {
@@ -137,17 +130,14 @@ var LngLatBounds = /*#__PURE__*/function () {
137
130
  key: "contains",
138
131
  value: function contains(lnglat) {
139
132
  var _LngLat$convert = LngLat.convert(lnglat),
140
- lng = _LngLat$convert.lng,
141
- lat = _LngLat$convert.lat;
142
-
133
+ lng = _LngLat$convert.lng,
134
+ lat = _LngLat$convert.lat;
143
135
  var containsLatitude = this.sw.lat <= lat && lat <= this.ne.lat;
144
136
  var containsLongitude = this.sw.lng <= lng && lng <= this.ne.lng;
145
-
146
137
  if (this.sw.lng > this.ne.lng) {
147
138
  // wrapped coordinates
148
139
  containsLongitude = this.sw.lng >= lng && lng >= this.ne.lng;
149
140
  }
150
-
151
141
  return containsLatitude && containsLongitude;
152
142
  }
153
143
  }], [{
@@ -156,12 +146,9 @@ var LngLatBounds = /*#__PURE__*/function () {
156
146
  if (input instanceof LngLatBounds) {
157
147
  return input;
158
148
  }
159
-
160
149
  return new LngLatBounds(input);
161
150
  }
162
151
  }]);
163
-
164
152
  return LngLatBounds;
165
153
  }();
166
-
167
154
  export { LngLatBounds as default };
@@ -1,20 +1,18 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
3
  import LngLat, { earthRadius } from "../geo/lng_lat";
4
+
4
5
  /*
5
6
  * The average circumference of the world in meters.
6
7
  */
7
-
8
8
  var earthCircumfrence = 2 * Math.PI * earthRadius; // meters
9
9
 
10
10
  /*
11
11
  * The circumference at a line of latitude in meters.
12
12
  */
13
-
14
13
  function circumferenceAtLatitude(latitude) {
15
14
  return earthCircumfrence * Math.cos(latitude * Math.PI / 180);
16
15
  }
17
-
18
16
  export function mercatorXfromLng(lng) {
19
17
  return (180 + lng) / 360;
20
18
  }
@@ -34,6 +32,7 @@ export function latFromMercatorY(y) {
34
32
  export function altitudeFromMercatorZ(z, y) {
35
33
  return z * circumferenceAtLatitude(latFromMercatorY(y));
36
34
  }
35
+
37
36
  /**
38
37
  * Determine the Mercator scale factor for a given latitude, see
39
38
  * https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor
@@ -44,22 +43,17 @@ export function altitudeFromMercatorZ(z, y) {
44
43
  * @returns {number} scale factor
45
44
  * @private
46
45
  */
47
-
48
46
  export function mercatorScale(lat) {
49
47
  return 1 / Math.cos(lat * Math.PI / 180);
50
48
  }
51
-
52
49
  var MercatorCoordinate = /*#__PURE__*/function () {
53
50
  function MercatorCoordinate(x, y) {
54
51
  var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
55
-
56
52
  _classCallCheck(this, MercatorCoordinate);
57
-
58
53
  this.x = +x;
59
54
  this.y = +y;
60
55
  this.z = +z;
61
56
  }
62
-
63
57
  _createClass(MercatorCoordinate, [{
64
58
  key: "toLngLat",
65
59
  value: function toLngLat() {
@@ -84,9 +78,7 @@ var MercatorCoordinate = /*#__PURE__*/function () {
84
78
  return new MercatorCoordinate(mercatorXfromLng(lngLat.lng), mercatorYfromLat(lngLat.lat), mercatorZfromAltitude(altitude, lngLat.lat));
85
79
  }
86
80
  }]);
87
-
88
81
  return MercatorCoordinate;
89
82
  }();
90
-
91
83
  export { MercatorCoordinate as default };
92
84
  export { MercatorCoordinate };
package/es/geo/point.js CHANGED
@@ -1,14 +1,11 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
3
-
4
3
  var Point = /*#__PURE__*/function () {
5
4
  function Point(x, y) {
6
5
  _classCallCheck(this, Point);
7
-
8
6
  this.x = x;
9
7
  this.y = y;
10
8
  }
11
-
12
9
  _createClass(Point, [{
13
10
  key: "clone",
14
11
  value: function clone() {
@@ -216,16 +213,12 @@ var Point = /*#__PURE__*/function () {
216
213
  if (a instanceof Point) {
217
214
  return a;
218
215
  }
219
-
220
216
  if (Array.isArray(a)) {
221
217
  return new Point(a[0], a[1]);
222
218
  }
223
-
224
219
  return a;
225
220
  }
226
221
  }]);
227
-
228
222
  return Point;
229
223
  }();
230
-
231
224
  export { Point as default };