@antv/l7-layers 2.9.26-alpha.1 → 2.9.27-alpha.0

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.
Files changed (47) hide show
  1. package/es/core/BaseLayer.d.ts +4 -0
  2. package/es/image/models/image.js +1 -1
  3. package/es/index.d.ts +2 -1
  4. package/es/index.js +3 -2
  5. package/es/line/index.d.ts +17 -0
  6. package/es/line/index.js +18 -0
  7. package/es/mask/index.d.ts +8 -0
  8. package/es/plugins/DataSourcePlugin.js +4 -10
  9. package/es/plugins/FeatureScalePlugin.d.ts +1 -0
  10. package/es/plugins/FeatureScalePlugin.js +80 -24
  11. package/es/point/index.d.ts +11 -1
  12. package/es/point/index.js +13 -3
  13. package/es/point/models/index.d.ts +1 -1
  14. package/es/point/models/index.js +2 -0
  15. package/es/point/models/tileText.d.ts +56 -0
  16. package/es/point/models/tileText.js +598 -0
  17. package/es/polygon/index.d.ts +8 -0
  18. package/es/tile/manager/tileLayerManager.d.ts +1 -0
  19. package/es/tile/manager/tileLayerManager.js +12 -1
  20. package/es/tile/models/tileModel.d.ts +1 -1
  21. package/es/tile/models/tileModel.js +8 -8
  22. package/es/tile/tileFactory/base.d.ts +1 -1
  23. package/es/tile/tileFactory/index.d.ts +1 -1
  24. package/es/tile/tileFactory/index.js +4 -0
  25. package/es/tile/tileFactory/test.d.ts +12 -0
  26. package/es/tile/tileFactory/test.js +82 -0
  27. package/es/tile/tileFactory/vectorLayer.d.ts +1 -1
  28. package/es/tile/tileFactory/vectorLayer.js +1 -1
  29. package/es/tile/tileTest.d.ts +14 -0
  30. package/es/tile/tileTest.js +63 -0
  31. package/es/tile/utils.js +1 -1
  32. package/lib/image/models/image.js +1 -1
  33. package/lib/index.js +10 -1
  34. package/lib/line/index.js +17 -0
  35. package/lib/plugins/DataSourcePlugin.js +4 -16
  36. package/lib/plugins/FeatureScalePlugin.js +80 -24
  37. package/lib/point/index.js +12 -3
  38. package/lib/point/models/index.js +3 -0
  39. package/lib/point/models/tileText.js +613 -0
  40. package/lib/tile/manager/tileLayerManager.js +12 -1
  41. package/lib/tile/models/tileModel.js +8 -8
  42. package/lib/tile/tileFactory/index.js +5 -0
  43. package/lib/tile/tileFactory/test.js +95 -0
  44. package/lib/tile/tileFactory/vectorLayer.js +2 -2
  45. package/lib/tile/tileTest.js +75 -0
  46. package/lib/tile/utils.js +1 -1
  47. package/package.json +6 -7
@@ -20,6 +20,10 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
20
20
  clusterZoom: number;
21
21
  layerType?: string | undefined;
22
22
  triangulation?: Triangulation | undefined;
23
+ defaultSourceConfig: {
24
+ data: any[];
25
+ options: ISourceCFG | undefined;
26
+ };
23
27
  dataState: IDataState;
24
28
  hooks: {
25
29
  init: SyncBailHook;
@@ -101,7 +101,7 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
101
101
  primitive: gl.TRIANGLES,
102
102
  blend: {
103
103
  // Tip: 优化显示效果
104
- enable: false
104
+ enable: true
105
105
  },
106
106
  depth: {
107
107
  enable: false
package/es/index.d.ts CHANGED
@@ -12,5 +12,6 @@ import RasterLayer from './raster';
12
12
  import EarthLayer from './earth';
13
13
  import MaskLayer from './mask';
14
14
  import WindLayer from './wind';
15
- export { BaseLayer, BaseModel, PointLayer, PolygonLayer, LineLayer, CityBuildingLayer, GeometryLayer, CanvasLayer, ImageLayer, RasterLayer, HeatmapLayer, EarthLayer, WindLayer, MaskLayer, };
15
+ import TileDebugLayer from './tile/tileTest';
16
+ export { BaseLayer, BaseModel, PointLayer, PolygonLayer, LineLayer, CityBuildingLayer, GeometryLayer, CanvasLayer, ImageLayer, RasterLayer, HeatmapLayer, EarthLayer, WindLayer, MaskLayer, TileDebugLayer };
16
17
  export * from './core/interface';
package/es/index.js CHANGED
@@ -13,7 +13,8 @@ import PolygonLayer from "./polygon";
13
13
  import RasterLayer from "./raster";
14
14
  import EarthLayer from "./earth";
15
15
  import MaskLayer from "./mask";
16
- import WindLayer from "./wind"; // import ConfigSchemaValidationPlugin from './plugins/ConfigSchemaValidationPlugin';
16
+ import WindLayer from "./wind";
17
+ import TileDebugLayer from "./tile/tileTest"; // import ConfigSchemaValidationPlugin from './plugins/ConfigSchemaValidationPlugin';
17
18
 
18
19
  import DataMappingPlugin from "./plugins/DataMappingPlugin";
19
20
  import DataSourcePlugin from "./plugins/DataSourcePlugin";
@@ -102,5 +103,5 @@ container.bind(TYPES.ILayerPlugin).to(PixelPickingPlugin).inRequestScope();
102
103
  */
103
104
 
104
105
  container.bind(TYPES.ILayerPlugin).to(LayerModelPlugin).inRequestScope();
105
- export { BaseLayer, BaseModel, PointLayer, PolygonLayer, LineLayer, CityBuildingLayer, GeometryLayer, CanvasLayer, ImageLayer, RasterLayer, HeatmapLayer, EarthLayer, WindLayer, MaskLayer };
106
+ export { BaseLayer, BaseModel, PointLayer, PolygonLayer, LineLayer, CityBuildingLayer, GeometryLayer, CanvasLayer, ImageLayer, RasterLayer, HeatmapLayer, EarthLayer, WindLayer, MaskLayer, TileDebugLayer };
106
107
  export * from "./core/interface";
@@ -3,6 +3,23 @@ import { ILineLayerStyleOptions } from '../core/interface';
3
3
  import { LineModelType } from './models';
4
4
  export default class LineLayer extends BaseLayer<ILineLayerStyleOptions> {
5
5
  type: string;
6
+ defaultSourceConfig: {
7
+ data: {
8
+ lng1: number;
9
+ lat1: number;
10
+ lng2: number;
11
+ lat2: number;
12
+ }[];
13
+ options: {
14
+ parser: {
15
+ type: string;
16
+ x: string;
17
+ y: string;
18
+ x1: string;
19
+ y1: string;
20
+ };
21
+ };
22
+ };
6
23
  buildModels(): void;
7
24
  rebuildModels(): void;
8
25
  protected getConfigSchema(): {
package/es/line/index.js CHANGED
@@ -32,6 +32,24 @@ var LineLayer = /*#__PURE__*/function (_BaseLayer) {
32
32
 
33
33
  _defineProperty(_assertThisInitialized(_this), "type", 'LineLayer');
34
34
 
35
+ _defineProperty(_assertThisInitialized(_this), "defaultSourceConfig", {
36
+ data: [{
37
+ lng1: 100,
38
+ lat1: 30.0,
39
+ lng2: 130,
40
+ lat2: 30
41
+ }],
42
+ options: {
43
+ parser: {
44
+ type: 'json',
45
+ x: 'lng1',
46
+ y: 'lat1',
47
+ x1: 'lng2',
48
+ y1: 'lat2'
49
+ }
50
+ }
51
+ });
52
+
35
53
  return _this;
36
54
  }
37
55
 
@@ -3,6 +3,14 @@ import { IMaskLayerStyleOptions } from '../core/interface';
3
3
  import { MaskModelType } from './models';
4
4
  export default class MaskLayer extends BaseLayer<IMaskLayerStyleOptions> {
5
5
  type: string;
6
+ defaultSourceConfig: {
7
+ data: [];
8
+ options: {
9
+ parser: {
10
+ type: 'geojson';
11
+ };
12
+ };
13
+ };
6
14
  buildModels(): void;
7
15
  rebuildModels(): void;
8
16
  protected getConfigSchema(): {
@@ -4,7 +4,7 @@ import _createClass from "@babel/runtime/helpers/createClass";
4
4
  var _dec, _class;
5
5
 
6
6
  import { TYPES } from '@antv/l7-core';
7
- import Source, { DEFAULT_DATA, DEFAULT_PARSER, DEFAULT_SOURCE } from '@antv/l7-source';
7
+ import Source from '@antv/l7-source';
8
8
  import { injectable } from 'inversify';
9
9
  import 'reflect-metadata';
10
10
  var DataSourcePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function () {
@@ -22,13 +22,8 @@ var DataSourcePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function
22
22
  var source = layer.getSource();
23
23
 
24
24
  if (!source) {
25
- // TODO: 允许用户不使用 layer 的 source 方法,在这里传入一个默认的替换的默认数据
26
- var defaultSourceConfig = DEFAULT_SOURCE[layer.type] || {
27
- data: DEFAULT_DATA,
28
- options: DEFAULT_PARSER
29
- };
30
-
31
- var _ref = layer.sourceOption || defaultSourceConfig,
25
+ // Tip: 用户没有传入 source 的时候使用图层的默认数据
26
+ var _ref = layer.sourceOption || layer.defaultSourceConfig,
32
27
  data = _ref.data,
33
28
  options = _ref.options;
34
29
 
@@ -40,8 +35,7 @@ var DataSourcePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function
40
35
  _this.updateClusterData(layer);
41
36
  } else {
42
37
  source.once('sourceUpdate', function () {
43
- _this.updateClusterData(layer); // TODO: layer.hooks.init.call();
44
-
38
+ _this.updateClusterData(layer);
45
39
  });
46
40
  } // this.updateClusterData(layer);
47
41
 
@@ -7,6 +7,7 @@ export default class FeatureScalePlugin implements ILayerPlugin {
7
7
  private readonly configService;
8
8
  private scaleCache;
9
9
  private scaleOptions;
10
+ private getSourceData;
10
11
  apply(layer: ILayer, { styleAttributeService, }: {
11
12
  styleAttributeService: IStyleAttributeService;
12
13
  }): void;
@@ -33,6 +33,19 @@ var FeatureScalePlugin = (_dec = injectable(), _dec2 = inject(TYPES.IGlobalConfi
33
33
  }
34
34
 
35
35
  _createClass(FeatureScalePlugin, [{
36
+ key: "getSourceData",
37
+ value: function getSourceData(layer, callback) {
38
+ var source = layer.getSource();
39
+
40
+ if (source.inited) {
41
+ callback(source.data);
42
+ } else {
43
+ source.once('sourceUpdate', function () {
44
+ callback(source.data);
45
+ });
46
+ }
47
+ }
48
+ }, {
36
49
  key: "apply",
37
50
  value: function apply(layer, _ref) {
38
51
  var _this = this;
@@ -41,23 +54,51 @@ var FeatureScalePlugin = (_dec = injectable(), _dec2 = inject(TYPES.IGlobalConfi
41
54
  layer.hooks.init.tap('FeatureScalePlugin', function () {
42
55
  _this.scaleOptions = layer.getScaleOptions();
43
56
  var attributes = styleAttributeService.getLayerStyleAttributes();
44
- var dataArray = layer.getSource().data.dataArray;
45
57
 
46
- if (dataArray.length === 0) {
47
- return;
48
- }
58
+ _this.getSourceData(layer, function (_ref2) {
59
+ var dataArray = _ref2.dataArray;
60
+
61
+ if (Array.isArray(dataArray) && dataArray.length === 0) {
62
+ return;
63
+ } else {
64
+ _this.caculateScalesForAttributes(attributes || [], dataArray);
65
+ }
66
+ }); // const { dataArray } = layer.getSource().data;
67
+ // if (dataArray.length === 0) {
68
+ // return;
69
+ // }
70
+ // this.caculateScalesForAttributes(
71
+ // attributes || [],
72
+ // dataArray as IParseDataItem[],
73
+ // );
49
74
 
50
- _this.caculateScalesForAttributes(attributes || [], dataArray);
51
75
  }); // 检测数据是否需要更新
52
76
 
53
77
  layer.hooks.beforeRenderData.tap('FeatureScalePlugin', function () {
54
78
  _this.scaleOptions = layer.getScaleOptions();
55
79
  var attributes = styleAttributeService.getLayerStyleAttributes();
56
- var dataArray = layer.getSource().data.dataArray;
57
80
 
58
- _this.caculateScalesForAttributes(attributes || [], dataArray);
81
+ _this.getSourceData(layer, function (_ref3) {
82
+ var dataArray = _ref3.dataArray;
83
+
84
+ if (Array.isArray(dataArray) && dataArray.length === 0) {
85
+ return;
86
+ }
87
+
88
+ _this.caculateScalesForAttributes(attributes || [], dataArray);
89
+
90
+ layer.layerModelNeedUpdate = true;
91
+ }); // const { dataArray } = layer.getSource().data;
92
+ // if (dataArray.length === 0) {
93
+ // return;
94
+ // }
95
+ // this.caculateScalesForAttributes(
96
+ // attributes || [],
97
+ // dataArray
98
+ // );
99
+ // layer.layerModelNeedUpdate = true;
100
+
59
101
 
60
- layer.layerModelNeedUpdate = true;
61
102
  return true;
62
103
  });
63
104
  layer.hooks.beforeRender.tap('FeatureScalePlugin', function () {
@@ -69,19 +110,34 @@ var FeatureScalePlugin = (_dec = injectable(), _dec2 = inject(TYPES.IGlobalConfi
69
110
  var attributes = styleAttributeService.getLayerStyleAttributes();
70
111
 
71
112
  if (attributes) {
72
- var dataArray = layer.getSource().data.dataArray;
113
+ _this.getSourceData(layer, function (_ref4) {
114
+ var dataArray = _ref4.dataArray;
73
115
 
74
- if (dataArray.length === 0) {
75
- return;
76
- }
116
+ if (dataArray.length === 0) {
117
+ return;
118
+ }
77
119
 
78
- var attributesToRescale = attributes.filter(function (attribute) {
79
- return attribute.needRescale;
80
- });
120
+ var attributesToRescale = attributes.filter(function (attribute) {
121
+ return attribute.needRescale;
122
+ });
123
+
124
+ if (attributesToRescale.length) {
125
+ _this.caculateScalesForAttributes(attributesToRescale, dataArray);
126
+ }
127
+ }); // const { dataArray } = layer.getSource().data;
128
+ // if (dataArray.length === 0) {
129
+ // return;
130
+ // }
131
+ // const attributesToRescale = attributes.filter(
132
+ // (attribute) => attribute.needRescale,
133
+ // );
134
+ // if (attributesToRescale.length) {
135
+ // this.caculateScalesForAttributes(
136
+ // attributesToRescale,
137
+ // dataArray,
138
+ // );
139
+ // }
81
140
 
82
- if (attributesToRescale.length) {
83
- _this.caculateScalesForAttributes(attributesToRescale, dataArray);
84
- }
85
141
  }
86
142
  });
87
143
  }
@@ -284,12 +340,12 @@ var FeatureScalePlugin = (_dec = injectable(), _dec2 = inject(TYPES.IGlobalConfi
284
340
 
285
341
  }, {
286
342
  key: "createDefaultScale",
287
- value: function createDefaultScale(_ref2) {
288
- var type = _ref2.type,
289
- domain = _ref2.domain,
290
- unknown = _ref2.unknown,
291
- clamp = _ref2.clamp,
292
- nice = _ref2.nice;
343
+ value: function createDefaultScale(_ref5) {
344
+ var type = _ref5.type,
345
+ domain = _ref5.domain,
346
+ unknown = _ref5.unknown,
347
+ clamp = _ref5.clamp,
348
+ nice = _ref5.nice;
293
349
  // @ts-ignore
294
350
  var scale = scaleMap[type]();
295
351
 
@@ -3,6 +3,16 @@ import { IPointLayerStyleOptions } from '../core/interface';
3
3
  import { PointType } from './models/index';
4
4
  export default class PointLayer extends BaseLayer<IPointLayerStyleOptions> {
5
5
  type: string;
6
+ defaultSourceConfig: {
7
+ data: never[];
8
+ options: {
9
+ parser: {
10
+ type: string;
11
+ x: string;
12
+ y: string;
13
+ };
14
+ };
15
+ };
6
16
  buildModels(): void;
7
17
  rebuildModels(): void;
8
18
  /**
@@ -25,6 +35,6 @@ export default class PointLayer extends BaseLayer<IPointLayerStyleOptions> {
25
35
  blend: string;
26
36
  } | {} | {} | {
27
37
  blend: string;
28
- } | {} | {} | {} | {};
38
+ } | {} | {} | {} | {} | {};
29
39
  protected getModelType(): PointType;
30
40
  }
package/es/point/index.js CHANGED
@@ -38,6 +38,17 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
38
38
 
39
39
  _defineProperty(_assertThisInitialized(_this), "type", 'PointLayer');
40
40
 
41
+ _defineProperty(_assertThisInitialized(_this), "defaultSourceConfig", {
42
+ data: [],
43
+ options: {
44
+ parser: {
45
+ type: 'json',
46
+ x: 'lng',
47
+ y: 'lat'
48
+ }
49
+ }
50
+ });
51
+
41
52
  return _this;
42
53
  }
43
54
 
@@ -79,8 +90,7 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
79
90
  values = _this$shapeOption.values;
80
91
 
81
92
  var _this$getLayerConfig = this.getLayerConfig(),
82
- shape2d = _this$getLayerConfig.shape2d,
83
- shape3d = _this$getLayerConfig.shape3d;
93
+ shape2d = _this$getLayerConfig.shape2d;
84
94
 
85
95
  var iconMap = this.iconService.getIconMap();
86
96
 
@@ -144,6 +154,7 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
144
154
  },
145
155
  vectorpoint: {},
146
156
  tile: {},
157
+ tileText: {},
147
158
  earthFill: {},
148
159
  earthExtrude: {}
149
160
  };
@@ -152,7 +163,6 @@ var PointLayer = /*#__PURE__*/function (_BaseLayer) {
152
163
  }, {
153
164
  key: "getModelType",
154
165
  value: function getModelType() {
155
- var PointTypes = ['fillImage', 'fill', 'radar', 'image', 'normal', 'simplePoint', 'extrude', 'text', 'vectorpoint', 'tile', 'earthFill', 'earthExtrude'];
156
166
  var parserType = this.layerSource.getParserType();
157
167
 
158
168
  if (isVectorTile(parserType)) {
@@ -1,4 +1,4 @@
1
- export declare type PointType = 'fillImage' | 'fill' | 'radar' | 'image' | 'normal' | 'simplePoint' | 'extrude' | 'text' | 'vectorpoint' | 'tile' | 'earthFill' | 'earthExtrude';
1
+ export declare type PointType = 'fillImage' | 'fill' | 'radar' | 'image' | 'normal' | 'simplePoint' | 'extrude' | 'text' | 'vectorpoint' | 'tile' | 'tileText' | 'earthFill' | 'earthExtrude';
2
2
  declare const PointModels: {
3
3
  [key in PointType]: any;
4
4
  };
@@ -10,6 +10,7 @@ import NormalModel from "./normal";
10
10
  import Radar from "./radar";
11
11
  import SimplePopint from "./simplePoint";
12
12
  import TextModel from "./text";
13
+ import TileTextModel from "./tileText";
13
14
  import TileFillModel from "./tile";
14
15
  var PointModels = {
15
16
  fillImage: FillImageModel,
@@ -22,6 +23,7 @@ var PointModels = {
22
23
  text: TextModel,
23
24
  vectorpoint: PointTileModel,
24
25
  tile: TileFillModel,
26
+ tileText: TileTextModel,
25
27
  earthFill: EarthFillModel,
26
28
  earthExtrude: EarthExtrudeModel
27
29
  };
@@ -0,0 +1,56 @@
1
+ import { IEncodeFeature, IModel, IModelUniform } from '@antv/l7-core';
2
+ import BaseModel from '../../core/BaseModel';
3
+ import { IGlyphQuad } from '../../utils/symbol-layout';
4
+ export declare function TextTriangulation(feature: IEncodeFeature): {
5
+ vertices: number[];
6
+ indices: number[];
7
+ size: number;
8
+ };
9
+ export default class TextModel extends BaseModel {
10
+ glyphInfo: IEncodeFeature[];
11
+ glyphInfoMap: {
12
+ [key: string]: {
13
+ shaping: any;
14
+ glyphQuads: IGlyphQuad[];
15
+ centroid: number[];
16
+ };
17
+ };
18
+ private texture;
19
+ private currentZoom;
20
+ private extent;
21
+ private textureHeight;
22
+ private textCount;
23
+ private preTextStyle;
24
+ getUninforms(): IModelUniform;
25
+ initModels(callbackModel: (models: IModel[]) => void): void;
26
+ buildModels: (callbackModel: (models: IModel[]) => void) => Promise<void>;
27
+ clearModels(): void;
28
+ protected registerBuiltinAttributes(): void;
29
+ private mapping;
30
+ private textExtent;
31
+ /**
32
+ * 生成文字纹理(生成文字纹理字典)
33
+ */
34
+ private initTextFont;
35
+ /**
36
+ * 生成 iconfont 纹理字典
37
+ */
38
+ private initIconFontTex;
39
+ /**
40
+ * 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
41
+ */
42
+ private generateGlyphLayout;
43
+ /**
44
+ * 文字避让 depend on originCentorid
45
+ */
46
+ private filterGlyphs;
47
+ /**
48
+ * 初始化文字布局
49
+ */
50
+ private initGlyph;
51
+ /**
52
+ * 更新文字纹理
53
+ */
54
+ private updateTexture;
55
+ private reBuildModel;
56
+ }