Custom HTML tools can be created for TerraExplorer Fusion by directly calling SGWorld interfaces, enabling you to use most ISGWorld properties and methods.
To create an HTML tool:
- Create an HTML file.
- Create an init function that references a variable to parent.SGWorld. Note that a cross-platform init function is necessary when developing a custom tool that may also be used also on TerraExplorer Desktop. See Create HTML Tools for more information.
<script>
var SGWorld = null;
function init() {
SGWorld = parent.SGWorld;
}
...
</script> - Add the TerraExplorer API code for the tool. The SGWorld object exposes the SGWorld interfaces, enabling you to use most of the ISGWorld properties and methods. More about: TerraExplorer API Interfaces >
- Save the HTML file. It is recommended to save it under the application files' "./custom" folder to avoid security CORS issues. This file must then be referenced in your startup script. More about: Adding custom tools to TerraExplorer Fusion >
Full Example:
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body onload="init()">
Hello world<br>
<button onclick="circle();">Click to circle around</button>
</body>
<script>
var SGWorld = null;
function init() {
SGWorld = parent.SGWorld;
}
function circle() {
SGWorld.Command.Execute (1057,0);
}
</script>
</html>