@antv/l7-map 2.21.0 → 2.21.2

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 (158) hide show
  1. package/es/camera.js +595 -674
  2. package/es/earthmap.js +313 -276
  3. package/es/geo/edge_insets.js +57 -72
  4. package/es/geo/lng_lat.js +50 -64
  5. package/es/geo/lng_lat_bounds.js +101 -137
  6. package/es/geo/mercator.js +23 -35
  7. package/es/geo/point.js +150 -221
  8. package/es/geo/simple.js +22 -34
  9. package/es/geo/transform.js +839 -905
  10. package/es/handler/blockable_map_event.js +46 -66
  11. package/es/handler/box_zoom.js +125 -143
  12. package/es/handler/click_zoom.js +37 -51
  13. package/es/handler/events/event.js +11 -9
  14. package/es/handler/events/map_mouse_event.js +39 -54
  15. package/es/handler/events/map_touch_event.js +54 -73
  16. package/es/handler/events/map_wheel_event.js +22 -38
  17. package/es/handler/events/render_event.js +6 -23
  18. package/es/handler/handler_inertia.js +98 -113
  19. package/es/handler/handler_manager.js +349 -437
  20. package/es/handler/handler_util.js +2 -2
  21. package/es/handler/keyboard.js +98 -110
  22. package/es/handler/map_event.js +81 -117
  23. package/es/handler/mouse/mouse_handler.js +81 -100
  24. package/es/handler/mouse/mousepan_handler.js +16 -39
  25. package/es/handler/mouse/mousepitch_hander.js +18 -40
  26. package/es/handler/mouse/mouserotate_hander.js +18 -40
  27. package/es/handler/mouse/util.js +7 -6
  28. package/es/handler/scroll_zoom.js +221 -231
  29. package/es/handler/shim/dblclick_zoom.js +36 -47
  30. package/es/handler/shim/drag_pan.js +41 -50
  31. package/es/handler/shim/drag_rotate.js +38 -48
  32. package/es/handler/shim/touch_zoom_rotate.js +68 -79
  33. package/es/handler/tap/single_tap_recognizer.js +60 -80
  34. package/es/handler/tap/tap_drag_zoom.js +72 -89
  35. package/es/handler/tap/tap_recognizer.js +37 -45
  36. package/es/handler/tap/tap_zoom.js +67 -95
  37. package/es/handler/touch/touch_pan.js +77 -96
  38. package/es/handler/touch/touch_pitch.js +61 -79
  39. package/es/handler/touch/touch_rotate.js +47 -67
  40. package/es/handler/touch/touch_zoom.js +29 -46
  41. package/es/handler/touch/two_touch.js +79 -104
  42. package/es/hash.js +75 -88
  43. package/es/map.js +318 -284
  44. package/es/util.js +18 -37
  45. package/es/utils/Aabb.js +60 -100
  46. package/es/utils/dom.js +32 -55
  47. package/es/utils/performance.js +25 -29
  48. package/es/utils/primitives.js +33 -43
  49. package/es/utils/task_queue.js +47 -76
  50. package/lib/camera.d.ts +86 -0
  51. package/lib/camera.js +597 -672
  52. package/lib/earthmap.d.ts +69 -0
  53. package/lib/earthmap.js +314 -276
  54. package/lib/geo/edge_insets.d.ts +54 -0
  55. package/lib/geo/edge_insets.js +58 -70
  56. package/lib/geo/lng_lat.d.ts +18 -0
  57. package/lib/geo/lng_lat.js +50 -62
  58. package/lib/geo/lng_lat_bounds.d.ts +25 -0
  59. package/lib/geo/lng_lat_bounds.js +102 -136
  60. package/lib/geo/mercator.d.ts +30 -0
  61. package/lib/geo/mercator.js +26 -37
  62. package/lib/geo/point.d.ts +40 -0
  63. package/lib/geo/point.js +151 -220
  64. package/lib/geo/simple.d.ts +30 -0
  65. package/lib/geo/simple.js +25 -36
  66. package/lib/geo/transform.d.ts +198 -0
  67. package/lib/geo/transform.js +844 -907
  68. package/lib/handler/IHandler.d.ts +34 -0
  69. package/lib/handler/blockable_map_event.d.ts +17 -0
  70. package/lib/handler/blockable_map_event.js +48 -65
  71. package/lib/handler/box_zoom.d.ts +59 -0
  72. package/lib/handler/box_zoom.js +126 -143
  73. package/lib/handler/click_zoom.d.ts +16 -0
  74. package/lib/handler/click_zoom.js +38 -50
  75. package/lib/handler/events/event.d.ts +4 -0
  76. package/lib/handler/events/event.js +12 -9
  77. package/lib/handler/events/index.d.ts +4 -0
  78. package/lib/handler/events/index.js +3 -3
  79. package/lib/handler/events/map_mouse_event.d.ts +34 -0
  80. package/lib/handler/events/map_mouse_event.js +41 -52
  81. package/lib/handler/events/map_touch_event.d.ts +57 -0
  82. package/lib/handler/events/map_touch_event.js +56 -71
  83. package/lib/handler/events/map_wheel_event.d.ts +33 -0
  84. package/lib/handler/events/map_wheel_event.js +23 -37
  85. package/lib/handler/events/render_event.d.ts +5 -0
  86. package/lib/handler/events/render_event.js +7 -22
  87. package/lib/handler/handler_inertia.d.ts +23 -0
  88. package/lib/handler/handler_inertia.js +102 -112
  89. package/lib/handler/handler_manager.d.ts +61 -0
  90. package/lib/handler/handler_manager.js +351 -437
  91. package/lib/handler/handler_util.d.ts +4 -0
  92. package/lib/handler/handler_util.js +2 -2
  93. package/lib/handler/keyboard.d.ts +36 -0
  94. package/lib/handler/keyboard.js +98 -110
  95. package/lib/handler/map_event.d.ts +29 -0
  96. package/lib/handler/map_event.js +83 -116
  97. package/lib/handler/mouse/index.d.ts +4 -0
  98. package/lib/handler/mouse/index.js +3 -3
  99. package/lib/handler/mouse/mouse_handler.d.ts +22 -0
  100. package/lib/handler/mouse/mouse_handler.js +83 -99
  101. package/lib/handler/mouse/mousepan_handler.d.ts +10 -0
  102. package/lib/handler/mouse/mousepan_handler.js +19 -38
  103. package/lib/handler/mouse/mousepitch_hander.d.ts +9 -0
  104. package/lib/handler/mouse/mousepitch_hander.js +21 -39
  105. package/lib/handler/mouse/mouserotate_hander.d.ts +9 -0
  106. package/lib/handler/mouse/mouserotate_hander.js +21 -39
  107. package/lib/handler/mouse/util.d.ts +6 -0
  108. package/lib/handler/mouse/util.js +7 -7
  109. package/lib/handler/scroll_zoom.d.ts +93 -0
  110. package/lib/handler/scroll_zoom.js +221 -231
  111. package/lib/handler/shim/dblclick_zoom.d.ts +40 -0
  112. package/lib/handler/shim/dblclick_zoom.js +37 -46
  113. package/lib/handler/shim/drag_pan.d.ts +61 -0
  114. package/lib/handler/shim/drag_pan.js +42 -49
  115. package/lib/handler/shim/drag_rotate.d.ts +46 -0
  116. package/lib/handler/shim/drag_rotate.js +39 -47
  117. package/lib/handler/shim/touch_zoom_rotate.d.ts +70 -0
  118. package/lib/handler/shim/touch_zoom_rotate.js +69 -78
  119. package/lib/handler/tap/single_tap_recognizer.d.ts +20 -0
  120. package/lib/handler/tap/single_tap_recognizer.js +63 -79
  121. package/lib/handler/tap/tap_drag_zoom.d.ts +22 -0
  122. package/lib/handler/tap/tap_drag_zoom.js +74 -88
  123. package/lib/handler/tap/tap_recognizer.d.ts +17 -0
  124. package/lib/handler/tap/tap_recognizer.js +41 -47
  125. package/lib/handler/tap/tap_zoom.d.ts +22 -0
  126. package/lib/handler/tap/tap_zoom.js +69 -94
  127. package/lib/handler/touch/index.d.ts +5 -0
  128. package/lib/handler/touch/index.js +4 -4
  129. package/lib/handler/touch/touch_pan.d.ts +30 -0
  130. package/lib/handler/touch/touch_pan.js +79 -95
  131. package/lib/handler/touch/touch_pitch.d.ts +13 -0
  132. package/lib/handler/touch/touch_pitch.js +64 -78
  133. package/lib/handler/touch/touch_rotate.d.ts +12 -0
  134. package/lib/handler/touch/touch_rotate.js +50 -66
  135. package/lib/handler/touch/touch_zoom.d.ts +12 -0
  136. package/lib/handler/touch/touch_zoom.js +32 -45
  137. package/lib/handler/touch/two_touch.d.ts +23 -0
  138. package/lib/handler/touch/two_touch.js +81 -103
  139. package/lib/hash.d.ts +14 -0
  140. package/lib/hash.js +75 -88
  141. package/lib/index.d.ts +4 -0
  142. package/lib/index.js +4 -4
  143. package/lib/interface.d.ts +34 -0
  144. package/lib/map.d.ts +70 -0
  145. package/lib/map.js +319 -284
  146. package/lib/util.d.ts +25 -0
  147. package/lib/util.js +20 -36
  148. package/lib/utils/Aabb.d.ts +12 -0
  149. package/lib/utils/Aabb.js +61 -99
  150. package/lib/utils/dom.d.ts +4 -0
  151. package/lib/utils/dom.js +34 -55
  152. package/lib/utils/performance.d.ts +17 -0
  153. package/lib/utils/performance.js +25 -29
  154. package/lib/utils/primitives.d.ts +6 -0
  155. package/lib/utils/primitives.js +34 -42
  156. package/lib/utils/task_queue.d.ts +13 -0
  157. package/lib/utils/task_queue.js +47 -76
  158. package/package.json +25 -32
package/lib/earthmap.js CHANGED
@@ -5,12 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.EarthMap = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
9
  var _l7Utils = require("@antv/l7-utils");
16
10
  var _camera = _interopRequireDefault(require("./camera"));
@@ -21,8 +15,6 @@ var _handler_manager = _interopRequireDefault(require("./handler/handler_manager
21
15
  var _util = require("./util");
22
16
  var _performance = require("./utils/performance");
23
17
  var _task_queue = _interopRequireDefault(require("./utils/task_queue"));
24
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
25
- 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; } }
26
18
  function loadStyles(css, doc) {
27
19
  var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
28
20
  var isWeChatMiniProgram = typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
@@ -53,14 +45,111 @@ function loadStyles(css, doc) {
53
45
  head.appendChild(style);
54
46
  return style;
55
47
  }
56
- loadStyles(".l7-map {\n font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;\n overflow: hidden;\n position: relative;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n\n.l7-canvas {\n position: absolute;\n left: 0;\n top: 0;\n}\n\n.l7-map:-webkit-full-screen {\n width: 100%;\n height: 100%;\n}\n\n.l7-canary {\n background-color: salmon;\n}\n\n.l7-canvas-container.l7-interactive,\n.l7-ctrl-group button.l7-ctrl-compass {\n cursor: -webkit-grab;\n cursor: grab;\n -moz-user-select: none;\n -webkit-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n.l7-canvas-container.l7-interactive.l7-track-pointer {\n cursor: pointer;\n}\n\n.l7-canvas-container.l7-interactive:active,\n.l7-ctrl-group button.l7-ctrl-compass:active {\n cursor: -webkit-grabbing;\n cursor: grabbing;\n}\n\n.l7-canvas-container.l7-touch-zoom-rotate,\n.l7-canvas-container.l7-touch-zoom-rotate .l7-canvas {\n -ms-touch-action: pan-x pan-y;\n touch-action: pan-x pan-y;\n}\n\n.l7-canvas-container.l7-touch-drag-pan,\n.l7-canvas-container.l7-touch-drag-pan .l7-canvas {\n -ms-touch-action: pinch-zoom;\n touch-action: pinch-zoom;\n}\n\n.l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan,\n.l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan .l7-canvas {\n -ms-touch-action: none;\n touch-action: none;\n}\n\n.l7-ctrl-top-left,\n.l7-ctrl-top-right,\n.l7-ctrl-bottom-left,\n.l7-ctrl-bottom-right { position: absolute; pointer-events: none; z-index: 2; }\n.l7-ctrl-top-left { top: 0; left: 0; }\n.l7-ctrl-top-right { top: 0; right: 0; }\n.l7-ctrl-bottom-left { bottom: 0; left: 0; }\n.l7-ctrl-bottom-right { right: 0; bottom: 0; }\n\n.l7-ctrl {\n clear: both;\n pointer-events: auto;\n\n /* workaround for a Safari bug https://github.com/mapbox/mapbox-gl-js/issues/8185 */\n -webkit-transform: translate(0, 0);\n transform: translate(0, 0);\n}\n.l7-ctrl-top-left .l7-ctrl { margin: 10px 0 0 10px; float: left; }\n.l7-ctrl-top-right .l7-ctrl { margin: 10px 10px 0 0; float: right; }\n.l7-ctrl-bottom-left .l7-ctrl { margin: 0 0 10px 10px; float: left; }\n.l7-ctrl-bottom-right .l7-ctrl { margin: 0 10px 10px 0; float: right; }\n\n\n.l7-crosshair,\n.l7-crosshair .l7-interactive,\n.l7-crosshair .l7-interactive:active {\n cursor: crosshair;\n}\n\n.l7-boxzoom {\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 0;\n background: #fff;\n border: 2px dotted #202020;\n opacity: 0.5;\n z-index: 10;\n}\n"); // @ts-ignore
57
- var defaultMinZoom = -2;
58
- var defaultMaxZoom = 22;
59
- var merge = _l7Utils.lodashUtil.merge;
48
+ loadStyles(`.l7-map {
49
+ font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
50
+ overflow: hidden;
51
+ position: relative;
52
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
53
+ }
54
+
55
+ .l7-canvas {
56
+ position: absolute;
57
+ left: 0;
58
+ top: 0;
59
+ }
60
+
61
+ .l7-map:-webkit-full-screen {
62
+ width: 100%;
63
+ height: 100%;
64
+ }
65
+
66
+ .l7-canary {
67
+ background-color: salmon;
68
+ }
69
+
70
+ .l7-canvas-container.l7-interactive,
71
+ .l7-ctrl-group button.l7-ctrl-compass {
72
+ cursor: grab;
73
+ -moz-user-select: none;
74
+ -webkit-user-select: none;
75
+ -ms-user-select: none;
76
+ user-select: none;
77
+ }
78
+
79
+ .l7-canvas-container.l7-interactive.l7-track-pointer {
80
+ cursor: pointer;
81
+ }
82
+
83
+ .l7-canvas-container.l7-interactive:active,
84
+ .l7-ctrl-group button.l7-ctrl-compass:active {
85
+ cursor: grabbing;
86
+ }
87
+
88
+ .l7-canvas-container.l7-touch-zoom-rotate,
89
+ .l7-canvas-container.l7-touch-zoom-rotate .l7-canvas {
90
+ touch-action: pan-x pan-y;
91
+ }
92
+
93
+ .l7-canvas-container.l7-touch-drag-pan,
94
+ .l7-canvas-container.l7-touch-drag-pan .l7-canvas {
95
+ touch-action: pinch-zoom;
96
+ }
97
+
98
+ .l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan,
99
+ .l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan .l7-canvas {
100
+ touch-action: none;
101
+ }
102
+
103
+ .l7-ctrl-top-left,
104
+ .l7-ctrl-top-right,
105
+ .l7-ctrl-bottom-left,
106
+ .l7-ctrl-bottom-right { position: absolute; pointer-events: none; z-index: 2; }
107
+ .l7-ctrl-top-left { top: 0; left: 0; }
108
+ .l7-ctrl-top-right { top: 0; right: 0; }
109
+ .l7-ctrl-bottom-left { bottom: 0; left: 0; }
110
+ .l7-ctrl-bottom-right { right: 0; bottom: 0; }
111
+
112
+ .l7-ctrl {
113
+ clear: both;
114
+ pointer-events: auto;
115
+
116
+ /* workaround for a Safari bug https://github.com/mapbox/mapbox-gl-js/issues/8185 */
117
+ -webkit-transform: translate(0, 0);
118
+ transform: translate(0, 0);
119
+ }
120
+ .l7-ctrl-top-left .l7-ctrl { margin: 10px 0 0 10px; float: left; }
121
+ .l7-ctrl-top-right .l7-ctrl { margin: 10px 10px 0 0; float: right; }
122
+ .l7-ctrl-bottom-left .l7-ctrl { margin: 0 0 10px 10px; float: left; }
123
+ .l7-ctrl-bottom-right .l7-ctrl { margin: 0 10px 10px 0; float: right; }
124
+
125
+
126
+ .l7-crosshair,
127
+ .l7-crosshair .l7-interactive,
128
+ .l7-crosshair .l7-interactive:active {
129
+ cursor: crosshair;
130
+ }
131
+
132
+ .l7-boxzoom {
133
+ position: absolute;
134
+ top: 0;
135
+ left: 0;
136
+ width: 0;
137
+ height: 0;
138
+ background: #fff;
139
+ border: 2px dotted #202020;
140
+ opacity: 0.5;
141
+ z-index: 10;
142
+ }
143
+ `); // @ts-ignore
144
+ const defaultMinZoom = -2;
145
+ const defaultMaxZoom = 22;
146
+ const {
147
+ merge
148
+ } = _l7Utils.lodashUtil;
60
149
  // the default values, but also the valid range
61
- var defaultMinPitch = 0;
62
- var defaultMaxPitch = 60;
63
- var DefaultOptions = {
150
+ const defaultMinPitch = 0;
151
+ const defaultMaxPitch = 60;
152
+ const DefaultOptions = {
64
153
  hash: false,
65
154
  zoom: -1,
66
155
  center: [112, 32],
@@ -87,296 +176,245 @@ var DefaultOptions = {
87
176
  pitchEnabled: true,
88
177
  rotateEnabled: true
89
178
  };
90
- var EarthMap = exports.EarthMap = /*#__PURE__*/function (_Camera) {
91
- (0, _inherits2.default)(EarthMap, _Camera);
92
- var _super = _createSuper(EarthMap);
93
- function EarthMap(options) {
94
- var _this;
95
- (0, _classCallCheck2.default)(this, EarthMap);
96
- _this = _super.call(this, merge({}, DefaultOptions, options));
97
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderTaskQueue", new _task_queue.default());
98
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "trackResize", true);
99
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onWindowOnline", function () {
100
- _this.update();
179
+ class EarthMap extends _camera.default {
180
+ constructor(options) {
181
+ super(merge({}, DefaultOptions, options));
182
+ (0, _defineProperty2.default)(this, "doubleClickZoom", void 0);
183
+ (0, _defineProperty2.default)(this, "dragRotate", void 0);
184
+ (0, _defineProperty2.default)(this, "dragPan", void 0);
185
+ (0, _defineProperty2.default)(this, "touchZoomRotate", void 0);
186
+ (0, _defineProperty2.default)(this, "scrollZoom", void 0);
187
+ (0, _defineProperty2.default)(this, "keyboard", void 0);
188
+ (0, _defineProperty2.default)(this, "touchPitch", void 0);
189
+ (0, _defineProperty2.default)(this, "boxZoom", void 0);
190
+ (0, _defineProperty2.default)(this, "handlers", void 0);
191
+ (0, _defineProperty2.default)(this, "container", void 0);
192
+ (0, _defineProperty2.default)(this, "canvas", void 0);
193
+ (0, _defineProperty2.default)(this, "canvasContainer", void 0);
194
+ (0, _defineProperty2.default)(this, "renderTaskQueue", new _task_queue.default());
195
+ (0, _defineProperty2.default)(this, "frame", void 0);
196
+ (0, _defineProperty2.default)(this, "trackResize", true);
197
+ (0, _defineProperty2.default)(this, "onWindowOnline", () => {
198
+ this.update();
101
199
  });
102
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onWindowResize", function (event) {
103
- if (_this.trackResize) {
104
- _this.resize({
200
+ (0, _defineProperty2.default)(this, "onWindowResize", event => {
201
+ if (this.trackResize) {
202
+ this.resize({
105
203
  originalEvent: event
106
204
  }).update();
107
205
  }
108
206
  });
109
- _this.initContainer();
110
- _this.resize();
111
- _this.handlers = new _handler_manager.default((0, _assertThisInitialized2.default)(_this), _this.options);
207
+ this.initContainer();
208
+ this.resize();
209
+ this.handlers = new _handler_manager.default(this, this.options);
112
210
  if (typeof window !== 'undefined') {
113
- window.addEventListener('online', _this.onWindowOnline, false);
114
- window.addEventListener('resize', _this.onWindowResize, false);
115
- window.addEventListener('orientationchange', _this.onWindowResize, false);
211
+ window.addEventListener('online', this.onWindowOnline, false);
212
+ window.addEventListener('resize', this.onWindowResize, false);
213
+ window.addEventListener('orientationchange', this.onWindowResize, false);
116
214
  }
117
- return _this;
118
- }
119
- (0, _createClass2.default)(EarthMap, [{
120
- key: "resize",
121
- value: function resize(eventData) {
122
- var dimensions = this.containerDimensions();
123
- var width = dimensions[0];
124
- var height = dimensions[1];
215
+ }
216
+ resize(eventData) {
217
+ const dimensions = this.containerDimensions();
218
+ const width = dimensions[0];
219
+ const height = dimensions[1];
125
220
 
126
- // this.resizeCanvas(width, height);
127
- this.transform.resize(width, height);
128
- var fireMoving = !this.moving;
129
- if (fireMoving) {
130
- this.stop();
131
- this.emit('movestart', new Event('movestart', eventData));
132
- this.emit('move', new Event('move', eventData));
133
- }
134
- this.emit('resize', new Event('resize', eventData));
135
- if (fireMoving) {
136
- this.emit('moveend', new Event('moveend', eventData));
137
- }
138
- return this;
139
- }
140
- }, {
141
- key: "getContainer",
142
- value: function getContainer() {
143
- return this.container;
144
- }
145
- }, {
146
- key: "getCanvas",
147
- value: function getCanvas() {
148
- return this.canvas;
149
- }
150
- }, {
151
- key: "getCanvasContainer",
152
- value: function getCanvasContainer() {
153
- return this.canvasContainer;
221
+ // this.resizeCanvas(width, height);
222
+ this.transform.resize(width, height);
223
+ const fireMoving = !this.moving;
224
+ if (fireMoving) {
225
+ this.stop();
226
+ this.emit('movestart', new Event('movestart', eventData));
227
+ this.emit('move', new Event('move', eventData));
154
228
  }
155
- }, {
156
- key: "project",
157
- value: function project(lngLat) {
158
- return this.transform.locationPoint(_lng_lat.default.convert(lngLat));
159
- }
160
- }, {
161
- key: "unproject",
162
- value: function unproject(point) {
163
- return this.transform.pointLocation(_point.default.convert(point));
164
- }
165
- }, {
166
- key: "getBounds",
167
- value: function getBounds() {
168
- return this.transform.getBounds();
169
- }
170
- }, {
171
- key: "getMaxBounds",
172
- value: function getMaxBounds() {
173
- return this.transform.getMaxBounds();
174
- }
175
- }, {
176
- key: "setMaxBounds",
177
- value: function setMaxBounds(bounds) {
178
- this.transform.setMaxBounds(_lng_lat_bounds.default.convert(bounds));
229
+ this.emit('resize', new Event('resize', eventData));
230
+ if (fireMoving) {
231
+ this.emit('moveend', new Event('moveend', eventData));
179
232
  }
233
+ return this;
234
+ }
235
+ getContainer() {
236
+ return this.container;
237
+ }
238
+ getCanvas() {
239
+ return this.canvas;
240
+ }
241
+ getCanvasContainer() {
242
+ return this.canvasContainer;
243
+ }
244
+ project(lngLat) {
245
+ return this.transform.locationPoint(_lng_lat.default.convert(lngLat));
246
+ }
247
+ unproject(point) {
248
+ return this.transform.pointLocation(_point.default.convert(point));
249
+ }
250
+ getBounds() {
251
+ return this.transform.getBounds();
252
+ }
253
+ getMaxBounds() {
254
+ return this.transform.getMaxBounds();
255
+ }
256
+ setMaxBounds(bounds) {
257
+ this.transform.setMaxBounds(_lng_lat_bounds.default.convert(bounds));
258
+ }
180
259
 
181
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
182
- }, {
183
- key: "setStyle",
184
- value: function setStyle(style) {
185
- return;
186
- }
187
- }, {
188
- key: "setMinZoom",
189
- value: function setMinZoom(minZoom) {
190
- minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
191
- if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
192
- this.transform.minZoom = minZoom;
193
- if (this.getZoom() < minZoom) {
194
- this.setZoom(minZoom);
195
- }
196
- return this;
197
- } else {
198
- throw new Error("minZoom must be between ".concat(defaultMinZoom, " and the current maxZoom, inclusive"));
260
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
261
+ setStyle(style) {
262
+ return;
263
+ }
264
+ setMinZoom(minZoom) {
265
+ minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
266
+ if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
267
+ this.transform.minZoom = minZoom;
268
+ if (this.getZoom() < minZoom) {
269
+ this.setZoom(minZoom);
199
270
  }
271
+ return this;
272
+ } else {
273
+ throw new Error(`minZoom must be between ${defaultMinZoom} and the current maxZoom, inclusive`);
200
274
  }
201
- }, {
202
- key: "getMinZoom",
203
- value: function getMinZoom() {
204
- return this.transform.minZoom;
205
- }
206
- }, {
207
- key: "setMaxZoom",
208
- value: function setMaxZoom(maxZoom) {
209
- maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
210
- if (maxZoom >= this.transform.minZoom) {
211
- this.transform.maxZoom = maxZoom;
212
- if (this.getZoom() > maxZoom) {
213
- this.setZoom(maxZoom);
214
- }
215
- return this;
216
- } else {
217
- throw new Error('maxZoom must be greater than the current minZoom');
275
+ }
276
+ getMinZoom() {
277
+ return this.transform.minZoom;
278
+ }
279
+ setMaxZoom(maxZoom) {
280
+ maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
281
+ if (maxZoom >= this.transform.minZoom) {
282
+ this.transform.maxZoom = maxZoom;
283
+ if (this.getZoom() > maxZoom) {
284
+ this.setZoom(maxZoom);
218
285
  }
286
+ return this;
287
+ } else {
288
+ throw new Error('maxZoom must be greater than the current minZoom');
219
289
  }
220
- }, {
221
- key: "getMaxZoom",
222
- value: function getMaxZoom() {
223
- return this.transform.maxZoom;
290
+ }
291
+ getMaxZoom() {
292
+ return this.transform.maxZoom;
293
+ }
294
+ setMinPitch(minPitch) {
295
+ minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
296
+ if (minPitch < defaultMinPitch) {
297
+ throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);
224
298
  }
225
- }, {
226
- key: "setMinPitch",
227
- value: function setMinPitch(minPitch) {
228
- minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
229
- if (minPitch < defaultMinPitch) {
230
- throw new Error("minPitch must be greater than or equal to ".concat(defaultMinPitch));
231
- }
232
- if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
233
- this.transform.minPitch = minPitch;
234
- if (this.getPitch() < minPitch) {
235
- this.setPitch(minPitch);
236
- }
237
- return this;
238
- } else {
239
- throw new Error("minPitch must be between ".concat(defaultMinPitch, " and the current maxPitch, inclusive"));
299
+ if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
300
+ this.transform.minPitch = minPitch;
301
+ if (this.getPitch() < minPitch) {
302
+ this.setPitch(minPitch);
240
303
  }
304
+ return this;
305
+ } else {
306
+ throw new Error(`minPitch must be between ${defaultMinPitch} and the current maxPitch, inclusive`);
241
307
  }
242
- }, {
243
- key: "getMinPitch",
244
- value: function getMinPitch() {
245
- return this.transform.minPitch;
308
+ }
309
+ getMinPitch() {
310
+ return this.transform.minPitch;
311
+ }
312
+ setMaxPitch(maxPitch) {
313
+ maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
314
+ if (maxPitch > defaultMaxPitch) {
315
+ throw new Error(`maxPitch must be less than or equal to ${defaultMaxPitch}`);
246
316
  }
247
- }, {
248
- key: "setMaxPitch",
249
- value: function setMaxPitch(maxPitch) {
250
- maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
251
- if (maxPitch > defaultMaxPitch) {
252
- throw new Error("maxPitch must be less than or equal to ".concat(defaultMaxPitch));
317
+ if (maxPitch >= this.transform.minPitch) {
318
+ this.transform.maxPitch = maxPitch;
319
+ if (this.getPitch() > maxPitch) {
320
+ this.setPitch(maxPitch);
253
321
  }
254
- if (maxPitch >= this.transform.minPitch) {
255
- this.transform.maxPitch = maxPitch;
256
- if (this.getPitch() > maxPitch) {
257
- this.setPitch(maxPitch);
258
- }
259
- return this;
260
- } else {
261
- throw new Error('maxPitch must be greater than the current minPitch');
262
- }
263
- }
264
- }, {
265
- key: "getMaxPitch",
266
- value: function getMaxPitch() {
267
- return this.transform.maxPitch;
322
+ return this;
323
+ } else {
324
+ throw new Error('maxPitch must be greater than the current minPitch');
268
325
  }
269
- }, {
270
- key: "getRenderWorldCopies",
271
- value: function getRenderWorldCopies() {
272
- return this.transform.renderWorldCopies;
326
+ }
327
+ getMaxPitch() {
328
+ return this.transform.maxPitch;
329
+ }
330
+ getRenderWorldCopies() {
331
+ return this.transform.renderWorldCopies;
332
+ }
333
+ setRenderWorldCopies(renderWorldCopies) {
334
+ this.transform.renderWorldCopies = !!renderWorldCopies;
335
+ }
336
+ remove() {
337
+ if (this.frame) {
338
+ this.frame.cancel();
339
+ this.frame = null;
273
340
  }
274
- }, {
275
- key: "setRenderWorldCopies",
276
- value: function setRenderWorldCopies(renderWorldCopies) {
277
- this.transform.renderWorldCopies = !!renderWorldCopies;
341
+ this.renderTaskQueue.clear();
342
+ //销毁事件
343
+ this.handlers.destroy();
344
+ if (typeof window !== 'undefined') {
345
+ window.removeEventListener('online', this.onWindowOnline, false);
346
+ window.removeEventListener('resize', this.onWindowResize, false);
347
+ window.removeEventListener('orientationchange', this.onWindowResize, false);
278
348
  }
279
- }, {
280
- key: "remove",
281
- value: function remove() {
282
- if (this.frame) {
283
- this.frame.cancel();
349
+ }
350
+ requestRenderFrame(cb) {
351
+ this.update();
352
+ return this.renderTaskQueue.add(cb);
353
+ }
354
+ cancelRenderFrame(id) {
355
+ return this.renderTaskQueue.remove(id);
356
+ }
357
+ triggerRepaint() {
358
+ if (!this.frame) {
359
+ this.frame = (0, _util.renderframe)(paintStartTimeStamp => {
360
+ _performance.PerformanceUtils.frame(paintStartTimeStamp);
284
361
  this.frame = null;
285
- }
286
- this.renderTaskQueue.clear();
287
- //销毁事件
288
- this.handlers.destroy();
289
- if (typeof window !== 'undefined') {
290
- window.removeEventListener('online', this.onWindowOnline, false);
291
- window.removeEventListener('resize', this.onWindowResize, false);
292
- window.removeEventListener('orientationchange', this.onWindowResize, false);
293
- }
294
- }
295
- }, {
296
- key: "requestRenderFrame",
297
- value: function requestRenderFrame(cb) {
298
- this.update();
299
- return this.renderTaskQueue.add(cb);
362
+ this.update(paintStartTimeStamp);
363
+ });
300
364
  }
301
- }, {
302
- key: "cancelRenderFrame",
303
- value: function cancelRenderFrame(id) {
304
- return this.renderTaskQueue.remove(id);
365
+ }
366
+ update(time) {
367
+ if (!this.frame) {
368
+ this.frame = (0, _util.renderframe)(paintStartTimeStamp => {
369
+ _performance.PerformanceUtils.frame(paintStartTimeStamp);
370
+ this.frame = null;
371
+ this.renderTaskQueue.run(time);
372
+ });
305
373
  }
306
- }, {
307
- key: "triggerRepaint",
308
- value: function triggerRepaint() {
309
- var _this2 = this;
310
- if (!this.frame) {
311
- this.frame = (0, _util.renderframe)(function (paintStartTimeStamp) {
312
- _performance.PerformanceUtils.frame(paintStartTimeStamp);
313
- _this2.frame = null;
314
- _this2.update(paintStartTimeStamp);
315
- });
374
+ }
375
+ initContainer() {
376
+ if (typeof this.options.container === 'string') {
377
+ this.container = window.document.getElementById(this.options.container);
378
+ if (!this.container) {
379
+ throw new Error(`Container '${this.options.container}' not found.`);
316
380
  }
381
+ } else if (this.options.container instanceof HTMLElement) {
382
+ this.container = this.options.container;
383
+ } else {
384
+ throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
317
385
  }
318
- }, {
319
- key: "update",
320
- value: function update(time) {
321
- var _this3 = this;
322
- if (!this.frame) {
323
- this.frame = (0, _util.renderframe)(function (paintStartTimeStamp) {
324
- _performance.PerformanceUtils.frame(paintStartTimeStamp);
325
- _this3.frame = null;
326
- _this3.renderTaskQueue.run(time);
327
- });
328
- }
386
+ const container = this.container;
387
+ container.classList.add('l7-map');
388
+ const canvasContainer = this.canvasContainer = _l7Utils.DOM.create('div', 'l7-canvas-container', container);
389
+ if (this.options.interactive) {
390
+ canvasContainer.classList.add('l7-interactive');
329
391
  }
330
- }, {
331
- key: "initContainer",
332
- value: function initContainer() {
333
- if (typeof this.options.container === 'string') {
334
- this.container = window.document.getElementById(this.options.container);
335
- if (!this.container) {
336
- throw new Error("Container '".concat(this.options.container, "' not found."));
337
- }
338
- } else if (this.options.container instanceof HTMLElement) {
339
- this.container = this.options.container;
340
- } else {
341
- throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
342
- }
343
- var container = this.container;
344
- container.classList.add('l7-map');
345
- var canvasContainer = this.canvasContainer = _l7Utils.DOM.create('div', 'l7-canvas-container', container);
346
- if (this.options.interactive) {
347
- canvasContainer.classList.add('l7-interactive');
348
- }
349
392
 
350
- // this.canvas = DOM.create(
351
- // 'canvas',
352
- // 'l7-canvas',
353
- // canvasContainer,
354
- // ) as HTMLCanvasElement;
355
- // this.canvas.setAttribute('tabindex', '-');
356
- // this.canvas.setAttribute('aria-label', 'Map');
357
- }
358
- }, {
359
- key: "containerDimensions",
360
- value: function containerDimensions() {
361
- var width = 0;
362
- var height = 0;
363
- if (this.container) {
364
- width = this.container.clientWidth || 400;
365
- height = this.container.clientHeight || 300;
366
- }
367
- return [width, height];
393
+ // this.canvas = DOM.create(
394
+ // 'canvas',
395
+ // 'l7-canvas',
396
+ // canvasContainer,
397
+ // ) as HTMLCanvasElement;
398
+ // this.canvas.setAttribute('tabindex', '-');
399
+ // this.canvas.setAttribute('aria-label', 'Map');
400
+ }
401
+ containerDimensions() {
402
+ let width = 0;
403
+ let height = 0;
404
+ if (this.container) {
405
+ width = this.container.clientWidth || 400;
406
+ height = this.container.clientHeight || 300;
368
407
  }
369
- }, {
370
- key: "resizeCanvas",
371
- value: function resizeCanvas(width, height) {
372
- var pixelRatio = _l7Utils.DOM.DPR || 1;
373
- this.canvas.width = pixelRatio * width;
374
- this.canvas.height = pixelRatio * height;
408
+ return [width, height];
409
+ }
410
+ resizeCanvas(width, height) {
411
+ const pixelRatio = _l7Utils.DOM.DPR || 1;
412
+ this.canvas.width = pixelRatio * width;
413
+ this.canvas.height = pixelRatio * height;
375
414
 
376
- // Maintain the same canvas size, potentially downscaling it for HiDPI displays
377
- this.canvas.style.width = "".concat(width, "px");
378
- this.canvas.style.height = "".concat(height, "px");
379
- }
380
- }]);
381
- return EarthMap;
382
- }(_camera.default);
415
+ // Maintain the same canvas size, potentially downscaling it for HiDPI displays
416
+ this.canvas.style.width = `${width}px`;
417
+ this.canvas.style.height = `${height}px`;
418
+ }
419
+ }
420
+ exports.EarthMap = EarthMap;