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