Adding TE4W Tools
TerraExplorer for Web (TE4W) capabilities can be customized and expanded with JavaScript tools that are added to TE4W’s sidebar, and activated, like any other TE4W tool, by clicking the sidebar tool entry. The tool can directly execute a custom code, or first open a customized dialog box. Skyline provides a TE4W API, which can be used together with its underlying Cesium API, or any other script. It is recommended to use the examples located under .\TerraExplorerWeb\userTools as a template for your new tool. These examples also appear below.
An online interactive tutorial with HTML and JavaScript code snippets that you can try out, as well as a code editor where you can write custom code and view its output is also available.
To add a tool:
1. Create a new JavaScript (JS) file that includes methods for setting the following:
§ Tool ID
§ Menu entry for the tool
§ Tool functionality. The tool functionality can range from very basic (e.g., activating an alert dialog box) to more complex (e.g., activating a dialog box and/or implementing some of the TE4W API methods). See “Defining a Tool’s Functionality” for more information.
2. Save your JS tool file in the following location: .\TerraExplorerWeb\userTools.
3. Register your tool by updating .\TerraExplorerWeb\js\userTools.js with the name of your JS tool file.
E.g.
TerraExplorer.tools.userTools = [
"ActivateAlertTool",
"MyToolWithDialog",
"MyViewshedTool"
];
Below are three sample tools, all with the same tool skeleton but with different tool functionality:
§ Example 1: Creating a Basic Tool that Activates an Alert
§ Example 2: Creating a Tool with a Tool Dialog that Uses a Div Element