* @private * @function WebMap.prototype.modifyMapboxstyleLayer * @description mapboxstyle图层:1. layer id重复问题 2.叠加图层背景色问题 * @param {Object} mapInfo 地图信息 * @param {Object} layerInfo 当前要添加到地图的图层
(mapInfo, layerInfo)
| 5096 | * @param {Object} layerInfo 当前要添加到地图的图层 |
| 5097 | */ |
| 5098 | modifyMapboxstyleLayer(mapInfo, layerInfo) { |
| 5099 | let that = this; |
| 5100 | if (mapInfo.layers && mapInfo.layers.length === 0) { |
| 5101 | return; |
| 5102 | } |
| 5103 | let curLayers = layerInfo.styles.layers; |
| 5104 | if (!curLayers) { |
| 5105 | return; |
| 5106 | } |
| 5107 | // 非底图,则移除"background"图层 |
| 5108 | curLayers = curLayers.filter((layer) => layer.type !== 'background'); |
| 5109 | layerInfo.styles.layers = curLayers; |
| 5110 | // 处理mapboxstyle图层layer id重复的情况 |
| 5111 | let addedLayersArr = mapInfo.layers |
| 5112 | .filter((layer) => layer.layerType === 'VECTOR_TILE' && layer.zIndex !== layerInfo.zIndex) |
| 5113 | .map((addLayer) => addLayer.styles && addLayer.styles.layers); |
| 5114 | if (!addedLayersArr || (addedLayersArr && addedLayersArr.length === 0)) { |
| 5115 | return; |
| 5116 | } |
| 5117 | addedLayersArr.forEach((layers) => { |
| 5118 | curLayers.forEach((curLayer) => { |
| 5119 | that.renameLayerId(layers, curLayer); |
| 5120 | }); |
| 5121 | }); |
| 5122 | } |
| 5123 | /** |
| 5124 | * @private |
| 5125 | * @function WebMap.prototype.renameLayerId |
no test coverage detected