(layerInfo, features)
| 1314 | } |
| 1315 | |
| 1316 | _createRankSymbolLayer(layerInfo, features) { |
| 1317 | const { minzoom, maxzoom } = layerInfo; |
| 1318 | const fieldName = layerInfo.themeSetting.themeField; |
| 1319 | const colors = layerInfo.themeSetting.colors; |
| 1320 | const style = layerInfo.style; |
| 1321 | const featureType = layerInfo.featureType; |
| 1322 | const styleSource = this.createRankStyleSource(layerInfo, features); |
| 1323 | const styleGroups = styleSource.styleGroups; |
| 1324 | features = this.getFilterFeatures(layerInfo.filterCondition, features); |
| 1325 | // 获取 expression |
| 1326 | const expression = ['match', ['get', 'index']]; |
| 1327 | const colorExpression = ['match', ['get', 'index']]; |
| 1328 | for (let index = 0; index < features.length; index++) { |
| 1329 | const row = features[index]; |
| 1330 | const tartget = parseFloat(row.properties[fieldName]); |
| 1331 | if (styleGroups) { |
| 1332 | for (let i = 0; i < styleGroups.length; i++) { |
| 1333 | if (styleGroups[i].start <= tartget && tartget < styleGroups[i].end) { |
| 1334 | const radius = |
| 1335 | style.type === 'SYMBOL_POINT' || style.type === 'IMAGE_POINT' |
| 1336 | ? style.type === 'SYMBOL_POINT' |
| 1337 | ? styleGroups[i].radius * 2 |
| 1338 | : Number.parseFloat((styleGroups[i].radius / style.imageInfo.size.h).toFixed(2)) * 2 |
| 1339 | : styleGroups[i].radius; |
| 1340 | expression.push(row.properties.index, radius); |
| 1341 | colorExpression.push(row.properties.index, styleGroups[i].color); |
| 1342 | break; |
| 1343 | } |
| 1344 | } |
| 1345 | } |
| 1346 | } |
| 1347 | expression.push(1); |
| 1348 | colorExpression.push('rgba(0, 0, 0, 0)'); |
| 1349 | // 图例处理 |
| 1350 | this._initLegendConfigInfo(layerInfo, styleGroups); |
| 1351 | if (colors && colors.length > 0) { |
| 1352 | style.fillColor = colorExpression; |
| 1353 | } |
| 1354 | if (style.type === 'SYMBOL_POINT') { |
| 1355 | this._createSymbolLayer(layerInfo, features, expression); |
| 1356 | } else if (['SVG_POINT', 'IMAGE_POINT'].includes(style.type)) { |
| 1357 | this._createGraphicLayer(layerInfo, features, expression); |
| 1358 | } else { |
| 1359 | const source = { |
| 1360 | type: 'geojson', |
| 1361 | data: { |
| 1362 | type: 'FeatureCollection', |
| 1363 | features: features |
| 1364 | } |
| 1365 | }; |
| 1366 | // 获取样式 |
| 1367 | const layerStyle = { |
| 1368 | layout: { |
| 1369 | visibility: layerInfo.visible |
| 1370 | }, |
| 1371 | style: this._transformStyleToMapBoxGl(layerInfo.style, featureType, expression, 'circle-radius') |
| 1372 | }; |
| 1373 | const layerID = layerInfo.layerID; |
no test coverage detected