@antv/l7-scene 2.25.7 → 2.25.9
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/ILayerManager.d.ts +9 -0
- package/es/ILayerManager.js +0 -0
- package/es/IMapController.d.ts +62 -0
- package/es/IMapController.js +0 -0
- package/es/IPostProcessingPassPluggable.d.ts +9 -0
- package/es/IPostProcessingPassPluggable.js +0 -0
- package/es/boxSelect.d.ts +23 -0
- package/es/boxSelect.js +104 -0
- package/es/index.d.ts +144 -0
- package/es/index.js +485 -0
- package/lib/ILayerManager.d.ts +9 -0
- package/lib/ILayerManager.js +17 -0
- package/lib/IMapController.d.ts +62 -0
- package/lib/IMapController.js +17 -0
- package/lib/IPostProcessingPassPluggable.d.ts +9 -0
- package/lib/IPostProcessingPassPluggable.js +17 -0
- package/lib/boxSelect.d.ts +23 -0
- package/lib/boxSelect.js +128 -0
- package/lib/index.d.ts +144 -0
- package/lib/index.js +516 -0
- package/package.json +8 -8
package/lib/boxSelect.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
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/boxSelect.ts
|
|
20
|
+
var boxSelect_exports = {};
|
|
21
|
+
__export(boxSelect_exports, {
|
|
22
|
+
BoxSelectEventList: () => BoxSelectEventList,
|
|
23
|
+
default: () => BoxSelect
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(boxSelect_exports);
|
|
26
|
+
var import_l7_utils = require("@antv/l7-utils");
|
|
27
|
+
var import_eventemitter3 = require("eventemitter3");
|
|
28
|
+
var BoxSelectEventList = ["selectstart", "selecting", "selectend"];
|
|
29
|
+
var BoxSelect = class extends import_eventemitter3.EventEmitter {
|
|
30
|
+
constructor(scene, options = {}) {
|
|
31
|
+
super();
|
|
32
|
+
this.isEnable = false;
|
|
33
|
+
this.onDragStart = (e) => {
|
|
34
|
+
if (e.target && e.stopPropagation) {
|
|
35
|
+
e.stopPropagation();
|
|
36
|
+
}
|
|
37
|
+
this.box.style.display = "block";
|
|
38
|
+
this.startEvent = this.endEvent = e;
|
|
39
|
+
this.syncBoxBound();
|
|
40
|
+
this.emit("selectstart", this.getLngLatBox(), this.startEvent, this.endEvent);
|
|
41
|
+
};
|
|
42
|
+
this.onDragging = (e) => {
|
|
43
|
+
if (e.target && e.stopPropagation) {
|
|
44
|
+
e.stopPropagation();
|
|
45
|
+
}
|
|
46
|
+
this.endEvent = e;
|
|
47
|
+
this.syncBoxBound();
|
|
48
|
+
this.emit("selecting", this.getLngLatBox(), this.startEvent, this.endEvent);
|
|
49
|
+
};
|
|
50
|
+
this.onDragEnd = (e) => {
|
|
51
|
+
if (e.target && e.stopPropagation) {
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
}
|
|
54
|
+
this.endEvent = e;
|
|
55
|
+
this.box.style.display = "none";
|
|
56
|
+
this.emit("selectend", this.getLngLatBox(), this.startEvent, this.endEvent);
|
|
57
|
+
};
|
|
58
|
+
this.scene = scene;
|
|
59
|
+
this.options = options;
|
|
60
|
+
}
|
|
61
|
+
get container() {
|
|
62
|
+
return this.scene.getMapService().getMarkerContainer();
|
|
63
|
+
}
|
|
64
|
+
enable() {
|
|
65
|
+
if (this.isEnable) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const { className } = this.options;
|
|
69
|
+
this.scene.setMapStatus({
|
|
70
|
+
dragEnable: false
|
|
71
|
+
});
|
|
72
|
+
this.container.style.cursor = "crosshair";
|
|
73
|
+
if (!this.box) {
|
|
74
|
+
const box = import_l7_utils.DOM.create("div", void 0, this.container);
|
|
75
|
+
box.classList.add("l7-select-box");
|
|
76
|
+
if (className) {
|
|
77
|
+
box.classList.add(className);
|
|
78
|
+
}
|
|
79
|
+
box.style.display = "none";
|
|
80
|
+
this.box = box;
|
|
81
|
+
}
|
|
82
|
+
this.scene.on("dragstart", this.onDragStart);
|
|
83
|
+
this.scene.on("dragging", this.onDragging);
|
|
84
|
+
this.scene.on("dragend", this.onDragEnd);
|
|
85
|
+
this.isEnable = true;
|
|
86
|
+
}
|
|
87
|
+
disable() {
|
|
88
|
+
if (!this.isEnable) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this.scene.setMapStatus({
|
|
92
|
+
dragEnable: true
|
|
93
|
+
});
|
|
94
|
+
this.container.style.cursor = "auto";
|
|
95
|
+
this.scene.off("dragstart", this.onDragStart);
|
|
96
|
+
this.scene.off("dragging", this.onDragging);
|
|
97
|
+
this.scene.off("dragend", this.onDragEnd);
|
|
98
|
+
this.isEnable = false;
|
|
99
|
+
}
|
|
100
|
+
syncBoxBound() {
|
|
101
|
+
const { x: x1, y: y1 } = this.startEvent;
|
|
102
|
+
const { x: x2, y: y2 } = this.endEvent;
|
|
103
|
+
const left = Math.min(x1, x2);
|
|
104
|
+
const top = Math.min(y1, y2);
|
|
105
|
+
const width = Math.abs(x1 - x2);
|
|
106
|
+
const height = Math.abs(y1 - y2);
|
|
107
|
+
this.box.style.top = `${top}px`;
|
|
108
|
+
this.box.style.left = `${left}px`;
|
|
109
|
+
this.box.style.width = `${width}px`;
|
|
110
|
+
this.box.style.height = `${height}px`;
|
|
111
|
+
}
|
|
112
|
+
getLngLatBox() {
|
|
113
|
+
const {
|
|
114
|
+
lngLat: { lng: lng1, lat: lat1 }
|
|
115
|
+
} = this.startEvent;
|
|
116
|
+
const {
|
|
117
|
+
lngLat: { lng: lng2, lat: lat2 }
|
|
118
|
+
} = this.endEvent;
|
|
119
|
+
return (0, import_l7_utils.getBBoxFromPoints)([
|
|
120
|
+
[lng1, lat1],
|
|
121
|
+
[lng2, lat2]
|
|
122
|
+
]);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
126
|
+
0 && (module.exports = {
|
|
127
|
+
BoxSelectEventList
|
|
128
|
+
});
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { Bounds, ICameraOptions, IControl, IDebugService, IIconFontGlyph, IImage, ILayer, ILngLat, IMapService, IMarker, IMarkerLayer, IPoint, IPopup, IPostProcessingPass, ISceneConfig, IStatusOptions, L7Container, Point } from '@antv/l7-core';
|
|
2
|
+
import type { IProtocolHandler } from '@antv/l7-utils';
|
|
3
|
+
import type ILayerManager from './ILayerManager';
|
|
4
|
+
import type IMapController from './IMapController';
|
|
5
|
+
import type IPostProcessingPassPluggable from './IPostProcessingPassPluggable';
|
|
6
|
+
/**
|
|
7
|
+
* 暴露 Scene API
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* import { Scene } from 'l7/scene';
|
|
11
|
+
* import { PointLayer } from 'l7/layers';
|
|
12
|
+
*
|
|
13
|
+
* const scene = new Scene();
|
|
14
|
+
* const pointLayer = new PointLayer();
|
|
15
|
+
* scene.addLayer(pointLayer);
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
declare class Scene implements IPostProcessingPassPluggable, IMapController, ILayerManager {
|
|
19
|
+
private sceneService;
|
|
20
|
+
private mapService;
|
|
21
|
+
private controlService;
|
|
22
|
+
private layerService;
|
|
23
|
+
private debugService;
|
|
24
|
+
private iconService;
|
|
25
|
+
private markerService;
|
|
26
|
+
private popupService;
|
|
27
|
+
private fontService;
|
|
28
|
+
private interactionService;
|
|
29
|
+
private boxSelect;
|
|
30
|
+
private container;
|
|
31
|
+
constructor(config: ISceneConfig);
|
|
32
|
+
get map(): unknown;
|
|
33
|
+
get loaded(): boolean;
|
|
34
|
+
getServiceContainer(): L7Container;
|
|
35
|
+
getSize(): [number, number];
|
|
36
|
+
getMinZoom(): number;
|
|
37
|
+
getMaxZoom(): number;
|
|
38
|
+
getType(): string;
|
|
39
|
+
getMapContainer(): HTMLElement | null;
|
|
40
|
+
getMapCanvasContainer(): HTMLElement;
|
|
41
|
+
getMapService(): IMapService<unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* 对外暴露 debugService
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
getDebugService(): IDebugService;
|
|
47
|
+
exportPng(type?: 'png' | 'jpg'): Promise<string>;
|
|
48
|
+
exportMap(type?: 'png' | 'jpg'): Promise<string>;
|
|
49
|
+
registerRenderService(render: any): void;
|
|
50
|
+
setBgColor(color: string): void;
|
|
51
|
+
addLayer(layer: ILayer): void;
|
|
52
|
+
preAddLayer(layer: ILayer): void;
|
|
53
|
+
initMask(layer: ILayer): ILayer | undefined;
|
|
54
|
+
addMask(mask: ILayer, layerId: string): void;
|
|
55
|
+
getPickedLayer(): number;
|
|
56
|
+
getLayers(): ILayer[];
|
|
57
|
+
getLayer(id: string): ILayer | undefined;
|
|
58
|
+
getLayerByName(name: string): ILayer | undefined;
|
|
59
|
+
removeLayer(layer: ILayer, parentLayer?: ILayer): Promise<void>;
|
|
60
|
+
removeAllLayer(): Promise<void>;
|
|
61
|
+
render(): void;
|
|
62
|
+
setEnableRender(flag: boolean): void;
|
|
63
|
+
/**
|
|
64
|
+
* 为 layer/point/text 支持 iconfont 模式支持
|
|
65
|
+
* @param fontUnicode
|
|
66
|
+
* @param name
|
|
67
|
+
*/
|
|
68
|
+
addIconFont(name: string, fontUnicode: string): void;
|
|
69
|
+
addIconFonts(options: string[][]): void;
|
|
70
|
+
/**
|
|
71
|
+
* 用户自定义添加第三方字体
|
|
72
|
+
* @param fontFamily
|
|
73
|
+
* @param fontPath
|
|
74
|
+
*/
|
|
75
|
+
addFontFace(fontFamily: string, fontPath: string): void;
|
|
76
|
+
addImage(id: string, img: IImage): Promise<void>;
|
|
77
|
+
hasImage(id: string): boolean;
|
|
78
|
+
removeImage(id: string): void;
|
|
79
|
+
addIconFontGlyphs(fontFamily: string, glyphs: IIconFontGlyph[]): void;
|
|
80
|
+
addControl(ctr: IControl): void;
|
|
81
|
+
removeControl(ctr: IControl): void;
|
|
82
|
+
getControlByName(name: string): IControl<any> | undefined;
|
|
83
|
+
addMarker(marker: IMarker): void;
|
|
84
|
+
addMarkerLayer(layer: IMarkerLayer): void;
|
|
85
|
+
removeMarkerLayer(layer: IMarkerLayer): void;
|
|
86
|
+
removeAllMarkers(): void;
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated 请使用 removeAllMarkers
|
|
89
|
+
*/
|
|
90
|
+
removeAllMakers(): void;
|
|
91
|
+
addPopup(popup: IPopup): void;
|
|
92
|
+
removePopup(popup: IPopup): void;
|
|
93
|
+
on(type: string, handle: (...args: any[]) => void): void;
|
|
94
|
+
once(type: string, handle: (...args: any[]) => void): void;
|
|
95
|
+
emit(type: string, ...args: any[]): void;
|
|
96
|
+
off(type: string, handle: (...args: any[]) => void): void;
|
|
97
|
+
getZoom(): number;
|
|
98
|
+
getCenter(options?: ICameraOptions): ILngLat;
|
|
99
|
+
setCenter(center: [number, number], options?: ICameraOptions): void;
|
|
100
|
+
getPitch(): number;
|
|
101
|
+
setPitch(pitch: number): void;
|
|
102
|
+
getRotation(): number;
|
|
103
|
+
getBounds(): Bounds;
|
|
104
|
+
setRotation(rotation: number): void;
|
|
105
|
+
zoomIn(): void;
|
|
106
|
+
zoomOut(): void;
|
|
107
|
+
panTo(p: Point): void;
|
|
108
|
+
panBy(x: number, y: number): void;
|
|
109
|
+
getContainer(): HTMLElement | null;
|
|
110
|
+
setZoom(zoom: number): void;
|
|
111
|
+
fitBounds(bound: Bounds, options?: unknown): void;
|
|
112
|
+
setZoomAndCenter(zoom: number, center: Point): void;
|
|
113
|
+
setMapStyle(style: any): void;
|
|
114
|
+
setMapStatus(options: Partial<IStatusOptions>): void;
|
|
115
|
+
pixelToLngLat(pixel: Point): ILngLat;
|
|
116
|
+
lngLatToPixel(lnglat: Point): IPoint;
|
|
117
|
+
containerToLngLat(pixel: Point): ILngLat;
|
|
118
|
+
lngLatToContainer(lnglat: Point): IPoint;
|
|
119
|
+
destroy(): void;
|
|
120
|
+
/**
|
|
121
|
+
* 注册自定义后处理效果
|
|
122
|
+
* @param constructor 后处理效果构造函数
|
|
123
|
+
* @param name 后处理效果名称,便于在 Layer 中引用
|
|
124
|
+
*/
|
|
125
|
+
registerPostProcessingPass(constructor: new (...args: any[]) => IPostProcessingPass<unknown>, name: string): void;
|
|
126
|
+
enableShaderPick(): void;
|
|
127
|
+
disableShaderPick(): void;
|
|
128
|
+
/**
|
|
129
|
+
* @deprecated 请使用 disableShaderPick
|
|
130
|
+
*/
|
|
131
|
+
diasbleShaderPick(): void;
|
|
132
|
+
enableBoxSelect(once?: boolean): void;
|
|
133
|
+
disableBoxSelect(): void;
|
|
134
|
+
static addProtocol(protocol: string, handler: IProtocolHandler): void;
|
|
135
|
+
static removeProtocol(protocol: string): void;
|
|
136
|
+
getProtocol(protocol: string): IProtocolHandler;
|
|
137
|
+
startAnimate(): void;
|
|
138
|
+
stopAnimate(): void;
|
|
139
|
+
getPointSizeRange(): Float32Array;
|
|
140
|
+
private initComponent;
|
|
141
|
+
private initControl;
|
|
142
|
+
private initTileLayer;
|
|
143
|
+
}
|
|
144
|
+
export { Scene };
|