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

Method copyLayer

src/common/mapping/WebMapV3.js:231–250  ·  view source on GitHub ↗
(id, layerInfo = {})

Source from the content-addressed store, hash-verified

229 }
230
231 async copyLayer(id, layerInfo = {}) {
232 const matchLayer = this._mapInfo.layers.find(layer => layer.id === id);
233 if (!matchLayer || this._getLayerOnMap(layerInfo.id)) {
234 return;
235 }
236 const copyLayerId = layerInfo.id || `${matchLayer.id}_copy`;
237 const copyLayer = { ...matchLayer, ...layerInfo, id: copyLayerId };
238 if (l7LayerUtil.isL7Layer(copyLayer)) {
239 const layers = [copyLayer];
240 const params = this._getAddL7LayersParams(layers, this._mapInfo.sources, layers);
241 await l7LayerUtil.addL7Layers(params);
242 } else {
243 if (typeof copyLayer.source === 'object') {
244 this.map.addSource(copyLayer.id, copyLayer.source);
245 copyLayer.source = copyLayer.id;
246 }
247 this.map.addLayer(copyLayer);
248 }
249 return copyLayer;
250 }
251
252 updateOverlayLayer(layerInfo, features, mergeByField) {
253 if (layerInfo.renderSource.type === 'geojson') {

Callers

nothing calls this directly

Calls 5

_getLayerOnMapMethod · 0.95
_getAddL7LayersParamsMethod · 0.95
addSourceMethod · 0.80
findMethod · 0.45
addLayerMethod · 0.45

Tested by

no test coverage detected