* @private * @function WebMap.prototype.renameLayerId * @description mapboxstyle图层 ID 重复的 layer 添加后缀编码 (n)[参考mapstudio]。 * @param {mapboxgl.Layer[]} layers 已添加到地图的图层组。 * @param {mapboxgl.Layer} curLayer 当前图层。
(layers, curLayer)
| 5128 | * @param {mapboxgl.Layer} curLayer 当前图层。 |
| 5129 | */ |
| 5130 | renameLayerId(layers, curLayer) { |
| 5131 | if (layers.find((l) => l.id === curLayer.id)) { |
| 5132 | const result = curLayer.id.match(/(.+)\((\w)\)$/); |
| 5133 | if (result) { |
| 5134 | curLayer.id = `${result[1]}(${+result[2] + 1})`; |
| 5135 | } else { |
| 5136 | curLayer.id += '(1)'; |
| 5137 | } |
| 5138 | if (layers.find((l) => l.id === curLayer.id)) { |
| 5139 | this.renameLayerId(layers, curLayer); |
| 5140 | } |
| 5141 | } |
| 5142 | } |
| 5143 | /** |
| 5144 | * @private |
| 5145 | * @function mapboxgl.supermap.WebMap.prototype._matchStyleObject |
no test coverage detected