@antv/l7-map 2.9.32-alpha.2 → 2.9.33
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.d.ts +84 -0
- package/es/camera.js +765 -0
- package/es/css/l7.css +98 -0
- package/es/earthmap.d.ts +66 -0
- package/es/earthmap.js +421 -0
- package/es/geo/edge_insets.d.ts +54 -0
- package/es/geo/edge_insets.js +118 -0
- package/es/geo/lng_lat.d.ts +18 -0
- package/es/geo/lng_lat.js +81 -0
- package/es/geo/lng_lat_bounds.d.ts +24 -0
- package/es/geo/lng_lat_bounds.js +167 -0
- package/es/geo/mercator.d.ts +28 -0
- package/es/geo/mercator.js +91 -0
- package/es/geo/point.d.ts +40 -0
- package/es/geo/point.js +231 -0
- package/es/geo/simple.d.ts +28 -0
- package/es/geo/simple.js +90 -0
- package/es/geo/transform.d.ts +198 -0
- package/es/geo/transform.js +971 -0
- package/es/handler/IHandler.d.ts +34 -0
- package/es/handler/IHandler.js +1 -0
- package/es/handler/blockable_map_event.d.ts +17 -0
- package/es/handler/blockable_map_event.js +83 -0
- package/es/handler/box_zoom.d.ts +59 -0
- package/es/handler/box_zoom.js +200 -0
- package/es/handler/click_zoom.d.ts +16 -0
- package/es/handler/click_zoom.js +59 -0
- package/es/handler/events/event.d.ts +4 -0
- package/es/handler/events/event.js +12 -0
- package/es/handler/events/index.d.ts +4 -0
- package/es/handler/events/index.js +4 -0
- package/es/handler/events/map_mouse_event.d.ts +34 -0
- package/es/handler/events/map_mouse_event.js +75 -0
- package/es/handler/events/map_touch_event.d.ts +57 -0
- package/es/handler/events/map_touch_event.js +105 -0
- package/es/handler/events/map_wheel_event.d.ts +33 -0
- package/es/handler/events/map_wheel_event.js +61 -0
- package/es/handler/events/render_event.d.ts +5 -0
- package/es/handler/events/render_event.js +39 -0
- package/es/handler/handler_inertia.d.ts +23 -0
- package/es/handler/handler_inertia.js +184 -0
- package/es/handler/handler_manager.d.ts +61 -0
- package/es/handler/handler_manager.js +684 -0
- package/es/handler/handler_util.d.ts +4 -0
- package/es/handler/handler_util.js +10 -0
- package/es/handler/keyboard.d.ts +36 -0
- package/es/handler/keyboard.js +162 -0
- package/es/handler/map_event.d.ts +29 -0
- package/es/handler/map_event.js +131 -0
- package/es/handler/mouse/index.d.ts +4 -0
- package/es/handler/mouse/index.js +4 -0
- package/es/handler/mouse/mouse_handler.d.ts +22 -0
- package/es/handler/mouse/mouse_handler.js +129 -0
- package/es/handler/mouse/mousepan_handler.d.ts +10 -0
- package/es/handler/mouse/mousepan_handler.js +54 -0
- package/es/handler/mouse/mousepitch_hander.d.ts +9 -0
- package/es/handler/mouse/mousepitch_hander.js +56 -0
- package/es/handler/mouse/mouserotate_hander.d.ts +9 -0
- package/es/handler/mouse/mouserotate_hander.js +56 -0
- package/es/handler/mouse/util.d.ts +6 -0
- package/es/handler/mouse/util.js +12 -0
- package/es/handler/scroll_zoom.d.ts +93 -0
- package/es/handler/scroll_zoom.js +353 -0
- package/es/handler/shim/dblclick_zoom.d.ts +40 -0
- package/es/handler/shim/dblclick_zoom.js +72 -0
- package/es/handler/shim/drag_pan.d.ts +61 -0
- package/es/handler/shim/drag_pan.js +96 -0
- package/es/handler/shim/drag_rotate.d.ts +46 -0
- package/es/handler/shim/drag_rotate.js +80 -0
- package/es/handler/shim/touch_zoom_rotate.d.ts +70 -0
- package/es/handler/shim/touch_zoom_rotate.js +130 -0
- package/es/handler/tap/single_tap_recognizer.d.ts +20 -0
- package/es/handler/tap/single_tap_recognizer.js +120 -0
- package/es/handler/tap/tap_drag_zoom.d.ts +22 -0
- package/es/handler/tap/tap_drag_zoom.js +114 -0
- package/es/handler/tap/tap_recognizer.d.ts +17 -0
- package/es/handler/tap/tap_recognizer.js +62 -0
- package/es/handler/tap/tap_zoom.d.ts +22 -0
- package/es/handler/tap/tap_zoom.js +115 -0
- package/es/handler/touch/index.d.ts +5 -0
- package/es/handler/touch/index.js +5 -0
- package/es/handler/touch/touch_pan.d.ts +30 -0
- package/es/handler/touch/touch_pan.js +128 -0
- package/es/handler/touch/touch_pitch.d.ts +13 -0
- package/es/handler/touch/touch_pitch.js +110 -0
- package/es/handler/touch/touch_rotate.d.ts +12 -0
- package/es/handler/touch/touch_rotate.js +88 -0
- package/es/handler/touch/touch_zoom.d.ts +12 -0
- package/es/handler/touch/touch_zoom.js +67 -0
- package/es/handler/touch/two_touch.d.ts +23 -0
- package/es/handler/touch/two_touch.js +134 -0
- package/es/hash.d.ts +14 -0
- package/es/hash.js +156 -0
- package/es/index.d.ts +3 -0
- package/es/index.js +3 -0
- package/es/interface.d.ts +34 -0
- package/es/interface.js +1 -0
- package/es/map.d.ts +70 -0
- package/es/map.js +463 -0
- package/es/util.d.ts +18 -0
- package/es/util.js +84 -0
- package/es/utils/Aabb.d.ts +12 -0
- package/es/utils/Aabb.js +133 -0
- package/es/utils/dom.d.ts +4 -0
- package/es/utils/dom.js +218 -0
- package/es/utils/performance.d.ts +17 -0
- package/es/utils/performance.js +62 -0
- package/es/utils/primitives.d.ts +6 -0
- package/es/utils/primitives.js +45 -0
- package/es/utils/task_queue.d.ts +13 -0
- package/es/utils/task_queue.js +106 -0
- package/lib/camera.js +533 -0
- package/lib/css/l7.css +98 -0
- package/lib/earthmap.js +278 -0
- package/lib/geo/edge_insets.js +76 -0
- package/lib/geo/lng_lat.js +73 -0
- package/lib/geo/lng_lat_bounds.js +138 -0
- package/lib/geo/mercator.js +91 -0
- package/lib/geo/point.js +176 -0
- package/lib/geo/simple.js +87 -0
- package/lib/geo/transform.js +503 -0
- package/lib/handler/IHandler.js +17 -0
- package/lib/handler/blockable_map_event.js +71 -0
- package/lib/handler/box_zoom.js +139 -0
- package/lib/handler/click_zoom.js +59 -0
- package/lib/handler/events/event.js +38 -0
- package/lib/handler/events/index.js +38 -0
- package/lib/handler/events/map_mouse_event.js +44 -0
- package/lib/handler/events/map_touch_event.js +48 -0
- package/lib/handler/events/map_wheel_event.js +36 -0
- package/lib/handler/events/render_event.js +33 -0
- package/lib/handler/handler_inertia.js +149 -0
- package/lib/handler/handler_manager.js +455 -0
- package/lib/handler/handler_util.js +35 -0
- package/lib/handler/keyboard.js +131 -0
- package/lib/handler/map_event.js +91 -0
- package/lib/handler/mouse/index.js +38 -0
- package/lib/handler/mouse/mouse_handler.js +103 -0
- package/lib/handler/mouse/mousepan_handler.js +48 -0
- package/lib/handler/mouse/mousepitch_hander.js +47 -0
- package/lib/handler/mouse/mouserotate_hander.js +47 -0
- package/lib/handler/mouse/util.js +44 -0
- package/lib/handler/scroll_zoom.js +225 -0
- package/lib/handler/shim/dblclick_zoom.js +46 -0
- package/lib/handler/shim/drag_pan.js +55 -0
- package/lib/handler/shim/drag_rotate.js +49 -0
- package/lib/handler/shim/touch_zoom_rotate.js +71 -0
- package/lib/handler/tap/single_tap_recognizer.js +102 -0
- package/lib/handler/tap/tap_drag_zoom.js +106 -0
- package/lib/handler/tap/tap_recognizer.js +66 -0
- package/lib/handler/tap/tap_zoom.js +99 -0
- package/lib/handler/touch/index.js +41 -0
- package/lib/handler/touch/touch_pan.js +110 -0
- package/lib/handler/touch/touch_pitch.js +86 -0
- package/lib/handler/touch/touch_rotate.js +65 -0
- package/lib/handler/touch/touch_zoom.js +56 -0
- package/lib/handler/touch/two_touch.js +105 -0
- package/lib/hash.js +120 -0
- package/lib/index.js +21 -0
- package/lib/interface.js +17 -0
- package/lib/map.js +308 -0
- package/lib/util.js +97 -0
- package/lib/utils/Aabb.js +90 -0
- package/lib/utils/dom.js +159 -0
- package/lib/utils/performance.js +80 -0
- package/lib/utils/primitives.js +63 -0
- package/lib/utils/task_queue.js +72 -0
- package/package.json +3 -3
package/lib/map.js
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/map.ts
|
|
23
|
+
var map_exports = {};
|
|
24
|
+
__export(map_exports, {
|
|
25
|
+
Map: () => Map
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(map_exports);
|
|
28
|
+
var import_l7_utils = require("@antv/l7-utils");
|
|
29
|
+
var import_lodash = require("lodash");
|
|
30
|
+
var import_camera = __toESM(require("./camera"));
|
|
31
|
+
var import_l7 = require("./css/l7.css");
|
|
32
|
+
var import_lng_lat = __toESM(require("./geo/lng_lat"));
|
|
33
|
+
var import_lng_lat_bounds = __toESM(require("./geo/lng_lat_bounds"));
|
|
34
|
+
var import_point = __toESM(require("./geo/point"));
|
|
35
|
+
var import_handler_manager = __toESM(require("./handler/handler_manager"));
|
|
36
|
+
var import_hash = __toESM(require("./hash"));
|
|
37
|
+
var import_util = require("./util");
|
|
38
|
+
var import_performance = require("./utils/performance");
|
|
39
|
+
var import_task_queue = __toESM(require("./utils/task_queue"));
|
|
40
|
+
var defaultMinZoom = -2;
|
|
41
|
+
var defaultMaxZoom = 22;
|
|
42
|
+
var defaultMinPitch = 0;
|
|
43
|
+
var defaultMaxPitch = 60;
|
|
44
|
+
var DefaultOptions = {
|
|
45
|
+
hash: false,
|
|
46
|
+
zoom: -1,
|
|
47
|
+
center: [112, 32],
|
|
48
|
+
pitch: 0,
|
|
49
|
+
bearing: 0,
|
|
50
|
+
interactive: true,
|
|
51
|
+
minZoom: defaultMinZoom,
|
|
52
|
+
maxZoom: defaultMaxZoom,
|
|
53
|
+
minPitch: defaultMinPitch,
|
|
54
|
+
maxPitch: defaultMaxPitch,
|
|
55
|
+
scrollZoom: true,
|
|
56
|
+
boxZoom: true,
|
|
57
|
+
dragRotate: true,
|
|
58
|
+
dragPan: true,
|
|
59
|
+
keyboard: true,
|
|
60
|
+
doubleClickZoom: true,
|
|
61
|
+
touchZoomRotate: true,
|
|
62
|
+
touchPitch: true,
|
|
63
|
+
bearingSnap: 7,
|
|
64
|
+
clickTolerance: 3,
|
|
65
|
+
pitchWithRotate: true,
|
|
66
|
+
trackResize: true,
|
|
67
|
+
renderWorldCopies: true,
|
|
68
|
+
pitchEnabled: true,
|
|
69
|
+
rotateEnabled: true
|
|
70
|
+
};
|
|
71
|
+
var Map = class extends import_camera.default {
|
|
72
|
+
constructor(options) {
|
|
73
|
+
super((0, import_lodash.merge)({}, DefaultOptions, options));
|
|
74
|
+
this.renderTaskQueue = new import_task_queue.default();
|
|
75
|
+
this.trackResize = true;
|
|
76
|
+
this.onWindowOnline = () => {
|
|
77
|
+
this.update();
|
|
78
|
+
};
|
|
79
|
+
this.onWindowResize = (event) => {
|
|
80
|
+
if (this.trackResize) {
|
|
81
|
+
this.resize({ originalEvent: event }).update();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
if (import_l7_utils.isMini) {
|
|
85
|
+
this.initMiniContainer();
|
|
86
|
+
} else {
|
|
87
|
+
this.initContainer();
|
|
88
|
+
}
|
|
89
|
+
this.resize();
|
|
90
|
+
this.handlers = new import_handler_manager.default(this, this.options);
|
|
91
|
+
if (typeof window !== "undefined") {
|
|
92
|
+
window.addEventListener("online", this.onWindowOnline, false);
|
|
93
|
+
window.addEventListener("resize", this.onWindowResize, false);
|
|
94
|
+
window.addEventListener("orientationchange", this.onWindowResize, false);
|
|
95
|
+
}
|
|
96
|
+
if (!import_l7_utils.isMini) {
|
|
97
|
+
const hashName = typeof options.hash === "string" && options.hash || void 0;
|
|
98
|
+
if (options.hash) {
|
|
99
|
+
this.hash = new import_hash.default(hashName).addTo(this);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (!this.hash || !this.hash.onHashChange()) {
|
|
103
|
+
this.jumpTo({
|
|
104
|
+
center: options.center,
|
|
105
|
+
zoom: options.zoom,
|
|
106
|
+
bearing: options.bearing,
|
|
107
|
+
pitch: options.pitch
|
|
108
|
+
});
|
|
109
|
+
if (options.bounds) {
|
|
110
|
+
this.resize();
|
|
111
|
+
this.fitBounds(options.bounds, (0, import_lodash.merge)({}, options.fitBoundsOptions, { duration: 0 }));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
resize(eventData) {
|
|
116
|
+
const [width, height] = this.containerDimensions();
|
|
117
|
+
this.transform.resize(width, height);
|
|
118
|
+
if (import_l7_utils.isMini) {
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
const fireMoving = !this.moving;
|
|
122
|
+
if (fireMoving) {
|
|
123
|
+
this.stop();
|
|
124
|
+
this.emit("movestart", new import_l7_utils.$window.Event("movestart", eventData));
|
|
125
|
+
this.emit("move", new import_l7_utils.$window.Event("move", eventData));
|
|
126
|
+
}
|
|
127
|
+
this.emit("resize", new import_l7_utils.$window.Event("resize", eventData));
|
|
128
|
+
if (fireMoving) {
|
|
129
|
+
this.emit("moveend", new import_l7_utils.$window.Event("moveend", eventData));
|
|
130
|
+
}
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
getContainer() {
|
|
134
|
+
return this.container;
|
|
135
|
+
}
|
|
136
|
+
getCanvas() {
|
|
137
|
+
return this.canvas;
|
|
138
|
+
}
|
|
139
|
+
getCanvasContainer() {
|
|
140
|
+
return this.canvasContainer;
|
|
141
|
+
}
|
|
142
|
+
project(lngLat) {
|
|
143
|
+
return this.transform.locationPoint(import_lng_lat.default.convert(lngLat));
|
|
144
|
+
}
|
|
145
|
+
unproject(point) {
|
|
146
|
+
return this.transform.pointLocation(import_point.default.convert(point));
|
|
147
|
+
}
|
|
148
|
+
getBounds() {
|
|
149
|
+
return this.transform.getBounds();
|
|
150
|
+
}
|
|
151
|
+
getMaxBounds() {
|
|
152
|
+
return this.transform.getMaxBounds();
|
|
153
|
+
}
|
|
154
|
+
setMaxBounds(bounds) {
|
|
155
|
+
this.transform.setMaxBounds(import_lng_lat_bounds.default.convert(bounds));
|
|
156
|
+
}
|
|
157
|
+
setStyle(style) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
setMinZoom(minZoom) {
|
|
161
|
+
minZoom = minZoom === null || minZoom === void 0 ? defaultMinZoom : minZoom;
|
|
162
|
+
if (minZoom >= defaultMinZoom && minZoom <= this.transform.maxZoom) {
|
|
163
|
+
this.transform.minZoom = minZoom;
|
|
164
|
+
if (this.getZoom() < minZoom) {
|
|
165
|
+
this.setZoom(minZoom);
|
|
166
|
+
}
|
|
167
|
+
return this;
|
|
168
|
+
} else {
|
|
169
|
+
throw new Error(`minZoom must be between ${defaultMinZoom} and the current maxZoom, inclusive`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
getMinZoom() {
|
|
173
|
+
return this.transform.minZoom;
|
|
174
|
+
}
|
|
175
|
+
setMaxZoom(maxZoom) {
|
|
176
|
+
maxZoom = maxZoom === null || maxZoom === void 0 ? defaultMaxZoom : maxZoom;
|
|
177
|
+
if (maxZoom >= this.transform.minZoom) {
|
|
178
|
+
this.transform.maxZoom = maxZoom;
|
|
179
|
+
if (this.getZoom() > maxZoom) {
|
|
180
|
+
this.setZoom(maxZoom);
|
|
181
|
+
}
|
|
182
|
+
return this;
|
|
183
|
+
} else {
|
|
184
|
+
throw new Error("maxZoom must be greater than the current minZoom");
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
getMaxZoom() {
|
|
188
|
+
return this.transform.maxZoom;
|
|
189
|
+
}
|
|
190
|
+
setMinPitch(minPitch) {
|
|
191
|
+
minPitch = minPitch === null || minPitch === void 0 ? defaultMinPitch : minPitch;
|
|
192
|
+
if (minPitch < defaultMinPitch) {
|
|
193
|
+
throw new Error(`minPitch must be greater than or equal to ${defaultMinPitch}`);
|
|
194
|
+
}
|
|
195
|
+
if (minPitch >= defaultMinPitch && minPitch <= this.transform.maxPitch) {
|
|
196
|
+
this.transform.minPitch = minPitch;
|
|
197
|
+
if (this.getPitch() < minPitch) {
|
|
198
|
+
this.setPitch(minPitch);
|
|
199
|
+
}
|
|
200
|
+
return this;
|
|
201
|
+
} else {
|
|
202
|
+
throw new Error(`minPitch must be between ${defaultMinPitch} and the current maxPitch, inclusive`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
getMinPitch() {
|
|
206
|
+
return this.transform.minPitch;
|
|
207
|
+
}
|
|
208
|
+
setMaxPitch(maxPitch) {
|
|
209
|
+
maxPitch = maxPitch === null || maxPitch === void 0 ? defaultMaxPitch : maxPitch;
|
|
210
|
+
if (maxPitch > defaultMaxPitch) {
|
|
211
|
+
throw new Error(`maxPitch must be less than or equal to ${defaultMaxPitch}`);
|
|
212
|
+
}
|
|
213
|
+
if (maxPitch >= this.transform.minPitch) {
|
|
214
|
+
this.transform.maxPitch = maxPitch;
|
|
215
|
+
if (this.getPitch() > maxPitch) {
|
|
216
|
+
this.setPitch(maxPitch);
|
|
217
|
+
}
|
|
218
|
+
return this;
|
|
219
|
+
} else {
|
|
220
|
+
throw new Error("maxPitch must be greater than the current minPitch");
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
getMaxPitch() {
|
|
224
|
+
return this.transform.maxPitch;
|
|
225
|
+
}
|
|
226
|
+
getRenderWorldCopies() {
|
|
227
|
+
return this.transform.renderWorldCopies;
|
|
228
|
+
}
|
|
229
|
+
setRenderWorldCopies(renderWorldCopies) {
|
|
230
|
+
this.transform.renderWorldCopies = !!renderWorldCopies;
|
|
231
|
+
}
|
|
232
|
+
remove() {
|
|
233
|
+
this.container.removeChild(this.canvasContainer);
|
|
234
|
+
this.canvasContainer = null;
|
|
235
|
+
if (this.frame) {
|
|
236
|
+
this.frame.cancel();
|
|
237
|
+
this.frame = null;
|
|
238
|
+
}
|
|
239
|
+
this.renderTaskQueue.clear();
|
|
240
|
+
}
|
|
241
|
+
requestRenderFrame(cb) {
|
|
242
|
+
this.update();
|
|
243
|
+
return this.renderTaskQueue.add(cb);
|
|
244
|
+
}
|
|
245
|
+
cancelRenderFrame(id) {
|
|
246
|
+
return this.renderTaskQueue.remove(id);
|
|
247
|
+
}
|
|
248
|
+
triggerRepaint() {
|
|
249
|
+
if (!this.frame) {
|
|
250
|
+
this.frame = (0, import_util.renderframe)((paintStartTimeStamp) => {
|
|
251
|
+
import_performance.PerformanceUtils.frame(paintStartTimeStamp);
|
|
252
|
+
this.frame = null;
|
|
253
|
+
this.update(paintStartTimeStamp);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
update(time) {
|
|
258
|
+
if (!this.frame) {
|
|
259
|
+
this.frame = (0, import_util.renderframe)((paintStartTimeStamp) => {
|
|
260
|
+
import_performance.PerformanceUtils.frame(paintStartTimeStamp);
|
|
261
|
+
this.frame = null;
|
|
262
|
+
this.renderTaskQueue.run(time);
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
initContainer() {
|
|
267
|
+
if (typeof this.options.container === "string") {
|
|
268
|
+
this.container = window.document.getElementById(this.options.container);
|
|
269
|
+
if (!this.container) {
|
|
270
|
+
throw new Error(`Container '${this.options.container}' not found.`);
|
|
271
|
+
}
|
|
272
|
+
} else if (this.options.container instanceof HTMLElement) {
|
|
273
|
+
this.container = this.options.container;
|
|
274
|
+
} else {
|
|
275
|
+
throw new Error("Invalid type: 'container' must be a String or HTMLElement.");
|
|
276
|
+
}
|
|
277
|
+
const container = this.container;
|
|
278
|
+
container.classList.add("l7-map");
|
|
279
|
+
const canvasContainer = this.canvasContainer = import_l7_utils.DOM.create("div", "l7-canvas-container", container);
|
|
280
|
+
if (this.options.interactive) {
|
|
281
|
+
canvasContainer.classList.add("l7-interactive");
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
initMiniContainer() {
|
|
285
|
+
this.container = this.options.canvas;
|
|
286
|
+
this.canvasContainer = this.container;
|
|
287
|
+
}
|
|
288
|
+
containerDimensions() {
|
|
289
|
+
let width = 0;
|
|
290
|
+
let height = 0;
|
|
291
|
+
if (this.container) {
|
|
292
|
+
if (import_l7_utils.isMini) {
|
|
293
|
+
width = this.container.width / import_l7_utils.$window.devicePixelRatio;
|
|
294
|
+
height = this.container.height / import_l7_utils.$window.devicePixelRatio;
|
|
295
|
+
} else {
|
|
296
|
+
width = this.container.clientWidth;
|
|
297
|
+
height = this.container.clientHeight;
|
|
298
|
+
width = width == 0 ? 400 : width;
|
|
299
|
+
height = height === 0 ? 300 : height;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return [width, height];
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
306
|
+
0 && (module.exports = {
|
|
307
|
+
Map
|
|
308
|
+
});
|
package/lib/util.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/util.ts
|
|
23
|
+
var util_exports = {};
|
|
24
|
+
__export(util_exports, {
|
|
25
|
+
bezier: () => bezier,
|
|
26
|
+
cancel: () => cancel,
|
|
27
|
+
clamp: () => clamp,
|
|
28
|
+
ease: () => ease,
|
|
29
|
+
interpolate: () => interpolate,
|
|
30
|
+
now: () => now,
|
|
31
|
+
pick: () => pick,
|
|
32
|
+
prefersReducedMotion: () => prefersReducedMotion,
|
|
33
|
+
raf: () => raf,
|
|
34
|
+
renderframe: () => renderframe,
|
|
35
|
+
wrap: () => wrap
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(util_exports);
|
|
38
|
+
var import_l7_utils = require("@antv/l7-utils");
|
|
39
|
+
var import_unitbezier = __toESM(require("@mapbox/unitbezier"));
|
|
40
|
+
var reducedMotionQuery;
|
|
41
|
+
function wrap(n, min, max) {
|
|
42
|
+
const d = max - min;
|
|
43
|
+
const w = ((n - min) % d + d) % d + min;
|
|
44
|
+
return w === min ? max : w;
|
|
45
|
+
}
|
|
46
|
+
function clamp(n, min, max) {
|
|
47
|
+
return Math.min(max, Math.max(min, n));
|
|
48
|
+
}
|
|
49
|
+
function interpolate(a, b, t) {
|
|
50
|
+
return a * (1 - t) + b * t;
|
|
51
|
+
}
|
|
52
|
+
function bezier(p1x, p1y, p2x, p2y) {
|
|
53
|
+
const bez = new import_unitbezier.default(p1x, p1y, p2x, p2y);
|
|
54
|
+
return (t) => {
|
|
55
|
+
return bez.solve(t);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
var ease = bezier(0.25, 0.1, 0.25, 1);
|
|
59
|
+
function prefersReducedMotion() {
|
|
60
|
+
if (import_l7_utils.isMini || !import_l7_utils.$window.matchMedia) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (reducedMotionQuery == null) {
|
|
64
|
+
reducedMotionQuery = import_l7_utils.$window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
65
|
+
}
|
|
66
|
+
return reducedMotionQuery.matches;
|
|
67
|
+
}
|
|
68
|
+
function pick(src, properties) {
|
|
69
|
+
const result = {};
|
|
70
|
+
for (const name of properties) {
|
|
71
|
+
if (name in src) {
|
|
72
|
+
result[name] = src[name];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
var now = import_l7_utils.isMini ? Date.now.bind(Date) : import_l7_utils.$window.performance && import_l7_utils.$window.performance.now ? import_l7_utils.$window.performance.now.bind(import_l7_utils.$window.performance) : Date.now.bind(Date);
|
|
78
|
+
var raf = import_l7_utils.$window.requestAnimationFrame || import_l7_utils.$window.mozRequestAnimationFrame || import_l7_utils.$window.webkitRequestAnimationFrame || import_l7_utils.$window.msRequestAnimationFrame;
|
|
79
|
+
var cancel = import_l7_utils.$window.cancelAnimationFrame || import_l7_utils.$window.mozCancelAnimationFrame || import_l7_utils.$window.webkitCancelAnimationFrame || import_l7_utils.$window.msCancelAnimationFrame;
|
|
80
|
+
function renderframe(fn) {
|
|
81
|
+
const frame = raf(fn);
|
|
82
|
+
return { cancel: () => cancel(frame) };
|
|
83
|
+
}
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
bezier,
|
|
87
|
+
cancel,
|
|
88
|
+
clamp,
|
|
89
|
+
ease,
|
|
90
|
+
interpolate,
|
|
91
|
+
now,
|
|
92
|
+
pick,
|
|
93
|
+
prefersReducedMotion,
|
|
94
|
+
raf,
|
|
95
|
+
renderframe,
|
|
96
|
+
wrap
|
|
97
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/Aabb.ts
|
|
20
|
+
var Aabb_exports = {};
|
|
21
|
+
__export(Aabb_exports, {
|
|
22
|
+
default: () => Aabb
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Aabb_exports);
|
|
25
|
+
var import_gl_matrix = require("gl-matrix");
|
|
26
|
+
var Aabb = class {
|
|
27
|
+
constructor(min, max) {
|
|
28
|
+
this.min = min;
|
|
29
|
+
this.max = max;
|
|
30
|
+
this.center = import_gl_matrix.vec3.scale(new Float32Array(3), import_gl_matrix.vec3.add(new Float32Array(3), this.min, this.max), 0.5);
|
|
31
|
+
}
|
|
32
|
+
quadrant(index) {
|
|
33
|
+
const split = [index % 2 === 0, index < 2];
|
|
34
|
+
const qMin = import_gl_matrix.vec3.clone(this.min);
|
|
35
|
+
const qMax = import_gl_matrix.vec3.clone(this.max);
|
|
36
|
+
for (let axis = 0; axis < split.length; axis++) {
|
|
37
|
+
qMin[axis] = split[axis] ? this.min[axis] : this.center[axis];
|
|
38
|
+
qMax[axis] = split[axis] ? this.center[axis] : this.max[axis];
|
|
39
|
+
}
|
|
40
|
+
qMax[2] = this.max[2];
|
|
41
|
+
return new Aabb(qMin, qMax);
|
|
42
|
+
}
|
|
43
|
+
distanceX(point) {
|
|
44
|
+
const pointOnAabb = Math.max(Math.min(this.max[0], point[0]), this.min[0]);
|
|
45
|
+
return pointOnAabb - point[0];
|
|
46
|
+
}
|
|
47
|
+
distanceY(point) {
|
|
48
|
+
const pointOnAabb = Math.max(Math.min(this.max[1], point[1]), this.min[1]);
|
|
49
|
+
return pointOnAabb - point[1];
|
|
50
|
+
}
|
|
51
|
+
intersects(frustum) {
|
|
52
|
+
const aabbPoints = [
|
|
53
|
+
[this.min[0], this.min[1], 0, 1],
|
|
54
|
+
[this.max[0], this.min[1], 0, 1],
|
|
55
|
+
[this.max[0], this.max[1], 0, 1],
|
|
56
|
+
[this.min[0], this.max[1], 0, 1]
|
|
57
|
+
];
|
|
58
|
+
let fullyInside = true;
|
|
59
|
+
for (const plane of frustum.planes) {
|
|
60
|
+
let pointsInside = 0;
|
|
61
|
+
for (const i of aabbPoints) {
|
|
62
|
+
pointsInside += import_gl_matrix.vec4.dot(plane, i) >= 0;
|
|
63
|
+
}
|
|
64
|
+
if (pointsInside === 0) {
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
if (pointsInside !== aabbPoints.length) {
|
|
68
|
+
fullyInside = false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (fullyInside) {
|
|
72
|
+
return 2;
|
|
73
|
+
}
|
|
74
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
75
|
+
let projMin = Number.MAX_VALUE;
|
|
76
|
+
let projMax = -Number.MAX_VALUE;
|
|
77
|
+
for (const p of frustum.points) {
|
|
78
|
+
const projectedPoint = p[axis] - this.min[axis];
|
|
79
|
+
projMin = Math.min(projMin, projectedPoint);
|
|
80
|
+
projMax = Math.max(projMax, projectedPoint);
|
|
81
|
+
}
|
|
82
|
+
if (projMax < 0 || projMin > this.max[axis] - this.min[axis]) {
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return 1;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
+
0 && (module.exports = {});
|
package/lib/utils/dom.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/utils/dom.ts
|
|
23
|
+
var dom_exports = {};
|
|
24
|
+
__export(dom_exports, {
|
|
25
|
+
default: () => dom_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(dom_exports);
|
|
28
|
+
var import_l7_utils = require("@antv/l7-utils");
|
|
29
|
+
var import_point = __toESM(require("../geo/point"));
|
|
30
|
+
var DOM = {};
|
|
31
|
+
var dom_default = DOM;
|
|
32
|
+
DOM.create = (tagName, className, container) => {
|
|
33
|
+
const el = import_l7_utils.$window.document.createElement(tagName);
|
|
34
|
+
if (className !== void 0) {
|
|
35
|
+
el.className = className;
|
|
36
|
+
}
|
|
37
|
+
if (container) {
|
|
38
|
+
container.appendChild(el);
|
|
39
|
+
}
|
|
40
|
+
return el;
|
|
41
|
+
};
|
|
42
|
+
DOM.createNS = (namespaceURI, tagName) => {
|
|
43
|
+
const el = import_l7_utils.$window.document.createElementNS(namespaceURI, tagName);
|
|
44
|
+
return el;
|
|
45
|
+
};
|
|
46
|
+
var docStyle = import_l7_utils.$window.document && import_l7_utils.$window.document.documentElement.style;
|
|
47
|
+
function testProp(props) {
|
|
48
|
+
if (!docStyle) {
|
|
49
|
+
return props[0];
|
|
50
|
+
}
|
|
51
|
+
for (const i of props) {
|
|
52
|
+
if (i in docStyle) {
|
|
53
|
+
return i;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return props[0];
|
|
57
|
+
}
|
|
58
|
+
var selectProp = testProp([
|
|
59
|
+
"userSelect",
|
|
60
|
+
"MozUserSelect",
|
|
61
|
+
"WebkitUserSelect",
|
|
62
|
+
"msUserSelect"
|
|
63
|
+
]);
|
|
64
|
+
var userSelect;
|
|
65
|
+
DOM.disableDrag = () => {
|
|
66
|
+
if (docStyle && selectProp) {
|
|
67
|
+
userSelect = docStyle[selectProp];
|
|
68
|
+
docStyle[selectProp] = "none";
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
DOM.enableDrag = () => {
|
|
72
|
+
if (docStyle && selectProp) {
|
|
73
|
+
docStyle[selectProp] = userSelect;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var transformProp = testProp(["transform", "WebkitTransform"]);
|
|
77
|
+
DOM.setTransform = (el, value) => {
|
|
78
|
+
el.style[transformProp] = value;
|
|
79
|
+
};
|
|
80
|
+
var passiveSupported = false;
|
|
81
|
+
try {
|
|
82
|
+
const options = Object.defineProperty({}, "passive", {
|
|
83
|
+
get() {
|
|
84
|
+
passiveSupported = true;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
import_l7_utils.$window.addEventListener("test", options, options);
|
|
88
|
+
import_l7_utils.$window.removeEventListener("test", options, options);
|
|
89
|
+
} catch (err) {
|
|
90
|
+
passiveSupported = false;
|
|
91
|
+
}
|
|
92
|
+
DOM.addEventListener = (target, type, callback, options = {}) => {
|
|
93
|
+
if ("passive" in options && passiveSupported) {
|
|
94
|
+
target.addEventListener(type, callback, options);
|
|
95
|
+
} else {
|
|
96
|
+
target.addEventListener(type, callback, options.capture);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
DOM.removeEventListener = (target, type, callback, options = {}) => {
|
|
100
|
+
if ("passive" in options && passiveSupported) {
|
|
101
|
+
target.removeEventListener(type, callback, options);
|
|
102
|
+
} else {
|
|
103
|
+
target.removeEventListener(type, callback, options.capture);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var suppressClick = (e) => {
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
e.stopPropagation();
|
|
109
|
+
import_l7_utils.$window.removeEventListener("click", suppressClick, true);
|
|
110
|
+
};
|
|
111
|
+
DOM.suppressClick = () => {
|
|
112
|
+
if (import_l7_utils.isMini) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
import_l7_utils.$window.addEventListener("click", suppressClick, true);
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
import_l7_utils.$window.removeEventListener("click", suppressClick, true);
|
|
118
|
+
}, 0);
|
|
119
|
+
};
|
|
120
|
+
DOM.mousePos = (el, e) => {
|
|
121
|
+
if (!import_l7_utils.isMini) {
|
|
122
|
+
const rect = el.getBoundingClientRect();
|
|
123
|
+
return new import_point.default(e.clientX - rect.left - el.clientLeft, e.clientY - rect.top - el.clientTop);
|
|
124
|
+
} else {
|
|
125
|
+
return new import_point.default(e.clientX - el.left - 0, e.clientY - el.top - 0);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
DOM.touchPos = (el, touches) => {
|
|
129
|
+
if (!import_l7_utils.isMini) {
|
|
130
|
+
const rect = el.getBoundingClientRect();
|
|
131
|
+
const points = [];
|
|
132
|
+
for (const touche of touches) {
|
|
133
|
+
points.push(new import_point.default(touche.clientX - rect.left - el.clientLeft, touche.clientY - rect.top - el.clientTop));
|
|
134
|
+
}
|
|
135
|
+
return points;
|
|
136
|
+
} else {
|
|
137
|
+
const points = [];
|
|
138
|
+
for (const touche of touches) {
|
|
139
|
+
points.push(new import_point.default(touche.clientX - el.left, touche.clientY - el.top));
|
|
140
|
+
}
|
|
141
|
+
return points;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
DOM.mouseButton = (e) => {
|
|
145
|
+
if (!import_l7_utils.isMini) {
|
|
146
|
+
return e.button;
|
|
147
|
+
}
|
|
148
|
+
if (typeof import_l7_utils.$window.InstallTrigger !== "undefined" && e.button === 2 && e.ctrlKey && import_l7_utils.$window.navigator.platform.toUpperCase().indexOf("MAC") >= 0) {
|
|
149
|
+
return 0;
|
|
150
|
+
}
|
|
151
|
+
return e.button;
|
|
152
|
+
};
|
|
153
|
+
DOM.remove = (node) => {
|
|
154
|
+
if (node.parentNode) {
|
|
155
|
+
node.parentNode.removeChild(node);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
159
|
+
0 && (module.exports = {});
|