@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/es/map.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
8
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
9
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
-
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; } }
|
|
11
2
|
import { DOM, lodashUtil } from '@antv/l7-utils';
|
|
12
3
|
import Camera from "./camera";
|
|
13
4
|
function loadStyles(css, doc) {
|
|
@@ -40,7 +31,102 @@ function loadStyles(css, doc) {
|
|
|
40
31
|
head.appendChild(style);
|
|
41
32
|
return style;
|
|
42
33
|
}
|
|
43
|
-
loadStyles(
|
|
34
|
+
loadStyles(`.l7-map {
|
|
35
|
+
font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
position: relative;
|
|
38
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.l7-canvas {
|
|
42
|
+
position: absolute;
|
|
43
|
+
left: 0;
|
|
44
|
+
top: 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.l7-map:-webkit-full-screen {
|
|
48
|
+
width: 100%;
|
|
49
|
+
height: 100%;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.l7-canary {
|
|
53
|
+
background-color: salmon;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.l7-canvas-container.l7-interactive,
|
|
57
|
+
.l7-ctrl-group button.l7-ctrl-compass {
|
|
58
|
+
cursor: grab;
|
|
59
|
+
-moz-user-select: none;
|
|
60
|
+
-webkit-user-select: none;
|
|
61
|
+
-ms-user-select: none;
|
|
62
|
+
user-select: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.l7-canvas-container.l7-interactive.l7-track-pointer {
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.l7-canvas-container.l7-interactive:active,
|
|
70
|
+
.l7-ctrl-group button.l7-ctrl-compass:active {
|
|
71
|
+
cursor: grabbing;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.l7-canvas-container.l7-touch-zoom-rotate,
|
|
75
|
+
.l7-canvas-container.l7-touch-zoom-rotate .l7-canvas {
|
|
76
|
+
touch-action: pan-x pan-y;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.l7-canvas-container.l7-touch-drag-pan,
|
|
80
|
+
.l7-canvas-container.l7-touch-drag-pan .l7-canvas {
|
|
81
|
+
touch-action: pinch-zoom;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan,
|
|
85
|
+
.l7-canvas-container.l7-touch-zoom-rotate.l7-touch-drag-pan .l7-canvas {
|
|
86
|
+
touch-action: none;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.l7-ctrl-top-left,
|
|
90
|
+
.l7-ctrl-top-right,
|
|
91
|
+
.l7-ctrl-bottom-left,
|
|
92
|
+
.l7-ctrl-bottom-right { position: absolute; pointer-events: none; z-index: 2; }
|
|
93
|
+
.l7-ctrl-top-left { top: 0; left: 0; }
|
|
94
|
+
.l7-ctrl-top-right { top: 0; right: 0; }
|
|
95
|
+
.l7-ctrl-bottom-left { bottom: 0; left: 0; }
|
|
96
|
+
.l7-ctrl-bottom-right { right: 0; bottom: 0; }
|
|
97
|
+
|
|
98
|
+
.l7-ctrl {
|
|
99
|
+
clear: both;
|
|
100
|
+
pointer-events: auto;
|
|
101
|
+
|
|
102
|
+
/* workaround for a Safari bug https://github.com/mapbox/mapbox-gl-js/issues/8185 */
|
|
103
|
+
-webkit-transform: translate(0, 0);
|
|
104
|
+
transform: translate(0, 0);
|
|
105
|
+
}
|
|
106
|
+
.l7-ctrl-top-left .l7-ctrl { margin: 10px 0 0 10px; float: left; }
|
|
107
|
+
.l7-ctrl-top-right .l7-ctrl { margin: 10px 10px 0 0; float: right; }
|
|
108
|
+
.l7-ctrl-bottom-left .l7-ctrl { margin: 0 0 10px 10px; float: left; }
|
|
109
|
+
.l7-ctrl-bottom-right .l7-ctrl { margin: 0 10px 10px 0; float: right; }
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
.l7-crosshair,
|
|
113
|
+
.l7-crosshair .l7-interactive,
|
|
114
|
+
.l7-crosshair .l7-interactive:active {
|
|
115
|
+
cursor: crosshair;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.l7-boxzoom {
|
|
119
|
+
position: absolute;
|
|
120
|
+
top: 0;
|
|
121
|
+
left: 0;
|
|
122
|
+
width: 0;
|
|
123
|
+
height: 0;
|
|
124
|
+
background: #fff;
|
|
125
|
+
border: 2px dotted #202020;
|
|
126
|
+
opacity: 0.5;
|
|
127
|
+
z-index: 10;
|
|
128
|
+
}
|
|
129
|
+
`);
|
|
44
130
|
import LngLat from "./geo/lng_lat";
|
|
45
131
|
import LngLatBounds from "./geo/lng_lat_bounds";
|
|
46
132
|
// @ts-ignore
|
|
@@ -60,7 +146,7 @@ import TaskQueue from "./utils/task_queue";
|
|
|
60
146
|
cancelable: false,
|
|
61
147
|
detail: undefined
|
|
62
148
|
};
|
|
63
|
-
|
|
149
|
+
const evt = document.createEvent('CustomEvent');
|
|
64
150
|
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
|
65
151
|
return evt;
|
|
66
152
|
}
|
|
@@ -68,13 +154,15 @@ import TaskQueue from "./utils/task_queue";
|
|
|
68
154
|
// @ts-ignore
|
|
69
155
|
window.CustomEvent = CustomEvent;
|
|
70
156
|
})();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
157
|
+
const defaultMinZoom = -2;
|
|
158
|
+
const defaultMaxZoom = 22;
|
|
159
|
+
const {
|
|
160
|
+
merge
|
|
161
|
+
} = lodashUtil;
|
|
74
162
|
// the default values, but also the valid range
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
163
|
+
const defaultMinPitch = 0;
|
|
164
|
+
const defaultMaxPitch = 60;
|
|
165
|
+
const DefaultOptions = {
|
|
78
166
|
hash: false,
|
|
79
167
|
zoom: -1,
|
|
80
168
|
center: [112, 32],
|
|
@@ -101,307 +189,253 @@ var DefaultOptions = {
|
|
|
101
189
|
pitchEnabled: true,
|
|
102
190
|
rotateEnabled: true
|
|
103
191
|
};
|
|
104
|
-
export
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
_defineProperty(
|
|
112
|
-
_defineProperty(
|
|
113
|
-
_defineProperty(
|
|
114
|
-
|
|
192
|
+
export class Map extends Camera {
|
|
193
|
+
constructor(options) {
|
|
194
|
+
super(merge({}, DefaultOptions, options));
|
|
195
|
+
_defineProperty(this, "doubleClickZoom", void 0);
|
|
196
|
+
_defineProperty(this, "dragRotate", void 0);
|
|
197
|
+
_defineProperty(this, "dragPan", void 0);
|
|
198
|
+
_defineProperty(this, "touchZoomRotate", void 0);
|
|
199
|
+
_defineProperty(this, "scrollZoom", void 0);
|
|
200
|
+
_defineProperty(this, "keyboard", void 0);
|
|
201
|
+
_defineProperty(this, "touchPitch", void 0);
|
|
202
|
+
_defineProperty(this, "boxZoom", void 0);
|
|
203
|
+
_defineProperty(this, "handlers", void 0);
|
|
204
|
+
_defineProperty(this, "container", void 0);
|
|
205
|
+
_defineProperty(this, "canvas", void 0);
|
|
206
|
+
_defineProperty(this, "canvasContainer", void 0);
|
|
207
|
+
_defineProperty(this, "renderTaskQueue", new TaskQueue());
|
|
208
|
+
_defineProperty(this, "frame", void 0);
|
|
209
|
+
_defineProperty(this, "trackResize", true);
|
|
210
|
+
_defineProperty(this, "hash", void 0);
|
|
211
|
+
_defineProperty(this, "onWindowOnline", () => {
|
|
212
|
+
this.update();
|
|
115
213
|
});
|
|
116
|
-
_defineProperty(
|
|
117
|
-
if (
|
|
118
|
-
|
|
214
|
+
_defineProperty(this, "onWindowResize", event => {
|
|
215
|
+
if (this.trackResize) {
|
|
216
|
+
this.resize({
|
|
119
217
|
originalEvent: event
|
|
120
218
|
}).update();
|
|
121
219
|
}
|
|
122
220
|
});
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
221
|
+
this.initContainer();
|
|
222
|
+
this.resize();
|
|
223
|
+
this.handlers = new HandlerManager(this, this.options);
|
|
126
224
|
if (typeof window !== 'undefined') {
|
|
127
|
-
window.addEventListener('online',
|
|
128
|
-
window.addEventListener('resize',
|
|
129
|
-
window.addEventListener('orientationchange',
|
|
225
|
+
window.addEventListener('online', this.onWindowOnline, false);
|
|
226
|
+
window.addEventListener('resize', this.onWindowResize, false);
|
|
227
|
+
window.addEventListener('orientationchange', this.onWindowResize, false);
|
|
130
228
|
}
|
|
131
|
-
|
|
229
|
+
const hashName = typeof options.hash === 'string' && options.hash || undefined;
|
|
132
230
|
if (options.hash) {
|
|
133
|
-
|
|
231
|
+
this.hash = new Hash(hashName).addTo(this);
|
|
134
232
|
}
|
|
135
233
|
|
|
136
234
|
// don't set position from options if set through hash
|
|
137
|
-
if (!
|
|
138
|
-
|
|
235
|
+
if (!this.hash || !this.hash.onHashChange()) {
|
|
236
|
+
this.jumpTo({
|
|
139
237
|
center: options.center,
|
|
140
238
|
zoom: options.zoom,
|
|
141
239
|
bearing: options.bearing,
|
|
142
240
|
pitch: options.pitch
|
|
143
241
|
});
|
|
144
242
|
if (options.bounds) {
|
|
145
|
-
|
|
146
|
-
|
|
243
|
+
this.resize();
|
|
244
|
+
this.fitBounds(options.bounds, merge({}, options.fitBoundsOptions, {
|
|
147
245
|
duration: 0
|
|
148
246
|
}));
|
|
149
247
|
}
|
|
150
248
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
this.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
key: "project",
|
|
196
|
-
value: function project(lngLat) {
|
|
197
|
-
return this.transform.locationPoint(LngLat.convert(lngLat));
|
|
198
|
-
}
|
|
199
|
-
}, {
|
|
200
|
-
key: "unproject",
|
|
201
|
-
value: function unproject(point) {
|
|
202
|
-
return this.transform.pointLocation(Point.convert(point));
|
|
203
|
-
}
|
|
204
|
-
}, {
|
|
205
|
-
key: "getBounds",
|
|
206
|
-
value: function getBounds() {
|
|
207
|
-
return this.transform.getBounds();
|
|
208
|
-
}
|
|
209
|
-
}, {
|
|
210
|
-
key: "getMaxBounds",
|
|
211
|
-
value: function getMaxBounds() {
|
|
212
|
-
return this.transform.getMaxBounds();
|
|
213
|
-
}
|
|
214
|
-
}, {
|
|
215
|
-
key: "setMaxBounds",
|
|
216
|
-
value: function setMaxBounds(bounds) {
|
|
217
|
-
this.transform.setMaxBounds(LngLatBounds.convert(bounds));
|
|
218
|
-
}
|
|
249
|
+
}
|
|
250
|
+
resize(eventData) {
|
|
251
|
+
const [width, height] = this.containerDimensions();
|
|
252
|
+
this.transform.resize(width, height);
|
|
253
|
+
// 小程序环境不需要执行后续动作
|
|
254
|
+
const fireMoving = !this.moving;
|
|
255
|
+
if (fireMoving) {
|
|
256
|
+
this.stop();
|
|
257
|
+
this.emit('movestart', new window.CustomEvent('movestart', eventData));
|
|
258
|
+
this.emit('move', new window.CustomEvent('move', eventData));
|
|
259
|
+
}
|
|
260
|
+
this.emit('resize', new window.CustomEvent('resize', eventData));
|
|
261
|
+
if (fireMoving) {
|
|
262
|
+
this.emit('moveend', new window.CustomEvent('moveend', eventData));
|
|
263
|
+
}
|
|
264
|
+
return this;
|
|
265
|
+
}
|
|
266
|
+
getContainer() {
|
|
267
|
+
return this.container;
|
|
268
|
+
}
|
|
269
|
+
getCanvas() {
|
|
270
|
+
return this.canvas;
|
|
271
|
+
}
|
|
272
|
+
getCanvasContainer() {
|
|
273
|
+
return this.canvasContainer;
|
|
274
|
+
}
|
|
275
|
+
getCanvasOverlays() {
|
|
276
|
+
return this.getCanvasContainer();
|
|
277
|
+
}
|
|
278
|
+
project(lngLat) {
|
|
279
|
+
return this.transform.locationPoint(LngLat.convert(lngLat));
|
|
280
|
+
}
|
|
281
|
+
unproject(point) {
|
|
282
|
+
return this.transform.pointLocation(Point.convert(point));
|
|
283
|
+
}
|
|
284
|
+
getBounds() {
|
|
285
|
+
return this.transform.getBounds();
|
|
286
|
+
}
|
|
287
|
+
getMaxBounds() {
|
|
288
|
+
return this.transform.getMaxBounds();
|
|
289
|
+
}
|
|
290
|
+
setMaxBounds(bounds) {
|
|
291
|
+
this.transform.setMaxBounds(LngLatBounds.convert(bounds));
|
|
292
|
+
}
|
|
219
293
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
|
|
231
|
-
this.transform.minZoom = minZoom;
|
|
232
|
-
if (this.getZoom() < minZoom) {
|
|
233
|
-
this.setZoom(minZoom);
|
|
234
|
-
}
|
|
235
|
-
return this;
|
|
236
|
-
} else {
|
|
237
|
-
throw new Error("minZoom must be between ".concat(defaultMinZoom, " and the current maxZoom, inclusive"));
|
|
294
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
295
|
+
setStyle(style) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
setMinZoom(minZoom) {
|
|
299
|
+
minZoom = minZoom === null || minZoom === undefined ? defaultMinZoom : minZoom;
|
|
300
|
+
if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
|
|
301
|
+
this.transform.minZoom = minZoom;
|
|
302
|
+
if (this.getZoom() < minZoom) {
|
|
303
|
+
this.setZoom(minZoom);
|
|
238
304
|
}
|
|
305
|
+
return this;
|
|
306
|
+
} else {
|
|
307
|
+
throw new Error(`minZoom must be between ${defaultMinZoom} and the current maxZoom, inclusive`);
|
|
239
308
|
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
this.transform.maxZoom = maxZoom;
|
|
251
|
-
if (this.getZoom() > maxZoom) {
|
|
252
|
-
this.setZoom(maxZoom);
|
|
253
|
-
}
|
|
254
|
-
return this;
|
|
255
|
-
} else {
|
|
256
|
-
throw new Error('maxZoom must be greater than the current minZoom');
|
|
309
|
+
}
|
|
310
|
+
getMinZoom() {
|
|
311
|
+
return this.transform.minZoom;
|
|
312
|
+
}
|
|
313
|
+
setMaxZoom(maxZoom) {
|
|
314
|
+
maxZoom = maxZoom === null || maxZoom === undefined ? defaultMaxZoom : maxZoom;
|
|
315
|
+
if (maxZoom >= this.transform.minZoom) {
|
|
316
|
+
this.transform.maxZoom = maxZoom;
|
|
317
|
+
if (this.getZoom() > maxZoom) {
|
|
318
|
+
this.setZoom(maxZoom);
|
|
257
319
|
}
|
|
320
|
+
return this;
|
|
321
|
+
} else {
|
|
322
|
+
throw new Error('maxZoom must be greater than the current minZoom');
|
|
258
323
|
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
this.transform.minPitch = minPitch;
|
|
273
|
-
if (this.getPitch() < minPitch) {
|
|
274
|
-
this.setPitch(minPitch);
|
|
275
|
-
}
|
|
276
|
-
return this;
|
|
277
|
-
} else {
|
|
278
|
-
throw new Error("minPitch must be between ".concat(defaultMinPitch, " and the current maxPitch, inclusive"));
|
|
324
|
+
}
|
|
325
|
+
getMaxZoom() {
|
|
326
|
+
return this.transform.maxZoom;
|
|
327
|
+
}
|
|
328
|
+
setMinPitch(minPitch) {
|
|
329
|
+
minPitch = minPitch === null || minPitch === undefined ? defaultMinPitch : minPitch;
|
|
330
|
+
if (minPitch < defaultMinPitch) {
|
|
331
|
+
throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);
|
|
332
|
+
}
|
|
333
|
+
if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
|
|
334
|
+
this.transform.minPitch = minPitch;
|
|
335
|
+
if (this.getPitch() < minPitch) {
|
|
336
|
+
this.setPitch(minPitch);
|
|
279
337
|
}
|
|
338
|
+
return this;
|
|
339
|
+
} else {
|
|
340
|
+
throw new Error(`minPitch must be between ${defaultMinPitch} and the current maxPitch, inclusive`);
|
|
280
341
|
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
this.transform.maxPitch = maxPitch;
|
|
295
|
-
if (this.getPitch() > maxPitch) {
|
|
296
|
-
this.setPitch(maxPitch);
|
|
297
|
-
}
|
|
298
|
-
return this;
|
|
299
|
-
} else {
|
|
300
|
-
throw new Error('maxPitch must be greater than the current minPitch');
|
|
342
|
+
}
|
|
343
|
+
getMinPitch() {
|
|
344
|
+
return this.transform.minPitch;
|
|
345
|
+
}
|
|
346
|
+
setMaxPitch(maxPitch) {
|
|
347
|
+
maxPitch = maxPitch === null || maxPitch === undefined ? defaultMaxPitch : maxPitch;
|
|
348
|
+
if (maxPitch > defaultMaxPitch) {
|
|
349
|
+
throw new Error(`maxPitch must be less than or equal to ${defaultMaxPitch}`);
|
|
350
|
+
}
|
|
351
|
+
if (maxPitch >= this.transform.minPitch) {
|
|
352
|
+
this.transform.maxPitch = maxPitch;
|
|
353
|
+
if (this.getPitch() > maxPitch) {
|
|
354
|
+
this.setPitch(maxPitch);
|
|
301
355
|
}
|
|
356
|
+
return this;
|
|
357
|
+
} else {
|
|
358
|
+
throw new Error('maxPitch must be greater than the current minPitch');
|
|
302
359
|
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
360
|
+
}
|
|
361
|
+
getMaxPitch() {
|
|
362
|
+
return this.transform.maxPitch;
|
|
363
|
+
}
|
|
364
|
+
getRenderWorldCopies() {
|
|
365
|
+
return this.transform.renderWorldCopies;
|
|
366
|
+
}
|
|
367
|
+
setRenderWorldCopies(renderWorldCopies) {
|
|
368
|
+
this.transform.renderWorldCopies = !!renderWorldCopies;
|
|
369
|
+
}
|
|
370
|
+
remove() {
|
|
371
|
+
this.container.removeChild(this.canvasContainer);
|
|
372
|
+
// @ts-ignore
|
|
373
|
+
this.canvasContainer = null;
|
|
374
|
+
if (this.frame) {
|
|
375
|
+
this.frame.cancel();
|
|
376
|
+
this.frame = null;
|
|
377
|
+
}
|
|
378
|
+
this.renderTaskQueue.clear();
|
|
379
|
+
//销毁事件
|
|
380
|
+
this.handlers.destroy();
|
|
381
|
+
if (typeof window !== 'undefined') {
|
|
382
|
+
window.removeEventListener('online', this.onWindowOnline, false);
|
|
383
|
+
window.removeEventListener('resize', this.onWindowResize, false);
|
|
384
|
+
window.removeEventListener('orientationchange', this.onWindowResize, false);
|
|
317
385
|
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
386
|
+
}
|
|
387
|
+
requestRenderFrame(cb) {
|
|
388
|
+
this.update();
|
|
389
|
+
return this.renderTaskQueue.add(cb);
|
|
390
|
+
}
|
|
391
|
+
cancelRenderFrame(id) {
|
|
392
|
+
return this.renderTaskQueue.remove(id);
|
|
393
|
+
}
|
|
394
|
+
triggerRepaint() {
|
|
395
|
+
if (!this.frame) {
|
|
396
|
+
this.frame = renderframe(paintStartTimeStamp => {
|
|
397
|
+
PerformanceUtils.frame(paintStartTimeStamp);
|
|
326
398
|
this.frame = null;
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
//销毁事件
|
|
330
|
-
this.handlers.destroy();
|
|
331
|
-
if (typeof window !== 'undefined') {
|
|
332
|
-
window.removeEventListener('online', this.onWindowOnline, false);
|
|
333
|
-
window.removeEventListener('resize', this.onWindowResize, false);
|
|
334
|
-
window.removeEventListener('orientationchange', this.onWindowResize, false);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}, {
|
|
338
|
-
key: "requestRenderFrame",
|
|
339
|
-
value: function requestRenderFrame(cb) {
|
|
340
|
-
this.update();
|
|
341
|
-
return this.renderTaskQueue.add(cb);
|
|
342
|
-
}
|
|
343
|
-
}, {
|
|
344
|
-
key: "cancelRenderFrame",
|
|
345
|
-
value: function cancelRenderFrame(id) {
|
|
346
|
-
return this.renderTaskQueue.remove(id);
|
|
347
|
-
}
|
|
348
|
-
}, {
|
|
349
|
-
key: "triggerRepaint",
|
|
350
|
-
value: function triggerRepaint() {
|
|
351
|
-
var _this2 = this;
|
|
352
|
-
if (!this.frame) {
|
|
353
|
-
this.frame = renderframe(function (paintStartTimeStamp) {
|
|
354
|
-
PerformanceUtils.frame(paintStartTimeStamp);
|
|
355
|
-
_this2.frame = null;
|
|
356
|
-
_this2.update(paintStartTimeStamp);
|
|
357
|
-
});
|
|
358
|
-
}
|
|
399
|
+
this.update(paintStartTimeStamp);
|
|
400
|
+
});
|
|
359
401
|
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
this.frame =
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
_this3.renderTaskQueue.run(time);
|
|
369
|
-
});
|
|
370
|
-
}
|
|
402
|
+
}
|
|
403
|
+
update(time) {
|
|
404
|
+
if (!this.frame) {
|
|
405
|
+
this.frame = renderframe(paintStartTimeStamp => {
|
|
406
|
+
PerformanceUtils.frame(paintStartTimeStamp);
|
|
407
|
+
this.frame = null;
|
|
408
|
+
this.renderTaskQueue.run(time);
|
|
409
|
+
});
|
|
371
410
|
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
throw new Error("Container '".concat(this.options.container, "' not found."));
|
|
379
|
-
}
|
|
380
|
-
} else if (this.options.container instanceof HTMLElement) {
|
|
381
|
-
this.container = this.options.container;
|
|
382
|
-
} else {
|
|
383
|
-
throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
|
|
384
|
-
}
|
|
385
|
-
var container = this.container;
|
|
386
|
-
container.classList.add('l7-map');
|
|
387
|
-
var canvasContainer = this.canvasContainer = DOM.create('div', 'l7-canvas-container', container);
|
|
388
|
-
if (this.options.interactive) {
|
|
389
|
-
canvasContainer.classList.add('l7-interactive');
|
|
411
|
+
}
|
|
412
|
+
initContainer() {
|
|
413
|
+
if (typeof this.options.container === 'string') {
|
|
414
|
+
this.container = window.document.getElementById(this.options.container);
|
|
415
|
+
if (!this.container) {
|
|
416
|
+
throw new Error(`Container '${this.options.container}' not found.`);
|
|
390
417
|
}
|
|
418
|
+
} else if (this.options.container instanceof HTMLElement) {
|
|
419
|
+
this.container = this.options.container;
|
|
420
|
+
} else {
|
|
421
|
+
throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
|
|
391
422
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
if (this.container) {
|
|
398
|
-
width = this.container.clientWidth;
|
|
399
|
-
height = this.container.clientHeight;
|
|
400
|
-
width = width === 0 ? 400 : width;
|
|
401
|
-
height = height === 0 ? 300 : height;
|
|
402
|
-
}
|
|
403
|
-
return [width, height];
|
|
423
|
+
const container = this.container;
|
|
424
|
+
container.classList.add('l7-map');
|
|
425
|
+
const canvasContainer = this.canvasContainer = DOM.create('div', 'l7-canvas-container', container);
|
|
426
|
+
if (this.options.interactive) {
|
|
427
|
+
canvasContainer.classList.add('l7-interactive');
|
|
404
428
|
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
|
|
429
|
+
}
|
|
430
|
+
containerDimensions() {
|
|
431
|
+
let width = 0;
|
|
432
|
+
let height = 0;
|
|
433
|
+
if (this.container) {
|
|
434
|
+
width = this.container.clientWidth;
|
|
435
|
+
height = this.container.clientHeight;
|
|
436
|
+
width = width === 0 ? 400 : width;
|
|
437
|
+
height = height === 0 ? 300 : height;
|
|
438
|
+
}
|
|
439
|
+
return [width, height];
|
|
440
|
+
}
|
|
441
|
+
}
|