@antv/l7-map 2.17.12 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/es/camera.js +92 -149
  2. package/es/earthmap.js +15 -68
  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 +128 -138
  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 +2 -3
  14. package/es/handler/events/map_mouse_event.js +2 -13
  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 +8 -35
  19. package/es/handler/handler_manager.js +90 -197
  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 +6 -18
  31. package/es/handler/shim/drag_rotate.js +4 -10
  32. package/es/handler/shim/touch_zoom_rotate.js +8 -23
  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 +13 -35
  43. package/es/map.js +30 -107
  44. package/es/util.d.ts +3 -3
  45. package/es/util.js +20 -33
  46. package/es/utils/Aabb.js +10 -31
  47. package/es/utils/dom.js +33 -111
  48. package/es/utils/performance.js +9 -9
  49. package/es/utils/primitives.js +13 -11
  50. package/es/utils/task_queue.js +6 -23
  51. package/lib/camera.js +102 -179
  52. package/lib/earthmap.js +14 -83
  53. package/lib/geo/edge_insets.js +3 -18
  54. package/lib/geo/lng_lat.js +5 -18
  55. package/lib/geo/lng_lat_bounds.js +4 -20
  56. package/lib/geo/mercator.js +1 -22
  57. package/lib/geo/point.js +0 -8
  58. package/lib/geo/simple.js +5 -24
  59. package/lib/geo/transform.js +128 -170
  60. package/lib/handler/blockable_map_event.js +6 -14
  61. package/lib/handler/box_zoom.js +8 -39
  62. package/lib/handler/click_zoom.js +0 -6
  63. package/lib/handler/events/event.js +4 -7
  64. package/lib/handler/events/index.js +0 -4
  65. package/lib/handler/events/map_mouse_event.js +5 -22
  66. package/lib/handler/events/map_touch_event.js +2 -21
  67. package/lib/handler/events/map_wheel_event.js +1 -16
  68. package/lib/handler/events/render_event.js +0 -19
  69. package/lib/handler/handler_inertia.js +13 -44
  70. package/lib/handler/handler_manager.js +92 -222
  71. package/lib/handler/handler_util.js +1 -3
  72. package/lib/handler/keyboard.js +1 -22
  73. package/lib/handler/map_event.js +2 -11
  74. package/lib/handler/mouse/index.js +0 -4
  75. package/lib/handler/mouse/mouse_handler.js +10 -27
  76. package/lib/handler/mouse/mousepan_handler.js +1 -18
  77. package/lib/handler/mouse/mousepitch_hander.js +1 -17
  78. package/lib/handler/mouse/mouserotate_hander.js +1 -17
  79. package/lib/handler/mouse/util.js +2 -6
  80. package/lib/handler/scroll_zoom.js +43 -77
  81. package/lib/handler/shim/dblclick_zoom.js +4 -10
  82. package/lib/handler/shim/drag_pan.js +6 -20
  83. package/lib/handler/shim/drag_rotate.js +4 -11
  84. package/lib/handler/shim/touch_zoom_rotate.js +8 -25
  85. package/lib/handler/tap/single_tap_recognizer.js +8 -33
  86. package/lib/handler/tap/tap_drag_zoom.js +6 -18
  87. package/lib/handler/tap/tap_recognizer.js +2 -17
  88. package/lib/handler/tap/tap_zoom.js +0 -9
  89. package/lib/handler/touch/index.js +0 -5
  90. package/lib/handler/touch/touch_pan.js +4 -25
  91. package/lib/handler/touch/touch_pitch.js +10 -32
  92. package/lib/handler/touch/touch_rotate.js +8 -25
  93. package/lib/handler/touch/touch_zoom.js +5 -24
  94. package/lib/handler/touch/two_touch.js +18 -35
  95. package/lib/hash.js +12 -38
  96. package/lib/index.js +0 -8
  97. package/lib/map.js +30 -125
  98. package/lib/util.js +19 -46
  99. package/lib/utils/Aabb.js +10 -34
  100. package/lib/utils/dom.js +32 -118
  101. package/lib/utils/performance.js +9 -11
  102. package/lib/utils/primitives.js +13 -16
  103. package/lib/utils/task_queue.js +6 -24
  104. package/package.json +4 -4
package/es/earthmap.js CHANGED
@@ -5,67 +5,53 @@ 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
- import { DOM } from '@antv/l7-utils';
14
- import { merge } from 'lodash';
10
+ import { DOM, lodashUtil } from '@antv/l7-utils';
15
11
  import Camera from "./camera";
16
-
17
12
  function loadStyles(css, doc) {
18
13
  var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
19
14
  var isWeChatMiniProgram = typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
20
-
21
15
  if (isMiniAli || isWeChatMiniProgram) {
22
16
  return;
23
17
  }
24
-
25
18
  if (!doc) doc = document;
26
-
27
19
  if (!doc) {
28
20
  return;
29
21
  }
30
-
31
22
  var head = doc.head || doc.getElementsByTagName('head')[0];
32
-
33
23
  if (!head) {
34
24
  head = doc.createElement('head');
35
25
  var body = doc.body || doc.getElementsByTagName('body')[0];
36
-
37
26
  if (body) {
38
27
  body.parentNode.insertBefore(head, body);
39
28
  } else {
40
29
  doc.documentElement.appendChild(head);
41
30
  }
42
31
  }
43
-
44
32
  var style = doc.createElement('style');
45
33
  style.type = 'text/css';
46
-
47
34
  if (style.styleSheet) {
48
35
  style.styleSheet.cssText = css;
49
36
  } else {
50
37
  style.appendChild(doc.createTextNode(css));
51
38
  }
52
-
53
39
  head.appendChild(style);
54
40
  return style;
55
41
  }
56
-
57
42
  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
43
  import LngLat from "./geo/lng_lat";
59
- import LngLatBounds from "./geo/lng_lat_bounds"; // @ts-ignore
60
-
44
+ import LngLatBounds from "./geo/lng_lat_bounds";
45
+ // @ts-ignore
61
46
  import Point from "./geo/point";
62
47
  import HandlerManager from "./handler/handler_manager";
63
48
  import { renderframe } from "./util";
64
49
  import { PerformanceUtils } from "./utils/performance";
65
50
  import TaskQueue from "./utils/task_queue";
66
51
  var defaultMinZoom = -2;
67
- var defaultMaxZoom = 22; // the default values, but also the valid range
68
-
52
+ var defaultMaxZoom = 22;
53
+ var merge = lodashUtil.merge;
54
+ // the default values, but also the valid range
69
55
  var defaultMinPitch = 0;
70
56
  var defaultMaxPitch = 60;
71
57
  var DefaultOptions = {
@@ -97,24 +83,16 @@ var DefaultOptions = {
97
83
  };
98
84
  export var EarthMap = /*#__PURE__*/function (_Camera) {
99
85
  _inherits(EarthMap, _Camera);
100
-
101
86
  var _super = _createSuper(EarthMap);
102
-
103
87
  function EarthMap(options) {
104
88
  var _this;
105
-
106
89
  _classCallCheck(this, EarthMap);
107
-
108
90
  _this = _super.call(this, merge({}, DefaultOptions, options));
109
-
110
91
  _defineProperty(_assertThisInitialized(_this), "renderTaskQueue", new TaskQueue());
111
-
112
92
  _defineProperty(_assertThisInitialized(_this), "trackResize", true);
113
-
114
93
  _defineProperty(_assertThisInitialized(_this), "onWindowOnline", function () {
115
94
  _this.update();
116
95
  });
117
-
118
96
  _defineProperty(_assertThisInitialized(_this), "onWindowResize", function (event) {
119
97
  if (_this.trackResize) {
120
98
  _this.resize({
@@ -122,44 +100,35 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
122
100
  }).update();
123
101
  }
124
102
  });
125
-
126
103
  _this.initContainer();
127
-
128
104
  _this.resize();
129
-
130
105
  _this.handlers = new HandlerManager(_assertThisInitialized(_this), _this.options);
131
-
132
106
  if (typeof window !== 'undefined') {
133
107
  window.addEventListener('online', _this.onWindowOnline, false);
134
108
  window.addEventListener('resize', _this.onWindowResize, false);
135
109
  window.addEventListener('orientationchange', _this.onWindowResize, false);
136
110
  }
137
-
138
111
  return _this;
139
112
  }
140
-
141
113
  _createClass(EarthMap, [{
142
114
  key: "resize",
143
115
  value: function resize(eventData) {
144
116
  var dimensions = this.containerDimensions();
145
117
  var width = dimensions[0];
146
- var height = dimensions[1]; // this.resizeCanvas(width, height);
118
+ var height = dimensions[1];
147
119
 
120
+ // this.resizeCanvas(width, height);
148
121
  this.transform.resize(width, height);
149
122
  var fireMoving = !this.moving;
150
-
151
123
  if (fireMoving) {
152
124
  this.stop();
153
125
  this.emit('movestart', new Event('movestart', eventData));
154
126
  this.emit('move', new Event('move', eventData));
155
127
  }
156
-
157
128
  this.emit('resize', new Event('resize', eventData));
158
-
159
129
  if (fireMoving) {
160
130
  this.emit('moveend', new Event('moveend', eventData));
161
131
  }
162
-
163
132
  return this;
164
133
  }
165
134
  }, {
@@ -201,8 +170,9 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
201
170
  key: "setMaxBounds",
202
171
  value: function setMaxBounds(bounds) {
203
172
  this.transform.setMaxBounds(LngLatBounds.convert(bounds));
204
- } // eslint-disable-next-line @typescript-eslint/no-unused-vars
173
+ }
205
174
 
175
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
206
176
  }, {
207
177
  key: "setStyle",
208
178
  value: function setStyle(style) {
@@ -212,14 +182,11 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
212
182
  key: "setMinZoom",
213
183
  value: function setMinZoom(minZoom) {
214
184
  minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
215
-
216
185
  if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
217
186
  this.transform.minZoom = minZoom;
218
-
219
187
  if (this.getZoom() < minZoom) {
220
188
  this.setZoom(minZoom);
221
189
  }
222
-
223
190
  return this;
224
191
  } else {
225
192
  throw new Error("minZoom must be between ".concat(defaultMinZoom, " and the current maxZoom, inclusive"));
@@ -234,14 +201,11 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
234
201
  key: "setMaxZoom",
235
202
  value: function setMaxZoom(maxZoom) {
236
203
  maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
237
-
238
204
  if (maxZoom >= this.transform.minZoom) {
239
205
  this.transform.maxZoom = maxZoom;
240
-
241
206
  if (this.getZoom() > maxZoom) {
242
207
  this.setZoom(maxZoom);
243
208
  }
244
-
245
209
  return this;
246
210
  } else {
247
211
  throw new Error('maxZoom must be greater than the current minZoom');
@@ -256,18 +220,14 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
256
220
  key: "setMinPitch",
257
221
  value: function setMinPitch(minPitch) {
258
222
  minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
259
-
260
223
  if (minPitch < defaultMinPitch) {
261
224
  throw new Error("minPitch must be greater than or equal to ".concat(defaultMinPitch));
262
225
  }
263
-
264
226
  if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
265
227
  this.transform.minPitch = minPitch;
266
-
267
228
  if (this.getPitch() < minPitch) {
268
229
  this.setPitch(minPitch);
269
230
  }
270
-
271
231
  return this;
272
232
  } else {
273
233
  throw new Error("minPitch must be between ".concat(defaultMinPitch, " and the current maxPitch, inclusive"));
@@ -282,18 +242,14 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
282
242
  key: "setMaxPitch",
283
243
  value: function setMaxPitch(maxPitch) {
284
244
  maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
285
-
286
245
  if (maxPitch > defaultMaxPitch) {
287
246
  throw new Error("maxPitch must be less than or equal to ".concat(defaultMaxPitch));
288
247
  }
289
-
290
248
  if (maxPitch >= this.transform.minPitch) {
291
249
  this.transform.maxPitch = maxPitch;
292
-
293
250
  if (this.getPitch() > maxPitch) {
294
251
  this.setPitch(maxPitch);
295
252
  }
296
-
297
253
  return this;
298
254
  } else {
299
255
  throw new Error('maxPitch must be greater than the current minPitch');
@@ -321,7 +277,6 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
321
277
  this.frame.cancel();
322
278
  this.frame = null;
323
279
  }
324
-
325
280
  this.renderTaskQueue.clear();
326
281
  }
327
282
  }, {
@@ -339,12 +294,10 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
339
294
  key: "triggerRepaint",
340
295
  value: function triggerRepaint() {
341
296
  var _this2 = this;
342
-
343
297
  if (!this.frame) {
344
298
  this.frame = renderframe(function (paintStartTimeStamp) {
345
299
  PerformanceUtils.frame(paintStartTimeStamp);
346
300
  _this2.frame = null;
347
-
348
301
  _this2.update(paintStartTimeStamp);
349
302
  });
350
303
  }
@@ -353,12 +306,10 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
353
306
  key: "update",
354
307
  value: function update(time) {
355
308
  var _this3 = this;
356
-
357
309
  if (!this.frame) {
358
310
  this.frame = renderframe(function (paintStartTimeStamp) {
359
311
  PerformanceUtils.frame(paintStartTimeStamp);
360
312
  _this3.frame = null;
361
-
362
313
  _this3.renderTaskQueue.run(time);
363
314
  });
364
315
  }
@@ -368,7 +319,6 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
368
319
  value: function initContainer() {
369
320
  if (typeof this.options.container === 'string') {
370
321
  this.container = window.document.getElementById(this.options.container);
371
-
372
322
  if (!this.container) {
373
323
  throw new Error("Container '".concat(this.options.container, "' not found."));
374
324
  }
@@ -377,33 +327,30 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
377
327
  } else {
378
328
  throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
379
329
  }
380
-
381
330
  var container = this.container;
382
331
  container.classList.add('l7-map');
383
332
  var canvasContainer = this.canvasContainer = DOM.create('div', 'l7-canvas-container', container);
384
-
385
333
  if (this.options.interactive) {
386
334
  canvasContainer.classList.add('l7-interactive');
387
- } // this.canvas = DOM.create(
335
+ }
336
+
337
+ // this.canvas = DOM.create(
388
338
  // 'canvas',
389
339
  // 'l7-canvas',
390
340
  // canvasContainer,
391
341
  // ) as HTMLCanvasElement;
392
342
  // this.canvas.setAttribute('tabindex', '-');
393
343
  // this.canvas.setAttribute('aria-label', 'Map');
394
-
395
344
  }
396
345
  }, {
397
346
  key: "containerDimensions",
398
347
  value: function containerDimensions() {
399
348
  var width = 0;
400
349
  var height = 0;
401
-
402
350
  if (this.container) {
403
351
  width = this.container.clientWidth || 400;
404
352
  height = this.container.clientHeight || 300;
405
353
  }
406
-
407
354
  return [width, height];
408
355
  }
409
356
  }, {
@@ -411,12 +358,12 @@ export var EarthMap = /*#__PURE__*/function (_Camera) {
411
358
  value: function resizeCanvas(width, height) {
412
359
  var pixelRatio = DOM.DPR || 1;
413
360
  this.canvas.width = pixelRatio * width;
414
- this.canvas.height = pixelRatio * height; // Maintain the same canvas size, potentially downscaling it for HiDPI displays
361
+ this.canvas.height = pixelRatio * height;
415
362
 
363
+ // Maintain the same canvas size, potentially downscaling it for HiDPI displays
416
364
  this.canvas.style.width = "".concat(width, "px");
417
365
  this.canvas.style.height = "".concat(height, "px");
418
366
  }
419
367
  }]);
420
-
421
368
  return EarthMap;
422
369
  }(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 };