MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / renameLayerId

Method renameLayerId

src/openlayers/mapping/WebMap.js:5130–5142  ·  view source on GitHub ↗

* @private * @function WebMap.prototype.renameLayerId * @description mapboxstyle图层 ID 重复的 layer 添加后缀编码 (n)[参考mapstudio]。 * @param {mapboxgl.Layer[]} layers 已添加到地图的图层组。 * @param {mapboxgl.Layer} curLayer 当前图层。

(layers, curLayer)

Source from the content-addressed store, hash-verified

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

Callers 2

WebMap2Spec.jsFile · 0.80

Calls 2

matchMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected