@antv/l7-layers 2.13.4 → 2.13.5
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/point/models/fill.js +3 -8
- package/es/point/models/fillmage.js +5 -9
- package/es/point/models/image.js +6 -9
- package/es/point/models/text.d.ts +1 -0
- package/es/point/models/text.js +88 -71
- package/lib/point/models/fill.js +2 -6
- package/lib/point/models/fillmage.js +6 -10
- package/lib/point/models/image.js +6 -9
- package/lib/point/models/text.js +87 -70
- package/package.json +6 -6
package/es/point/models/fill.js
CHANGED
|
@@ -14,9 +14,9 @@ import { AttributeType, gl } from '@antv/l7-core';
|
|
|
14
14
|
import { getMask, PointFillTriangulation } from '@antv/l7-utils';
|
|
15
15
|
import { isNumber } from 'lodash';
|
|
16
16
|
import BaseModel from "../../core/BaseModel";
|
|
17
|
+
import { SizeUnitType } from "../../core/interface"; // animate pointLayer shader - support animate
|
|
17
18
|
|
|
18
19
|
/* babel-plugin-inline-import '../shaders/animate/wave_frag.glsl' */
|
|
19
|
-
// animate pointLayer shader - support animate
|
|
20
20
|
var waveFillFrag = "\nuniform float u_additive;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_animate: [ 1., 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n\n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n \n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n\n\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df);\n\n float color_t = smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n gl_FragColor = vec4(v_color.rgb, v_color.a * opacity);\n\n float d = length(v_data.xy);\n if(d > 0.5) {\n discard;\n }\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_animate.z - u_animate.y * u_time)), 0.0, 1.0);\n \n // \u6839\u636E\u53E0\u52A0\u6A21\u5F0F\u9009\u62E9\u6548\u679C\n if(u_additive > 0.0) {\n gl_FragColor *= intensity;\n // \u4F18\u5316\u6C34\u6CE2\u70B9 blend additive \u6A21\u5F0F\u4E0B\u6709\u7684\u62FE\u53D6\u6548\u679C \n gl_FragColor = filterColorAlpha(gl_FragColor, gl_FragColor.a);\n } else {\n gl_FragColor = vec4(gl_FragColor.xyz, gl_FragColor.a * intensity);\n gl_FragColor = filterColor(gl_FragColor);\n }\n}\n"; // static pointLayer shader - not support animate
|
|
21
21
|
|
|
22
22
|
/* babel-plugin-inline-import '../shaders/fill_frag.glsl' */
|
|
@@ -24,7 +24,6 @@ var pointFillFrag = "uniform float u_additive;\n\nvarying mat4 styleMappingMat;
|
|
|
24
24
|
|
|
25
25
|
/* babel-plugin-inline-import '../shaders/fill_vert.glsl' */
|
|
26
26
|
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\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 mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform int u_Size_Unit;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\nuniform float u_opacity : 1;\nuniform float u_stroke_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\nuniform vec2 u_offsets;\n\nuniform float u_blur : 0.0;\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n /*\n * setPickingSize \u8BBE\u7F6E\u62FE\u53D6\u5927\u5C0F\n * u_meter2coord \u5728\u7B49\u9762\u79EF\u5927\u5C0F\u7684\u65F6\u5019\u8BBE\u7F6E\u5355\u4F4D\n */\n float newSize = setPickingSize(a_Size);\n // float newSize = setPickingSize(a_Size) * 0.00001038445708445579;\n\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 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][1] = strokeOpacityAndOffset.r;\n textureOffset = strokeOpacityAndOffset.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 vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\n\n // unpack color(vec2)\n v_color = a_Color;\nif(u_Size_Unit == 1) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n v_radius = newSize;\n\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(2.0 / u_DevicePixelRatio / newSize, u_blur);\n\n vec2 offset = (extrude.xy * (newSize + u_stroke_width) + textrueOffsets);\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n \n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n\n // vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n float raisingHeight = u_raisingHeight;\n\n if(u_heightfixed < 1.0) { // false\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\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 raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n \n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
27
|
-
import { SizeUnitType } from "../../core/interface";
|
|
28
27
|
|
|
29
28
|
var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
30
29
|
_inherits(FillModel, _BaseModel);
|
|
@@ -145,13 +144,9 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
145
144
|
while (1) {
|
|
146
145
|
switch (_context.prev = _context.next) {
|
|
147
146
|
case 0:
|
|
148
|
-
_context.
|
|
149
|
-
return this.buildModels();
|
|
147
|
+
return _context.abrupt("return", this.buildModels());
|
|
150
148
|
|
|
151
|
-
case
|
|
152
|
-
return _context.abrupt("return", _context.sent);
|
|
153
|
-
|
|
154
|
-
case 3:
|
|
149
|
+
case 1:
|
|
155
150
|
case "end":
|
|
156
151
|
return _context.stop();
|
|
157
152
|
}
|
|
@@ -16,6 +16,7 @@ import { AttributeType, gl } from '@antv/l7-core';
|
|
|
16
16
|
import { getCullFace, getMask } from '@antv/l7-utils';
|
|
17
17
|
import { isNumber } from 'lodash';
|
|
18
18
|
import BaseModel from "../../core/BaseModel";
|
|
19
|
+
import { SizeUnitType } from "../../core/interface";
|
|
19
20
|
import { PointFillTriangulation } from "../../core/triangulation"; // static pointLayer shader - not support animate
|
|
20
21
|
|
|
21
22
|
/* babel-plugin-inline-import '../shaders/image/fillImage_frag.glsl' */
|
|
@@ -23,7 +24,6 @@ var pointFillFrag = "uniform sampler2D u_texture;\nuniform vec2 u_textSize;\n\nv
|
|
|
23
24
|
|
|
24
25
|
/* babel-plugin-inline-import '../shaders/image/fillImage_vert.glsl' */
|
|
25
26
|
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute vec2 a_Uv;\nattribute float a_Rotate;\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 mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform mat2 u_RotateMatrix;\nuniform int u_Size_Unit;\n\nvarying vec2 v_uv; // \u672C\u8EAB\u7684 uv \u5750\u6807\nvarying vec2 v_Iconuv; // icon \u8D34\u56FE\u7684 uv \u5750\u6807\n\nuniform float u_raisingHeight: 0.0;\nuniform float u_heightfixed: 0.0;\nuniform float u_opacity : 1;\nuniform vec2 u_offsets;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n\n v_uv = (a_Extrude.xy + 1.0)/2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n\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 - empty - empty - empty\n 0.0, 0.0, 0.0, 0.0, // empty - empty - empty - empty\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 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\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 float newSize = a_Size;\n if(u_Size_Unit == 1) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = (rotation_matrix * u_RotateMatrix * extrude.xy * (newSize) + textrueOffsets);\n vec3 aPosition = a_Position;\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));\n float raisingHeight = u_raisingHeight;\n if(u_heightfixed < 1.0) { // height fixed\n raisingHeight = project_pixel(u_raisingHeight);\n } else {\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 raisingHeight = u_raisingHeight * mapboxZoomScale;\n }\n }\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp *vec4(project_pos.xy + offset, raisingHeight, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, raisingHeight, 1.0));\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
26
|
-
import { SizeUnitType } from "../../core/interface";
|
|
27
27
|
|
|
28
28
|
var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
29
29
|
_inherits(FillImageModel, _BaseModel);
|
|
@@ -180,13 +180,9 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
180
180
|
case 0:
|
|
181
181
|
this.iconService.on('imageUpdate', this.updateTexture);
|
|
182
182
|
this.updateTexture();
|
|
183
|
-
_context.
|
|
184
|
-
return this.buildModels();
|
|
185
|
-
|
|
186
|
-
case 4:
|
|
187
|
-
return _context.abrupt("return", _context.sent);
|
|
183
|
+
return _context.abrupt("return", this.buildModels());
|
|
188
184
|
|
|
189
|
-
case
|
|
185
|
+
case 3:
|
|
190
186
|
case "end":
|
|
191
187
|
return _context.stop();
|
|
192
188
|
}
|
|
@@ -297,8 +293,8 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
297
293
|
var shape = feature.shape;
|
|
298
294
|
|
|
299
295
|
var _ref3 = iconMap[shape] || {
|
|
300
|
-
x:
|
|
301
|
-
y:
|
|
296
|
+
x: -64,
|
|
297
|
+
y: -64
|
|
302
298
|
},
|
|
303
299
|
x = _ref3.x,
|
|
304
300
|
y = _ref3.y;
|
package/es/point/models/image.js
CHANGED
|
@@ -147,13 +147,9 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
147
147
|
case 0:
|
|
148
148
|
this.iconService.on('imageUpdate', this.updateTexture);
|
|
149
149
|
this.updateTexture();
|
|
150
|
-
_context.
|
|
151
|
-
return this.buildModels();
|
|
150
|
+
return _context.abrupt("return", this.buildModels());
|
|
152
151
|
|
|
153
|
-
case
|
|
154
|
-
return _context.abrupt("return", _context.sent);
|
|
155
|
-
|
|
156
|
-
case 5:
|
|
152
|
+
case 3:
|
|
157
153
|
case "end":
|
|
158
154
|
return _context.stop();
|
|
159
155
|
}
|
|
@@ -263,11 +259,12 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
263
259
|
var shape = feature.shape;
|
|
264
260
|
|
|
265
261
|
var _ref3 = iconMap[shape] || {
|
|
266
|
-
x:
|
|
267
|
-
y:
|
|
262
|
+
x: -64,
|
|
263
|
+
y: -64
|
|
268
264
|
},
|
|
269
265
|
x = _ref3.x,
|
|
270
|
-
y = _ref3.y;
|
|
266
|
+
y = _ref3.y; // 非画布区域,默认的图标改为透明
|
|
267
|
+
|
|
271
268
|
|
|
272
269
|
return [x, y];
|
|
273
270
|
}
|
package/es/point/models/text.js
CHANGED
|
@@ -22,7 +22,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
22
22
|
|
|
23
23
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
24
24
|
import { boundsContains, calculateCentroid, getMask, padBounds } from '@antv/l7-utils';
|
|
25
|
-
import { isNumber } from 'lodash';
|
|
25
|
+
import { isEqual, isNumber } from 'lodash';
|
|
26
26
|
import BaseModel from "../../core/BaseModel";
|
|
27
27
|
import CollisionIndex from "../../utils/collision-index";
|
|
28
28
|
import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
|
|
@@ -123,11 +123,6 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
123
123
|
stroke = _ref2$stroke === void 0 ? '#fff' : _ref2$stroke,
|
|
124
124
|
_ref2$strokeWidth = _ref2.strokeWidth,
|
|
125
125
|
strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
|
|
126
|
-
_ref2$textAnchor = _ref2.textAnchor,
|
|
127
|
-
textAnchor = _ref2$textAnchor === void 0 ? 'center' : _ref2$textAnchor,
|
|
128
|
-
textOffset = _ref2.textOffset,
|
|
129
|
-
_ref2$textAllowOverla = _ref2.textAllowOverlap,
|
|
130
|
-
textAllowOverlap = _ref2$textAllowOverla === void 0 ? false : _ref2$textAllowOverla,
|
|
131
126
|
_ref2$halo = _ref2.halo,
|
|
132
127
|
halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
|
|
133
128
|
_ref2$gamma = _ref2.gamma,
|
|
@@ -144,11 +139,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
144
139
|
this.textCount = Object.keys(mapping).length;
|
|
145
140
|
}
|
|
146
141
|
|
|
147
|
-
this.preTextStyle =
|
|
148
|
-
textAnchor: textAnchor,
|
|
149
|
-
textAllowOverlap: textAllowOverlap,
|
|
150
|
-
textOffset: textOffset
|
|
151
|
-
};
|
|
142
|
+
this.preTextStyle = this.getTextStyle();
|
|
152
143
|
|
|
153
144
|
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
154
145
|
opacity: opacity,
|
|
@@ -204,8 +195,6 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
204
195
|
key: "initModels",
|
|
205
196
|
value: function () {
|
|
206
197
|
var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
207
|
-
var _ref3, _ref3$textAnchor, textAnchor, _ref3$textAllowOverla, textAllowOverlap, textOffset;
|
|
208
|
-
|
|
209
198
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
210
199
|
while (1) {
|
|
211
200
|
switch (_context2.prev = _context2.next) {
|
|
@@ -213,19 +202,10 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
213
202
|
// 绑定事件
|
|
214
203
|
this.bindEvent();
|
|
215
204
|
this.extent = this.textExtent();
|
|
216
|
-
|
|
217
|
-
this.
|
|
218
|
-
textAnchor: textAnchor,
|
|
219
|
-
textAllowOverlap: textAllowOverlap,
|
|
220
|
-
textOffset: textOffset
|
|
221
|
-
};
|
|
222
|
-
_context2.next = 6;
|
|
223
|
-
return this.buildModels();
|
|
224
|
-
|
|
225
|
-
case 6:
|
|
226
|
-
return _context2.abrupt("return", _context2.sent);
|
|
205
|
+
this.preTextStyle = this.getTextStyle();
|
|
206
|
+
return _context2.abrupt("return", this.buildModels());
|
|
227
207
|
|
|
228
|
-
case
|
|
208
|
+
case 4:
|
|
229
209
|
case "end":
|
|
230
210
|
return _context2.stop();
|
|
231
211
|
}
|
|
@@ -243,13 +223,13 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
243
223
|
key: "buildModels",
|
|
244
224
|
value: function () {
|
|
245
225
|
var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
246
|
-
var
|
|
226
|
+
var _ref3, _ref3$mask, mask, _ref3$maskInside, maskInside, _ref3$textAllowOverla, textAllowOverlap, model;
|
|
247
227
|
|
|
248
228
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
249
229
|
while (1) {
|
|
250
230
|
switch (_context3.prev = _context3.next) {
|
|
251
231
|
case 0:
|
|
252
|
-
|
|
232
|
+
_ref3 = this.layer.getLayerConfig(), _ref3$mask = _ref3.mask, mask = _ref3$mask === void 0 ? false : _ref3$mask, _ref3$maskInside = _ref3.maskInside, maskInside = _ref3$maskInside === void 0 ? true : _ref3$maskInside, _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla; // this.mapping(); 重复调用
|
|
253
233
|
|
|
254
234
|
this.initGlyph(); //
|
|
255
235
|
|
|
@@ -289,60 +269,65 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
289
269
|
}
|
|
290
270
|
|
|
291
271
|
return buildModels;
|
|
292
|
-
}()
|
|
272
|
+
}() // 需要更新的场景
|
|
273
|
+
// 1. 文本偏移量发生改变
|
|
274
|
+
// 2. 文本锚点发生改变
|
|
275
|
+
// 3. 文本允许重叠发生改变
|
|
276
|
+
// 4. 文本字体发生改变
|
|
277
|
+
// 5. 文本字体粗细发生改变
|
|
278
|
+
|
|
293
279
|
}, {
|
|
294
280
|
key: "needUpdate",
|
|
295
281
|
value: function () {
|
|
296
282
|
var _needUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
297
|
-
var
|
|
283
|
+
var _ref4, _ref4$textAllowOverla, textAllowOverlap, _ref4$textAnchor, textAnchor, textOffset, padding, fontFamily, fontWeight, zoom, extent, flag;
|
|
298
284
|
|
|
299
285
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
300
286
|
while (1) {
|
|
301
287
|
switch (_context4.prev = _context4.next) {
|
|
302
288
|
case 0:
|
|
303
|
-
|
|
304
|
-
data = this.layer.getEncodedData();
|
|
289
|
+
_ref4 = this.getTextStyle(), _ref4$textAllowOverla = _ref4.textAllowOverlap, textAllowOverlap = _ref4$textAllowOverla === void 0 ? false : _ref4$textAllowOverla, _ref4$textAnchor = _ref4.textAnchor, textAnchor = _ref4$textAnchor === void 0 ? 'center' : _ref4$textAnchor, textOffset = _ref4.textOffset, padding = _ref4.padding, fontFamily = _ref4.fontFamily, fontWeight = _ref4.fontWeight;
|
|
305
290
|
|
|
306
|
-
if (!(
|
|
307
|
-
_context4.next =
|
|
291
|
+
if (!(!isEqual(padding, this.preTextStyle.padding) || !isEqual(textOffset, this.preTextStyle.textOffset) || !isEqual(textAnchor, this.preTextStyle.textAnchor) || !isEqual(fontFamily, this.preTextStyle.fontFamily) || !isEqual(fontWeight, this.preTextStyle.fontWeight))) {
|
|
292
|
+
_context4.next = 5;
|
|
308
293
|
break;
|
|
309
294
|
}
|
|
310
295
|
|
|
311
|
-
_context4.next =
|
|
296
|
+
_context4.next = 4;
|
|
312
297
|
return this.mapping();
|
|
313
298
|
|
|
314
|
-
case
|
|
299
|
+
case 4:
|
|
315
300
|
return _context4.abrupt("return", true);
|
|
316
301
|
|
|
317
|
-
case
|
|
318
|
-
if (!
|
|
319
|
-
_context4.next =
|
|
302
|
+
case 5:
|
|
303
|
+
if (!textAllowOverlap) {
|
|
304
|
+
_context4.next = 7;
|
|
320
305
|
break;
|
|
321
306
|
}
|
|
322
307
|
|
|
323
308
|
return _context4.abrupt("return", false);
|
|
324
309
|
|
|
325
|
-
case
|
|
310
|
+
case 7:
|
|
326
311
|
// textAllowOverlap 发生改变
|
|
327
312
|
zoom = this.mapService.getZoom();
|
|
328
313
|
extent = this.mapService.getBounds();
|
|
329
314
|
flag = boundsContains(this.extent, extent); // 文本不能压盖则进行过滤
|
|
330
315
|
|
|
331
|
-
if (!(Math.abs(this.currentZoom - zoom) >
|
|
332
|
-
_context4.next =
|
|
316
|
+
if (!(Math.abs(this.currentZoom - zoom) > 0.5 || !flag || textAllowOverlap !== this.preTextStyle.textAllowOverlap)) {
|
|
317
|
+
_context4.next = 14;
|
|
333
318
|
break;
|
|
334
319
|
}
|
|
335
320
|
|
|
336
|
-
_context4.next =
|
|
321
|
+
_context4.next = 13;
|
|
337
322
|
return this.reBuildModel();
|
|
338
323
|
|
|
339
|
-
case
|
|
324
|
+
case 13:
|
|
340
325
|
return _context4.abrupt("return", true);
|
|
341
326
|
|
|
342
|
-
case
|
|
327
|
+
case 14:
|
|
343
328
|
return _context4.abrupt("return", false);
|
|
344
329
|
|
|
345
|
-
case
|
|
330
|
+
case 15:
|
|
346
331
|
case "end":
|
|
347
332
|
return _context4.stop();
|
|
348
333
|
}
|
|
@@ -462,11 +447,9 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
462
447
|
}, {
|
|
463
448
|
key: "initTextFont",
|
|
464
449
|
value: function initTextFont() {
|
|
465
|
-
var
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
_ref6$fontFamily = _ref6.fontFamily,
|
|
469
|
-
fontFamily = _ref6$fontFamily === void 0 ? 'sans-serif' : _ref6$fontFamily;
|
|
450
|
+
var _this$getTextStyle = this.getTextStyle(),
|
|
451
|
+
fontWeight = _this$getTextStyle.fontWeight,
|
|
452
|
+
fontFamily = _this$getTextStyle.fontFamily;
|
|
470
453
|
|
|
471
454
|
var data = this.layer.getEncodedData();
|
|
472
455
|
var characterSet = [];
|
|
@@ -507,11 +490,9 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
507
490
|
}, {
|
|
508
491
|
key: "initIconFontTex",
|
|
509
492
|
value: function initIconFontTex() {
|
|
510
|
-
var
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
_ref7$fontFamily = _ref7.fontFamily,
|
|
514
|
-
fontFamily = _ref7$fontFamily === void 0 ? 'sans-serif' : _ref7$fontFamily;
|
|
493
|
+
var _this$getTextStyle2 = this.getTextStyle(),
|
|
494
|
+
fontWeight = _this$getTextStyle2.fontWeight,
|
|
495
|
+
fontFamily = _this$getTextStyle2.fontFamily;
|
|
515
496
|
|
|
516
497
|
var data = this.layer.getEncodedData();
|
|
517
498
|
var characterSet = [];
|
|
@@ -531,6 +512,44 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
531
512
|
iconfont: true
|
|
532
513
|
});
|
|
533
514
|
}
|
|
515
|
+
}, {
|
|
516
|
+
key: "getTextStyle",
|
|
517
|
+
value: function getTextStyle() {
|
|
518
|
+
var _ref5 = this.layer.getLayerConfig(),
|
|
519
|
+
_ref5$fontWeight = _ref5.fontWeight,
|
|
520
|
+
fontWeight = _ref5$fontWeight === void 0 ? '400' : _ref5$fontWeight,
|
|
521
|
+
_ref5$fontFamily = _ref5.fontFamily,
|
|
522
|
+
fontFamily = _ref5$fontFamily === void 0 ? 'sans-serif' : _ref5$fontFamily,
|
|
523
|
+
_ref5$textAllowOverla = _ref5.textAllowOverlap,
|
|
524
|
+
textAllowOverlap = _ref5$textAllowOverla === void 0 ? false : _ref5$textAllowOverla,
|
|
525
|
+
_ref5$padding = _ref5.padding,
|
|
526
|
+
padding = _ref5$padding === void 0 ? [0, 0] : _ref5$padding,
|
|
527
|
+
_ref5$textAnchor = _ref5.textAnchor,
|
|
528
|
+
textAnchor = _ref5$textAnchor === void 0 ? 'center' : _ref5$textAnchor,
|
|
529
|
+
_ref5$textOffset = _ref5.textOffset,
|
|
530
|
+
textOffset = _ref5$textOffset === void 0 ? [0, 0] : _ref5$textOffset,
|
|
531
|
+
_ref5$opacity = _ref5.opacity,
|
|
532
|
+
opacity = _ref5$opacity === void 0 ? 1 : _ref5$opacity,
|
|
533
|
+
_ref5$strokeOpacity = _ref5.strokeOpacity,
|
|
534
|
+
strokeOpacity = _ref5$strokeOpacity === void 0 ? 1 : _ref5$strokeOpacity,
|
|
535
|
+
_ref5$strokeWidth = _ref5.strokeWidth,
|
|
536
|
+
strokeWidth = _ref5$strokeWidth === void 0 ? 0 : _ref5$strokeWidth,
|
|
537
|
+
_ref5$stroke = _ref5.stroke,
|
|
538
|
+
stroke = _ref5$stroke === void 0 ? '#000' : _ref5$stroke;
|
|
539
|
+
|
|
540
|
+
return {
|
|
541
|
+
fontWeight: fontWeight,
|
|
542
|
+
fontFamily: fontFamily,
|
|
543
|
+
textAllowOverlap: textAllowOverlap,
|
|
544
|
+
padding: padding,
|
|
545
|
+
textAnchor: textAnchor,
|
|
546
|
+
textOffset: textOffset,
|
|
547
|
+
opacity: opacity,
|
|
548
|
+
strokeOpacity: strokeOpacity,
|
|
549
|
+
strokeWidth: strokeWidth,
|
|
550
|
+
stroke: stroke
|
|
551
|
+
};
|
|
552
|
+
}
|
|
534
553
|
/**
|
|
535
554
|
* 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
|
|
536
555
|
*/
|
|
@@ -543,12 +562,12 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
543
562
|
// 更新文字布局
|
|
544
563
|
var mapping = this.fontService.mapping;
|
|
545
564
|
|
|
546
|
-
var
|
|
547
|
-
|
|
548
|
-
spacing =
|
|
549
|
-
|
|
550
|
-
textAnchor =
|
|
551
|
-
textOffset =
|
|
565
|
+
var _ref6 = this.layer.getLayerConfig(),
|
|
566
|
+
_ref6$spacing = _ref6.spacing,
|
|
567
|
+
spacing = _ref6$spacing === void 0 ? 2 : _ref6$spacing,
|
|
568
|
+
_ref6$textAnchor = _ref6.textAnchor,
|
|
569
|
+
textAnchor = _ref6$textAnchor === void 0 ? 'center' : _ref6$textAnchor,
|
|
570
|
+
textOffset = _ref6.textOffset;
|
|
552
571
|
|
|
553
572
|
var data = this.layer.getEncodedData();
|
|
554
573
|
this.glyphInfo = data.map(function (feature) {
|
|
@@ -583,15 +602,14 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
583
602
|
value: function filterGlyphs() {
|
|
584
603
|
var _this3 = this;
|
|
585
604
|
|
|
586
|
-
var
|
|
587
|
-
|
|
588
|
-
padding =
|
|
589
|
-
|
|
590
|
-
textAllowOverlap =
|
|
605
|
+
var _ref7 = this.layer.getLayerConfig(),
|
|
606
|
+
_ref7$padding = _ref7.padding,
|
|
607
|
+
padding = _ref7$padding === void 0 ? [0, 0] : _ref7$padding,
|
|
608
|
+
_ref7$textAllowOverla = _ref7.textAllowOverlap,
|
|
609
|
+
textAllowOverlap = _ref7$textAllowOverla === void 0 ? false : _ref7$textAllowOverla;
|
|
591
610
|
|
|
592
611
|
if (textAllowOverlap) {
|
|
593
612
|
// 如果允许文本覆盖
|
|
594
|
-
// this.layer.setEncodedData(this.glyphInfo);
|
|
595
613
|
return;
|
|
596
614
|
}
|
|
597
615
|
|
|
@@ -650,8 +668,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
650
668
|
iconfont = _this$layer$getLayerC2 === void 0 ? false : _this$layer$getLayerC2; // 1.生成文字纹理(或是生成 iconfont)
|
|
651
669
|
|
|
652
670
|
|
|
653
|
-
iconfont ? this.initIconFontTex() : this.initTextFont(); //
|
|
654
|
-
// 2.生成文字布局
|
|
671
|
+
iconfont ? this.initIconFontTex() : this.initTextFont(); // 2.生成文字布局
|
|
655
672
|
|
|
656
673
|
this.generateGlyphLayout(iconfont);
|
|
657
674
|
}
|
|
@@ -682,13 +699,13 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
682
699
|
key: "reBuildModel",
|
|
683
700
|
value: function () {
|
|
684
701
|
var _reBuildModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
685
|
-
var
|
|
702
|
+
var _ref8, _ref8$mask, mask, _ref8$maskInside, maskInside, model;
|
|
686
703
|
|
|
687
704
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
688
705
|
while (1) {
|
|
689
706
|
switch (_context5.prev = _context5.next) {
|
|
690
707
|
case 0:
|
|
691
|
-
|
|
708
|
+
_ref8 = this.layer.getLayerConfig(), _ref8$mask = _ref8.mask, mask = _ref8$mask === void 0 ? false : _ref8$mask, _ref8$maskInside = _ref8.maskInside, maskInside = _ref8$maskInside === void 0 ? true : _ref8$maskInside;
|
|
692
709
|
this.filterGlyphs();
|
|
693
710
|
_context5.next = 4;
|
|
694
711
|
return this.layer.buildLayerModel({
|
package/lib/point/models/fill.js
CHANGED
|
@@ -163,13 +163,9 @@ var FillModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
163
163
|
while (1) {
|
|
164
164
|
switch (_context.prev = _context.next) {
|
|
165
165
|
case 0:
|
|
166
|
-
_context.
|
|
167
|
-
return this.buildModels();
|
|
166
|
+
return _context.abrupt("return", this.buildModels());
|
|
168
167
|
|
|
169
|
-
case
|
|
170
|
-
return _context.abrupt("return", _context.sent);
|
|
171
|
-
|
|
172
|
-
case 3:
|
|
168
|
+
case 1:
|
|
173
169
|
case "end":
|
|
174
170
|
return _context.stop();
|
|
175
171
|
}
|
|
@@ -33,10 +33,10 @@ var _lodash = require("lodash");
|
|
|
33
33
|
|
|
34
34
|
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
35
35
|
|
|
36
|
-
var _triangulation = require("../../core/triangulation");
|
|
37
|
-
|
|
38
36
|
var _interface = require("../../core/interface");
|
|
39
37
|
|
|
38
|
+
var _triangulation = require("../../core/triangulation");
|
|
39
|
+
|
|
40
40
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
41
41
|
|
|
42
42
|
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; } }
|
|
@@ -198,13 +198,9 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
198
198
|
case 0:
|
|
199
199
|
this.iconService.on('imageUpdate', this.updateTexture);
|
|
200
200
|
this.updateTexture();
|
|
201
|
-
_context.
|
|
202
|
-
return this.buildModels();
|
|
201
|
+
return _context.abrupt("return", this.buildModels());
|
|
203
202
|
|
|
204
|
-
case
|
|
205
|
-
return _context.abrupt("return", _context.sent);
|
|
206
|
-
|
|
207
|
-
case 5:
|
|
203
|
+
case 3:
|
|
208
204
|
case "end":
|
|
209
205
|
return _context.stop();
|
|
210
206
|
}
|
|
@@ -315,8 +311,8 @@ var FillImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
315
311
|
var shape = feature.shape;
|
|
316
312
|
|
|
317
313
|
var _ref3 = iconMap[shape] || {
|
|
318
|
-
x:
|
|
319
|
-
y:
|
|
314
|
+
x: -64,
|
|
315
|
+
y: -64
|
|
320
316
|
},
|
|
321
317
|
x = _ref3.x,
|
|
322
318
|
y = _ref3.y;
|
|
@@ -166,13 +166,9 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
166
166
|
case 0:
|
|
167
167
|
this.iconService.on('imageUpdate', this.updateTexture);
|
|
168
168
|
this.updateTexture();
|
|
169
|
-
_context.
|
|
170
|
-
return this.buildModels();
|
|
169
|
+
return _context.abrupt("return", this.buildModels());
|
|
171
170
|
|
|
172
|
-
case
|
|
173
|
-
return _context.abrupt("return", _context.sent);
|
|
174
|
-
|
|
175
|
-
case 5:
|
|
171
|
+
case 3:
|
|
176
172
|
case "end":
|
|
177
173
|
return _context.stop();
|
|
178
174
|
}
|
|
@@ -282,11 +278,12 @@ var ImageModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
282
278
|
var shape = feature.shape;
|
|
283
279
|
|
|
284
280
|
var _ref3 = iconMap[shape] || {
|
|
285
|
-
x:
|
|
286
|
-
y:
|
|
281
|
+
x: -64,
|
|
282
|
+
y: -64
|
|
287
283
|
},
|
|
288
284
|
x = _ref3.x,
|
|
289
|
-
y = _ref3.y;
|
|
285
|
+
y = _ref3.y; // 非画布区域,默认的图标改为透明
|
|
286
|
+
|
|
290
287
|
|
|
291
288
|
return [x, y];
|
|
292
289
|
}
|
package/lib/point/models/text.js
CHANGED
|
@@ -140,11 +140,6 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
140
140
|
stroke = _ref2$stroke === void 0 ? '#fff' : _ref2$stroke,
|
|
141
141
|
_ref2$strokeWidth = _ref2.strokeWidth,
|
|
142
142
|
strokeWidth = _ref2$strokeWidth === void 0 ? 0 : _ref2$strokeWidth,
|
|
143
|
-
_ref2$textAnchor = _ref2.textAnchor,
|
|
144
|
-
textAnchor = _ref2$textAnchor === void 0 ? 'center' : _ref2$textAnchor,
|
|
145
|
-
textOffset = _ref2.textOffset,
|
|
146
|
-
_ref2$textAllowOverla = _ref2.textAllowOverlap,
|
|
147
|
-
textAllowOverlap = _ref2$textAllowOverla === void 0 ? false : _ref2$textAllowOverla,
|
|
148
143
|
_ref2$halo = _ref2.halo,
|
|
149
144
|
halo = _ref2$halo === void 0 ? 0.5 : _ref2$halo,
|
|
150
145
|
_ref2$gamma = _ref2.gamma,
|
|
@@ -161,11 +156,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
161
156
|
this.textCount = Object.keys(mapping).length;
|
|
162
157
|
}
|
|
163
158
|
|
|
164
|
-
this.preTextStyle =
|
|
165
|
-
textAnchor: textAnchor,
|
|
166
|
-
textAllowOverlap: textAllowOverlap,
|
|
167
|
-
textOffset: textOffset
|
|
168
|
-
};
|
|
159
|
+
this.preTextStyle = this.getTextStyle();
|
|
169
160
|
|
|
170
161
|
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
171
162
|
opacity: opacity,
|
|
@@ -221,8 +212,6 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
221
212
|
key: "initModels",
|
|
222
213
|
value: function () {
|
|
223
214
|
var _initModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
224
|
-
var _ref3, _ref3$textAnchor, textAnchor, _ref3$textAllowOverla, textAllowOverlap, textOffset;
|
|
225
|
-
|
|
226
215
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
227
216
|
while (1) {
|
|
228
217
|
switch (_context2.prev = _context2.next) {
|
|
@@ -230,19 +219,10 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
230
219
|
// 绑定事件
|
|
231
220
|
this.bindEvent();
|
|
232
221
|
this.extent = this.textExtent();
|
|
233
|
-
|
|
234
|
-
this.
|
|
235
|
-
textAnchor: textAnchor,
|
|
236
|
-
textAllowOverlap: textAllowOverlap,
|
|
237
|
-
textOffset: textOffset
|
|
238
|
-
};
|
|
239
|
-
_context2.next = 6;
|
|
240
|
-
return this.buildModels();
|
|
241
|
-
|
|
242
|
-
case 6:
|
|
243
|
-
return _context2.abrupt("return", _context2.sent);
|
|
222
|
+
this.preTextStyle = this.getTextStyle();
|
|
223
|
+
return _context2.abrupt("return", this.buildModels());
|
|
244
224
|
|
|
245
|
-
case
|
|
225
|
+
case 4:
|
|
246
226
|
case "end":
|
|
247
227
|
return _context2.stop();
|
|
248
228
|
}
|
|
@@ -260,13 +240,13 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
260
240
|
key: "buildModels",
|
|
261
241
|
value: function () {
|
|
262
242
|
var _buildModels = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
263
|
-
var
|
|
243
|
+
var _ref3, _ref3$mask, mask, _ref3$maskInside, maskInside, _ref3$textAllowOverla, textAllowOverlap, model;
|
|
264
244
|
|
|
265
245
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
266
246
|
while (1) {
|
|
267
247
|
switch (_context3.prev = _context3.next) {
|
|
268
248
|
case 0:
|
|
269
|
-
|
|
249
|
+
_ref3 = this.layer.getLayerConfig(), _ref3$mask = _ref3.mask, mask = _ref3$mask === void 0 ? false : _ref3$mask, _ref3$maskInside = _ref3.maskInside, maskInside = _ref3$maskInside === void 0 ? true : _ref3$maskInside, _ref3$textAllowOverla = _ref3.textAllowOverlap, textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla; // this.mapping(); 重复调用
|
|
270
250
|
|
|
271
251
|
this.initGlyph(); //
|
|
272
252
|
|
|
@@ -306,60 +286,65 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
306
286
|
}
|
|
307
287
|
|
|
308
288
|
return buildModels;
|
|
309
|
-
}()
|
|
289
|
+
}() // 需要更新的场景
|
|
290
|
+
// 1. 文本偏移量发生改变
|
|
291
|
+
// 2. 文本锚点发生改变
|
|
292
|
+
// 3. 文本允许重叠发生改变
|
|
293
|
+
// 4. 文本字体发生改变
|
|
294
|
+
// 5. 文本字体粗细发生改变
|
|
295
|
+
|
|
310
296
|
}, {
|
|
311
297
|
key: "needUpdate",
|
|
312
298
|
value: function () {
|
|
313
299
|
var _needUpdate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
314
|
-
var
|
|
300
|
+
var _ref4, _ref4$textAllowOverla, textAllowOverlap, _ref4$textAnchor, textAnchor, textOffset, padding, fontFamily, fontWeight, zoom, extent, flag;
|
|
315
301
|
|
|
316
302
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
317
303
|
while (1) {
|
|
318
304
|
switch (_context4.prev = _context4.next) {
|
|
319
305
|
case 0:
|
|
320
|
-
|
|
321
|
-
data = this.layer.getEncodedData();
|
|
306
|
+
_ref4 = this.getTextStyle(), _ref4$textAllowOverla = _ref4.textAllowOverlap, textAllowOverlap = _ref4$textAllowOverla === void 0 ? false : _ref4$textAllowOverla, _ref4$textAnchor = _ref4.textAnchor, textAnchor = _ref4$textAnchor === void 0 ? 'center' : _ref4$textAnchor, textOffset = _ref4.textOffset, padding = _ref4.padding, fontFamily = _ref4.fontFamily, fontWeight = _ref4.fontWeight;
|
|
322
307
|
|
|
323
|
-
if (!(
|
|
324
|
-
_context4.next =
|
|
308
|
+
if (!(!(0, _lodash.isEqual)(padding, this.preTextStyle.padding) || !(0, _lodash.isEqual)(textOffset, this.preTextStyle.textOffset) || !(0, _lodash.isEqual)(textAnchor, this.preTextStyle.textAnchor) || !(0, _lodash.isEqual)(fontFamily, this.preTextStyle.fontFamily) || !(0, _lodash.isEqual)(fontWeight, this.preTextStyle.fontWeight))) {
|
|
309
|
+
_context4.next = 5;
|
|
325
310
|
break;
|
|
326
311
|
}
|
|
327
312
|
|
|
328
|
-
_context4.next =
|
|
313
|
+
_context4.next = 4;
|
|
329
314
|
return this.mapping();
|
|
330
315
|
|
|
331
|
-
case
|
|
316
|
+
case 4:
|
|
332
317
|
return _context4.abrupt("return", true);
|
|
333
318
|
|
|
334
|
-
case
|
|
335
|
-
if (!
|
|
336
|
-
_context4.next =
|
|
319
|
+
case 5:
|
|
320
|
+
if (!textAllowOverlap) {
|
|
321
|
+
_context4.next = 7;
|
|
337
322
|
break;
|
|
338
323
|
}
|
|
339
324
|
|
|
340
325
|
return _context4.abrupt("return", false);
|
|
341
326
|
|
|
342
|
-
case
|
|
327
|
+
case 7:
|
|
343
328
|
// textAllowOverlap 发生改变
|
|
344
329
|
zoom = this.mapService.getZoom();
|
|
345
330
|
extent = this.mapService.getBounds();
|
|
346
331
|
flag = (0, _l7Utils.boundsContains)(this.extent, extent); // 文本不能压盖则进行过滤
|
|
347
332
|
|
|
348
|
-
if (!(Math.abs(this.currentZoom - zoom) >
|
|
349
|
-
_context4.next =
|
|
333
|
+
if (!(Math.abs(this.currentZoom - zoom) > 0.5 || !flag || textAllowOverlap !== this.preTextStyle.textAllowOverlap)) {
|
|
334
|
+
_context4.next = 14;
|
|
350
335
|
break;
|
|
351
336
|
}
|
|
352
337
|
|
|
353
|
-
_context4.next =
|
|
338
|
+
_context4.next = 13;
|
|
354
339
|
return this.reBuildModel();
|
|
355
340
|
|
|
356
|
-
case
|
|
341
|
+
case 13:
|
|
357
342
|
return _context4.abrupt("return", true);
|
|
358
343
|
|
|
359
|
-
case
|
|
344
|
+
case 14:
|
|
360
345
|
return _context4.abrupt("return", false);
|
|
361
346
|
|
|
362
|
-
case
|
|
347
|
+
case 15:
|
|
363
348
|
case "end":
|
|
364
349
|
return _context4.stop();
|
|
365
350
|
}
|
|
@@ -479,11 +464,9 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
479
464
|
}, {
|
|
480
465
|
key: "initTextFont",
|
|
481
466
|
value: function initTextFont() {
|
|
482
|
-
var
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
_ref6$fontFamily = _ref6.fontFamily,
|
|
486
|
-
fontFamily = _ref6$fontFamily === void 0 ? 'sans-serif' : _ref6$fontFamily;
|
|
467
|
+
var _this$getTextStyle = this.getTextStyle(),
|
|
468
|
+
fontWeight = _this$getTextStyle.fontWeight,
|
|
469
|
+
fontFamily = _this$getTextStyle.fontFamily;
|
|
487
470
|
|
|
488
471
|
var data = this.layer.getEncodedData();
|
|
489
472
|
var characterSet = [];
|
|
@@ -524,11 +507,9 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
524
507
|
}, {
|
|
525
508
|
key: "initIconFontTex",
|
|
526
509
|
value: function initIconFontTex() {
|
|
527
|
-
var
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
_ref7$fontFamily = _ref7.fontFamily,
|
|
531
|
-
fontFamily = _ref7$fontFamily === void 0 ? 'sans-serif' : _ref7$fontFamily;
|
|
510
|
+
var _this$getTextStyle2 = this.getTextStyle(),
|
|
511
|
+
fontWeight = _this$getTextStyle2.fontWeight,
|
|
512
|
+
fontFamily = _this$getTextStyle2.fontFamily;
|
|
532
513
|
|
|
533
514
|
var data = this.layer.getEncodedData();
|
|
534
515
|
var characterSet = [];
|
|
@@ -548,6 +529,44 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
548
529
|
iconfont: true
|
|
549
530
|
});
|
|
550
531
|
}
|
|
532
|
+
}, {
|
|
533
|
+
key: "getTextStyle",
|
|
534
|
+
value: function getTextStyle() {
|
|
535
|
+
var _ref5 = this.layer.getLayerConfig(),
|
|
536
|
+
_ref5$fontWeight = _ref5.fontWeight,
|
|
537
|
+
fontWeight = _ref5$fontWeight === void 0 ? '400' : _ref5$fontWeight,
|
|
538
|
+
_ref5$fontFamily = _ref5.fontFamily,
|
|
539
|
+
fontFamily = _ref5$fontFamily === void 0 ? 'sans-serif' : _ref5$fontFamily,
|
|
540
|
+
_ref5$textAllowOverla = _ref5.textAllowOverlap,
|
|
541
|
+
textAllowOverlap = _ref5$textAllowOverla === void 0 ? false : _ref5$textAllowOverla,
|
|
542
|
+
_ref5$padding = _ref5.padding,
|
|
543
|
+
padding = _ref5$padding === void 0 ? [0, 0] : _ref5$padding,
|
|
544
|
+
_ref5$textAnchor = _ref5.textAnchor,
|
|
545
|
+
textAnchor = _ref5$textAnchor === void 0 ? 'center' : _ref5$textAnchor,
|
|
546
|
+
_ref5$textOffset = _ref5.textOffset,
|
|
547
|
+
textOffset = _ref5$textOffset === void 0 ? [0, 0] : _ref5$textOffset,
|
|
548
|
+
_ref5$opacity = _ref5.opacity,
|
|
549
|
+
opacity = _ref5$opacity === void 0 ? 1 : _ref5$opacity,
|
|
550
|
+
_ref5$strokeOpacity = _ref5.strokeOpacity,
|
|
551
|
+
strokeOpacity = _ref5$strokeOpacity === void 0 ? 1 : _ref5$strokeOpacity,
|
|
552
|
+
_ref5$strokeWidth = _ref5.strokeWidth,
|
|
553
|
+
strokeWidth = _ref5$strokeWidth === void 0 ? 0 : _ref5$strokeWidth,
|
|
554
|
+
_ref5$stroke = _ref5.stroke,
|
|
555
|
+
stroke = _ref5$stroke === void 0 ? '#000' : _ref5$stroke;
|
|
556
|
+
|
|
557
|
+
return {
|
|
558
|
+
fontWeight: fontWeight,
|
|
559
|
+
fontFamily: fontFamily,
|
|
560
|
+
textAllowOverlap: textAllowOverlap,
|
|
561
|
+
padding: padding,
|
|
562
|
+
textAnchor: textAnchor,
|
|
563
|
+
textOffset: textOffset,
|
|
564
|
+
opacity: opacity,
|
|
565
|
+
strokeOpacity: strokeOpacity,
|
|
566
|
+
strokeWidth: strokeWidth,
|
|
567
|
+
stroke: stroke
|
|
568
|
+
};
|
|
569
|
+
}
|
|
551
570
|
/**
|
|
552
571
|
* 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
|
|
553
572
|
*/
|
|
@@ -560,12 +579,12 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
560
579
|
// 更新文字布局
|
|
561
580
|
var mapping = this.fontService.mapping;
|
|
562
581
|
|
|
563
|
-
var
|
|
564
|
-
|
|
565
|
-
spacing =
|
|
566
|
-
|
|
567
|
-
textAnchor =
|
|
568
|
-
textOffset =
|
|
582
|
+
var _ref6 = this.layer.getLayerConfig(),
|
|
583
|
+
_ref6$spacing = _ref6.spacing,
|
|
584
|
+
spacing = _ref6$spacing === void 0 ? 2 : _ref6$spacing,
|
|
585
|
+
_ref6$textAnchor = _ref6.textAnchor,
|
|
586
|
+
textAnchor = _ref6$textAnchor === void 0 ? 'center' : _ref6$textAnchor,
|
|
587
|
+
textOffset = _ref6.textOffset;
|
|
569
588
|
|
|
570
589
|
var data = this.layer.getEncodedData();
|
|
571
590
|
this.glyphInfo = data.map(function (feature) {
|
|
@@ -600,15 +619,14 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
600
619
|
value: function filterGlyphs() {
|
|
601
620
|
var _this3 = this;
|
|
602
621
|
|
|
603
|
-
var
|
|
604
|
-
|
|
605
|
-
padding =
|
|
606
|
-
|
|
607
|
-
textAllowOverlap =
|
|
622
|
+
var _ref7 = this.layer.getLayerConfig(),
|
|
623
|
+
_ref7$padding = _ref7.padding,
|
|
624
|
+
padding = _ref7$padding === void 0 ? [0, 0] : _ref7$padding,
|
|
625
|
+
_ref7$textAllowOverla = _ref7.textAllowOverlap,
|
|
626
|
+
textAllowOverlap = _ref7$textAllowOverla === void 0 ? false : _ref7$textAllowOverla;
|
|
608
627
|
|
|
609
628
|
if (textAllowOverlap) {
|
|
610
629
|
// 如果允许文本覆盖
|
|
611
|
-
// this.layer.setEncodedData(this.glyphInfo);
|
|
612
630
|
return;
|
|
613
631
|
}
|
|
614
632
|
|
|
@@ -667,8 +685,7 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
667
685
|
iconfont = _this$layer$getLayerC2 === void 0 ? false : _this$layer$getLayerC2; // 1.生成文字纹理(或是生成 iconfont)
|
|
668
686
|
|
|
669
687
|
|
|
670
|
-
iconfont ? this.initIconFontTex() : this.initTextFont(); //
|
|
671
|
-
// 2.生成文字布局
|
|
688
|
+
iconfont ? this.initIconFontTex() : this.initTextFont(); // 2.生成文字布局
|
|
672
689
|
|
|
673
690
|
this.generateGlyphLayout(iconfont);
|
|
674
691
|
}
|
|
@@ -699,13 +716,13 @@ var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
699
716
|
key: "reBuildModel",
|
|
700
717
|
value: function () {
|
|
701
718
|
var _reBuildModel = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
702
|
-
var
|
|
719
|
+
var _ref8, _ref8$mask, mask, _ref8$maskInside, maskInside, model;
|
|
703
720
|
|
|
704
721
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
705
722
|
while (1) {
|
|
706
723
|
switch (_context5.prev = _context5.next) {
|
|
707
724
|
case 0:
|
|
708
|
-
|
|
725
|
+
_ref8 = this.layer.getLayerConfig(), _ref8$mask = _ref8.mask, mask = _ref8$mask === void 0 ? false : _ref8$mask, _ref8$maskInside = _ref8.maskInside, maskInside = _ref8$maskInside === void 0 ? true : _ref8$maskInside;
|
|
709
726
|
this.filterGlyphs();
|
|
710
727
|
_context5.next = 4;
|
|
711
728
|
return this.layer.buildLayerModel({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.5",
|
|
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.13.
|
|
31
|
-
"@antv/l7-maps": "2.13.
|
|
32
|
-
"@antv/l7-source": "2.13.
|
|
33
|
-
"@antv/l7-utils": "2.13.
|
|
30
|
+
"@antv/l7-core": "2.13.5",
|
|
31
|
+
"@antv/l7-maps": "2.13.5",
|
|
32
|
+
"@antv/l7-source": "2.13.5",
|
|
33
|
+
"@antv/l7-utils": "2.13.5",
|
|
34
34
|
"@babel/runtime": "^7.7.7",
|
|
35
35
|
"@mapbox/martini": "^0.2.0",
|
|
36
36
|
"@turf/clone": "^6.5.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@types/gl-matrix": "^2.4.5",
|
|
62
62
|
"@types/lodash": "^4.14.138"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "0b3af09f76cb5e7ee27b495678ad4833fdb53434",
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
}
|