MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / _createRangeLayer

Method _createRangeLayer

src/common/mapping/WebMapV2.js:2401–2469  ·  view source on GitHub ↗
(layerInfo, features)

Source from the content-addressed store, hash-verified

2399 }
2400
2401 _createRangeLayer(layerInfo, features) {
2402 const fieldName = layerInfo.themeSetting.themeField;
2403 const featureType = layerInfo.featureType;
2404 const { minzoom, maxzoom, style } = layerInfo;
2405 const styleGroups = this.getRangeStyleGroup(layerInfo, features);
2406
2407 features = this.getFilterFeatures(layerInfo.filterCondition, features);
2408
2409 // 获取 expression
2410 const expression = ['match', ['get', 'index']];
2411 const datas = features.filter((row) => {
2412 const tartget = parseFloat(row.properties[fieldName]);
2413 if (!tartget && tartget !== 0) {
2414 // expression.push(row.properties['index'], 'rgba(0, 0, 0, 0)');
2415 return false;
2416 }
2417 if (styleGroups) {
2418 for (let i = 0; i < styleGroups.length; i++) {
2419 const startFlag = styleGroups[i].start <= tartget;
2420 const endFlag = tartget < styleGroups[i].end;
2421 const lastEndFlag = i === styleGroups.length - 1 && tartget === styleGroups[i].end;
2422 if (startFlag && (endFlag || lastEndFlag)) {
2423 expression.push(row.properties.index, styleGroups[i].color);
2424 break;
2425 }
2426 }
2427 }
2428 return true;
2429 }, this);
2430 expression.push('rgba(0, 0, 0, 0)');
2431 const source = {
2432 type: 'geojson',
2433 data: {
2434 type: 'FeatureCollection',
2435 features: datas
2436 }
2437 };
2438 // 图例处理
2439 this._initLegendConfigInfo(layerInfo, styleGroups || []);
2440
2441 // 获取样式
2442 const layerStyle = {
2443 layout: {}
2444 };
2445 if (featureType === 'LINE' && style.lineCap) {
2446 layerStyle.layout = {
2447 'line-cap': style.lineCap
2448 };
2449 }
2450 const visible = layerInfo.visible;
2451 layerStyle.layout.visibility = visible;
2452 layerStyle.style = this._transformStyleToMapBoxGl(style, featureType, expression);
2453 // 添加图层
2454 const layerID = layerInfo.layerID;
2455 this._addOverlayToMap({ type: featureType, source, layerID, layerStyle, minzoom, maxzoom });
2456 // 如果面有边框
2457 featureType === 'POLYGON' &&
2458 style.strokeColor &&

Callers 3

_initOverlayLayerMethod · 0.95
callbackFunction · 0.80
callbackFunction · 0.80

Calls 9

_initLegendConfigInfoMethod · 0.95
_addOverlayToMapMethod · 0.95
_addStrokeLineForPolyMethod · 0.95
_addLayerSucceededMethod · 0.95
getFilterFeaturesMethod · 0.80
filterMethod · 0.80
pushMethod · 0.80
getRangeStyleGroupMethod · 0.45

Tested by

no test coverage detected