Getting 3D layers list

Feedback


We can get the scene list of the realspace service through the scenes resource. Each scene can contain multiple 3D layers.

To get the scene list, we need to implement the GET request on the scenes resource, i.e., the URI below. For more details, please refer to scenes.

http://localhost:8090/iserver/services/components-rest/rest/realspace/scenes.json

In the collection, name is the scene name, and path is the access path of the scene.

Below is a sample path for a scene.

http://localhost:8090/iserver/services/components-rest/rest/realspace/scenes/scene

By appending "/layers.json" to the path, we can get the layer information of the scene. Please refer to scenes.

By this way, we can get the scene information and the layer information of the REST realspace service. Below is the sample code:

//Get 3D layer information on the server

function getRLayers()

{

        var commit=getcommit();

        var uri="http://localhost:8090/iserver/services/components-rest/rest/realspace/scenes.json";

        

        commit.open("GET",encodeURI(uri),false,"","");

        commit.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");

        commit.send(null);

        

        //Parse the json string returned from the server to a JavaScript object

        var response = json_parse(commit.responseText, null);       

        //Get the Div container for display

        var container = document.getElementById('container');

        //Output the result  

        //The number of scenes

        var len=response.length;

        container.innerHTML="There are "+len+" scene(s): ";

        var str ='<ol>';

        for(var i=0;i<len;i++)

        {

                str += '<li>Scene name: ' + response[i].name + '; Layers contained: ' + '<ul>';

                var layerspath=response[i].path+'/layers.json';

                //Get the layers of the scene

                commit.open("GET",encodeURI(layerspath),false,"","");

                commit.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");

                commit.send(null);

                var layersInfo=json_parse(commit.responseText, null);

                //The number of 3D layers

                var len1=layersInfo.length;

                for(var j=0;j<len1;j++)

                {

                        str += '<li>Layer name: '+layersInfo[j].name+'; Layer type: '+layersInfo[j].layer3DType+"; Data: "+layersInfo[j].dataName+'</li>';

                }

                str +='</ul></li>';

        }   

        str +='</ol>';

        container.innerHTML+=str;

}

The information about the scene and the layers is shown as below:

There are 1 scene(s):

  1. Scene name: scene; Layers contained:
    • Layer name: OlympicGreen; Layer type: VectorLayer; Data: OlympicGreen_1358161394

    • Layer name: flyRoute2; Layer type: KMLLayer; Data: flyRoute2_492950542

    • Layer name: flyRoute1; Layer type: KMLLayer; Data: flyRoute1_493874063

    • Layer name: BirdNestRoad; Layer type: KMLLayer; Data: BirdNestRoad_1596249843

    • Layer name: SubwayPoint@RealspaceSample; Layer type: VectorLayer; Data: SubwayPoint@RealspaceSample

    • Layer name: GasPoint@RealspaceSample; Layer type: VectorLayer; Data: GasPoint@RealspaceSample

    • Layer name: BusPoint@RealspaceSample; Layer type: VectorLayer; Data: BusPoint@RealspaceSample

    • Layer name: RoadA@RealspaceSample; Layer type: VectorLayer; Data: RoadA@RealspaceSample

    • Layer name: lawn@RealspaceSample; Layer type: VectorLayer; Data: lawn@RealspaceSample

    • Layer name: buildings@RealspaceSample; Layer type: VectorLayer; Data: buildings@RealspaceSample

    • Layer name: 2015beijingsubway; Layer type: KMZLayer; Data: 2015beijingsubway_1078398575

    • Layer name: bridge_beijing; Layer type: KMLLayer; Data: bridge_beijing_1681266282

    • Layer name: beijing@beijing; Layer type: ImageFileLayer; Data: beijing@beijing

    • Layer name: WorldMap; Layer type: ImageFileLayer; Data: WorldMap

    • Layer name: Beijing@RealspaceSample_Terrain; Layer type: TerrainFileLayer; Data: Beijing@RealspaceSample_Terrain