(layerInfo, features = [], mergeByField, featureProjection)
| 570 | } |
| 571 | |
| 572 | _initOverlayLayer(layerInfo, features = [], mergeByField, featureProjection) { |
| 573 | const { layerID, layerType, visible, style, featureType, projection } = layerInfo; |
| 574 | layerInfo.visible = visible ? 'visible' : 'none'; |
| 575 | features = mergeFeatures({ sourceId: layerID, features, mergeByField, map: this.map }); |
| 576 | if (layerType === 'restMap') { |
| 577 | this._createRestMapLayer(features, layerInfo); |
| 578 | return; |
| 579 | } |
| 580 | if (layerType === 'mvt') { |
| 581 | this._createMvtLayer(features.info, layerInfo, features.featureType); |
| 582 | return; |
| 583 | } |
| 584 | |
| 585 | // mbgl 目前不能处理 geojson 复杂面情况 |
| 586 | // mbgl isssue https://github.com/mapbox/mapbox-gl-js/issues/7023 |
| 587 | if (features && features[0] && features[0].geometry && features[0].geometry.type === 'Polygon') { |
| 588 | features = this._handleMultyPolygon(features); |
| 589 | } |
| 590 | const realProjection = featureProjection || projection; |
| 591 | if ( |
| 592 | features && |
| 593 | realProjection && |
| 594 | realProjection !== 'EPSG:4326' && |
| 595 | layerInfo.dataSource && |
| 596 | layerInfo.dataSource.type !== 'REST_DATA' |
| 597 | ) { |
| 598 | this._unprojectProjection = toEpsgCode(projection); |
| 599 | features = this.transformFeatures(features); |
| 600 | } |
| 601 | |
| 602 | features = this.handleLayerFeatures(features, layerInfo); |
| 603 | |
| 604 | if (layerType === 'VECTOR') { |
| 605 | const styleGroups = this.getVectorStyleGroup(layerInfo); |
| 606 | this._initLegendConfigInfo(layerInfo, styleGroups); |
| 607 | if (featureType === 'POINT') { |
| 608 | if (style.type === 'SYMBOL_POINT') { |
| 609 | this._createSymbolLayer(layerInfo, features); |
| 610 | } else { |
| 611 | this._createGraphicLayer(layerInfo, features); |
| 612 | } |
| 613 | } else { |
| 614 | // 线和面 |
| 615 | this._createVectorLayer(layerInfo, features); |
| 616 | // 不在 _createVectorLayer 里面处理 layerAdded++ 的原因:_createDataflowLayer 也调用了_createVectorLayer ,会导致layerAdded > expectLayerLen |
| 617 | this._addLayerSucceeded({ layerInfo, features }); |
| 618 | } |
| 619 | } else if (layerType === 'UNIQUE') { |
| 620 | this._createUniqueLayer(layerInfo, features); |
| 621 | } else if (layerType === 'RANGE') { |
| 622 | this._createRangeLayer(layerInfo, features); |
| 623 | } else if (layerType === 'HEAT') { |
| 624 | this._createHeatLayer(layerInfo, features); |
| 625 | } else if (layerType === 'MARKER') { |
| 626 | this._createMarkerLayer(layerInfo, features); |
| 627 | } else if (layerType === 'MIGRATION') { |
| 628 | this._createMigrationLayer(layerInfo, features); |
| 629 | } else if (layerType === 'RANK_SYMBOL') { |
no test coverage detected