1. Loading SceneControl and Default Scene

Feedback


Overview

SceneControl is the 3D scene control, which is mainly used to view the work window of the 3D operations, such as view the 3D scene, view the dynamic fly, control layers, etc.

A 3D scene control (SceneControl) corresponds to a 3D scene (Scene), indicating that a 3D scene window only displays a 3D scene.

This section mainly shows how to load a 3D scene control and open the default 3D scene.

SceneControl the structure chart of the 3D scene control

Scene diagram

SceneControl the common attributes

  Interface Description
layer3DServicesList Gets the 3D layer set service list which is published by the SuperMap iServer.
asyncHelper Sets the asynchronous assistant of the current setting, which allows users obtain layers in the scene by the way of asynchronous download.
scene Obtains the 3D scene. A 3D scene control only supports a 3D scene, but you can use the open interface of the scene to open different scenes, and you need to close the old scene before opening a new scene.
sceneAction Gets or sets the current operation type of the user.
sceneServicesList Gets all the 3D scene service lists published by the SuperMap iServer.

SceneControl common methods

  Interface Description
addEvent Adds events to the map control, and bind events with the callback functions. Indicating that the operation of the handler callback function is completed when the event specified by the eventName occurs.
checkPluginVersion Determines whether the version of the local control is the latest. If not, get the download address of the new version.
getPluginVersion Gets the version number of the local plugin.
pixelToGlobe Converts the 2D point Point in the screen into the 3D point Point3D in the geographic coordinate system.
removeEvent Removes the specified callback function handler which is bound with the event.
resetTerrain Resets the terrain layer. You need to call this function to refresh the terrain display when the terrain layer is added, deleted or set to be visible or invisible.
save Saves the current scene configuration as an XML file in GML standard, and upload to the server.
setRefreshRaster Sets whether the real-time rasterization is refreshed. If there are display problems for the raster data in the 3D system, this function can be called to refresh the display of raster data only.
viewEntire Zooms the 3D map scene to full extent.

Load SceneControl and the default Scene

  1. New a folder named “GettingStarted” anywhere, the users also can customize the folder name.

    Put the picture folders "images" in the script library folder "lib" and the folder samplecode/samplecode into the folder “GettingStarted” .

  2. Create a folder named “Scripts” which is used to store script files in the folder " GettingStarted ".

    Then create two script files named "“SuperMap.Include.js" and "GettingStarted.js" respectively in the folder "Scripts”", where the "GettingStarted.js" file implements the specific functions, the "SuperMap.Include.js" file is the reference file list of the code library. Note that the two js files need to be saved as the UTF-8 format. Add the following code in the "SuperMap.Include.js" folder:

    JavaScript copy code
    function _IncludeScript(inc)
    {
    //the script file in the lib and the relative path "src="lib/'+inc+'"'+'" of the html page file in the reference SuperMap.Include.js file //If the users don’t put the lib folder and the html page of the referenced SuperMap.Include.js file in the same level folder directory, then the path need to be changed according to the actual situation. var script='<'+'script type="text/javascript" src="lib/'+inc+'"'+'><'+'/script>'; document.writeln(script); } if(!Function.__typeName)
    {
    //the framework script _IncludeScript('lib_Ajax/MicrosoftAjax.js'); //SuperMap iClient 6R for Ajax the 2D script library _IncludeScript('lib_Ajax/SuperMap.Web.js'); //the 3D core library _IncludeScript('lib_Realspace/SuperMap.Web.Realspace.js'); }
  3. Create a home page named "default.html" in the folder "GettingStarted", please save the "default.html" file as the UTF-8 format in order to maintain the consistency of files, and then add the following code in the file:
    JavaScript copy code
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>SuperMap iClient 6R for 3D GettingStarted</title>
    <!--Reference the SuperMap.Include.js, so the library file in the SuperMap.Include.js will be referenced in this html--> <script type="text/javascript" src="Scripts/SuperMap.Include.js"></script> <!--Reference the GettingStarted.js, so the specific function of the system can be implemented in this script--> <script type="text/javascript" src="Scripts/GettingStarted.js"></script>
    </head> <body onLoad="onPageLoad()">
    <!--the scene control--> <div id="sceneControlDiv" style="position:relative; margin: 0; padding: 0; border: 1px solid black; z-index:1; left: 0%; width: 100%; top: 0%; height: 95%; visibility: visible;background-image: images/logo.png;"> </div> </body> </html>
  4. Add the following code to the file "GettingStarted.js" to load the default scene:
    JavaScript copy code
    var scene = null;
    var sceneControl = null;
    var htmlUrl = document.location.host;
    //determine that the way to open the web page is by local or by network //different opening ways with different url values if(htmlUrl == "") { htmlUrl = "http://localhost:8090"; } else { htmlUrl = "http://" + htmlUrl; } function onPageLoad() { try { //obtain the div object named sceneControlDiv in the html page as the scene control sceneControl = new SuperMap.Web.UI.Controls.SceneControl($get("sceneControlDiv"), initCallback, failedCallback); } catch(e) { //If the plugin is not installed, then this exception is thrown. if (e.name == SuperMap.Web.Realspace.ExceptionName.PlugInNotInstalled) { var url = htmlUrl + "/SuperMapRealspace/SuperMap iClient 6R for Realspace.exe"; document.write("<a href='"+url+"'>Please click to download plug-in SuperMapiClientForRealspace and then install</a>"); return; } //If the IE browser is not used, this exception is thrown else if (e.name == SuperMap.Web.Realspace.ExceptionName.BrowserNotSupport) { document.write("<p>SuperMap iClient 6R for 3D supports the IE browser only</p>"); return; } //throw other exceptions else { alert(e.message); } } } //the callback function after the control is initialized successfully. load the data only after the completion of initialization. function initCallback() { //obtain the scene of the Realspace control, a control corresponds to a scene scene = sceneControl.get_scene(); } //the callback function after the initialization of the control is failed function failedCallback() { alert("Realspace initialized failed!"); }
  5. When running the IE6 or other browsers above the IE6, a warning will be popupped to stop the file to display, it'll be OK when you right-click to choose "Allow the blocked content". The following figure shows the map control and scene which have been loaded successfully.
    Map control and default scene

    Figure1 Load the map control and the default scene