@antv/l7-layers 2.9.26-alpha.2 → 2.9.26
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/core/BaseLayer.d.ts +4 -0
- package/es/image/models/image.js +1 -1
- package/es/index.d.ts +2 -1
- package/es/index.js +3 -2
- package/es/line/index.d.ts +17 -0
- package/es/line/index.js +18 -0
- package/es/mask/index.d.ts +8 -0
- package/es/plugins/DataSourcePlugin.js +4 -10
- package/es/plugins/FeatureScalePlugin.d.ts +1 -0
- package/es/plugins/FeatureScalePlugin.js +80 -24
- package/es/point/index.d.ts +11 -1
- package/es/point/index.js +13 -3
- package/es/point/models/index.d.ts +1 -1
- package/es/point/models/index.js +2 -0
- package/es/point/models/tileText.d.ts +56 -0
- package/es/point/models/tileText.js +598 -0
- package/es/polygon/index.d.ts +8 -0
- package/es/tile/manager/tileLayerManager.d.ts +1 -0
- package/es/tile/manager/tileLayerManager.js +12 -1
- package/es/tile/models/tileModel.d.ts +1 -1
- package/es/tile/models/tileModel.js +8 -8
- package/es/tile/tileFactory/base.d.ts +1 -1
- package/es/tile/tileFactory/index.d.ts +1 -1
- package/es/tile/tileFactory/index.js +4 -0
- package/es/tile/tileFactory/test.d.ts +12 -0
- package/es/tile/tileFactory/test.js +82 -0
- package/es/tile/tileFactory/vectorLayer.d.ts +1 -1
- package/es/tile/tileFactory/vectorLayer.js +1 -1
- package/es/tile/tileTest.d.ts +14 -0
- package/es/tile/tileTest.js +63 -0
- package/es/tile/utils.js +1 -1
- package/lib/image/models/image.js +1 -1
- package/lib/index.js +10 -1
- package/lib/line/index.js +17 -0
- package/lib/plugins/DataSourcePlugin.js +4 -16
- package/lib/plugins/FeatureScalePlugin.js +80 -24
- package/lib/point/index.js +12 -3
- package/lib/point/models/index.js +3 -0
- package/lib/point/models/tileText.js +613 -0
- package/lib/tile/manager/tileLayerManager.js +12 -1
- package/lib/tile/models/tileModel.js +8 -8
- package/lib/tile/tileFactory/index.js +5 -0
- package/lib/tile/tileFactory/test.js +95 -0
- package/lib/tile/tileFactory/vectorLayer.js +2 -2
- package/lib/tile/tileTest.js +75 -0
- package/lib/tile/utils.js +1 -1
- package/package.json +6 -7
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
10
|
+
|
|
11
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
12
|
+
|
|
13
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
+
|
|
15
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
16
|
+
|
|
17
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
18
|
+
|
|
19
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
20
|
+
|
|
21
|
+
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; } }
|
|
22
|
+
|
|
23
|
+
import { AttributeType, gl } from '@antv/l7-core';
|
|
24
|
+
import { calculateCentroid, getMask, padBounds } from '@antv/l7-utils';
|
|
25
|
+
import { isNumber } from 'lodash';
|
|
26
|
+
import BaseModel from "../../core/BaseModel";
|
|
27
|
+
import CollisionIndex from "../../utils/collision-index";
|
|
28
|
+
import { getGlyphQuads, shapeText } from "../../utils/symbol-layout";
|
|
29
|
+
|
|
30
|
+
/* babel-plugin-inline-import '../shaders/text_frag.glsl' */
|
|
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 gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
32
|
+
|
|
33
|
+
/* babel-plugin-inline-import '../shaders/text_vert.glsl' */
|
|
34
|
+
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";
|
|
35
|
+
export function TextTriangulation(feature) {
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
var that = this;
|
|
38
|
+
var id = feature.id;
|
|
39
|
+
var vertices = [];
|
|
40
|
+
var indices = [];
|
|
41
|
+
|
|
42
|
+
if (!that.glyphInfoMap || !that.glyphInfoMap[id]) {
|
|
43
|
+
return {
|
|
44
|
+
vertices: [],
|
|
45
|
+
// [ x, y, z, tex.x,tex.y, offset.x. offset.y]
|
|
46
|
+
indices: [],
|
|
47
|
+
size: 7
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var centroid = that.glyphInfoMap[id].centroid; // 计算中心点
|
|
52
|
+
|
|
53
|
+
var coord = centroid.length === 2 ? [centroid[0], centroid[1], 0] : centroid;
|
|
54
|
+
that.glyphInfoMap[id].glyphQuads.forEach(function (quad, index) {
|
|
55
|
+
vertices.push.apply(vertices, _toConsumableArray(coord).concat([quad.tex.x, quad.tex.y + quad.tex.height, quad.tl.x, quad.tl.y], _toConsumableArray(coord), [quad.tex.x + quad.tex.width, quad.tex.y + quad.tex.height, quad.tr.x, quad.tr.y], _toConsumableArray(coord), [quad.tex.x + quad.tex.width, quad.tex.y, quad.br.x, quad.br.y], _toConsumableArray(coord), [quad.tex.x, quad.tex.y, quad.bl.x, quad.bl.y]));
|
|
56
|
+
indices.push(0 + index * 4, 1 + index * 4, 2 + index * 4, 2 + index * 4, 3 + index * 4, 0 + index * 4);
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
vertices: vertices,
|
|
60
|
+
// [ x, y, z, tex.x,tex.y, offset.x. offset.y]
|
|
61
|
+
indices: indices,
|
|
62
|
+
size: 7
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
var TextModel = /*#__PURE__*/function (_BaseModel) {
|
|
67
|
+
_inherits(TextModel, _BaseModel);
|
|
68
|
+
|
|
69
|
+
var _super = _createSuper(TextModel);
|
|
70
|
+
|
|
71
|
+
function TextModel() {
|
|
72
|
+
var _this;
|
|
73
|
+
|
|
74
|
+
_classCallCheck(this, TextModel);
|
|
75
|
+
|
|
76
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
77
|
+
args[_key] = arguments[_key];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
81
|
+
|
|
82
|
+
_defineProperty(_assertThisInitialized(_this), "glyphInfoMap", {});
|
|
83
|
+
|
|
84
|
+
_defineProperty(_assertThisInitialized(_this), "currentZoom", -1);
|
|
85
|
+
|
|
86
|
+
_defineProperty(_assertThisInitialized(_this), "textureHeight", 0);
|
|
87
|
+
|
|
88
|
+
_defineProperty(_assertThisInitialized(_this), "textCount", 0);
|
|
89
|
+
|
|
90
|
+
_defineProperty(_assertThisInitialized(_this), "preTextStyle", {});
|
|
91
|
+
|
|
92
|
+
_defineProperty(_assertThisInitialized(_this), "buildModels", /*#__PURE__*/function () {
|
|
93
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(callbackModel) {
|
|
94
|
+
var _ref2, _ref2$mask, mask, _ref2$maskInside, maskInside;
|
|
95
|
+
|
|
96
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
97
|
+
while (1) {
|
|
98
|
+
switch (_context.prev = _context.next) {
|
|
99
|
+
case 0:
|
|
100
|
+
_ref2 = _this.layer.getLayerConfig(), _ref2$mask = _ref2.mask, mask = _ref2$mask === void 0 ? false : _ref2$mask, _ref2$maskInside = _ref2.maskInside, maskInside = _ref2$maskInside === void 0 ? true : _ref2$maskInside;
|
|
101
|
+
|
|
102
|
+
_this.mapping();
|
|
103
|
+
|
|
104
|
+
_this.layer.buildLayerModel({
|
|
105
|
+
moduleName: 'pointText',
|
|
106
|
+
vertexShader: textVert,
|
|
107
|
+
fragmentShader: textFrag,
|
|
108
|
+
triangulation: TextTriangulation.bind(_assertThisInitialized(_this)),
|
|
109
|
+
depth: {
|
|
110
|
+
enable: false
|
|
111
|
+
},
|
|
112
|
+
blend: _this.getBlend(),
|
|
113
|
+
stencil: getMask(mask, maskInside)
|
|
114
|
+
}).then(function (model) {
|
|
115
|
+
callbackModel([model]);
|
|
116
|
+
}).catch(function (err) {
|
|
117
|
+
console.warn(err);
|
|
118
|
+
callbackModel([]);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
case 3:
|
|
122
|
+
case "end":
|
|
123
|
+
return _context.stop();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}, _callee);
|
|
127
|
+
}));
|
|
128
|
+
|
|
129
|
+
return function (_x) {
|
|
130
|
+
return _ref.apply(this, arguments);
|
|
131
|
+
};
|
|
132
|
+
}());
|
|
133
|
+
|
|
134
|
+
_defineProperty(_assertThisInitialized(_this), "mapping", function () {
|
|
135
|
+
_this.initGlyph();
|
|
136
|
+
|
|
137
|
+
_this.updateTexture();
|
|
138
|
+
|
|
139
|
+
_this.filterGlyphs();
|
|
140
|
+
|
|
141
|
+
_this.reBuildModel();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return _this;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
_createClass(TextModel, [{
|
|
148
|
+
key: "getUninforms",
|
|
149
|
+
value: function getUninforms() {
|
|
150
|
+
var _ref3 = this.layer.getLayerConfig(),
|
|
151
|
+
_ref3$opacity = _ref3.opacity,
|
|
152
|
+
opacity = _ref3$opacity === void 0 ? 1.0 : _ref3$opacity,
|
|
153
|
+
_ref3$stroke = _ref3.stroke,
|
|
154
|
+
stroke = _ref3$stroke === void 0 ? '#fff' : _ref3$stroke,
|
|
155
|
+
_ref3$strokeWidth = _ref3.strokeWidth,
|
|
156
|
+
strokeWidth = _ref3$strokeWidth === void 0 ? 0 : _ref3$strokeWidth,
|
|
157
|
+
_ref3$textAnchor = _ref3.textAnchor,
|
|
158
|
+
textAnchor = _ref3$textAnchor === void 0 ? 'center' : _ref3$textAnchor,
|
|
159
|
+
_ref3$textAllowOverla = _ref3.textAllowOverlap,
|
|
160
|
+
textAllowOverlap = _ref3$textAllowOverla === void 0 ? false : _ref3$textAllowOverla,
|
|
161
|
+
_ref3$halo = _ref3.halo,
|
|
162
|
+
halo = _ref3$halo === void 0 ? 0.5 : _ref3$halo,
|
|
163
|
+
_ref3$gamma = _ref3.gamma,
|
|
164
|
+
gamma = _ref3$gamma === void 0 ? 2.0 : _ref3$gamma,
|
|
165
|
+
_ref3$raisingHeight = _ref3.raisingHeight,
|
|
166
|
+
raisingHeight = _ref3$raisingHeight === void 0 ? 0 : _ref3$raisingHeight;
|
|
167
|
+
|
|
168
|
+
var _this$fontService = this.fontService,
|
|
169
|
+
canvas = _this$fontService.canvas,
|
|
170
|
+
mapping = _this$fontService.mapping;
|
|
171
|
+
|
|
172
|
+
if (Object.keys(mapping).length !== this.textCount) {
|
|
173
|
+
this.updateTexture();
|
|
174
|
+
this.textCount = Object.keys(mapping).length;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
this.preTextStyle = {
|
|
178
|
+
textAnchor: textAnchor,
|
|
179
|
+
textAllowOverlap: textAllowOverlap
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
183
|
+
opacity: opacity,
|
|
184
|
+
strokeWidth: strokeWidth,
|
|
185
|
+
stroke: stroke
|
|
186
|
+
})) {
|
|
187
|
+
this.judgeStyleAttributes({
|
|
188
|
+
opacity: opacity,
|
|
189
|
+
strokeWidth: strokeWidth,
|
|
190
|
+
stroke: stroke
|
|
191
|
+
});
|
|
192
|
+
var encodeData = this.layer.getEncodedData();
|
|
193
|
+
|
|
194
|
+
var _this$calDataFrame = this.calDataFrame(this.cellLength, encodeData, this.cellProperties),
|
|
195
|
+
data = _this$calDataFrame.data,
|
|
196
|
+
width = _this$calDataFrame.width,
|
|
197
|
+
height = _this$calDataFrame.height;
|
|
198
|
+
|
|
199
|
+
this.rowCount = height; // 当前数据纹理有多少行
|
|
200
|
+
|
|
201
|
+
this.dataTexture = this.cellLength > 0 && data.length > 0 ? this.createTexture2D({
|
|
202
|
+
flipY: true,
|
|
203
|
+
data: data,
|
|
204
|
+
format: gl.LUMINANCE,
|
|
205
|
+
type: gl.FLOAT,
|
|
206
|
+
width: width,
|
|
207
|
+
height: height
|
|
208
|
+
}) : this.createTexture2D({
|
|
209
|
+
flipY: true,
|
|
210
|
+
data: [1],
|
|
211
|
+
format: gl.LUMINANCE,
|
|
212
|
+
type: gl.FLOAT,
|
|
213
|
+
width: 1,
|
|
214
|
+
height: 1
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
u_dataTexture: this.dataTexture,
|
|
220
|
+
// 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]
|
|
221
|
+
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
222
|
+
u_raisingHeight: Number(raisingHeight),
|
|
223
|
+
u_opacity: isNumber(opacity) ? opacity : 1.0,
|
|
224
|
+
u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 1.0,
|
|
225
|
+
u_stroke_color: this.getStrokeColor(stroke),
|
|
226
|
+
u_sdf_map: this.texture,
|
|
227
|
+
u_halo_blur: halo,
|
|
228
|
+
u_gamma_scale: gamma,
|
|
229
|
+
u_sdf_map_size: [canvas.width, canvas.height]
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
}, {
|
|
233
|
+
key: "initModels",
|
|
234
|
+
value: function initModels(callbackModel) {
|
|
235
|
+
this.layer.on('remapping', this.mapping);
|
|
236
|
+
this.extent = this.textExtent();
|
|
237
|
+
|
|
238
|
+
var _ref4 = this.layer.getLayerConfig(),
|
|
239
|
+
_ref4$textAnchor = _ref4.textAnchor,
|
|
240
|
+
textAnchor = _ref4$textAnchor === void 0 ? 'center' : _ref4$textAnchor,
|
|
241
|
+
_ref4$textAllowOverla = _ref4.textAllowOverlap,
|
|
242
|
+
textAllowOverlap = _ref4$textAllowOverla === void 0 ? true : _ref4$textAllowOverla;
|
|
243
|
+
|
|
244
|
+
this.preTextStyle = {
|
|
245
|
+
textAnchor: textAnchor,
|
|
246
|
+
textAllowOverlap: textAllowOverlap
|
|
247
|
+
};
|
|
248
|
+
this.buildModels(callbackModel);
|
|
249
|
+
}
|
|
250
|
+
}, {
|
|
251
|
+
key: "clearModels",
|
|
252
|
+
value: function clearModels() {
|
|
253
|
+
var _this$texture, _this$dataTexture;
|
|
254
|
+
|
|
255
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
256
|
+
(_this$dataTexture = this.dataTexture) === null || _this$dataTexture === void 0 ? void 0 : _this$dataTexture.destroy();
|
|
257
|
+
this.layer.off('remapping', this.mapping);
|
|
258
|
+
}
|
|
259
|
+
}, {
|
|
260
|
+
key: "registerBuiltinAttributes",
|
|
261
|
+
value: function registerBuiltinAttributes() {
|
|
262
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
263
|
+
name: 'rotate',
|
|
264
|
+
type: AttributeType.Attribute,
|
|
265
|
+
descriptor: {
|
|
266
|
+
name: 'a_Rotate',
|
|
267
|
+
buffer: {
|
|
268
|
+
usage: gl.DYNAMIC_DRAW,
|
|
269
|
+
data: [],
|
|
270
|
+
type: gl.FLOAT
|
|
271
|
+
},
|
|
272
|
+
size: 1,
|
|
273
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
274
|
+
var _feature$rotate = feature.rotate,
|
|
275
|
+
rotate = _feature$rotate === void 0 ? 0 : _feature$rotate;
|
|
276
|
+
return Array.isArray(rotate) ? [rotate[0]] : [rotate];
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
281
|
+
name: 'textOffsets',
|
|
282
|
+
type: AttributeType.Attribute,
|
|
283
|
+
descriptor: {
|
|
284
|
+
name: 'a_textOffsets',
|
|
285
|
+
buffer: {
|
|
286
|
+
// give the WebGL driver a hint that this buffer may change
|
|
287
|
+
usage: gl.STATIC_DRAW,
|
|
288
|
+
data: [],
|
|
289
|
+
type: gl.FLOAT
|
|
290
|
+
},
|
|
291
|
+
size: 2,
|
|
292
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
293
|
+
return [vertex[5], vertex[6]];
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}); // point layer size;
|
|
297
|
+
|
|
298
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
299
|
+
name: 'size',
|
|
300
|
+
type: AttributeType.Attribute,
|
|
301
|
+
descriptor: {
|
|
302
|
+
name: 'a_Size',
|
|
303
|
+
buffer: {
|
|
304
|
+
// give the WebGL driver a hint that this buffer may change
|
|
305
|
+
usage: gl.DYNAMIC_DRAW,
|
|
306
|
+
data: [],
|
|
307
|
+
type: gl.FLOAT
|
|
308
|
+
},
|
|
309
|
+
size: 1,
|
|
310
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
311
|
+
var _feature$size = feature.size,
|
|
312
|
+
size = _feature$size === void 0 ? 12 : _feature$size;
|
|
313
|
+
return Array.isArray(size) ? [size[0]] : [size];
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}); // point layer size;
|
|
317
|
+
|
|
318
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
319
|
+
name: 'textUv',
|
|
320
|
+
type: AttributeType.Attribute,
|
|
321
|
+
descriptor: {
|
|
322
|
+
name: 'a_tex',
|
|
323
|
+
buffer: {
|
|
324
|
+
// give the WebGL driver a hint that this buffer may change
|
|
325
|
+
usage: gl.DYNAMIC_DRAW,
|
|
326
|
+
data: [],
|
|
327
|
+
type: gl.FLOAT
|
|
328
|
+
},
|
|
329
|
+
size: 2,
|
|
330
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
331
|
+
return [vertex[3], vertex[4]];
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}, {
|
|
337
|
+
key: "textExtent",
|
|
338
|
+
value: function textExtent() {
|
|
339
|
+
var bounds = this.mapService.getBounds();
|
|
340
|
+
return padBounds(bounds, 0.5);
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* 生成文字纹理(生成文字纹理字典)
|
|
344
|
+
*/
|
|
345
|
+
|
|
346
|
+
}, {
|
|
347
|
+
key: "initTextFont",
|
|
348
|
+
value: function initTextFont() {
|
|
349
|
+
var _ref5 = this.layer.getLayerConfig(),
|
|
350
|
+
_ref5$fontWeight = _ref5.fontWeight,
|
|
351
|
+
fontWeight = _ref5$fontWeight === void 0 ? '400' : _ref5$fontWeight,
|
|
352
|
+
_ref5$fontFamily = _ref5.fontFamily,
|
|
353
|
+
fontFamily = _ref5$fontFamily === void 0 ? 'sans-serif' : _ref5$fontFamily;
|
|
354
|
+
|
|
355
|
+
var data = this.layer.getEncodedData();
|
|
356
|
+
var characterSet = [];
|
|
357
|
+
data.forEach(function (item) {
|
|
358
|
+
var _item$shape = item.shape,
|
|
359
|
+
shape = _item$shape === void 0 ? '' : _item$shape;
|
|
360
|
+
shape = shape.toString();
|
|
361
|
+
|
|
362
|
+
var _iterator = _createForOfIteratorHelper(shape),
|
|
363
|
+
_step;
|
|
364
|
+
|
|
365
|
+
try {
|
|
366
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
367
|
+
var char = _step.value;
|
|
368
|
+
|
|
369
|
+
// 去重
|
|
370
|
+
if (characterSet.indexOf(char) === -1) {
|
|
371
|
+
characterSet.push(char);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
} catch (err) {
|
|
375
|
+
_iterator.e(err);
|
|
376
|
+
} finally {
|
|
377
|
+
_iterator.f();
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
this.fontService.setFontOptions({
|
|
381
|
+
characterSet: characterSet,
|
|
382
|
+
fontWeight: fontWeight,
|
|
383
|
+
fontFamily: fontFamily,
|
|
384
|
+
iconfont: false
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* 生成 iconfont 纹理字典
|
|
389
|
+
*/
|
|
390
|
+
|
|
391
|
+
}, {
|
|
392
|
+
key: "initIconFontTex",
|
|
393
|
+
value: function initIconFontTex() {
|
|
394
|
+
var _ref6 = this.layer.getLayerConfig(),
|
|
395
|
+
_ref6$fontWeight = _ref6.fontWeight,
|
|
396
|
+
fontWeight = _ref6$fontWeight === void 0 ? '400' : _ref6$fontWeight,
|
|
397
|
+
_ref6$fontFamily = _ref6.fontFamily,
|
|
398
|
+
fontFamily = _ref6$fontFamily === void 0 ? 'sans-serif' : _ref6$fontFamily;
|
|
399
|
+
|
|
400
|
+
var data = this.layer.getEncodedData();
|
|
401
|
+
var characterSet = [];
|
|
402
|
+
data.forEach(function (item) {
|
|
403
|
+
var _item$shape2 = item.shape,
|
|
404
|
+
shape = _item$shape2 === void 0 ? '' : _item$shape2;
|
|
405
|
+
shape = "".concat(shape);
|
|
406
|
+
|
|
407
|
+
if (characterSet.indexOf(shape) === -1) {
|
|
408
|
+
characterSet.push(shape);
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
this.fontService.setFontOptions({
|
|
412
|
+
characterSet: characterSet,
|
|
413
|
+
fontWeight: fontWeight,
|
|
414
|
+
fontFamily: fontFamily,
|
|
415
|
+
iconfont: true
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* 生成文字布局(对照文字纹理字典提取对应文字的位置很好信息)
|
|
420
|
+
*/
|
|
421
|
+
|
|
422
|
+
}, {
|
|
423
|
+
key: "generateGlyphLayout",
|
|
424
|
+
value: function generateGlyphLayout(iconfont) {
|
|
425
|
+
var _this2 = this;
|
|
426
|
+
|
|
427
|
+
// TODO:更新文字布局
|
|
428
|
+
var mapping = this.fontService.mapping;
|
|
429
|
+
|
|
430
|
+
var _ref7 = this.layer.getLayerConfig(),
|
|
431
|
+
_ref7$spacing = _ref7.spacing,
|
|
432
|
+
spacing = _ref7$spacing === void 0 ? 2 : _ref7$spacing,
|
|
433
|
+
_ref7$textAnchor = _ref7.textAnchor,
|
|
434
|
+
textAnchor = _ref7$textAnchor === void 0 ? 'center' : _ref7$textAnchor;
|
|
435
|
+
|
|
436
|
+
var data = this.layer.getEncodedData();
|
|
437
|
+
this.glyphInfo = data.map(function (feature) {
|
|
438
|
+
var _feature$shape = feature.shape,
|
|
439
|
+
shape = _feature$shape === void 0 ? '' : _feature$shape,
|
|
440
|
+
id = feature.id,
|
|
441
|
+
_feature$size2 = feature.size,
|
|
442
|
+
size = _feature$size2 === void 0 ? 1 : _feature$size2,
|
|
443
|
+
_feature$textOffset = feature.textOffset,
|
|
444
|
+
textOffset = _feature$textOffset === void 0 ? [0, 0] : _feature$textOffset;
|
|
445
|
+
var shaping = shapeText(shape.toString(), mapping, // @ts-ignore
|
|
446
|
+
size, textAnchor, 'left', spacing, textOffset, iconfont);
|
|
447
|
+
var glyphQuads = getGlyphQuads(shaping, textOffset, false);
|
|
448
|
+
feature.shaping = shaping;
|
|
449
|
+
feature.glyphQuads = glyphQuads;
|
|
450
|
+
feature.centroid = calculateCentroid(feature.coordinates); // 此时地图高德2.0 originCentroid == centroid
|
|
451
|
+
|
|
452
|
+
feature.originCentroid = feature.version === 'GAODE2.x' ? calculateCentroid(feature.originCoordinates) : feature.originCentroid = feature.centroid;
|
|
453
|
+
_this2.glyphInfoMap[id] = {
|
|
454
|
+
shaping: shaping,
|
|
455
|
+
glyphQuads: glyphQuads,
|
|
456
|
+
centroid: calculateCentroid(feature.coordinates)
|
|
457
|
+
};
|
|
458
|
+
return feature;
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* 文字避让 depend on originCentorid
|
|
463
|
+
*/
|
|
464
|
+
|
|
465
|
+
}, {
|
|
466
|
+
key: "filterGlyphs",
|
|
467
|
+
value: function filterGlyphs() {
|
|
468
|
+
var _this3 = this;
|
|
469
|
+
|
|
470
|
+
var _ref8 = this.layer.getLayerConfig(),
|
|
471
|
+
_ref8$padding = _ref8.padding,
|
|
472
|
+
padding = _ref8$padding === void 0 ? [4, 4] : _ref8$padding,
|
|
473
|
+
_ref8$textAllowOverla = _ref8.textAllowOverlap,
|
|
474
|
+
textAllowOverlap = _ref8$textAllowOverla === void 0 ? false : _ref8$textAllowOverla;
|
|
475
|
+
|
|
476
|
+
if (textAllowOverlap) {
|
|
477
|
+
// 如果允许文本覆盖
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
this.glyphInfoMap = {};
|
|
482
|
+
this.currentZoom = this.mapService.getZoom();
|
|
483
|
+
this.extent = this.textExtent();
|
|
484
|
+
|
|
485
|
+
var _this$rendererService = this.rendererService.getViewportSize(),
|
|
486
|
+
width = _this$rendererService.width,
|
|
487
|
+
height = _this$rendererService.height;
|
|
488
|
+
|
|
489
|
+
var collisionIndex = new CollisionIndex(width, height);
|
|
490
|
+
var filterData = this.glyphInfo.filter(function (feature) {
|
|
491
|
+
var shaping = feature.shaping,
|
|
492
|
+
_feature$id = feature.id,
|
|
493
|
+
id = _feature$id === void 0 ? 0 : _feature$id;
|
|
494
|
+
var centroid = feature.version === 'GAODE2.x' ? feature.originCentroid : feature.centroid;
|
|
495
|
+
var size = feature.size;
|
|
496
|
+
var fontScale = size / 24;
|
|
497
|
+
|
|
498
|
+
var pixels = _this3.mapService.lngLatToContainer(centroid);
|
|
499
|
+
|
|
500
|
+
var _collisionIndex$place = collisionIndex.placeCollisionBox({
|
|
501
|
+
x1: shaping.left * fontScale - padding[0],
|
|
502
|
+
x2: shaping.right * fontScale + padding[0],
|
|
503
|
+
y1: shaping.top * fontScale - padding[1],
|
|
504
|
+
y2: shaping.bottom * fontScale + padding[1],
|
|
505
|
+
anchorPointX: pixels.x,
|
|
506
|
+
anchorPointY: pixels.y
|
|
507
|
+
}),
|
|
508
|
+
box = _collisionIndex$place.box;
|
|
509
|
+
|
|
510
|
+
if (box && box.length) {
|
|
511
|
+
// TODO:featureIndex
|
|
512
|
+
collisionIndex.insertCollisionBox(box, id);
|
|
513
|
+
return true;
|
|
514
|
+
} else {
|
|
515
|
+
return false;
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
filterData.forEach(function (item) {
|
|
519
|
+
// @ts-ignore
|
|
520
|
+
_this3.glyphInfoMap[item.id] = item;
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* 初始化文字布局
|
|
525
|
+
*/
|
|
526
|
+
|
|
527
|
+
}, {
|
|
528
|
+
key: "initGlyph",
|
|
529
|
+
value: function initGlyph() {
|
|
530
|
+
var _this$layer$getLayerC = this.layer.getLayerConfig(),
|
|
531
|
+
_this$layer$getLayerC2 = _this$layer$getLayerC.iconfont,
|
|
532
|
+
iconfont = _this$layer$getLayerC2 === void 0 ? false : _this$layer$getLayerC2; // 1.生成文字纹理(或是生成 iconfont)
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
iconfont ? this.initIconFontTex() : this.initTextFont(); // 2.生成文字布局
|
|
536
|
+
|
|
537
|
+
this.generateGlyphLayout(iconfont);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* 更新文字纹理
|
|
541
|
+
*/
|
|
542
|
+
|
|
543
|
+
}, {
|
|
544
|
+
key: "updateTexture",
|
|
545
|
+
value: function updateTexture() {
|
|
546
|
+
var createTexture2D = this.rendererService.createTexture2D;
|
|
547
|
+
var canvas = this.fontService.canvas;
|
|
548
|
+
this.textureHeight = canvas.height;
|
|
549
|
+
|
|
550
|
+
if (this.texture) {
|
|
551
|
+
this.texture.destroy();
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
this.texture = createTexture2D({
|
|
555
|
+
data: canvas,
|
|
556
|
+
mag: gl.LINEAR,
|
|
557
|
+
min: gl.LINEAR,
|
|
558
|
+
width: canvas.width,
|
|
559
|
+
height: canvas.height
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
}, {
|
|
563
|
+
key: "reBuildModel",
|
|
564
|
+
value: function reBuildModel() {
|
|
565
|
+
var _this4 = this;
|
|
566
|
+
|
|
567
|
+
var _ref9 = this.layer.getLayerConfig(),
|
|
568
|
+
_ref9$mask = _ref9.mask,
|
|
569
|
+
mask = _ref9$mask === void 0 ? false : _ref9$mask,
|
|
570
|
+
_ref9$maskInside = _ref9.maskInside,
|
|
571
|
+
maskInside = _ref9$maskInside === void 0 ? true : _ref9$maskInside;
|
|
572
|
+
|
|
573
|
+
this.filterGlyphs();
|
|
574
|
+
this.layer.buildLayerModel({
|
|
575
|
+
moduleName: 'pointTileText',
|
|
576
|
+
vertexShader: textVert,
|
|
577
|
+
fragmentShader: textFrag,
|
|
578
|
+
triangulation: TextTriangulation.bind(this),
|
|
579
|
+
depth: {
|
|
580
|
+
enable: false
|
|
581
|
+
},
|
|
582
|
+
blend: this.getBlend(),
|
|
583
|
+
stencil: getMask(mask, maskInside)
|
|
584
|
+
}).then(function (model) {
|
|
585
|
+
_this4.layer.models = [model];
|
|
586
|
+
|
|
587
|
+
_this4.layer.renderLayers();
|
|
588
|
+
}).catch(function (err) {
|
|
589
|
+
console.warn(err);
|
|
590
|
+
_this4.layer.models = [];
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
}]);
|
|
594
|
+
|
|
595
|
+
return TextModel;
|
|
596
|
+
}(BaseModel);
|
|
597
|
+
|
|
598
|
+
export { TextModel as default };
|
package/es/polygon/index.d.ts
CHANGED
|
@@ -3,6 +3,14 @@ import { IPolygonLayerStyleOptions } from '../core/interface';
|
|
|
3
3
|
import { PolygonModelType } from './models/';
|
|
4
4
|
export default class PolygonLayer extends BaseLayer<IPolygonLayerStyleOptions> {
|
|
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(): {
|
|
@@ -30,6 +30,7 @@ export declare class TileLayerManager implements ITileLayerManager {
|
|
|
30
30
|
render(): void;
|
|
31
31
|
pickLayers(target: IInteractionTarget): boolean;
|
|
32
32
|
private setSubLayerInitOptipn;
|
|
33
|
+
private getSourceLayer;
|
|
33
34
|
private setConfigListener;
|
|
34
35
|
private updateStyle;
|
|
35
36
|
private initTileFactory;
|
|
@@ -187,7 +187,7 @@ export var TileLayerManager = /*#__PURE__*/function () {
|
|
|
187
187
|
shape: layerShape,
|
|
188
188
|
zIndex: zIndex,
|
|
189
189
|
opacity: opacity,
|
|
190
|
-
sourceLayer: parentParserType
|
|
190
|
+
sourceLayer: this.getSourceLayer(parentParserType, sourceLayer),
|
|
191
191
|
coords: coords,
|
|
192
192
|
featureId: featureId,
|
|
193
193
|
color: colorValue,
|
|
@@ -211,6 +211,17 @@ export var TileLayerManager = /*#__PURE__*/function () {
|
|
|
211
211
|
pixelConstantRGB: pixelConstantRGB
|
|
212
212
|
};
|
|
213
213
|
}
|
|
214
|
+
}, {
|
|
215
|
+
key: "getSourceLayer",
|
|
216
|
+
value: function getSourceLayer(parentParserType, sourceLayer) {
|
|
217
|
+
if (parentParserType === 'geojsonvt') {
|
|
218
|
+
return 'geojsonvt';
|
|
219
|
+
} else if (parentParserType === 'testTile') {
|
|
220
|
+
return 'testTile';
|
|
221
|
+
} else {
|
|
222
|
+
return sourceLayer;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
214
225
|
}, {
|
|
215
226
|
key: "setConfigListener",
|
|
216
227
|
value: function setConfigListener() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IModelUniform } from '@antv/l7-core';
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
|
-
export default class
|
|
3
|
+
export default class TileModel extends BaseModel {
|
|
4
4
|
getUninforms(): IModelUniform;
|
|
5
5
|
initModels(): never[];
|
|
6
6
|
buildModels(): never[];
|