@antv/l7-map 2.16.1 → 2.16.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.
- package/es/camera.js +90 -148
- package/es/earthmap.js +13 -65
- package/es/geo/edge_insets.js +4 -14
- package/es/geo/lng_lat.js +5 -13
- package/es/geo/lng_lat_bounds.js +4 -17
- package/es/geo/mercator.js +2 -10
- package/es/geo/point.js +0 -7
- package/es/geo/simple.js +6 -11
- package/es/geo/transform.js +123 -132
- package/es/handler/blockable_map_event.js +7 -12
- package/es/handler/box_zoom.js +10 -30
- package/es/handler/click_zoom.js +0 -5
- package/es/handler/events/event.js +0 -2
- package/es/handler/events/map_mouse_event.js +0 -12
- package/es/handler/events/map_touch_event.js +2 -12
- package/es/handler/events/map_wheel_event.js +1 -12
- package/es/handler/events/render_event.js +0 -13
- package/es/handler/handler_inertia.js +6 -34
- package/es/handler/handler_manager.js +55 -147
- package/es/handler/handler_util.js +1 -2
- package/es/handler/keyboard.js +1 -20
- package/es/handler/map_event.js +3 -9
- package/es/handler/mouse/mouse_handler.js +11 -24
- package/es/handler/mouse/mousepan_handler.js +1 -11
- package/es/handler/mouse/mousepitch_hander.js +1 -11
- package/es/handler/mouse/mouserotate_hander.js +1 -11
- package/es/handler/mouse/util.js +2 -3
- package/es/handler/scroll_zoom.js +43 -71
- package/es/handler/shim/dblclick_zoom.js +4 -9
- package/es/handler/shim/drag_pan.js +4 -11
- package/es/handler/shim/drag_rotate.js +4 -10
- package/es/handler/shim/touch_zoom_rotate.js +6 -16
- package/es/handler/tap/single_tap_recognizer.js +8 -31
- package/es/handler/tap/tap_drag_zoom.js +7 -15
- package/es/handler/tap/tap_recognizer.js +3 -11
- package/es/handler/tap/tap_zoom.js +1 -7
- package/es/handler/touch/touch_pan.js +4 -22
- package/es/handler/touch/touch_pitch.js +10 -27
- package/es/handler/touch/touch_rotate.js +8 -19
- package/es/handler/touch/touch_zoom.js +5 -18
- package/es/handler/touch/two_touch.js +19 -32
- package/es/hash.js +9 -31
- package/es/map.js +16 -78
- package/es/util.js +18 -23
- package/es/utils/Aabb.js +10 -31
- package/es/utils/dom.js +24 -58
- package/es/utils/performance.js +8 -7
- package/es/utils/primitives.js +13 -11
- package/es/utils/task_queue.js +6 -23
- package/lib/camera.js +90 -168
- package/lib/earthmap.js +11 -79
- package/lib/geo/edge_insets.js +3 -18
- package/lib/geo/lng_lat.js +5 -18
- package/lib/geo/lng_lat_bounds.js +4 -20
- package/lib/geo/mercator.js +1 -22
- package/lib/geo/point.js +0 -8
- package/lib/geo/simple.js +5 -24
- package/lib/geo/transform.js +123 -164
- package/lib/handler/blockable_map_event.js +6 -14
- package/lib/handler/box_zoom.js +8 -39
- package/lib/handler/click_zoom.js +0 -6
- package/lib/handler/events/event.js +0 -5
- package/lib/handler/events/index.js +0 -4
- package/lib/handler/events/map_mouse_event.js +0 -19
- package/lib/handler/events/map_touch_event.js +1 -20
- package/lib/handler/events/map_wheel_event.js +1 -16
- package/lib/handler/events/render_event.js +0 -19
- package/lib/handler/handler_inertia.js +4 -37
- package/lib/handler/handler_manager.js +55 -171
- package/lib/handler/handler_util.js +1 -3
- package/lib/handler/keyboard.js +1 -22
- package/lib/handler/map_event.js +2 -11
- package/lib/handler/mouse/index.js +0 -4
- package/lib/handler/mouse/mouse_handler.js +10 -27
- package/lib/handler/mouse/mousepan_handler.js +0 -17
- package/lib/handler/mouse/mousepitch_hander.js +0 -16
- package/lib/handler/mouse/mouserotate_hander.js +0 -16
- package/lib/handler/mouse/util.js +2 -6
- package/lib/handler/scroll_zoom.js +43 -77
- package/lib/handler/shim/dblclick_zoom.js +4 -10
- package/lib/handler/shim/drag_pan.js +4 -13
- package/lib/handler/shim/drag_rotate.js +4 -11
- package/lib/handler/shim/touch_zoom_rotate.js +6 -18
- package/lib/handler/tap/single_tap_recognizer.js +8 -33
- package/lib/handler/tap/tap_drag_zoom.js +6 -18
- package/lib/handler/tap/tap_recognizer.js +2 -17
- package/lib/handler/tap/tap_zoom.js +0 -9
- package/lib/handler/touch/index.js +0 -5
- package/lib/handler/touch/touch_pan.js +4 -25
- package/lib/handler/touch/touch_pitch.js +9 -31
- package/lib/handler/touch/touch_rotate.js +7 -24
- package/lib/handler/touch/touch_zoom.js +4 -23
- package/lib/handler/touch/two_touch.js +18 -35
- package/lib/hash.js +8 -35
- package/lib/index.js +0 -8
- package/lib/map.js +14 -94
- package/lib/util.js +16 -34
- package/lib/utils/Aabb.js +10 -34
- package/lib/utils/dom.js +22 -64
- package/lib/utils/performance.js +8 -9
- package/lib/utils/primitives.js +13 -16
- package/lib/utils/task_queue.js +6 -24
- package/package.json +3 -3
package/lib/earthmap.js
CHANGED
|
@@ -1,94 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.EarthMap = void 0;
|
|
9
|
-
|
|
10
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
10
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
11
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
12
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
13
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
22
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
15
|
var _l7Utils = require("@antv/l7-utils");
|
|
25
|
-
|
|
26
16
|
var _lodash = require("lodash");
|
|
27
|
-
|
|
28
17
|
var _camera = _interopRequireDefault(require("./camera"));
|
|
29
|
-
|
|
30
18
|
var _lng_lat = _interopRequireDefault(require("./geo/lng_lat"));
|
|
31
|
-
|
|
32
19
|
var _lng_lat_bounds = _interopRequireDefault(require("./geo/lng_lat_bounds"));
|
|
33
|
-
|
|
34
20
|
var _point = _interopRequireDefault(require("./geo/point"));
|
|
35
|
-
|
|
36
21
|
var _handler_manager = _interopRequireDefault(require("./handler/handler_manager"));
|
|
37
|
-
|
|
38
22
|
var _util = require("./util");
|
|
39
|
-
|
|
40
23
|
var _performance = require("./utils/performance");
|
|
41
|
-
|
|
42
24
|
var _task_queue = _interopRequireDefault(require("./utils/task_queue"));
|
|
43
|
-
|
|
44
25
|
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
26
|
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
27
|
function loadStyles(css, doc) {
|
|
49
28
|
var isMiniAli = typeof my !== 'undefined' && !!my && typeof my.showToast === 'function' && my.isFRM !== true;
|
|
50
29
|
var isWeChatMiniProgram = typeof wx !== 'undefined' && wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined');
|
|
51
|
-
|
|
52
30
|
if (isMiniAli || isWeChatMiniProgram) {
|
|
53
31
|
return;
|
|
54
32
|
}
|
|
55
|
-
|
|
56
33
|
if (!doc) doc = document;
|
|
57
|
-
|
|
58
34
|
if (!doc) {
|
|
59
35
|
return;
|
|
60
36
|
}
|
|
61
|
-
|
|
62
37
|
var head = doc.head || doc.getElementsByTagName('head')[0];
|
|
63
|
-
|
|
64
38
|
if (!head) {
|
|
65
39
|
head = doc.createElement('head');
|
|
66
40
|
var body = doc.body || doc.getElementsByTagName('body')[0];
|
|
67
|
-
|
|
68
41
|
if (body) {
|
|
69
42
|
body.parentNode.insertBefore(head, body);
|
|
70
43
|
} else {
|
|
71
44
|
doc.documentElement.appendChild(head);
|
|
72
45
|
}
|
|
73
46
|
}
|
|
74
|
-
|
|
75
47
|
var style = doc.createElement('style');
|
|
76
48
|
style.type = 'text/css';
|
|
77
|
-
|
|
78
49
|
if (style.styleSheet) {
|
|
79
50
|
style.styleSheet.cssText = css;
|
|
80
51
|
} else {
|
|
81
52
|
style.appendChild(doc.createTextNode(css));
|
|
82
53
|
}
|
|
83
|
-
|
|
84
54
|
head.appendChild(style);
|
|
85
55
|
return style;
|
|
86
56
|
}
|
|
87
|
-
|
|
88
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");
|
|
89
58
|
var defaultMinZoom = -2;
|
|
90
|
-
var defaultMaxZoom = 22;
|
|
59
|
+
var defaultMaxZoom = 22;
|
|
91
60
|
|
|
61
|
+
// the default values, but also the valid range
|
|
92
62
|
var defaultMinPitch = 0;
|
|
93
63
|
var defaultMaxPitch = 60;
|
|
94
64
|
var DefaultOptions = {
|
|
@@ -118,15 +88,11 @@ var DefaultOptions = {
|
|
|
118
88
|
pitchEnabled: true,
|
|
119
89
|
rotateEnabled: true
|
|
120
90
|
};
|
|
121
|
-
|
|
122
91
|
var EarthMap = /*#__PURE__*/function (_Camera) {
|
|
123
92
|
(0, _inherits2.default)(EarthMap, _Camera);
|
|
124
|
-
|
|
125
93
|
var _super = _createSuper(EarthMap);
|
|
126
|
-
|
|
127
94
|
function EarthMap(options) {
|
|
128
95
|
var _this;
|
|
129
|
-
|
|
130
96
|
(0, _classCallCheck2.default)(this, EarthMap);
|
|
131
97
|
_this = _super.call(this, (0, _lodash.merge)({}, DefaultOptions, options));
|
|
132
98
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderTaskQueue", new _task_queue.default());
|
|
@@ -141,44 +107,35 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
|
|
|
141
107
|
}).update();
|
|
142
108
|
}
|
|
143
109
|
});
|
|
144
|
-
|
|
145
110
|
_this.initContainer();
|
|
146
|
-
|
|
147
111
|
_this.resize();
|
|
148
|
-
|
|
149
112
|
_this.handlers = new _handler_manager.default((0, _assertThisInitialized2.default)(_this), _this.options);
|
|
150
|
-
|
|
151
113
|
if (typeof window !== 'undefined') {
|
|
152
114
|
window.addEventListener('online', _this.onWindowOnline, false);
|
|
153
115
|
window.addEventListener('resize', _this.onWindowResize, false);
|
|
154
116
|
window.addEventListener('orientationchange', _this.onWindowResize, false);
|
|
155
117
|
}
|
|
156
|
-
|
|
157
118
|
return _this;
|
|
158
119
|
}
|
|
159
|
-
|
|
160
120
|
(0, _createClass2.default)(EarthMap, [{
|
|
161
121
|
key: "resize",
|
|
162
122
|
value: function resize(eventData) {
|
|
163
123
|
var dimensions = this.containerDimensions();
|
|
164
124
|
var width = dimensions[0];
|
|
165
|
-
var height = dimensions[1];
|
|
125
|
+
var height = dimensions[1];
|
|
166
126
|
|
|
127
|
+
// this.resizeCanvas(width, height);
|
|
167
128
|
this.transform.resize(width, height);
|
|
168
129
|
var fireMoving = !this.moving;
|
|
169
|
-
|
|
170
130
|
if (fireMoving) {
|
|
171
131
|
this.stop();
|
|
172
132
|
this.emit('movestart', new Event('movestart', eventData));
|
|
173
133
|
this.emit('move', new Event('move', eventData));
|
|
174
134
|
}
|
|
175
|
-
|
|
176
135
|
this.emit('resize', new Event('resize', eventData));
|
|
177
|
-
|
|
178
136
|
if (fireMoving) {
|
|
179
137
|
this.emit('moveend', new Event('moveend', eventData));
|
|
180
138
|
}
|
|
181
|
-
|
|
182
139
|
return this;
|
|
183
140
|
}
|
|
184
141
|
}, {
|
|
@@ -220,8 +177,9 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
|
|
|
220
177
|
key: "setMaxBounds",
|
|
221
178
|
value: function setMaxBounds(bounds) {
|
|
222
179
|
this.transform.setMaxBounds(_lng_lat_bounds.default.convert(bounds));
|
|
223
|
-
}
|
|
180
|
+
}
|
|
224
181
|
|
|
182
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
225
183
|
}, {
|
|
226
184
|
key: "setStyle",
|
|
227
185
|
value: function setStyle(style) {
|
|
@@ -231,14 +189,11 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
|
|
|
231
189
|
key: "setMinZoom",
|
|
232
190
|
value: function setMinZoom(minZoom) {
|
|
233
191
|
minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
|
|
234
|
-
|
|
235
192
|
if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
|
|
236
193
|
this.transform.minZoom = minZoom;
|
|
237
|
-
|
|
238
194
|
if (this.getZoom() < minZoom) {
|
|
239
195
|
this.setZoom(minZoom);
|
|
240
196
|
}
|
|
241
|
-
|
|
242
197
|
return this;
|
|
243
198
|
} else {
|
|
244
199
|
throw new Error("minZoom must be between ".concat(defaultMinZoom, " and the current maxZoom, inclusive"));
|
|
@@ -253,14 +208,11 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
|
|
|
253
208
|
key: "setMaxZoom",
|
|
254
209
|
value: function setMaxZoom(maxZoom) {
|
|
255
210
|
maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
|
|
256
|
-
|
|
257
211
|
if (maxZoom >= this.transform.minZoom) {
|
|
258
212
|
this.transform.maxZoom = maxZoom;
|
|
259
|
-
|
|
260
213
|
if (this.getZoom() > maxZoom) {
|
|
261
214
|
this.setZoom(maxZoom);
|
|
262
215
|
}
|
|
263
|
-
|
|
264
216
|
return this;
|
|
265
217
|
} else {
|
|
266
218
|
throw new Error('maxZoom must be greater than the current minZoom');
|
|
@@ -275,18 +227,14 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
|
|
|
275
227
|
key: "setMinPitch",
|
|
276
228
|
value: function setMinPitch(minPitch) {
|
|
277
229
|
minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
|
|
278
|
-
|
|
279
230
|
if (minPitch < defaultMinPitch) {
|
|
280
231
|
throw new Error("minPitch must be greater than or equal to ".concat(defaultMinPitch));
|
|
281
232
|
}
|
|
282
|
-
|
|
283
233
|
if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
|
|
284
234
|
this.transform.minPitch = minPitch;
|
|
285
|
-
|
|
286
235
|
if (this.getPitch() < minPitch) {
|
|
287
236
|
this.setPitch(minPitch);
|
|
288
237
|
}
|
|
289
|
-
|
|
290
238
|
return this;
|
|
291
239
|
} else {
|
|
292
240
|
throw new Error("minPitch must be between ".concat(defaultMinPitch, " and the current maxPitch, inclusive"));
|
|
@@ -301,18 +249,14 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
|
|
|
301
249
|
key: "setMaxPitch",
|
|
302
250
|
value: function setMaxPitch(maxPitch) {
|
|
303
251
|
maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
|
|
304
|
-
|
|
305
252
|
if (maxPitch > defaultMaxPitch) {
|
|
306
253
|
throw new Error("maxPitch must be less than or equal to ".concat(defaultMaxPitch));
|
|
307
254
|
}
|
|
308
|
-
|
|
309
255
|
if (maxPitch >= this.transform.minPitch) {
|
|
310
256
|
this.transform.maxPitch = maxPitch;
|
|
311
|
-
|
|
312
257
|
if (this.getPitch() > maxPitch) {
|
|
313
258
|
this.setPitch(maxPitch);
|
|
314
259
|
}
|
|
315
|
-
|
|
316
260
|
return this;
|
|
317
261
|
} else {
|
|
318
262
|
throw new Error('maxPitch must be greater than the current minPitch');
|
|
@@ -340,7 +284,6 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
|
|
|
340
284
|
this.frame.cancel();
|
|
341
285
|
this.frame = null;
|
|
342
286
|
}
|
|
343
|
-
|
|
344
287
|
this.renderTaskQueue.clear();
|
|
345
288
|
}
|
|
346
289
|
}, {
|
|
@@ -358,13 +301,10 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
|
|
|
358
301
|
key: "triggerRepaint",
|
|
359
302
|
value: function triggerRepaint() {
|
|
360
303
|
var _this2 = this;
|
|
361
|
-
|
|
362
304
|
if (!this.frame) {
|
|
363
305
|
this.frame = (0, _util.renderframe)(function (paintStartTimeStamp) {
|
|
364
306
|
_performance.PerformanceUtils.frame(paintStartTimeStamp);
|
|
365
|
-
|
|
366
307
|
_this2.frame = null;
|
|
367
|
-
|
|
368
308
|
_this2.update(paintStartTimeStamp);
|
|
369
309
|
});
|
|
370
310
|
}
|
|
@@ -373,13 +313,10 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
|
|
|
373
313
|
key: "update",
|
|
374
314
|
value: function update(time) {
|
|
375
315
|
var _this3 = this;
|
|
376
|
-
|
|
377
316
|
if (!this.frame) {
|
|
378
317
|
this.frame = (0, _util.renderframe)(function (paintStartTimeStamp) {
|
|
379
318
|
_performance.PerformanceUtils.frame(paintStartTimeStamp);
|
|
380
|
-
|
|
381
319
|
_this3.frame = null;
|
|
382
|
-
|
|
383
320
|
_this3.renderTaskQueue.run(time);
|
|
384
321
|
});
|
|
385
322
|
}
|
|
@@ -389,7 +326,6 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
|
|
|
389
326
|
value: function initContainer() {
|
|
390
327
|
if (typeof this.options.container === 'string') {
|
|
391
328
|
this.container = window.document.getElementById(this.options.container);
|
|
392
|
-
|
|
393
329
|
if (!this.container) {
|
|
394
330
|
throw new Error("Container '".concat(this.options.container, "' not found."));
|
|
395
331
|
}
|
|
@@ -398,34 +334,30 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
|
|
|
398
334
|
} else {
|
|
399
335
|
throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
|
|
400
336
|
}
|
|
401
|
-
|
|
402
337
|
var container = this.container;
|
|
403
338
|
container.classList.add('l7-map');
|
|
404
|
-
|
|
405
339
|
var canvasContainer = this.canvasContainer = _l7Utils.DOM.create('div', 'l7-canvas-container', container);
|
|
406
|
-
|
|
407
340
|
if (this.options.interactive) {
|
|
408
341
|
canvasContainer.classList.add('l7-interactive');
|
|
409
|
-
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// this.canvas = DOM.create(
|
|
410
345
|
// 'canvas',
|
|
411
346
|
// 'l7-canvas',
|
|
412
347
|
// canvasContainer,
|
|
413
348
|
// ) as HTMLCanvasElement;
|
|
414
349
|
// this.canvas.setAttribute('tabindex', '-');
|
|
415
350
|
// this.canvas.setAttribute('aria-label', 'Map');
|
|
416
|
-
|
|
417
351
|
}
|
|
418
352
|
}, {
|
|
419
353
|
key: "containerDimensions",
|
|
420
354
|
value: function containerDimensions() {
|
|
421
355
|
var width = 0;
|
|
422
356
|
var height = 0;
|
|
423
|
-
|
|
424
357
|
if (this.container) {
|
|
425
358
|
width = this.container.clientWidth || 400;
|
|
426
359
|
height = this.container.clientHeight || 300;
|
|
427
360
|
}
|
|
428
|
-
|
|
429
361
|
return [width, height];
|
|
430
362
|
}
|
|
431
363
|
}, {
|
|
@@ -433,13 +365,13 @@ var EarthMap = /*#__PURE__*/function (_Camera) {
|
|
|
433
365
|
value: function resizeCanvas(width, height) {
|
|
434
366
|
var pixelRatio = _l7Utils.DOM.DPR || 1;
|
|
435
367
|
this.canvas.width = pixelRatio * width;
|
|
436
|
-
this.canvas.height = pixelRatio * height;
|
|
368
|
+
this.canvas.height = pixelRatio * height;
|
|
437
369
|
|
|
370
|
+
// Maintain the same canvas size, potentially downscaling it for HiDPI displays
|
|
438
371
|
this.canvas.style.width = "".concat(width, "px");
|
|
439
372
|
this.canvas.style.height = "".concat(height, "px");
|
|
440
373
|
}
|
|
441
374
|
}]);
|
|
442
375
|
return EarthMap;
|
|
443
376
|
}(_camera.default);
|
|
444
|
-
|
|
445
377
|
exports.EarthMap = EarthMap;
|
package/lib/geo/edge_insets.js
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
10
|
var _util = require("../util");
|
|
15
|
-
|
|
16
11
|
var _point = _interopRequireDefault(require("./point"));
|
|
17
|
-
|
|
18
12
|
// @ts-ignore
|
|
19
|
-
|
|
20
13
|
/**
|
|
21
14
|
* An `EdgeInset` object represents screen space padding applied to the edges of the viewport.
|
|
22
15
|
* This shifts the apprent center or the vanishing point of the map. This is useful for adding floating UI elements
|
|
@@ -34,16 +27,15 @@ var EdgeInsets = /*#__PURE__*/function () {
|
|
|
34
27
|
var left = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
35
28
|
var right = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
36
29
|
(0, _classCallCheck2.default)(this, EdgeInsets);
|
|
37
|
-
|
|
38
30
|
if (isNaN(top) || top < 0 || isNaN(bottom) || bottom < 0 || isNaN(left) || left < 0 || isNaN(right) || right < 0) {
|
|
39
31
|
throw new Error('Invalid value for edge-insets, top, bottom, left and right must all be numbers');
|
|
40
32
|
}
|
|
41
|
-
|
|
42
33
|
this.top = top;
|
|
43
34
|
this.bottom = bottom;
|
|
44
35
|
this.left = left;
|
|
45
36
|
this.right = right;
|
|
46
37
|
}
|
|
38
|
+
|
|
47
39
|
/**
|
|
48
40
|
* Interpolates the inset in-place.
|
|
49
41
|
* This maintains the current inset value for any inset not present in `target`.
|
|
@@ -53,29 +45,24 @@ var EdgeInsets = /*#__PURE__*/function () {
|
|
|
53
45
|
* @returns {EdgeInsets}
|
|
54
46
|
* @memberof EdgeInsets
|
|
55
47
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
48
|
(0, _createClass2.default)(EdgeInsets, [{
|
|
59
49
|
key: "interpolate",
|
|
60
50
|
value: function interpolate(start, target, t) {
|
|
61
51
|
if (target.top != null && start.top != null) {
|
|
62
52
|
this.top = (0, _util.interpolate)(start.top, target.top, t);
|
|
63
53
|
}
|
|
64
|
-
|
|
65
54
|
if (target.bottom != null && start.bottom != null) {
|
|
66
55
|
this.bottom = (0, _util.interpolate)(start.bottom, target.bottom, t);
|
|
67
56
|
}
|
|
68
|
-
|
|
69
57
|
if (target.left != null && start.left != null) {
|
|
70
58
|
this.left = (0, _util.interpolate)(start.left, target.left, t);
|
|
71
59
|
}
|
|
72
|
-
|
|
73
60
|
if (target.right != null && start.right != null) {
|
|
74
61
|
this.right = (0, _util.interpolate)(start.right, target.right, t);
|
|
75
62
|
}
|
|
76
|
-
|
|
77
63
|
return this;
|
|
78
64
|
}
|
|
65
|
+
|
|
79
66
|
/**
|
|
80
67
|
* Utility method that computes the new apprent center or vanishing point after applying insets.
|
|
81
68
|
* This is in pixels and with the top left being (0.0) and +y being downwards.
|
|
@@ -85,7 +72,6 @@ var EdgeInsets = /*#__PURE__*/function () {
|
|
|
85
72
|
* @returns {Point}
|
|
86
73
|
* @memberof EdgeInsets
|
|
87
74
|
*/
|
|
88
|
-
|
|
89
75
|
}, {
|
|
90
76
|
key: "getCenter",
|
|
91
77
|
value: function getCenter(width, height) {
|
|
@@ -104,6 +90,7 @@ var EdgeInsets = /*#__PURE__*/function () {
|
|
|
104
90
|
value: function clone() {
|
|
105
91
|
return new EdgeInsets(this.top, this.bottom, this.left, this.right);
|
|
106
92
|
}
|
|
93
|
+
|
|
107
94
|
/**
|
|
108
95
|
* Returns the current sdtate as json, useful when you want to have a
|
|
109
96
|
* read-only representation of the inset.
|
|
@@ -111,7 +98,6 @@ var EdgeInsets = /*#__PURE__*/function () {
|
|
|
111
98
|
* @returns {PaddingOptions}
|
|
112
99
|
* @memberof EdgeInsets
|
|
113
100
|
*/
|
|
114
|
-
|
|
115
101
|
}, {
|
|
116
102
|
key: "toJSON",
|
|
117
103
|
value: function toJSON() {
|
|
@@ -125,5 +111,4 @@ var EdgeInsets = /*#__PURE__*/function () {
|
|
|
125
111
|
}]);
|
|
126
112
|
return EdgeInsets;
|
|
127
113
|
}();
|
|
128
|
-
|
|
129
114
|
exports.default = EdgeInsets;
|
package/lib/geo/lng_lat.js
CHANGED
|
@@ -1,39 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.earthRadius = exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
-
|
|
12
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
11
|
var _util = require("../util");
|
|
17
|
-
|
|
18
12
|
var earthRadius = 6371008.8;
|
|
19
13
|
exports.earthRadius = earthRadius;
|
|
20
|
-
|
|
21
14
|
var LngLat = /*#__PURE__*/function () {
|
|
22
15
|
function LngLat(lng, lat) {
|
|
23
16
|
(0, _classCallCheck2.default)(this, LngLat);
|
|
24
|
-
|
|
25
17
|
if (isNaN(lng) || isNaN(lat)) {
|
|
26
18
|
throw new Error("Invalid LngLat object: (".concat(lng, ", ").concat(lat, ")"));
|
|
27
19
|
}
|
|
28
|
-
|
|
29
20
|
this.lng = +lng;
|
|
30
21
|
this.lat = +lat;
|
|
31
|
-
|
|
32
22
|
if (this.lat > 90 || this.lat < -90) {
|
|
33
23
|
throw new Error('Invalid LngLat latitude value: must be between -90 and 90');
|
|
34
24
|
}
|
|
35
25
|
}
|
|
36
|
-
|
|
37
26
|
(0, _createClass2.default)(LngLat, [{
|
|
38
27
|
key: "wrap",
|
|
39
28
|
value: function wrap() {
|
|
@@ -43,16 +32,17 @@ var LngLat = /*#__PURE__*/function () {
|
|
|
43
32
|
key: "toArray",
|
|
44
33
|
value: function toArray() {
|
|
45
34
|
return [this.lng, this.lat];
|
|
46
|
-
}
|
|
35
|
+
}
|
|
36
|
+
// public toBounds(radius: number = 0) {
|
|
47
37
|
// const earthCircumferenceInMetersAtEquator = 40075017;
|
|
48
38
|
// const latAccuracy = (360 * radius) / earthCircumferenceInMetersAtEquator;
|
|
49
39
|
// const lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);
|
|
40
|
+
|
|
50
41
|
// return new LngLatBounds(
|
|
51
42
|
// new LngLat(this.lng - lngAccuracy, this.lat - latAccuracy),
|
|
52
43
|
// new LngLat(this.lng + lngAccuracy, this.lat + latAccuracy),
|
|
53
44
|
// );
|
|
54
45
|
// }
|
|
55
|
-
|
|
56
46
|
}, {
|
|
57
47
|
key: "toString",
|
|
58
48
|
value: function toString() {
|
|
@@ -74,21 +64,18 @@ var LngLat = /*#__PURE__*/function () {
|
|
|
74
64
|
if (input instanceof LngLat) {
|
|
75
65
|
return input;
|
|
76
66
|
}
|
|
77
|
-
|
|
78
67
|
if (Array.isArray(input) && (input.length === 2 || input.length === 3)) {
|
|
79
68
|
return new LngLat(Number(input[0]), Number(input[1]));
|
|
80
69
|
}
|
|
81
|
-
|
|
82
70
|
if (!Array.isArray(input) && (0, _typeof2.default)(input) === 'object' && input !== null) {
|
|
83
71
|
var lng = 'lng' in input ? input.lng : input.lon;
|
|
84
|
-
return new LngLat(
|
|
72
|
+
return new LngLat(
|
|
73
|
+
// flow can't refine this to have one of lng or lat, so we have to cast to any
|
|
85
74
|
Number(lng), Number(input.lat));
|
|
86
75
|
}
|
|
87
|
-
|
|
88
76
|
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>]');
|
|
89
77
|
}
|
|
90
78
|
}]);
|
|
91
79
|
return LngLat;
|
|
92
80
|
}();
|
|
93
|
-
|
|
94
81
|
exports.default = LngLat;
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
10
|
var _lng_lat = _interopRequireDefault(require("./lng_lat"));
|
|
15
|
-
|
|
16
11
|
var LngLatBounds = /*#__PURE__*/function () {
|
|
17
12
|
function LngLatBounds(sw, ne) {
|
|
18
13
|
(0, _classCallCheck2.default)(this, LngLatBounds);
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
if (!sw) {
|
|
15
|
+
// noop
|
|
21
16
|
} else if (ne) {
|
|
22
17
|
this.setSouthWest(sw).setNorthEast(ne);
|
|
23
18
|
} else if (sw.length === 4) {
|
|
@@ -26,7 +21,6 @@ var LngLatBounds = /*#__PURE__*/function () {
|
|
|
26
21
|
this.setSouthWest(sw[0]).setNorthEast(sw[1]);
|
|
27
22
|
}
|
|
28
23
|
}
|
|
29
|
-
|
|
30
24
|
(0, _createClass2.default)(LngLatBounds, [{
|
|
31
25
|
key: "setNorthEast",
|
|
32
26
|
value: function setNorthEast(ne) {
|
|
@@ -46,14 +40,12 @@ var LngLatBounds = /*#__PURE__*/function () {
|
|
|
46
40
|
var ne = this.ne;
|
|
47
41
|
var sw2;
|
|
48
42
|
var ne2;
|
|
49
|
-
|
|
50
43
|
if (obj instanceof _lng_lat.default) {
|
|
51
44
|
sw2 = obj;
|
|
52
45
|
ne2 = obj;
|
|
53
46
|
} else if (obj instanceof LngLatBounds) {
|
|
54
47
|
sw2 = obj.sw;
|
|
55
48
|
ne2 = obj.ne;
|
|
56
|
-
|
|
57
49
|
if (!sw2 || !ne2) {
|
|
58
50
|
return this;
|
|
59
51
|
}
|
|
@@ -68,10 +60,8 @@ var LngLatBounds = /*#__PURE__*/function () {
|
|
|
68
60
|
return this.extend(_lng_lat.default.convert(lngLatObj));
|
|
69
61
|
}
|
|
70
62
|
}
|
|
71
|
-
|
|
72
63
|
return this;
|
|
73
64
|
}
|
|
74
|
-
|
|
75
65
|
if (!sw && !ne) {
|
|
76
66
|
this.sw = new _lng_lat.default(sw2.lng, sw2.lat);
|
|
77
67
|
this.ne = new _lng_lat.default(ne2.lng, ne2.lat);
|
|
@@ -81,7 +71,6 @@ var LngLatBounds = /*#__PURE__*/function () {
|
|
|
81
71
|
ne.lng = Math.max(ne2.lng, ne.lng);
|
|
82
72
|
ne.lat = Math.max(ne2.lat, ne.lat);
|
|
83
73
|
}
|
|
84
|
-
|
|
85
74
|
return this;
|
|
86
75
|
}
|
|
87
76
|
}, {
|
|
@@ -148,17 +137,14 @@ var LngLatBounds = /*#__PURE__*/function () {
|
|
|
148
137
|
key: "contains",
|
|
149
138
|
value: function contains(lnglat) {
|
|
150
139
|
var _LngLat$convert = _lng_lat.default.convert(lnglat),
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
140
|
+
lng = _LngLat$convert.lng,
|
|
141
|
+
lat = _LngLat$convert.lat;
|
|
154
142
|
var containsLatitude = this.sw.lat <= lat && lat <= this.ne.lat;
|
|
155
143
|
var containsLongitude = this.sw.lng <= lng && lng <= this.ne.lng;
|
|
156
|
-
|
|
157
144
|
if (this.sw.lng > this.ne.lng) {
|
|
158
145
|
// wrapped coordinates
|
|
159
146
|
containsLongitude = this.sw.lng >= lng && lng >= this.ne.lng;
|
|
160
147
|
}
|
|
161
|
-
|
|
162
148
|
return containsLatitude && containsLongitude;
|
|
163
149
|
}
|
|
164
150
|
}], [{
|
|
@@ -167,11 +153,9 @@ var LngLatBounds = /*#__PURE__*/function () {
|
|
|
167
153
|
if (input instanceof LngLatBounds) {
|
|
168
154
|
return input;
|
|
169
155
|
}
|
|
170
|
-
|
|
171
156
|
return new LngLatBounds(input);
|
|
172
157
|
}
|
|
173
158
|
}]);
|
|
174
159
|
return LngLatBounds;
|
|
175
160
|
}();
|
|
176
|
-
|
|
177
161
|
exports.default = LngLatBounds;
|