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