MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / addL7Layers

Function addL7Layers

src/common/mapping/utils/L7LayerUtil.js:2033–2073  ·  view source on GitHub ↗
({ map, webMapInfo, l7Layers, spriteDatas, options })

Source from the content-addressed store, hash-verified

2031
2032 return {
2033 async addL7Layers({ map, webMapInfo, l7Layers, spriteDatas, options }) {
2034 // 添加L7图层
2035 const { layers, sources, sprite } = webMapInfo;
2036 const formateL7Layers = await restoreL7Layers({
2037 layers: l7Layers,
2038 sources,
2039 map,
2040 options: Object.assign({ withoutFormatSuffix: true }, options)
2041 });
2042 // 批量处理L7纹理
2043 const scene = await getScene(map);
2044 if (Object.keys(spriteDatas).length > 0) {
2045 try {
2046 await addTextures({
2047 layers: formateL7Layers.filter((l) => !!l.texture),
2048 spriteJson: spriteDatas,
2049 sprite,
2050 scene,
2051 options
2052 });
2053 } catch (error) {
2054 console.error(error);
2055 options.emitterEvent('layercreatefailed', { error, map });
2056 }
2057 }
2058 for (const l of formateL7Layers) {
2059 const layerIndex = layers.findIndex((wLayer) => wLayer.id === l.id);
2060 // 从剩下的图层中找到第一个通过setStyle已经添加过的mapboxgl图层
2061 const beforeLayer = layers.slice(layerIndex + 1).find((r) => !isL7Layer(r));
2062 if (l.layerType === AntvL7LayerType.MarkerLayer) {
2063 const actionLayer = l;
2064 (l.options || {}).visible !== false && addL7MarkerLayer(actionLayer, scene);
2065 ChartController.setSceneChartLayer(l.id, actionLayer);
2066 } else {
2067 const layer = getL7Layer(l, sources[layers[layerIndex].source]);
2068 if (!map.getLayer(layer.id)) {
2069 map.addLayer(layer, beforeLayer && beforeLayer.id);
2070 }
2071 }
2072 }
2073 },
2074 isL7Layer,
2075 getL7MarkerLayers() {
2076 return ChartController.markerLayers;

Callers

nothing calls this directly

Calls 10

restoreL7LayersFunction · 0.85
getSceneFunction · 0.85
addTexturesFunction · 0.85
isL7LayerFunction · 0.85
addL7MarkerLayerFunction · 0.85
getL7LayerFunction · 0.85
filterMethod · 0.80
findMethod · 0.45
getLayerMethod · 0.45
addLayerMethod · 0.45

Tested by

no test coverage detected