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