A startup script is a code that runs automatically when the user opens TerraExplorer Fusion. This script can directly run SGWorld commands or use the TerraExplorer Fusion API to add custom tools 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. More about: TerraExplorer API and TerraExplorer Fusion API >
Example Using TerraExplorer API
var circle = SGWorld.Creator.CreateCircle(
SGWorld.Creator.CreatePosition(-84.5, 39.1, 0, 2),
50
);
SGWorld.Navigate.FlyTo(circle.ID);OR
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({url:'./custom/tools/MyAnalysisTool/MyTool.html',title:'My tool'})`
});Implementing a Custom Startup Script
Startup scripts can be implemented in any of the following ways:
-
Customize the default startup script. Customize StartupScript.js, located in the application’s
./Customfolder. This script runs whenever TerraExplorer Fusion is opened. -
Create a custom startup script for selected users. Use either of the following methods:
-
In SGS Manager, define a custom configuration that includes your startup script. Then append the config parameter to the TerraExplorer Fusion URL. More about: Configure Your TerraExplorer Fusion > and Set URL Parameters >
config=[ConfigurationName]
-
Save the script under a different filename as a new custom startup script under the application files' "./Custom" folder. To run TEF with your script, append the script parameter to the TerraExplorer Fusion URL. Include the
.jsextension in the script filename. More about: Setting URL parameters >script=[NameOfScriptFile.js]
-
-
Create a project-specific startup script. In TerraExplorer Desktop, create a startup message containing the script, save it in the project, and publish the project to SGS. To open the project in TerraExplorerFusion, append the project parameter to the TerraExplorer Fusion URL. More about: Creating startup messages from Project Settings and Setting URL parameters >
project=[URL of project on SGS]
E.g., https://cloud.skylineglobe.com/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.
All scripts that are created and used in one of the documented methods will run. When multiple startup scripts are used, they are executed in the following order:
- Script message created in a TerraExplorer Desktop project
- Script saved in SGS custom configuration
- Script specified by the "script" URL parameter
- Default startup script: StartupScript.js, that is included under the application files' "./Custom" folder.