Using Startup Scripts

A startup script is a code that runs automatically when the user opens TerraExplorer Fusion. This script can directly run SGWorld commands or reference custom tools, adding them to the analysis or navigation tool panels.

A default startup script: StartupScript.js, included under the application files' "./Custom" folder, runs whenever TerraExplorer Fusion is opened. This default script can be changed and customized. Additional startup scripts can be created and run using any of the methods described below. 

Creating a Startup Script

Create a startup JavaScript that either directly runs SGWorld TerraExplorer API commands or uses TerraExplorer Fusion API to add custom tools to the analysis or navigation tool panels. See "Using TerraExplorer API" and "Using TerraExplorer Fusion API" in this chapter for information.


Example Using TerraExplorer API

var circle = SGWorld.Creator.CreateCircle(SGWorld.Creator.CreatePosition(-84.5,39.1,0,2),50);
SGWorld.Navigate.FlyTo(circle.ID);

 

Example Using TerraExplorer Fusion API

analysis.addAnalysisTool ({
    id:"myToolBtnID",
    name:'My Tool',
    title:'My analysis tool',
    icon:"./custom/tools/MyAnalysisTool/myTool.png",
    action:'analysis.openAnalysisToolURL('./custom/tools/MyAnalysisTool/MyTool.html','My tool',true)'
});

Implementing a Custom Startup Script

Startup scripts can be implemented in any of the following ways:

§  Create a startup script that will be used whenever TerraExplorer Fusion is opened without a specifically defined startup script - Save your new script as StartupScript.js, under the application files' "./Custom" folder. This replaces the default script with your new one.

§  Create a custom startup script that will only be used by some users. Do either of the following:

§  In SGS Manager, define a custom configuration that includes your startup script. Then append the configuration parameter to your URL query string. See "URL Parameters" and "Configuring Your TerraExplorer Fusion" in this chapter for information.

config=[ConfigurationName]

E.g., https://cloud.skylineglobe.com/sg/TEF/te.html?project=https://cloud.skylineglobe.com/SG/demos/projects/Mexico_Beach_Emergency_Response&config=KB_ConfigurationExample

 

§  Save the script with a different name as a new custom startup script under the application files' "./Custom" folder. When you want to run TEF with your script, append the following script parameter to the end of your TerraExplorer Fusion URL. The name of the script file should be passed with the .js extension. See "URL Parameters" in this chapter for information.

script=[NameOfScriptFile.js]

E.g., https://cloud.skylineglobe.com/sg/TEF/te.html?project=https://cloud.skylineglobe.com/SG/demos/projects/Mexico_Beach_Emergency_Response&script=myscript.js

§  Create a custom startup script that will run whenever the project it is saved in is loaded. To do this, create a startup message script in a TerraExplorer Desktop project, save it in the project, and publish the project to SGS. When you want to run TEF, append the project parameter to your URL query string. See "URL Parameters" and "Using Startup Scripts" in this chapter for information.

project=[URL of project on SGS]

E.g., https://cloud.skylineglobe.com/sg/TEF/te.html?project=https://cloud.skylineglobe.com/SG/demos/projects/Mexico_Beach_Emergency_Response.

This startup script will run automatically, in addition to the default startup script. Since this script will run in the Desktop version as well as in Fusion, it is recommended to only use general API (SGWorld) and not Fusion API. Note that in contrast to TerraExplorer Desktop, TerraExplorer Fusion will always run the latest SGWorld API, regardless of what version you reference in the script. This might lead to slight differences in how the script executes in Desktop vs. Fusion. 

All scripts that are created and used in one of the documented methods will run. Note that they will be executed in the following order:

1.     Script run from "script" URL parameter

2.     StartupScript.js

3.     Script saved in SGS custom configuration