@antv/l7-scene 2.21.1 → 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.
@@ -0,0 +1,9 @@
1
+ import type { 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
+ }
@@ -0,0 +1,62 @@
1
+ import type { 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'): Promise<string>;
62
+ }
@@ -0,0 +1,9 @@
1
+ import type { 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
+ }
@@ -0,0 +1,23 @@
1
+ import { EventEmitter } from 'eventemitter3';
2
+ import type { Scene } from './index';
3
+ export declare const BoxSelectEventList: string[];
4
+ export 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/lib/index.d.ts ADDED
@@ -0,0 +1,132 @@
1
+ import type { Bounds, ICameraOptions, IControl, IDebugService, IIconFontGlyph, IImage, ILayer, ILngLat, IMapService, IMarker, IMarkerLayer, IPoint, IPopup, IPostProcessingPass, ISceneConfig, IStatusOptions, Point, L7Container } 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
+ removeAllMakers(): void;
88
+ addPopup(popup: IPopup): void;
89
+ removePopup(popup: IPopup): void;
90
+ on(type: string, handle: (...args: any[]) => void): void;
91
+ once(type: string, handle: (...args: any[]) => void): void;
92
+ emit(type: string, handle: (...args: any[]) => void): void;
93
+ off(type: string, handle: (...args: any[]) => void): void;
94
+ getZoom(): number;
95
+ getCenter(options?: ICameraOptions): ILngLat;
96
+ setCenter(center: [number, number], options?: ICameraOptions): void;
97
+ getPitch(): number;
98
+ setPitch(pitch: number): void;
99
+ getRotation(): number;
100
+ getBounds(): Bounds;
101
+ setRotation(rotation: number): void;
102
+ zoomIn(): void;
103
+ zoomOut(): void;
104
+ panTo(p: Point): void;
105
+ panBy(x: number, y: number): void;
106
+ getContainer(): HTMLElement | null;
107
+ setZoom(zoom: number): void;
108
+ fitBounds(bound: Bounds, options?: unknown): void;
109
+ setZoomAndCenter(zoom: number, center: Point): void;
110
+ setMapStyle(style: any): void;
111
+ setMapStatus(options: Partial<IStatusOptions>): void;
112
+ pixelToLngLat(pixel: Point): ILngLat;
113
+ lngLatToPixel(lnglat: Point): IPoint;
114
+ containerToLngLat(pixel: Point): ILngLat;
115
+ lngLatToContainer(lnglat: Point): IPoint;
116
+ destroy(): void;
117
+ registerPostProcessingPass(constructor: new (...args: any[]) => IPostProcessingPass<unknown>): void;
118
+ enableShaderPick(): void;
119
+ diasbleShaderPick(): void;
120
+ enableBoxSelect(once?: boolean): void;
121
+ disableBoxSelect(): void;
122
+ static addProtocol(protocol: string, handler: IProtocolHandler): void;
123
+ static removeProtocol(protocol: string): void;
124
+ getProtocol(protocol: string): IProtocolHandler;
125
+ startAnimate(): void;
126
+ stopAnimate(): void;
127
+ getPointSizeRange(): Float32Array;
128
+ private initComponent;
129
+ private initControl;
130
+ private initTileLayer;
131
+ }
132
+ export { Scene };
package/lib/index.js CHANGED
@@ -1,9 +1,26 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
8
  var __getProtoOf = Object.getPrototypeOf;
6
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7
24
  var __export = (target, all) => {
8
25
  for (var name in all)
9
26
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -25,6 +42,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
42
  mod
26
43
  ));
27
44
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
45
+ var __async = (__this, __arguments, generator) => {
46
+ return new Promise((resolve, reject) => {
47
+ var fulfilled = (value) => {
48
+ try {
49
+ step(generator.next(value));
50
+ } catch (e) {
51
+ reject(e);
52
+ }
53
+ };
54
+ var rejected = (value) => {
55
+ try {
56
+ step(generator.throw(value));
57
+ } catch (e) {
58
+ reject(e);
59
+ }
60
+ };
61
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
62
+ step((generator = generator.apply(__this, __arguments)).next());
63
+ });
64
+ };
28
65
 
29
66
  // src/index.ts
30
67
  var src_exports = {};
@@ -102,11 +139,15 @@ var Scene = class {
102
139
  getDebugService() {
103
140
  return this.debugService;
104
141
  }
105
- async exportPng(type) {
106
- return this.sceneService.exportPng(type);
142
+ exportPng(type) {
143
+ return __async(this, null, function* () {
144
+ return this.sceneService.exportPng(type);
145
+ });
107
146
  }
108
- async exportMap(type) {
109
- return this.sceneService.exportPng(type);
147
+ exportMap(type) {
148
+ return __async(this, null, function* () {
149
+ return this.sceneService.exportPng(type);
150
+ });
110
151
  }
111
152
  registerRenderService(render) {
112
153
  if (this.sceneService.loaded) {
@@ -191,11 +232,15 @@ var Scene = class {
191
232
  getLayerByName(name) {
192
233
  return this.layerService.getLayerByName(name);
193
234
  }
194
- async removeLayer(layer, parentLayer) {
195
- await this.layerService.remove(layer, parentLayer);
235
+ removeLayer(layer, parentLayer) {
236
+ return __async(this, null, function* () {
237
+ yield this.layerService.remove(layer, parentLayer);
238
+ });
196
239
  }
197
- async removeAllLayer() {
198
- await this.layerService.removeAllLayers();
240
+ removeAllLayer() {
241
+ return __async(this, null, function* () {
242
+ yield this.layerService.removeAllLayers();
243
+ });
199
244
  }
200
245
  render() {
201
246
  this.sceneService.render();
@@ -228,8 +273,10 @@ var Scene = class {
228
273
  });
229
274
  this.fontService.addFontFace(fontFamily, fontPath);
230
275
  }
231
- async addImage(id, img) {
232
- await this.iconService.addImage(id, img);
276
+ addImage(id, img) {
277
+ return __async(this, null, function* () {
278
+ yield this.iconService.addImage(id, img);
279
+ });
233
280
  }
234
281
  hasImage(id) {
235
282
  return this.iconService.hasImage(id);
@@ -354,10 +401,9 @@ var Scene = class {
354
401
  this.mapService.fitBounds(
355
402
  bound,
356
403
  // 选项优先级:用户传入,覆盖animate直接配置,覆盖Scene配置项传入
357
- options || {
358
- ...fitBoundsOptions,
404
+ options || __spreadProps(__spreadValues({}, fitBoundsOptions), {
359
405
  animate
360
- }
406
+ })
361
407
  );
362
408
  }
363
409
  setZoomAndCenter(zoom, center) {
package/package.json CHANGED
@@ -1,43 +1,40 @@
1
1
  {
2
2
  "name": "@antv/l7-scene",
3
- "version": "2.21.1",
3
+ "version": "2.21.2",
4
4
  "description": "",
5
- "license": "ISC",
6
- "author": "xiaoiver",
5
+ "license": "MIT",
6
+ "author": "https://github.com/orgs/antvis/people",
7
7
  "sideEffects": false,
8
8
  "main": "lib/index.js",
9
9
  "module": "es/index.js",
10
10
  "types": "es/index.d.ts",
11
11
  "files": [
12
12
  "lib",
13
- "es",
14
- "README.md"
13
+ "es"
15
14
  ],
16
15
  "scripts": {
17
- "build": "father build",
18
- "build:cjs": "BABEL_ENV=cjs babel src --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
19
- "build:esm": "BABEL_ENV=esm babel src --root-mode upward --out-dir es --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
20
- "clean": "rimraf dist; rimraf es; rimraf lib;",
21
- "sync": "tnpm sync",
22
- "tsc": "tsc --project tsconfig.build.json",
23
- "watch": "BABEL_ENV=cjs babel src --watch --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments"
16
+ "dev": "father dev",
17
+ "build": "npm run clean && father build",
18
+ "check-deps": "father doctor",
19
+ "lint": "eslint src __tests__",
20
+ "clean": "rimraf dist es lib",
21
+ "sync": "tnpm sync"
24
22
  },
25
23
  "dependencies": {
26
- "@antv/l7-component": "2.21.1",
27
- "@antv/l7-core": "2.21.1",
28
- "@antv/l7-layers": "2.21.1",
29
- "@antv/l7-maps": "2.21.1",
30
- "@antv/l7-renderer": "2.21.1",
31
- "@antv/l7-utils": "2.21.1",
24
+ "@antv/l7-component": "^2.21.2",
25
+ "@antv/l7-core": "^2.21.2",
26
+ "@antv/l7-layers": "^2.21.2",
27
+ "@antv/l7-maps": "^2.21.2",
28
+ "@antv/l7-renderer": "^2.21.2",
29
+ "@antv/l7-utils": "^2.21.2",
32
30
  "@babel/runtime": "^7.7.7",
33
- "eventemitter3": "^4.0.7",
34
- "mapbox-gl": "^1.2.1"
31
+ "eventemitter3": "^4.0.7"
35
32
  },
36
33
  "devDependencies": {
37
- "@antv/l7-test-utils": "2.21.1"
34
+ "@antv/l7-test-utils": "^2.21.2"
38
35
  },
39
36
  "publishConfig": {
40
37
  "access": "public"
41
38
  },
42
- "gitHead": "1e0d2e5920f479f77095a2c5eddda8a8d7ac9e0f"
39
+ "gitHead": "5c2d29d2ac1d631bdecf741cb1725316c0d6f9b9"
43
40
  }