@antv/l7-map 2.9.32 → 2.9.34

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 (56) hide show
  1. package/lib/camera.js +766 -508
  2. package/lib/earthmap.js +389 -223
  3. package/lib/geo/edge_insets.js +117 -64
  4. package/lib/geo/lng_lat.js +86 -65
  5. package/lib/geo/lng_lat_bounds.js +162 -123
  6. package/lib/geo/mercator.js +91 -62
  7. package/lib/geo/point.js +234 -171
  8. package/lib/geo/simple.js +93 -61
  9. package/lib/geo/transform.js +982 -472
  10. package/lib/handler/IHandler.js +4 -16
  11. package/lib/handler/blockable_map_event.js +84 -63
  12. package/lib/handler/box_zoom.js +201 -123
  13. package/lib/handler/click_zoom.js +63 -55
  14. package/lib/handler/events/event.js +20 -35
  15. package/lib/handler/events/index.js +28 -35
  16. package/lib/handler/events/map_mouse_event.js +85 -42
  17. package/lib/handler/events/map_touch_event.js +116 -45
  18. package/lib/handler/events/map_wheel_event.js +70 -34
  19. package/lib/handler/events/render_event.js +50 -31
  20. package/lib/handler/handler_inertia.js +158 -114
  21. package/lib/handler/handler_manager.js +640 -381
  22. package/lib/handler/handler_util.js +11 -29
  23. package/lib/handler/keyboard.js +155 -114
  24. package/lib/handler/map_event.js +133 -84
  25. package/lib/handler/mouse/index.js +28 -35
  26. package/lib/handler/mouse/mouse_handler.js +126 -90
  27. package/lib/handler/mouse/mousepan_handler.js +64 -46
  28. package/lib/handler/mouse/mousepitch_hander.js +64 -44
  29. package/lib/handler/mouse/mouserotate_hander.js +64 -44
  30. package/lib/handler/mouse/util.js +22 -40
  31. package/lib/handler/scroll_zoom.js +318 -176
  32. package/lib/handler/shim/dblclick_zoom.js +76 -42
  33. package/lib/handler/shim/drag_pan.js +98 -48
  34. package/lib/handler/shim/drag_rotate.js +82 -43
  35. package/lib/handler/shim/touch_zoom_rotate.js +127 -59
  36. package/lib/handler/tap/single_tap_recognizer.js +113 -84
  37. package/lib/handler/tap/tap_drag_zoom.js +111 -93
  38. package/lib/handler/tap/tap_recognizer.js +72 -60
  39. package/lib/handler/tap/tap_zoom.js +113 -88
  40. package/lib/handler/touch/index.js +36 -38
  41. package/lib/handler/touch/touch_pan.js +126 -98
  42. package/lib/handler/touch/touch_pitch.js +108 -74
  43. package/lib/handler/touch/touch_rotate.js +93 -59
  44. package/lib/handler/touch/touch_zoom.js +71 -49
  45. package/lib/handler/touch/two_touch.js +129 -90
  46. package/lib/hash.js +149 -100
  47. package/lib/index.js +43 -20
  48. package/lib/interface.js +4 -16
  49. package/lib/map.js +420 -240
  50. package/lib/util.js +88 -69
  51. package/lib/utils/Aabb.js +134 -81
  52. package/lib/utils/dom.js +162 -88
  53. package/lib/utils/performance.js +46 -54
  54. package/lib/utils/primitives.js +53 -59
  55. package/lib/utils/task_queue.js +104 -61
  56. package/package.json +3 -3
package/lib/map.js CHANGED
@@ -1,44 +1,98 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";
21
2
 
22
- // src/map.ts
23
- var map_exports = {};
24
- __export(map_exports, {
25
- Map: () => Map
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
26
7
  });
27
- module.exports = __toCommonJS(map_exports);
28
- var import_l7_utils = require("@antv/l7-utils");
29
- var import_lodash = require("lodash");
30
- var import_camera = __toESM(require("./camera"));
31
- var import_l7 = require("./css/l7.css");
32
- var import_lng_lat = __toESM(require("./geo/lng_lat"));
33
- var import_lng_lat_bounds = __toESM(require("./geo/lng_lat_bounds"));
34
- var import_point = __toESM(require("./geo/point"));
35
- var import_handler_manager = __toESM(require("./handler/handler_manager"));
36
- var import_hash = __toESM(require("./hash"));
37
- var import_util = require("./util");
38
- var import_performance = require("./utils/performance");
39
- var import_task_queue = __toESM(require("./utils/task_queue"));
8
+ exports.Map = void 0;
9
+
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
16
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
+
18
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
+
20
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
+
22
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
+
24
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
+
26
+ var _l7Utils = require("@antv/l7-utils");
27
+
28
+ var _lodash = require("lodash");
29
+
30
+ var _camera = _interopRequireDefault(require("./camera"));
31
+
32
+ var _lng_lat = _interopRequireDefault(require("./geo/lng_lat"));
33
+
34
+ var _lng_lat_bounds = _interopRequireDefault(require("./geo/lng_lat_bounds"));
35
+
36
+ var _point = _interopRequireDefault(require("./geo/point"));
37
+
38
+ var _handler_manager = _interopRequireDefault(require("./handler/handler_manager"));
39
+
40
+ var _hash = _interopRequireDefault(require("./hash"));
41
+
42
+ var _util = require("./util");
43
+
44
+ var _performance = require("./utils/performance");
45
+
46
+ var _task_queue = _interopRequireDefault(require("./utils/task_queue"));
47
+
48
+ 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); }; }
49
+
50
+ 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; } }
51
+
52
+ function loadStyles(css, doc) {
53
+ var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
54
+ var isWeChatMiniProgram = typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
55
+
56
+ if (isMiniAli || isWeChatMiniProgram) {
57
+ return;
58
+ }
59
+
60
+ if (!doc) doc = document;
61
+
62
+ if (!doc) {
63
+ return;
64
+ }
65
+
66
+ var head = doc.head || doc.getElementsByTagName('head')[0];
67
+
68
+ if (!head) {
69
+ head = doc.createElement('head');
70
+ var body = doc.body || doc.getElementsByTagName('body')[0];
71
+
72
+ if (body) {
73
+ body.parentNode.insertBefore(head, body);
74
+ } else {
75
+ doc.documentElement.appendChild(head);
76
+ }
77
+ }
78
+
79
+ var style = doc.createElement('style');
80
+ style.type = 'text/css';
81
+
82
+ if (style.styleSheet) {
83
+ style.styleSheet.cssText = css;
84
+ } else {
85
+ style.appendChild(doc.createTextNode(css));
86
+ }
87
+
88
+ head.appendChild(style);
89
+ return style;
90
+ }
91
+
92
+ 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");
40
93
  var defaultMinZoom = -2;
41
- var defaultMaxZoom = 22;
94
+ var defaultMaxZoom = 22; // the default values, but also the valid range
95
+
42
96
  var defaultMinPitch = 0;
43
97
  var defaultMaxPitch = 60;
44
98
  var DefaultOptions = {
@@ -68,241 +122,367 @@ var DefaultOptions = {
68
122
  pitchEnabled: true,
69
123
  rotateEnabled: true
70
124
  };
71
- var Map = class extends import_camera.default {
72
- constructor(options) {
73
- super((0, import_lodash.merge)({}, DefaultOptions, options));
74
- this.renderTaskQueue = new import_task_queue.default();
75
- this.trackResize = true;
76
- this.onWindowOnline = () => {
77
- this.update();
78
- };
79
- this.onWindowResize = (event) => {
80
- if (this.trackResize) {
81
- this.resize({ originalEvent: event }).update();
125
+
126
+ var Map = /*#__PURE__*/function (_Camera) {
127
+ (0, _inherits2.default)(Map, _Camera);
128
+
129
+ var _super = _createSuper(Map);
130
+
131
+ function Map(options) {
132
+ var _this;
133
+
134
+ (0, _classCallCheck2.default)(this, Map);
135
+ _this = _super.call(this, (0, _lodash.merge)({}, DefaultOptions, options));
136
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderTaskQueue", new _task_queue.default());
137
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "trackResize", true);
138
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onWindowOnline", function () {
139
+ _this.update();
140
+ });
141
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onWindowResize", function (event) {
142
+ if (_this.trackResize) {
143
+ _this.resize({
144
+ originalEvent: event
145
+ }).update();
82
146
  }
83
- };
84
- if (import_l7_utils.isMini) {
85
- this.initMiniContainer();
147
+ });
148
+
149
+ if (_l7Utils.isMini) {
150
+ _this.initMiniContainer();
86
151
  } else {
87
- this.initContainer();
152
+ _this.initContainer();
88
153
  }
89
- this.resize();
90
- this.handlers = new import_handler_manager.default(this, this.options);
91
- if (typeof window !== "undefined") {
92
- window.addEventListener("online", this.onWindowOnline, false);
93
- window.addEventListener("resize", this.onWindowResize, false);
94
- window.addEventListener("orientationchange", this.onWindowResize, false);
154
+
155
+ _this.resize();
156
+
157
+ _this.handlers = new _handler_manager.default((0, _assertThisInitialized2.default)(_this), _this.options);
158
+
159
+ if (typeof window !== 'undefined') {
160
+ window.addEventListener('online', _this.onWindowOnline, false);
161
+ window.addEventListener('resize', _this.onWindowResize, false);
162
+ window.addEventListener('orientationchange', _this.onWindowResize, false);
95
163
  }
96
- if (!import_l7_utils.isMini) {
97
- const hashName = typeof options.hash === "string" && options.hash || void 0;
164
+
165
+ if (!_l7Utils.isMini) {
166
+ var hashName = typeof options.hash === 'string' && options.hash || undefined;
167
+
98
168
  if (options.hash) {
99
- this.hash = new import_hash.default(hashName).addTo(this);
169
+ _this.hash = new _hash.default(hashName).addTo((0, _assertThisInitialized2.default)(_this));
100
170
  }
101
- }
102
- if (!this.hash || !this.hash.onHashChange()) {
103
- this.jumpTo({
171
+ } // don't set position from options if set through hash
172
+
173
+
174
+ if (!_this.hash || !_this.hash.onHashChange()) {
175
+ _this.jumpTo({
104
176
  center: options.center,
105
177
  zoom: options.zoom,
106
178
  bearing: options.bearing,
107
179
  pitch: options.pitch
108
180
  });
181
+
109
182
  if (options.bounds) {
110
- this.resize();
111
- this.fitBounds(options.bounds, (0, import_lodash.merge)({}, options.fitBoundsOptions, { duration: 0 }));
183
+ _this.resize();
184
+
185
+ _this.fitBounds(options.bounds, (0, _lodash.merge)({}, options.fitBoundsOptions, {
186
+ duration: 0
187
+ }));
112
188
  }
113
189
  }
190
+
191
+ return _this;
114
192
  }
115
- resize(eventData) {
116
- const [width, height] = this.containerDimensions();
117
- this.transform.resize(width, height);
118
- if (import_l7_utils.isMini) {
193
+
194
+ (0, _createClass2.default)(Map, [{
195
+ key: "resize",
196
+ value: function resize(eventData) {
197
+ var _this$containerDimens = this.containerDimensions(),
198
+ _this$containerDimens2 = (0, _slicedToArray2.default)(_this$containerDimens, 2),
199
+ width = _this$containerDimens2[0],
200
+ height = _this$containerDimens2[1];
201
+
202
+ this.transform.resize(width, height); // 小程序环境不需要执行后续动作
203
+
204
+ if (_l7Utils.isMini) {
205
+ return this;
206
+ }
207
+
208
+ var fireMoving = !this.moving;
209
+
210
+ if (fireMoving) {
211
+ this.stop();
212
+ this.emit('movestart', new _l7Utils.$window.Event('movestart', eventData));
213
+ this.emit('move', new _l7Utils.$window.Event('move', eventData));
214
+ }
215
+
216
+ this.emit('resize', new _l7Utils.$window.Event('resize', eventData));
217
+
218
+ if (fireMoving) {
219
+ this.emit('moveend', new _l7Utils.$window.Event('moveend', eventData));
220
+ }
221
+
119
222
  return this;
120
223
  }
121
- const fireMoving = !this.moving;
122
- if (fireMoving) {
123
- this.stop();
124
- this.emit("movestart", new import_l7_utils.$window.Event("movestart", eventData));
125
- this.emit("move", new import_l7_utils.$window.Event("move", eventData));
224
+ }, {
225
+ key: "getContainer",
226
+ value: function getContainer() {
227
+ return this.container;
126
228
  }
127
- this.emit("resize", new import_l7_utils.$window.Event("resize", eventData));
128
- if (fireMoving) {
129
- this.emit("moveend", new import_l7_utils.$window.Event("moveend", eventData));
229
+ }, {
230
+ key: "getCanvas",
231
+ value: function getCanvas() {
232
+ return this.canvas;
130
233
  }
131
- return this;
132
- }
133
- getContainer() {
134
- return this.container;
135
- }
136
- getCanvas() {
137
- return this.canvas;
138
- }
139
- getCanvasContainer() {
140
- return this.canvasContainer;
141
- }
142
- project(lngLat) {
143
- return this.transform.locationPoint(import_lng_lat.default.convert(lngLat));
144
- }
145
- unproject(point) {
146
- return this.transform.pointLocation(import_point.default.convert(point));
147
- }
148
- getBounds() {
149
- return this.transform.getBounds();
150
- }
151
- getMaxBounds() {
152
- return this.transform.getMaxBounds();
153
- }
154
- setMaxBounds(bounds) {
155
- this.transform.setMaxBounds(import_lng_lat_bounds.default.convert(bounds));
156
- }
157
- setStyle(style) {
158
- return;
159
- }
160
- setMinZoom(minZoom) {
161
- minZoom = minZoom === null || minZoom === void 0 ? defaultMinZoom : minZoom;
162
- if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
163
- this.transform.minZoom = minZoom;
164
- if (this.getZoom() < minZoom) {
165
- this.setZoom(minZoom);
234
+ }, {
235
+ key: "getCanvasContainer",
236
+ value: function getCanvasContainer() {
237
+ return this.canvasContainer;
238
+ }
239
+ }, {
240
+ key: "project",
241
+ value: function project(lngLat) {
242
+ return this.transform.locationPoint(_lng_lat.default.convert(lngLat));
243
+ }
244
+ }, {
245
+ key: "unproject",
246
+ value: function unproject(point) {
247
+ return this.transform.pointLocation(_point.default.convert(point));
248
+ }
249
+ }, {
250
+ key: "getBounds",
251
+ value: function getBounds() {
252
+ return this.transform.getBounds();
253
+ }
254
+ }, {
255
+ key: "getMaxBounds",
256
+ value: function getMaxBounds() {
257
+ return this.transform.getMaxBounds();
258
+ }
259
+ }, {
260
+ key: "setMaxBounds",
261
+ value: function setMaxBounds(bounds) {
262
+ this.transform.setMaxBounds(_lng_lat_bounds.default.convert(bounds));
263
+ }
264
+ }, {
265
+ key: "setStyle",
266
+ value: function setStyle(style) {
267
+ return;
268
+ }
269
+ }, {
270
+ key: "setMinZoom",
271
+ value: function setMinZoom(minZoom) {
272
+ minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
273
+
274
+ if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
275
+ this.transform.minZoom = minZoom;
276
+
277
+ if (this.getZoom() < minZoom) {
278
+ this.setZoom(minZoom);
279
+ }
280
+
281
+ return this;
282
+ } else {
283
+ throw new Error("minZoom must be between ".concat(defaultMinZoom, " and the current maxZoom, inclusive"));
166
284
  }
167
- return this;
168
- } else {
169
- throw new Error(`minZoom must be between ${defaultMinZoom} and the current maxZoom, inclusive`);
170
285
  }
171
- }
172
- getMinZoom() {
173
- return this.transform.minZoom;
174
- }
175
- setMaxZoom(maxZoom) {
176
- maxZoom = maxZoom === null || maxZoom === void 0 ? defaultMaxZoom : maxZoom;
177
- if (maxZoom >= this.transform.minZoom) {
178
- this.transform.maxZoom = maxZoom;
179
- if (this.getZoom() > maxZoom) {
180
- this.setZoom(maxZoom);
286
+ }, {
287
+ key: "getMinZoom",
288
+ value: function getMinZoom() {
289
+ return this.transform.minZoom;
290
+ }
291
+ }, {
292
+ key: "setMaxZoom",
293
+ value: function setMaxZoom(maxZoom) {
294
+ maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
295
+
296
+ if (maxZoom >= this.transform.minZoom) {
297
+ this.transform.maxZoom = maxZoom;
298
+
299
+ if (this.getZoom() > maxZoom) {
300
+ this.setZoom(maxZoom);
301
+ }
302
+
303
+ return this;
304
+ } else {
305
+ throw new Error('maxZoom must be greater than the current minZoom');
181
306
  }
182
- return this;
183
- } else {
184
- throw new Error("maxZoom must be greater than the current minZoom");
185
307
  }
186
- }
187
- getMaxZoom() {
188
- return this.transform.maxZoom;
189
- }
190
- setMinPitch(minPitch) {
191
- minPitch = minPitch === null || minPitch === void 0 ? defaultMinPitch : minPitch;
192
- if (minPitch < defaultMinPitch) {
193
- throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);
194
- }
195
- if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
196
- this.transform.minPitch = minPitch;
197
- if (this.getPitch() < minPitch) {
198
- this.setPitch(minPitch);
308
+ }, {
309
+ key: "getMaxZoom",
310
+ value: function getMaxZoom() {
311
+ return this.transform.maxZoom;
312
+ }
313
+ }, {
314
+ key: "setMinPitch",
315
+ value: function setMinPitch(minPitch) {
316
+ minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
317
+
318
+ if (minPitch < defaultMinPitch) {
319
+ throw new Error("minPitch must be greater than or equal to ".concat(defaultMinPitch));
320
+ }
321
+
322
+ if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
323
+ this.transform.minPitch = minPitch;
324
+
325
+ if (this.getPitch() < minPitch) {
326
+ this.setPitch(minPitch);
327
+ }
328
+
329
+ return this;
330
+ } else {
331
+ throw new Error("minPitch must be between ".concat(defaultMinPitch, " and the current maxPitch, inclusive"));
199
332
  }
200
- return this;
201
- } else {
202
- throw new Error(`minPitch must be between ${defaultMinPitch} and the current maxPitch, inclusive`);
203
333
  }
204
- }
205
- getMinPitch() {
206
- return this.transform.minPitch;
207
- }
208
- setMaxPitch(maxPitch) {
209
- maxPitch = maxPitch === null || maxPitch === void 0 ? defaultMaxPitch : maxPitch;
210
- if (maxPitch > defaultMaxPitch) {
211
- throw new Error(`maxPitch must be less than or equal to ${defaultMaxPitch}`);
212
- }
213
- if (maxPitch >= this.transform.minPitch) {
214
- this.transform.maxPitch = maxPitch;
215
- if (this.getPitch() > maxPitch) {
216
- this.setPitch(maxPitch);
334
+ }, {
335
+ key: "getMinPitch",
336
+ value: function getMinPitch() {
337
+ return this.transform.minPitch;
338
+ }
339
+ }, {
340
+ key: "setMaxPitch",
341
+ value: function setMaxPitch(maxPitch) {
342
+ maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
343
+
344
+ if (maxPitch > defaultMaxPitch) {
345
+ throw new Error("maxPitch must be less than or equal to ".concat(defaultMaxPitch));
346
+ }
347
+
348
+ if (maxPitch >= this.transform.minPitch) {
349
+ this.transform.maxPitch = maxPitch;
350
+
351
+ if (this.getPitch() > maxPitch) {
352
+ this.setPitch(maxPitch);
353
+ }
354
+
355
+ return this;
356
+ } else {
357
+ throw new Error('maxPitch must be greater than the current minPitch');
217
358
  }
218
- return this;
219
- } else {
220
- throw new Error("maxPitch must be greater than the current minPitch");
221
359
  }
222
- }
223
- getMaxPitch() {
224
- return this.transform.maxPitch;
225
- }
226
- getRenderWorldCopies() {
227
- return this.transform.renderWorldCopies;
228
- }
229
- setRenderWorldCopies(renderWorldCopies) {
230
- this.transform.renderWorldCopies = !!renderWorldCopies;
231
- }
232
- remove() {
233
- this.container.removeChild(this.canvasContainer);
234
- this.canvasContainer = null;
235
- if (this.frame) {
236
- this.frame.cancel();
237
- this.frame = null;
238
- }
239
- this.renderTaskQueue.clear();
240
- }
241
- requestRenderFrame(cb) {
242
- this.update();
243
- return this.renderTaskQueue.add(cb);
244
- }
245
- cancelRenderFrame(id) {
246
- return this.renderTaskQueue.remove(id);
247
- }
248
- triggerRepaint() {
249
- if (!this.frame) {
250
- this.frame = (0, import_util.renderframe)((paintStartTimeStamp) => {
251
- import_performance.PerformanceUtils.frame(paintStartTimeStamp);
252
- this.frame = null;
253
- this.update(paintStartTimeStamp);
254
- });
360
+ }, {
361
+ key: "getMaxPitch",
362
+ value: function getMaxPitch() {
363
+ return this.transform.maxPitch;
255
364
  }
256
- }
257
- update(time) {
258
- if (!this.frame) {
259
- this.frame = (0, import_util.renderframe)((paintStartTimeStamp) => {
260
- import_performance.PerformanceUtils.frame(paintStartTimeStamp);
365
+ }, {
366
+ key: "getRenderWorldCopies",
367
+ value: function getRenderWorldCopies() {
368
+ return this.transform.renderWorldCopies;
369
+ }
370
+ }, {
371
+ key: "setRenderWorldCopies",
372
+ value: function setRenderWorldCopies(renderWorldCopies) {
373
+ this.transform.renderWorldCopies = !!renderWorldCopies;
374
+ }
375
+ }, {
376
+ key: "remove",
377
+ value: function remove() {
378
+ this.container.removeChild(this.canvasContainer); // @ts-ignore
379
+
380
+ this.canvasContainer = null;
381
+
382
+ if (this.frame) {
383
+ this.frame.cancel();
261
384
  this.frame = null;
262
- this.renderTaskQueue.run(time);
263
- });
385
+ }
386
+
387
+ this.renderTaskQueue.clear();
264
388
  }
265
- }
266
- initContainer() {
267
- if (typeof this.options.container === "string") {
268
- this.container = window.document.getElementById(this.options.container);
269
- if (!this.container) {
270
- throw new Error(`Container '${this.options.container}' not found.`);
389
+ }, {
390
+ key: "requestRenderFrame",
391
+ value: function requestRenderFrame(cb) {
392
+ this.update();
393
+ return this.renderTaskQueue.add(cb);
394
+ }
395
+ }, {
396
+ key: "cancelRenderFrame",
397
+ value: function cancelRenderFrame(id) {
398
+ return this.renderTaskQueue.remove(id);
399
+ }
400
+ }, {
401
+ key: "triggerRepaint",
402
+ value: function triggerRepaint() {
403
+ var _this2 = this;
404
+
405
+ if (!this.frame) {
406
+ this.frame = (0, _util.renderframe)(function (paintStartTimeStamp) {
407
+ _performance.PerformanceUtils.frame(paintStartTimeStamp);
408
+
409
+ _this2.frame = null;
410
+
411
+ _this2.update(paintStartTimeStamp);
412
+ });
271
413
  }
272
- } else if (this.options.container instanceof HTMLElement) {
273
- this.container = this.options.container;
274
- } else {
275
- throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
276
414
  }
277
- const container = this.container;
278
- container.classList.add("l7-map");
279
- const canvasContainer = this.canvasContainer = import_l7_utils.DOM.create("div", "l7-canvas-container", container);
280
- if (this.options.interactive) {
281
- canvasContainer.classList.add("l7-interactive");
415
+ }, {
416
+ key: "update",
417
+ value: function update(time) {
418
+ var _this3 = this;
419
+
420
+ if (!this.frame) {
421
+ this.frame = (0, _util.renderframe)(function (paintStartTimeStamp) {
422
+ _performance.PerformanceUtils.frame(paintStartTimeStamp);
423
+
424
+ _this3.frame = null;
425
+
426
+ _this3.renderTaskQueue.run(time);
427
+ });
428
+ }
282
429
  }
283
- }
284
- initMiniContainer() {
285
- this.container = this.options.canvas;
286
- this.canvasContainer = this.container;
287
- }
288
- containerDimensions() {
289
- let width = 0;
290
- let height = 0;
291
- if (this.container) {
292
- if (import_l7_utils.isMini) {
293
- width = this.container.width / import_l7_utils.$window.devicePixelRatio;
294
- height = this.container.height / import_l7_utils.$window.devicePixelRatio;
430
+ }, {
431
+ key: "initContainer",
432
+ value: function initContainer() {
433
+ if (typeof this.options.container === 'string') {
434
+ this.container = window.document.getElementById(this.options.container);
435
+
436
+ if (!this.container) {
437
+ throw new Error("Container '".concat(this.options.container, "' not found."));
438
+ }
439
+ } else if (this.options.container instanceof HTMLElement) {
440
+ this.container = this.options.container;
295
441
  } else {
296
- width = this.container.clientWidth;
297
- height = this.container.clientHeight;
298
- width = width == 0 ? 400 : width;
299
- height = height === 0 ? 300 : height;
442
+ throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
443
+ }
444
+
445
+ var container = this.container;
446
+ container.classList.add('l7-map');
447
+
448
+ var canvasContainer = this.canvasContainer = _l7Utils.DOM.create('div', 'l7-canvas-container', container);
449
+
450
+ if (this.options.interactive) {
451
+ canvasContainer.classList.add('l7-interactive');
300
452
  }
301
453
  }
302
- return [width, height];
303
- }
304
- };
305
- // Annotate the CommonJS export names for ESM import in node:
306
- 0 && (module.exports = {
307
- Map
308
- });
454
+ /**
455
+ * 小程序环境构建容器
456
+ */
457
+
458
+ }, {
459
+ key: "initMiniContainer",
460
+ value: function initMiniContainer() {
461
+ this.container = this.options.canvas;
462
+ this.canvasContainer = this.container;
463
+ }
464
+ }, {
465
+ key: "containerDimensions",
466
+ value: function containerDimensions() {
467
+ var width = 0;
468
+ var height = 0;
469
+
470
+ if (this.container) {
471
+ if (_l7Utils.isMini) {
472
+ width = this.container.width / _l7Utils.$window.devicePixelRatio;
473
+ height = this.container.height / _l7Utils.$window.devicePixelRatio;
474
+ } else {
475
+ width = this.container.clientWidth;
476
+ height = this.container.clientHeight;
477
+ width = width == 0 ? 400 : width;
478
+ height = height === 0 ? 300 : height;
479
+ }
480
+ }
481
+
482
+ return [width, height];
483
+ }
484
+ }]);
485
+ return Map;
486
+ }(_camera.default);
487
+
488
+ exports.Map = Map;