@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.
- package/es/camera.js +595 -674
- package/es/earthmap.js +313 -276
- package/es/geo/edge_insets.js +57 -72
- package/es/geo/lng_lat.js +50 -64
- package/es/geo/lng_lat_bounds.js +101 -137
- package/es/geo/mercator.js +23 -35
- package/es/geo/point.js +150 -221
- package/es/geo/simple.js +22 -34
- package/es/geo/transform.js +839 -905
- package/es/handler/blockable_map_event.js +46 -66
- package/es/handler/box_zoom.js +125 -143
- package/es/handler/click_zoom.js +37 -51
- package/es/handler/events/event.js +11 -9
- package/es/handler/events/map_mouse_event.js +39 -54
- package/es/handler/events/map_touch_event.js +54 -73
- package/es/handler/events/map_wheel_event.js +22 -38
- package/es/handler/events/render_event.js +6 -23
- package/es/handler/handler_inertia.js +98 -113
- package/es/handler/handler_manager.js +349 -437
- package/es/handler/handler_util.js +2 -2
- package/es/handler/keyboard.js +98 -110
- package/es/handler/map_event.js +81 -117
- package/es/handler/mouse/mouse_handler.js +81 -100
- package/es/handler/mouse/mousepan_handler.js +16 -39
- package/es/handler/mouse/mousepitch_hander.js +18 -40
- package/es/handler/mouse/mouserotate_hander.js +18 -40
- package/es/handler/mouse/util.js +7 -6
- package/es/handler/scroll_zoom.js +221 -231
- package/es/handler/shim/dblclick_zoom.js +36 -47
- package/es/handler/shim/drag_pan.js +41 -50
- package/es/handler/shim/drag_rotate.js +38 -48
- package/es/handler/shim/touch_zoom_rotate.js +68 -79
- package/es/handler/tap/single_tap_recognizer.js +60 -80
- package/es/handler/tap/tap_drag_zoom.js +72 -89
- package/es/handler/tap/tap_recognizer.js +37 -45
- package/es/handler/tap/tap_zoom.js +67 -95
- package/es/handler/touch/touch_pan.js +77 -96
- package/es/handler/touch/touch_pitch.js +61 -79
- package/es/handler/touch/touch_rotate.js +47 -67
- package/es/handler/touch/touch_zoom.js +29 -46
- package/es/handler/touch/two_touch.js +79 -104
- package/es/hash.js +75 -88
- package/es/map.js +318 -284
- package/es/util.js +18 -37
- package/es/utils/Aabb.js +60 -100
- package/es/utils/dom.js +32 -55
- package/es/utils/performance.js +25 -29
- package/es/utils/primitives.js +33 -43
- package/es/utils/task_queue.js +47 -76
- package/lib/camera.d.ts +86 -0
- package/lib/camera.js +597 -672
- package/lib/earthmap.d.ts +69 -0
- package/lib/earthmap.js +314 -276
- package/lib/geo/edge_insets.d.ts +54 -0
- package/lib/geo/edge_insets.js +58 -70
- package/lib/geo/lng_lat.d.ts +18 -0
- package/lib/geo/lng_lat.js +50 -62
- package/lib/geo/lng_lat_bounds.d.ts +25 -0
- package/lib/geo/lng_lat_bounds.js +102 -136
- package/lib/geo/mercator.d.ts +30 -0
- package/lib/geo/mercator.js +26 -37
- package/lib/geo/point.d.ts +40 -0
- package/lib/geo/point.js +151 -220
- package/lib/geo/simple.d.ts +30 -0
- package/lib/geo/simple.js +25 -36
- package/lib/geo/transform.d.ts +198 -0
- package/lib/geo/transform.js +844 -907
- package/lib/handler/IHandler.d.ts +34 -0
- package/lib/handler/blockable_map_event.d.ts +17 -0
- package/lib/handler/blockable_map_event.js +48 -65
- package/lib/handler/box_zoom.d.ts +59 -0
- package/lib/handler/box_zoom.js +126 -143
- package/lib/handler/click_zoom.d.ts +16 -0
- package/lib/handler/click_zoom.js +38 -50
- package/lib/handler/events/event.d.ts +4 -0
- package/lib/handler/events/event.js +12 -9
- package/lib/handler/events/index.d.ts +4 -0
- package/lib/handler/events/index.js +3 -3
- package/lib/handler/events/map_mouse_event.d.ts +34 -0
- package/lib/handler/events/map_mouse_event.js +41 -52
- package/lib/handler/events/map_touch_event.d.ts +57 -0
- package/lib/handler/events/map_touch_event.js +56 -71
- package/lib/handler/events/map_wheel_event.d.ts +33 -0
- package/lib/handler/events/map_wheel_event.js +23 -37
- package/lib/handler/events/render_event.d.ts +5 -0
- package/lib/handler/events/render_event.js +7 -22
- package/lib/handler/handler_inertia.d.ts +23 -0
- package/lib/handler/handler_inertia.js +102 -112
- package/lib/handler/handler_manager.d.ts +61 -0
- package/lib/handler/handler_manager.js +351 -437
- package/lib/handler/handler_util.d.ts +4 -0
- package/lib/handler/handler_util.js +2 -2
- package/lib/handler/keyboard.d.ts +36 -0
- package/lib/handler/keyboard.js +98 -110
- package/lib/handler/map_event.d.ts +29 -0
- package/lib/handler/map_event.js +83 -116
- package/lib/handler/mouse/index.d.ts +4 -0
- package/lib/handler/mouse/index.js +3 -3
- package/lib/handler/mouse/mouse_handler.d.ts +22 -0
- package/lib/handler/mouse/mouse_handler.js +83 -99
- package/lib/handler/mouse/mousepan_handler.d.ts +10 -0
- package/lib/handler/mouse/mousepan_handler.js +19 -38
- package/lib/handler/mouse/mousepitch_hander.d.ts +9 -0
- package/lib/handler/mouse/mousepitch_hander.js +21 -39
- package/lib/handler/mouse/mouserotate_hander.d.ts +9 -0
- package/lib/handler/mouse/mouserotate_hander.js +21 -39
- package/lib/handler/mouse/util.d.ts +6 -0
- package/lib/handler/mouse/util.js +7 -7
- package/lib/handler/scroll_zoom.d.ts +93 -0
- package/lib/handler/scroll_zoom.js +221 -231
- package/lib/handler/shim/dblclick_zoom.d.ts +40 -0
- package/lib/handler/shim/dblclick_zoom.js +37 -46
- package/lib/handler/shim/drag_pan.d.ts +61 -0
- package/lib/handler/shim/drag_pan.js +42 -49
- package/lib/handler/shim/drag_rotate.d.ts +46 -0
- package/lib/handler/shim/drag_rotate.js +39 -47
- package/lib/handler/shim/touch_zoom_rotate.d.ts +70 -0
- package/lib/handler/shim/touch_zoom_rotate.js +69 -78
- package/lib/handler/tap/single_tap_recognizer.d.ts +20 -0
- package/lib/handler/tap/single_tap_recognizer.js +63 -79
- package/lib/handler/tap/tap_drag_zoom.d.ts +22 -0
- package/lib/handler/tap/tap_drag_zoom.js +74 -88
- package/lib/handler/tap/tap_recognizer.d.ts +17 -0
- package/lib/handler/tap/tap_recognizer.js +41 -47
- package/lib/handler/tap/tap_zoom.d.ts +22 -0
- package/lib/handler/tap/tap_zoom.js +69 -94
- package/lib/handler/touch/index.d.ts +5 -0
- package/lib/handler/touch/index.js +4 -4
- package/lib/handler/touch/touch_pan.d.ts +30 -0
- package/lib/handler/touch/touch_pan.js +79 -95
- package/lib/handler/touch/touch_pitch.d.ts +13 -0
- package/lib/handler/touch/touch_pitch.js +64 -78
- package/lib/handler/touch/touch_rotate.d.ts +12 -0
- package/lib/handler/touch/touch_rotate.js +50 -66
- package/lib/handler/touch/touch_zoom.d.ts +12 -0
- package/lib/handler/touch/touch_zoom.js +32 -45
- package/lib/handler/touch/two_touch.d.ts +23 -0
- package/lib/handler/touch/two_touch.js +81 -103
- package/lib/hash.d.ts +14 -0
- package/lib/hash.js +75 -88
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -4
- package/lib/interface.d.ts +34 -0
- package/lib/map.d.ts +70 -0
- package/lib/map.js +319 -284
- package/lib/util.d.ts +25 -0
- package/lib/util.js +20 -36
- package/lib/utils/Aabb.d.ts +12 -0
- package/lib/utils/Aabb.js +61 -99
- package/lib/utils/dom.d.ts +4 -0
- package/lib/utils/dom.js +34 -55
- package/lib/utils/performance.d.ts +17 -0
- package/lib/utils/performance.js +25 -29
- package/lib/utils/primitives.d.ts +6 -0
- package/lib/utils/primitives.js +34 -42
- package/lib/utils/task_queue.d.ts +13 -0
- package/lib/utils/task_queue.js +47 -76
- 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(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
91
|
-
(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
(0,
|
|
96
|
-
|
|
97
|
-
(0, _defineProperty2.default)(
|
|
98
|
-
(0, _defineProperty2.default)(
|
|
99
|
-
(0, _defineProperty2.default)(
|
|
100
|
-
|
|
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)(
|
|
103
|
-
if (
|
|
104
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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',
|
|
114
|
-
window.addEventListener('resize',
|
|
115
|
-
window.addEventListener('orientationchange',
|
|
211
|
+
window.addEventListener('online', this.onWindowOnline, false);
|
|
212
|
+
window.addEventListener('resize', this.onWindowResize, false);
|
|
213
|
+
window.addEventListener('orientationchange', this.onWindowResize, false);
|
|
116
214
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
157
|
-
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
-
|
|
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
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
if (!this.
|
|
311
|
-
|
|
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
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
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
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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;
|