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. 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('./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 designed script. You can customize the default startup script: StartupScript.js, that is included under the application files' "./Custom" folder.
- 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. More about: Configure Your TerraExplorer Fusion > and Set URL Parameters >
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. More about: Setting URL parameters >
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.
- In SGS Manager, define a custom configuration that includes your startup script. Then append the configuration parameter to your URL query string. More about: Configure Your TerraExplorer Fusion > and Set URL Parameters >
- Create a custom startup script for a project that will run whenever the project 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. More about: Creating startup messages from Project Settings and Setting URL parameters >
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.
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:
- Script message created in a TerraExplorer Desktop project
- Script saved in SGS custom configuration
- Script run from "script" URL parameter
- Default startup script: StartupScript.js, that is included under the application files' "./Custom" folder.