@antv/l7-scene 2.9.37-alpha.2 → 2.9.37-alpha.3
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 +148 -0
- package/es/index.d.ts +118 -0
- package/es/index.js +586 -0
- package/lib/ILayerManager.js +17 -0
- package/lib/IMapController.js +17 -0
- package/lib/IPostProcessingPassPluggable.js +17 -0
- package/lib/boxSelect.js +119 -0
- package/lib/index.js +378 -0
- package/package.json +9 -9
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ILayer } from '@antv/l7-core';
|
|
2
|
+
export default interface ILayerManager {
|
|
3
|
+
enableShaderPick: () => void;
|
|
4
|
+
diasbleShaderPick: () => void;
|
|
5
|
+
addLayer(layer: ILayer): void;
|
|
6
|
+
getLayers(): ILayer[];
|
|
7
|
+
getLayer(id: string): ILayer | undefined;
|
|
8
|
+
removeLayer(layer: ILayer): void;
|
|
9
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Bounds, ICameraOptions, ILngLat, IPoint, IStatusOptions, Point } from '@antv/l7-core';
|
|
2
|
+
export default interface IMapController {
|
|
3
|
+
/**
|
|
4
|
+
* 当前缩放等级
|
|
5
|
+
*/
|
|
6
|
+
getZoom(): number;
|
|
7
|
+
/**
|
|
8
|
+
* 中心点经纬度
|
|
9
|
+
*/
|
|
10
|
+
getCenter(options?: ICameraOptions): ILngLat;
|
|
11
|
+
/**
|
|
12
|
+
* 仰角
|
|
13
|
+
*/
|
|
14
|
+
getPitch(): number;
|
|
15
|
+
/**
|
|
16
|
+
* 逆时针旋转角度
|
|
17
|
+
*/
|
|
18
|
+
getRotation(): number;
|
|
19
|
+
/**
|
|
20
|
+
* 获取当前地图可视区域 `[西南角、东北角]`
|
|
21
|
+
*/
|
|
22
|
+
getBounds(): Bounds;
|
|
23
|
+
/**
|
|
24
|
+
* 放大地图
|
|
25
|
+
*/
|
|
26
|
+
zoomIn(): void;
|
|
27
|
+
/**
|
|
28
|
+
* 缩小地图
|
|
29
|
+
*/
|
|
30
|
+
zoomOut(): void;
|
|
31
|
+
/**
|
|
32
|
+
* 地图平移到指定点 `[x, y]`
|
|
33
|
+
*/
|
|
34
|
+
panTo(p: Point): void;
|
|
35
|
+
/**
|
|
36
|
+
* 地图平移到指定点 `[x, y]`
|
|
37
|
+
*/
|
|
38
|
+
panBy(x: number, y: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* 调整地图适合指定区域
|
|
41
|
+
*/
|
|
42
|
+
fitBounds(bound: Bounds, fitBoundsOptions?: unknown): void;
|
|
43
|
+
getContainer(): HTMLElement | null;
|
|
44
|
+
getSize(): [number, number];
|
|
45
|
+
getMinZoom(): number;
|
|
46
|
+
getMaxZoom(): number;
|
|
47
|
+
getType(): string;
|
|
48
|
+
getMapContainer(): HTMLElement | null;
|
|
49
|
+
getMapCanvasContainer(): HTMLElement;
|
|
50
|
+
setRotation(rotation: number): void;
|
|
51
|
+
setZoomAndCenter(zoom: number, center: Point): void;
|
|
52
|
+
setCenter(center: [number, number], options?: ICameraOptions): void;
|
|
53
|
+
setPitch(pitch: number): void;
|
|
54
|
+
setZoom(zoom: number): void;
|
|
55
|
+
setMapStyle(style: any): void;
|
|
56
|
+
setMapStatus(option: Partial<IStatusOptions>): void;
|
|
57
|
+
pixelToLngLat(pixel: Point): ILngLat;
|
|
58
|
+
lngLatToPixel(lnglat: Point): IPoint;
|
|
59
|
+
containerToLngLat(pixel: Point): ILngLat;
|
|
60
|
+
lngLatToContainer(lnglat: Point): IPoint;
|
|
61
|
+
exportMap(type: 'jpg' | 'png'): string;
|
|
62
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IPostProcessingPass } from '@antv/l7-core';
|
|
2
|
+
export default interface IPostProcessingPassPluggable {
|
|
3
|
+
/**
|
|
4
|
+
* 注册自定义后处理效果
|
|
5
|
+
* @param constructor 效果构造函数
|
|
6
|
+
* @param name 效果名,便于在 Layer 中引用
|
|
7
|
+
*/
|
|
8
|
+
registerPostProcessingPass(constructor: new (...args: any[]) => IPostProcessingPass<unknown>, name: string): void;
|
|
9
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EventEmitter } from 'eventemitter3';
|
|
2
|
+
import { Scene } from './index';
|
|
3
|
+
export declare const BoxSelectEventList: string[];
|
|
4
|
+
export declare type BoxSelectOptions = {
|
|
5
|
+
className?: string;
|
|
6
|
+
};
|
|
7
|
+
export default class BoxSelect extends EventEmitter {
|
|
8
|
+
protected scene: Scene;
|
|
9
|
+
protected options: BoxSelectOptions;
|
|
10
|
+
protected isEnable: boolean;
|
|
11
|
+
protected box: HTMLElement;
|
|
12
|
+
protected startEvent: any;
|
|
13
|
+
protected endEvent: any;
|
|
14
|
+
constructor(scene: Scene, options?: BoxSelectOptions);
|
|
15
|
+
get container(): HTMLElement;
|
|
16
|
+
enable(): void;
|
|
17
|
+
disable(): void;
|
|
18
|
+
protected onDragStart: (e: any) => void;
|
|
19
|
+
protected onDragging: (e: any) => void;
|
|
20
|
+
protected onDragEnd: (e: any) => void;
|
|
21
|
+
protected syncBoxBound(): void;
|
|
22
|
+
protected getLngLatBox(): import("@turf/helpers").BBox;
|
|
23
|
+
}
|
package/es/boxSelect.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
|
|
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
|
+
|
|
11
|
+
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; } }
|
|
12
|
+
|
|
13
|
+
import { DOM, getBBoxFromPoints } from '@antv/l7-utils';
|
|
14
|
+
import { EventEmitter } from 'eventemitter3';
|
|
15
|
+
export var BoxSelectEventList = ['selectstart', 'selecting', 'selectend'];
|
|
16
|
+
|
|
17
|
+
// TODO: 将 BoxSelect 模块放在哪里比较合适
|
|
18
|
+
var BoxSelect = /*#__PURE__*/function (_EventEmitter) {
|
|
19
|
+
_inherits(BoxSelect, _EventEmitter);
|
|
20
|
+
|
|
21
|
+
var _super = _createSuper(BoxSelect);
|
|
22
|
+
|
|
23
|
+
function BoxSelect(scene) {
|
|
24
|
+
var _this;
|
|
25
|
+
|
|
26
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
27
|
+
|
|
28
|
+
_classCallCheck(this, BoxSelect);
|
|
29
|
+
|
|
30
|
+
_this = _super.call(this);
|
|
31
|
+
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "isEnable", false);
|
|
33
|
+
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "onDragStart", function (e) {
|
|
35
|
+
_this.box.style.display = 'block';
|
|
36
|
+
_this.startEvent = _this.endEvent = e;
|
|
37
|
+
|
|
38
|
+
_this.syncBoxBound();
|
|
39
|
+
|
|
40
|
+
_this.emit('selectstart', _this.getLngLatBox(), _this.startEvent, _this.endEvent);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
_defineProperty(_assertThisInitialized(_this), "onDragging", function (e) {
|
|
44
|
+
_this.endEvent = e;
|
|
45
|
+
|
|
46
|
+
_this.syncBoxBound();
|
|
47
|
+
|
|
48
|
+
_this.emit('selecting', _this.getLngLatBox(), _this.startEvent, _this.endEvent);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
_defineProperty(_assertThisInitialized(_this), "onDragEnd", function (e) {
|
|
52
|
+
_this.endEvent = e;
|
|
53
|
+
_this.box.style.display = 'none';
|
|
54
|
+
|
|
55
|
+
_this.emit('selectend', _this.getLngLatBox(), _this.startEvent, _this.endEvent);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
_this.scene = scene;
|
|
59
|
+
_this.options = options;
|
|
60
|
+
return _this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
_createClass(BoxSelect, [{
|
|
64
|
+
key: "container",
|
|
65
|
+
get: function get() {
|
|
66
|
+
return this.scene.getMapService().getMarkerContainer();
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "enable",
|
|
70
|
+
value: function enable() {
|
|
71
|
+
if (this.isEnable) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
var className = this.options.className;
|
|
76
|
+
this.scene.setMapStatus({
|
|
77
|
+
dragEnable: false
|
|
78
|
+
});
|
|
79
|
+
this.container.style.cursor = 'crosshair';
|
|
80
|
+
|
|
81
|
+
if (!this.box) {
|
|
82
|
+
var box = DOM.create('div', undefined, this.container);
|
|
83
|
+
box.classList.add('l7-select-box');
|
|
84
|
+
|
|
85
|
+
if (className) {
|
|
86
|
+
box.classList.add(className);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
box.style.display = 'none';
|
|
90
|
+
this.box = box;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
this.scene.on('dragstart', this.onDragStart);
|
|
94
|
+
this.scene.on('dragging', this.onDragging);
|
|
95
|
+
this.scene.on('dragend', this.onDragEnd);
|
|
96
|
+
this.isEnable = true;
|
|
97
|
+
}
|
|
98
|
+
}, {
|
|
99
|
+
key: "disable",
|
|
100
|
+
value: function disable() {
|
|
101
|
+
if (!this.isEnable) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
this.scene.setMapStatus({
|
|
106
|
+
dragEnable: true
|
|
107
|
+
});
|
|
108
|
+
this.container.style.cursor = 'auto';
|
|
109
|
+
this.scene.off('dragstart', this.onDragStart);
|
|
110
|
+
this.scene.off('dragging', this.onDragging);
|
|
111
|
+
this.scene.off('dragend', this.onDragEnd);
|
|
112
|
+
this.isEnable = false;
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "syncBoxBound",
|
|
116
|
+
value: function syncBoxBound() {
|
|
117
|
+
var _this$startEvent = this.startEvent,
|
|
118
|
+
x1 = _this$startEvent.x,
|
|
119
|
+
y1 = _this$startEvent.y;
|
|
120
|
+
var _this$endEvent = this.endEvent,
|
|
121
|
+
x2 = _this$endEvent.x,
|
|
122
|
+
y2 = _this$endEvent.y;
|
|
123
|
+
var left = Math.min(x1, x2);
|
|
124
|
+
var top = Math.min(y1, y2);
|
|
125
|
+
var width = Math.abs(x1 - x2);
|
|
126
|
+
var height = Math.abs(y1 - y2);
|
|
127
|
+
this.box.style.top = "".concat(top, "px");
|
|
128
|
+
this.box.style.left = "".concat(left, "px");
|
|
129
|
+
this.box.style.width = "".concat(width, "px");
|
|
130
|
+
this.box.style.height = "".concat(height, "px");
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "getLngLatBox",
|
|
134
|
+
value: function getLngLatBox() {
|
|
135
|
+
var _this$startEvent$lngL = this.startEvent.lngLat,
|
|
136
|
+
lng1 = _this$startEvent$lngL.lng,
|
|
137
|
+
lat1 = _this$startEvent$lngL.lat;
|
|
138
|
+
var _this$endEvent$lngLat = this.endEvent.lngLat,
|
|
139
|
+
lng2 = _this$endEvent$lngLat.lng,
|
|
140
|
+
lat2 = _this$endEvent$lngLat.lat;
|
|
141
|
+
return getBBoxFromPoints([[lng1, lat1], [lng2, lat2]]);
|
|
142
|
+
}
|
|
143
|
+
}]);
|
|
144
|
+
|
|
145
|
+
return BoxSelect;
|
|
146
|
+
}(EventEmitter);
|
|
147
|
+
|
|
148
|
+
export { BoxSelect as default };
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Bounds, ICameraOptions, IControl, IIconFontGlyph, IImage, ILayer, ILngLat, IMapService, IMarker, IMarkerLayer, IPoint, IPopup, IPostProcessingPass, ISceneConfig, IStatusOptions, Point } from '@antv/l7-core';
|
|
2
|
+
import { Container } from 'inversify';
|
|
3
|
+
import ILayerManager from './ILayerManager';
|
|
4
|
+
import IMapController from './IMapController';
|
|
5
|
+
import 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 iconService;
|
|
24
|
+
private markerService;
|
|
25
|
+
private popupService;
|
|
26
|
+
private fontService;
|
|
27
|
+
private interactionService;
|
|
28
|
+
private boxSelect;
|
|
29
|
+
private container;
|
|
30
|
+
constructor(config: ISceneConfig);
|
|
31
|
+
get map(): unknown;
|
|
32
|
+
get loaded(): boolean;
|
|
33
|
+
getServiceContainer(): Container;
|
|
34
|
+
getSize(): [number, number];
|
|
35
|
+
getMinZoom(): number;
|
|
36
|
+
getMaxZoom(): number;
|
|
37
|
+
getType(): string;
|
|
38
|
+
getMapContainer(): HTMLElement | null;
|
|
39
|
+
getMapCanvasContainer(): HTMLElement;
|
|
40
|
+
getMapService(): IMapService<unknown>;
|
|
41
|
+
exportPng(type?: 'png' | 'jpg'): string;
|
|
42
|
+
exportMap(type?: 'png' | 'jpg'): string;
|
|
43
|
+
registerRenderService(render: any): void;
|
|
44
|
+
setBgColor(color: string): void;
|
|
45
|
+
addLayer(layer: ILayer): void;
|
|
46
|
+
initMask(layer: ILayer): ILayer | undefined;
|
|
47
|
+
addMask(mask: ILayer, layerId: string): void;
|
|
48
|
+
getPickedLayer(): number;
|
|
49
|
+
getLayers(): ILayer[];
|
|
50
|
+
getLayer(id: string): ILayer | undefined;
|
|
51
|
+
getLayerByName(name: string): ILayer | undefined;
|
|
52
|
+
removeLayer(layer: ILayer, parentLayer?: ILayer): void;
|
|
53
|
+
removeAllLayer(): void;
|
|
54
|
+
render(): void;
|
|
55
|
+
setEnableRender(flag: boolean): void;
|
|
56
|
+
/**
|
|
57
|
+
* 为 layer/point/text 支持 iconfont 模式支持
|
|
58
|
+
* @param fontUnicode
|
|
59
|
+
* @param name
|
|
60
|
+
*/
|
|
61
|
+
addIconFont(name: string, fontUnicode: string): void;
|
|
62
|
+
addIconFonts(options: string[][]): void;
|
|
63
|
+
/**
|
|
64
|
+
* 用户自定义添加第三方字体
|
|
65
|
+
* @param fontFamily
|
|
66
|
+
* @param fontPath
|
|
67
|
+
*/
|
|
68
|
+
addFontFace(fontFamily: string, fontPath: string): void;
|
|
69
|
+
addImage(id: string, img: IImage): void;
|
|
70
|
+
hasImage(id: string): boolean;
|
|
71
|
+
removeImage(id: string): void;
|
|
72
|
+
addIconFontGlyphs(fontFamily: string, glyphs: IIconFontGlyph[]): void;
|
|
73
|
+
addControl(ctr: IControl): void;
|
|
74
|
+
removeControl(ctr: IControl): void;
|
|
75
|
+
getControlByName(name: string): IControl<any> | undefined;
|
|
76
|
+
addMarker(marker: IMarker): void;
|
|
77
|
+
addMarkerLayer(layer: IMarkerLayer): void;
|
|
78
|
+
removeMarkerLayer(layer: IMarkerLayer): void;
|
|
79
|
+
removeAllMakers(): void;
|
|
80
|
+
addPopup(popup: IPopup): void;
|
|
81
|
+
removePopup(popup: IPopup): void;
|
|
82
|
+
on(type: string, handle: (...args: any[]) => void): void;
|
|
83
|
+
once(type: string, handle: (...args: any[]) => void): void;
|
|
84
|
+
emit(type: string, handle: (...args: any[]) => void): void;
|
|
85
|
+
off(type: string, handle: (...args: any[]) => void): void;
|
|
86
|
+
getZoom(): number;
|
|
87
|
+
getCenter(options?: ICameraOptions): ILngLat;
|
|
88
|
+
setCenter(center: [number, number], options?: ICameraOptions): void;
|
|
89
|
+
getPitch(): number;
|
|
90
|
+
setPitch(pitch: number): void;
|
|
91
|
+
getRotation(): number;
|
|
92
|
+
getBounds(): Bounds;
|
|
93
|
+
setRotation(rotation: number): void;
|
|
94
|
+
zoomIn(): void;
|
|
95
|
+
zoomOut(): void;
|
|
96
|
+
panTo(p: Point): void;
|
|
97
|
+
panBy(x: number, y: number): void;
|
|
98
|
+
getContainer(): HTMLElement | null;
|
|
99
|
+
setZoom(zoom: number): void;
|
|
100
|
+
fitBounds(bound: Bounds, options?: unknown): void;
|
|
101
|
+
setZoomAndCenter(zoom: number, center: Point): void;
|
|
102
|
+
setMapStyle(style: any): void;
|
|
103
|
+
setMapStatus(options: Partial<IStatusOptions>): void;
|
|
104
|
+
pixelToLngLat(pixel: Point): ILngLat;
|
|
105
|
+
lngLatToPixel(lnglat: Point): IPoint;
|
|
106
|
+
containerToLngLat(pixel: Point): ILngLat;
|
|
107
|
+
lngLatToContainer(lnglat: Point): IPoint;
|
|
108
|
+
destroy(): void;
|
|
109
|
+
registerPostProcessingPass(constructor: new (...args: any[]) => IPostProcessingPass<unknown>, name: string): void;
|
|
110
|
+
enableShaderPick(): void;
|
|
111
|
+
diasbleShaderPick(): void;
|
|
112
|
+
enableBoxSelect(once?: boolean): void;
|
|
113
|
+
disableBoxSelect(): void;
|
|
114
|
+
getPointSizeRange(): Float32Array;
|
|
115
|
+
private initComponent;
|
|
116
|
+
private initControl;
|
|
117
|
+
}
|
|
118
|
+
export { Scene };
|