Overview

In the 3D scene, you can open all layers in the 3D scene and the specified layers in the scene, such as the terrain, image, model, vector layer, etc. Layers are divided into six categories in the SuperMap iClient 7C for 3D: the terrain image layer, the 3D model layer, the image layer, the vector layer, the KML layer and the KMZ layer.

Different layers have different loading methods, the 3D model layer, the image layer, the vector layer, the KML layer and the KMZ layer are loaded by the LayerD type, the terrain image layer is loaded by the TerrainLayer type. When loading the layers, you need to know the type and name of the layer and the data path, which can be obtained by the Layer3DServicesList class. The Layer3DServicesList class records all 3D layer set services and the information of each layer in the 3D layer set.

 layer3DServicesList Structure Chart

layer3DServicesList Structure Chart

 layer3DServicesList 常用属性

  Interface Description
Public property count Obtains the total number of the layer services in the layer set.
Public property item Obtains the 3D layer service information with the specified layer index number (Nember type) or name (String type) in the 3D layer set.
Public property sceneName Obtains the name of the belonged scene service.
Public property sceneAddress Obtains the service address of the layer set.

 layer3DServicesList Common Methods

  Interface Description
Public method load Obtains the lists of the layer set services in the specified scene.
Public method removeAll Removes all the layer service information in the layer service set.

 Layer3Ds Structure Chart

Scene Structure Chart

 Layer3Ds Common Attributes

  Interface Description
Public property count Obtains the total number of the 3D layer objects in a given 3D layer set.
Public property isVisible Gets or sets the visibility of the 3D layer set.
Public property item Obtains the 3D layer object with the specified index number (Nember type) or the specified layer name type (String type) in the 3D layer set. If the specified layer doesn't exist, Null will be returned.

 Layer3Ds Common Methods

  Interface Description
Public method add Add 3D layers with the type of the 3DImage, 3DModel and KML to the 3D layer set.
Public method indexOf Finds the index number of the specified layer name in the 3D layer set.
Public method insert Inserts 3D layers with the type of the Image, Model or KML to the specified location in the 3D layer set.
Public method moveDown Moves the 3D layer with the specified index number in the 3D layer set down one level.
Public method moveTo >Moves the 3D layer with the specified index number in the 3D layer set to the location with the specified index number.
Public method moveToBottom Moves the 3D layer with the specified index number in the 3D layer set to the bottom.
Public method moveToTop Moves the 3D layer with the specified index number in the 3D layer set to the top.
Public method moveUp Moves the 3D layer with the specified index number in the 3D layer set up one level.
Public method removeAll Removes all the layers in the layer set.
Public method removeAt Removes the layers with the specified layer name or index number.

 TerrainLayers Structure Chart

TerrainLayers Structure Chart

 TerrainLayers Common Attributes

  Interface Explanation
Public property count Obtains the total number of the terrain layer objects in the specified terrain layer set.
Public property item Obtains the terrain layer object with the specified index number (Nember type) or the specified layer name (String type) in the terrain layer set.

 TerrainLayers Common Methods

  Interface Description
Public method add Add the terrain layers to the terrain layer set.
Public method indexOf finds the index number with the specified layer name in the terrain layer set.
Public method insert Inserts terrain layers to the specified location in the 3D layer set.
Public method moveDown Moves the terrain layer with the specified index number in the terrain layer set down one level.
Public method moveTo Moves the terrain layer with the specified index number in the terrain layer set to the location with the specified index number.
Public method moveToBottom Moves the terrain layer with the specified index number in the terrain layer set to the bottom.
Public method moveToTop Moves the terrain layer with the specified index number in the terrain layer set to the top.
Public method moveUp Moves the terrain layer with the specified index number in the terrain layer set up one level.
Public method removeAll Removes all the layers in the terrain layer set.
Public method removeAt Removes layers with the specified layer name or index number.

Load the 3D layers

  • Add controls to load layers. in the <body onLoad="onPageLoad()"> </body> of the "default.html" page, add the following code in the </div> before the scene control to implement to add layer service list which lists layer services provided by the specified server scene services in the interface system:
  • JavaScript  
    <!--the scene layer list-->
    <p><label for="layersList" >the scene layer list:</label><br /></p>
    <p><select id="LayersList" name="LayersList" ></select><br /></p>
    <p><input id="LayerOpen" type="button" value="load layers" onClick="return LayerOpen_onclick()" /></p>
    
  • Fill the following code at the end of the "function SceneLoad_onclick()" function in the "GettingStarted.js" to obtain the layer service provided by the scene service when loading the scene service:
  • JavaScript  
    LoadLayers();
                                    
    
  • Fill the following code in the "GettingStarted.js" to obtain all the layer services in the specified scene services:
  • JavaScript  
    function LoadLayers()
    {
            //obtain the layer list from the selected scene
            var layer3DServicesList = sceneControl.get_layer3DServicesList(); 
            //determine whether to obtain the layer set service lists of the specified scene
      var bLayersLoad = layer3DServicesList.load(sceneAddress,sceneName);
            //if the layer services of the specified scene are loaded successfully, then obtain the type of layer in each scene
            if(bLayersLoad)
            { 
                    var layersList = document.getElementById("LayersList");
                    if(layersList.length > 0)
                    {
                            layersList.length = 0;
                    }
                    //the total number of the layer service information provided by this scene 
              var count = layer3DServicesList.get_count(); 
                    for(var i=0; i<count; i++)
                    {
                            //obtain the information of the specified layer, including the server address, the layer name and the layer type
                      var layer3DServiceInfo = layer3DServicesList.get_item(i); 
                            var layer3DName= layer3DServiceInfo.get_name(); 
                            var layer3DType= layer3DServiceInfo.get_type(); 
                            var displayName = null;
                            switch (layer3DType)
                            {
                                    case 7:
                                            displayName="Load the 3D model";
                                            break;
                                    case 8:
                                            displayName="Load the terrain model";
                                            break;
                                    case 1:
                                            displayName="Load the image layer";
                                            break;
                                    case 2:
                                            displayName="Load the KML layer";
                                            break;
                                    case 102:
                                            displayName="Load the KMZ layer";
                                            break;
                                    case 10:
                                            displayName="Load the vector layer";
                                            break;
                                    default:
                                            displayName="the none layer";
                            } 
                            var oPtion = document.createElement("option");
                            oPtion.value = displayName;
                            oPtion.text = oPtion.value;
                            //the first layer service is selected by default
                      if (i == 0)
                            {
                                    oPtion.selected = true;
                            }
                            layersList.options.add(oPtion);
                    }
            }
    }
    
  • Fill the following code in the "GettingStarted.js" to open the specified layer services in the scene services:
  • JavaScript  
    function LayerOpen_onclick()
    {
            var layerTypes = document.getElementById("LayersList"); 
            //traverse all names of the layer services, and determine the selected layer name currently, then open the specified layer
      for(var i=0; i<layerTypes.length; i++)
            {
                    if(layerTypes.options[i].selected == true)
                    {
                            var layer3DServicesList = sceneControl.get_layer3DServicesList(); 
                            var layer3DServiceInfo = layer3DServicesList.get_item(i);
                            var layer3DName= layer3DServiceInfo.get_name();
                            var layer3DDataName = layer3DServiceInfo.get_dataName();
                            var layer3DType= layer3DServiceInfo.get_type(); 
                            //open the specified layer service
                            //If terrain data, Terrainlayers is used to load; If the model, KML or image layer, Layer3Ds is used to load. 
                      if(layer3DType == SuperMap.Web.Realspace.Layer3DType.TERRAIN)
                            { 
                                    var terrainLayers = scene.get_terrainLayers(); 
                                    terrainLayers.add(sceneAddress, layer3DName, layer3DDataName);
                            }
                            else
                            {
                                    var layer3ds = scene.get_layer3Ds(); 
                                    layer3ds.add(sceneAddress, layer3DName, layer3DDataName, layer3DType);
                            }
                    }
            }
    }
    
  • The following picture shows the visualization after loading the specified layer instead of opening all the layers after loading the scene, the scene contains KMZ layers, KML layers, vector layers, image layers and terrain layers, but loads the image layers only:
  • Load image layer

    Figure 1 Load the specified layers (image layers) in the scene