@antv/l7-layers 2.15.4 → 2.16.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.
@@ -597,7 +597,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
597
597
  key: "renderLayers",
598
598
  value: function renderLayers() {
599
599
  this.rendering = true;
600
- this.layerService.renderLayers();
600
+ this.layerService.reRender();
601
601
  this.rendering = false;
602
602
  }
603
603
  }, {
@@ -1172,6 +1172,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1172
1172
  return reject(err);
1173
1173
  });
1174
1174
  } else {
1175
+ // console.log(this.encodedData)
1175
1176
  var _this9$styleAttribute = _this9.styleAttributeService.createAttributesAndIndices(_this9.encodedData, triangulation, segmentNumber),
1176
1177
  attributes = _this9$styleAttribute.attributes,
1177
1178
  elements = _this9$styleAttribute.elements,
@@ -1323,6 +1324,8 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
1323
1324
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1324
1325
  // TODO: this.getEncodedData().length > 0 这个判断是为了解决在 2.5.x 引入数据纹理后产生的 空数据渲染导致 texture 超出上限问题
1325
1326
  if (this.encodeDataLength <= 0 && !this.forceRender) {
1327
+ // 数据为空销毁model
1328
+ this.clearModels();
1326
1329
  return this;
1327
1330
  }
1328
1331
  this.hooks.beforeRender.call();
@@ -1,7 +1,7 @@
1
1
  import { IEncodeFeature, IModel, IModelUniform } from '@antv/l7-core';
2
2
  import BaseModel from '../../core/BaseModel';
3
3
  import { IGlyphQuad } from '../../utils/symbol-layout';
4
- export declare function TextTriangulation(feature: IEncodeFeature): {
4
+ export declare function TextTrianglation(feature: IEncodeFeature): {
5
5
  vertices: number[];
6
6
  indices: number[];
7
7
  size: number;
@@ -15,6 +15,7 @@ export default class TextModel extends BaseModel {
15
15
  centroid: number[];
16
16
  };
17
17
  };
18
+ private rawEncodeData;
18
19
  private texture;
19
20
  private currentZoom;
20
21
  private extent;
@@ -23,7 +23,7 @@ import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
23
23
  var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\n// uniform float u_font_size : 24.0;\nuniform float u_opacity : 1.0;\nuniform vec4 u_stroke_color : [0, 0, 0, 1];\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n float opacity = styleMappingMat[0][0];\n float strokeWidth = styleMappingMat[0][2];\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n // float fontScale = u_font_size / FONT_SIZE;\n\n // lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n lowp float buff = (6.0 - strokeWidth / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n // gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), vec4(textrueStroke.rgb, textrueStroke.a * opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor.a= gl_FragColor.a * alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
24
24
  /* babel-plugin-inline-import '../shaders/text_vert.glsl' */
25
25
  var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform float u_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n \n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n v_uv = a_tex / u_sdf_map_size;\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp *(vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
26
- export function TextTriangulation(feature) {
26
+ export function TextTrianglation(feature) {
27
27
  // @ts-ignore
28
28
  var that = this;
29
29
  var id = feature.id;
@@ -120,7 +120,6 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
120
120
  width = _this$calDataFrame.width,
121
121
  height = _this$calDataFrame.height;
122
122
  this.rowCount = height; // 当前数据纹理有多少行
123
-
124
123
  this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
125
124
  flipY: true,
126
125
  data: data,
@@ -161,9 +160,10 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
161
160
  // 绑定事件
162
161
  this.bindEvent();
163
162
  this.extent = this.textExtent();
163
+ this.rawEncodeData = this.layer.getEncodedData();
164
164
  this.preTextStyle = this.getTextStyle();
165
165
  return _context2.abrupt("return", this.buildModels());
166
- case 4:
166
+ case 5:
167
167
  case "end":
168
168
  return _context2.stop();
169
169
  }
@@ -193,7 +193,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
193
193
  moduleName: 'pointText',
194
194
  vertexShader: textVert,
195
195
  fragmentShader: textFrag,
196
- triangulation: TextTriangulation.bind(this),
196
+ triangulation: TextTrianglation.bind(this),
197
197
  depth: {
198
198
  enable: false
199
199
  }
@@ -374,7 +374,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
374
374
  var _this$getTextStyle = this.getTextStyle(),
375
375
  fontWeight = _this$getTextStyle.fontWeight,
376
376
  fontFamily = _this$getTextStyle.fontFamily;
377
- var data = this.layer.getEncodedData();
377
+ var data = this.rawEncodeData;
378
378
  var characterSet = [];
379
379
  data.forEach(function (item) {
380
380
  var _item$shape = item.shape,
@@ -413,7 +413,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
413
413
  var _this$getTextStyle2 = this.getTextStyle(),
414
414
  fontWeight = _this$getTextStyle2.fontWeight,
415
415
  fontFamily = _this$getTextStyle2.fontFamily;
416
- var data = this.layer.getEncodedData();
416
+ var data = this.rawEncodeData;
417
417
  var characterSet = [];
418
418
  data.forEach(function (item) {
419
419
  var _item$shape2 = item.shape,
@@ -482,7 +482,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
482
482
  _ref6$textAnchor = _ref6.textAnchor,
483
483
  textAnchor = _ref6$textAnchor === void 0 ? 'center' : _ref6$textAnchor,
484
484
  textOffset = _ref6.textOffset;
485
- var data = this.layer.getEncodedData();
485
+ var data = this.rawEncodeData;
486
486
  this.glyphInfo = data.map(function (feature) {
487
487
  var _feature$shape = feature.shape,
488
488
  shape = _feature$shape === void 0 ? '' : _feature$shape,
@@ -634,7 +634,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
634
634
  moduleName: 'pointText',
635
635
  vertexShader: textVert,
636
636
  fragmentShader: textFrag,
637
- triangulation: TextTriangulation.bind(this),
637
+ triangulation: TextTrianglation.bind(this),
638
638
  depth: {
639
639
  enable: false
640
640
  }
@@ -86,8 +86,12 @@ export var TileLayerService = /*#__PURE__*/function () {
86
86
  // tile?.updateVisible(false);
87
87
  // }
88
88
  // }
89
-
90
89
  tile === null || tile === void 0 ? void 0 : tile.updateVisible(sourceTile.isVisible);
90
+ // if (sourceTile.isVisible) {
91
+ // tile?.updateVisible(sourceTile.isVisible);
92
+ // } else {
93
+ // this.removeTile(sourceTile.key);
94
+ // }
91
95
  }
92
96
  }, {
93
97
  key: "isParentLoaded",
@@ -143,8 +147,9 @@ export var TileLayerService = /*#__PURE__*/function () {
143
147
  return _ref2.apply(this, arguments);
144
148
  };
145
149
  }());
146
- Promise.all(renders);
147
- case 3:
150
+ _context2.next = 4;
151
+ return Promise.all(renders);
152
+ case 4:
148
153
  case "end":
149
154
  return _context2.stop();
150
155
  }
@@ -30,12 +30,13 @@ var DebugTile = /*#__PURE__*/function (_Tile) {
30
30
  lineLayer = new LineLayer().source(sourceOptions.data, sourceOptions.options).size(1).shape('line').color('red');
31
31
  pointLayer = new PointLayer({
32
32
  minZoom: this.z - 1,
33
- maxZoom: this.z + 1
33
+ maxZoom: this.z + 1,
34
+ textAllowOverlap: true
34
35
  }).source([pointData], {
35
36
  parser: {
36
37
  type: 'json',
37
- x: 'textLng',
38
- y: 'textLat'
38
+ x: 'x',
39
+ y: 'y'
39
40
  }
40
41
  }).size(20).color('red').shape(this.key).style({
41
42
  stroke: '#fff',
@@ -18,6 +18,7 @@ export default abstract class Tile implements ITile {
18
18
  abstract initTileLayer(): Promise<void>;
19
19
  lnglatInBounds(lnglat: ILngLat): boolean;
20
20
  protected getLayerOptions(): {
21
+ textAllowOverlap: boolean;
21
22
  autoFit: boolean;
22
23
  maskLayers: ILayer[];
23
24
  tileMask: boolean;
@@ -52,6 +52,8 @@ var Tile = /*#__PURE__*/function () {
52
52
  var _options$maskLayers;
53
53
  var options = this.parent.getLayerConfig();
54
54
  return _objectSpread(_objectSpread({}, options), {}, {
55
+ textAllowOverlap: true,
56
+ // 文本允许重叠
55
57
  autoFit: false,
56
58
  maskLayers: this.getMaskLayer(),
57
59
  tileMask: isNeedMask(this.parent.type),
@@ -603,7 +603,7 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
603
603
  key: "renderLayers",
604
604
  value: function renderLayers() {
605
605
  this.rendering = true;
606
- this.layerService.renderLayers();
606
+ this.layerService.reRender();
607
607
  this.rendering = false;
608
608
  }
609
609
  }, {
@@ -1178,6 +1178,7 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
1178
1178
  return reject(err);
1179
1179
  });
1180
1180
  } else {
1181
+ // console.log(this.encodedData)
1181
1182
  var _this9$styleAttribute = _this9.styleAttributeService.createAttributesAndIndices(_this9.encodedData, triangulation, segmentNumber),
1182
1183
  attributes = _this9$styleAttribute.attributes,
1183
1184
  elements = _this9$styleAttribute.elements,
@@ -1329,6 +1330,8 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
1329
1330
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1330
1331
  // TODO: this.getEncodedData().length > 0 这个判断是为了解决在 2.5.x 引入数据纹理后产生的 空数据渲染导致 texture 超出上限问题
1331
1332
  if (this.encodeDataLength <= 0 && !this.forceRender) {
1333
+ // 数据为空销毁model
1334
+ this.clearModels();
1332
1335
  return this;
1333
1336
  }
1334
1337
  this.hooks.beforeRender.call();
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.TextTriangulation = TextTriangulation;
7
+ exports.TextTrianglation = TextTrianglation;
8
8
  exports.default = void 0;
9
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
@@ -31,7 +31,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
31
31
  var textFrag = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 48.0\nuniform sampler2D u_sdf_map;\nuniform float u_gamma_scale : 0.5;\n// uniform float u_font_size : 24.0;\nuniform float u_opacity : 1.0;\nuniform vec4 u_stroke_color : [0, 0, 0, 1];\nuniform float u_stroke_width : 2.0;\nuniform float u_halo_blur : 0.5;\nuniform float u_DevicePixelRatio;\n\nvarying vec4 v_color;\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\nvoid main() {\n // get style data mapping\n float opacity = styleMappingMat[0][0];\n float strokeWidth = styleMappingMat[0][2];\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n // get sdf from atlas\n float dist = texture2D(u_sdf_map, v_uv).a;\n\n // float fontScale = u_font_size / FONT_SIZE;\n\n // lowp float buff = (6.0 - u_stroke_width / v_fontScale) / SDF_PX;\n lowp float buff = (6.0 - strokeWidth / v_fontScale) / SDF_PX;\n highp float gamma = (u_halo_blur * 1.19 / SDF_PX + EDGE_GAMMA) / (v_fontScale * u_gamma_scale) / 1.0;\n\n highp float gamma_scaled = gamma * v_gamma_scale;\n\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n // gl_FragColor = mix(vec4(v_color.rgb, v_color.a * u_opacity), vec4(u_stroke_color.rgb, u_stroke_color.a * u_opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), vec4(textrueStroke.rgb, textrueStroke.a * opacity), smoothstep(0., 0.5, 1. - dist));\n gl_FragColor.a= gl_FragColor.a * alpha;\n // \u4F5C\u4E3A mask \u6A21\u677F\u65F6\u9700\u8981\u4E22\u5F03\u900F\u660E\u7684\u50CF\u7D20\n if (gl_FragColor.a < 0.01) {\n discard;\n }\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
32
32
  /* babel-plugin-inline-import '../shaders/text_vert.glsl' */
33
33
  var textVert = "#define SDF_PX 8.0\n#define EDGE_GAMMA 0.105\n#define FONT_SIZE 24.0\nattribute vec3 a_Position;\nattribute vec2 a_tex;\nattribute vec2 a_textOffsets;\nattribute vec4 a_Color;\nattribute float a_Size;\nattribute float a_Rotate;\n\nuniform vec2 u_sdf_map_size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_raisingHeight: 0.0;\n\nvarying vec2 v_uv;\nvarying float v_gamma_scale;\nvarying vec4 v_color;\nvarying float v_fontScale;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform float u_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n \n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_color = a_Color;\n v_uv = a_tex / u_sdf_map_size;\n\n // \u6587\u672C\u7F29\u653E\u6BD4\u4F8B\n float fontScale = a_Size / FONT_SIZE;\n v_fontScale = fontScale;\n\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // vec4 projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n highp float angle_sin = sin(a_Rotate);\n highp float angle_cos = cos(a_Rotate);\n mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);\n \n // gl_Position = vec4(projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n vec4 projected_position;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n projected_position = u_Mvp *(vec4(a_Position.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n } else { // else\n projected_position = project_common_position_to_clipspace(vec4(project_pos.xyz + vec3(0.0, 0.0, raiseHeight), 1.0));\n }\n\n gl_Position = vec4(\n projected_position.xy / projected_position.w + rotation_matrix * a_textOffsets * fontScale / u_ViewportSize * 2.0 * u_DevicePixelRatio, 0.0, 1.0);\n v_gamma_scale = gl_Position.w;\n setPickingColor(a_PickingColor);\n\n}\n";
34
- function TextTriangulation(feature) {
34
+ function TextTrianglation(feature) {
35
35
  // @ts-ignore
36
36
  var that = this;
37
37
  var id = feature.id;
@@ -128,7 +128,6 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
128
128
  width = _this$calDataFrame.width,
129
129
  height = _this$calDataFrame.height;
130
130
  this.rowCount = height; // 当前数据纹理有多少行
131
-
132
131
  this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
133
132
  flipY: true,
134
133
  data: data,
@@ -169,9 +168,10 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
169
168
  // 绑定事件
170
169
  this.bindEvent();
171
170
  this.extent = this.textExtent();
171
+ this.rawEncodeData = this.layer.getEncodedData();
172
172
  this.preTextStyle = this.getTextStyle();
173
173
  return _context2.abrupt("return", this.buildModels());
174
- case 4:
174
+ case 5:
175
175
  case "end":
176
176
  return _context2.stop();
177
177
  }
@@ -201,7 +201,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
201
201
  moduleName: 'pointText',
202
202
  vertexShader: textVert,
203
203
  fragmentShader: textFrag,
204
- triangulation: TextTriangulation.bind(this),
204
+ triangulation: TextTrianglation.bind(this),
205
205
  depth: {
206
206
  enable: false
207
207
  }
@@ -382,7 +382,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
382
382
  var _this$getTextStyle = this.getTextStyle(),
383
383
  fontWeight = _this$getTextStyle.fontWeight,
384
384
  fontFamily = _this$getTextStyle.fontFamily;
385
- var data = this.layer.getEncodedData();
385
+ var data = this.rawEncodeData;
386
386
  var characterSet = [];
387
387
  data.forEach(function (item) {
388
388
  var _item$shape = item.shape,
@@ -421,7 +421,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
421
421
  var _this$getTextStyle2 = this.getTextStyle(),
422
422
  fontWeight = _this$getTextStyle2.fontWeight,
423
423
  fontFamily = _this$getTextStyle2.fontFamily;
424
- var data = this.layer.getEncodedData();
424
+ var data = this.rawEncodeData;
425
425
  var characterSet = [];
426
426
  data.forEach(function (item) {
427
427
  var _item$shape2 = item.shape,
@@ -490,7 +490,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
490
490
  _ref6$textAnchor = _ref6.textAnchor,
491
491
  textAnchor = _ref6$textAnchor === void 0 ? 'center' : _ref6$textAnchor,
492
492
  textOffset = _ref6.textOffset;
493
- var data = this.layer.getEncodedData();
493
+ var data = this.rawEncodeData;
494
494
  this.glyphInfo = data.map(function (feature) {
495
495
  var _feature$shape = feature.shape,
496
496
  shape = _feature$shape === void 0 ? '' : _feature$shape,
@@ -642,7 +642,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
642
642
  moduleName: 'pointText',
643
643
  vertexShader: textVert,
644
644
  fragmentShader: textFrag,
645
- triangulation: TextTriangulation.bind(this),
645
+ triangulation: TextTrianglation.bind(this),
646
646
  depth: {
647
647
  enable: false
648
648
  }
@@ -93,8 +93,12 @@ var TileLayerService = /*#__PURE__*/function () {
93
93
  // tile?.updateVisible(false);
94
94
  // }
95
95
  // }
96
-
97
96
  tile === null || tile === void 0 ? void 0 : tile.updateVisible(sourceTile.isVisible);
97
+ // if (sourceTile.isVisible) {
98
+ // tile?.updateVisible(sourceTile.isVisible);
99
+ // } else {
100
+ // this.removeTile(sourceTile.key);
101
+ // }
98
102
  }
99
103
  }, {
100
104
  key: "isParentLoaded",
@@ -150,8 +154,9 @@ var TileLayerService = /*#__PURE__*/function () {
150
154
  return _ref2.apply(this, arguments);
151
155
  };
152
156
  }());
153
- Promise.all(renders);
154
- case 3:
157
+ _context2.next = 4;
158
+ return Promise.all(renders);
159
+ case 4:
155
160
  case "end":
156
161
  return _context2.stop();
157
162
  }
@@ -37,12 +37,13 @@ var DebugTile = /*#__PURE__*/function (_Tile) {
37
37
  lineLayer = new _line.default().source(sourceOptions.data, sourceOptions.options).size(1).shape('line').color('red');
38
38
  pointLayer = new _point.default({
39
39
  minZoom: this.z - 1,
40
- maxZoom: this.z + 1
40
+ maxZoom: this.z + 1,
41
+ textAllowOverlap: true
41
42
  }).source([pointData], {
42
43
  parser: {
43
44
  type: 'json',
44
- x: 'textLng',
45
- y: 'textLat'
45
+ x: 'x',
46
+ y: 'y'
46
47
  }
47
48
  }).size(20).color('red').shape(this.key).style({
48
49
  stroke: '#fff',
@@ -59,6 +59,8 @@ var Tile = /*#__PURE__*/function () {
59
59
  var _options$maskLayers;
60
60
  var options = this.parent.getLayerConfig();
61
61
  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, options), {}, {
62
+ textAllowOverlap: true,
63
+ // 文本允许重叠
62
64
  autoFit: false,
63
65
  maskLayers: this.getMaskLayer(),
64
66
  tileMask: (0, _util.isNeedMask)(this.parent.type),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.15.4",
3
+ "version": "2.16.0",
4
4
  "description": "L7's collection of built-in layers",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -27,10 +27,10 @@
27
27
  "license": "ISC",
28
28
  "dependencies": {
29
29
  "@antv/async-hook": "^2.2.9",
30
- "@antv/l7-core": "2.15.4",
31
- "@antv/l7-maps": "2.15.4",
32
- "@antv/l7-source": "2.15.4",
33
- "@antv/l7-utils": "2.15.4",
30
+ "@antv/l7-core": "2.16.0",
31
+ "@antv/l7-maps": "2.16.0",
32
+ "@antv/l7-source": "2.16.0",
33
+ "@antv/l7-utils": "2.16.0",
34
34
  "@babel/runtime": "^7.7.7",
35
35
  "@mapbox/martini": "^0.2.0",
36
36
  "@turf/clone": "^6.5.0",
@@ -53,7 +53,7 @@
53
53
  "reflect-metadata": "^0.1.13"
54
54
  },
55
55
  "devDependencies": {
56
- "@antv/l7-test-utils": "2.15.4",
56
+ "@antv/l7-test-utils": "2.16.0",
57
57
  "@types/d3-array": "^2.0.0",
58
58
  "@types/d3-color": "^1.2.2",
59
59
  "@types/d3-interpolate": "1.1.6",
@@ -62,7 +62,7 @@
62
62
  "@types/gl-matrix": "^2.4.5",
63
63
  "@types/lodash": "^4.14.138"
64
64
  },
65
- "gitHead": "ab8429be57c8950a65493e33eb2fa9b38b2a125f",
65
+ "gitHead": "901d07c0523b128fbc69ca04e6b3b8367ea3572d",
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  }