Topics
Getting Started
Cmd Line Opts
Tcl/Tk Version
X/Motif Version
NS Plugin Version
•   Embedding
•   Navigation
•   JavaScript
ActiveX Version
Configuration
Creating Data
OAA Interface
   
Go to FAQ
 

Digital Earth > TerravisionTM > User Guide > NS Plugin

TerraVision's JavaScript Interface

Once you have embedded TerraVision inside of your web page, you can navigate around the terrain models that you originally loaded, but what if you want change one of the settings? For example, what if you want to load another terrain model, or jump to a specific latitude/longitude, or turn on wireframe rendering? All of this can be achieved by sending commands to the TerraVision plugin's LiveConnect API.

LiveConnect provides a way to send commands from a web page into a plugin via Java or JavaScript. The Netscape plugin implements one entry function, called "cmd", which can be used to send commands to TerraVision. The format and suite of commands is exactly the same as for TerraVision's OAA interface.

To begin, we must give our TerraVision plugin instance a name so that we can refer to it later in the HTML file, e.g.


<EMBED TYPE="application/x-terravision" NAME="mytv"
 WIDTH="640" HEIGHT="480">
Then, we can refer to this instance using JavaScript calls. For example, the following HTML segment creates a button that when clicked will send the viewer back to the original viewpoint (the Origin).

<FORM>
  <INPUT TYPE="button" VALUE="Go To Origin"
     ONCLICK="document.mytv.cmd('resetview')">
</FORM>
You can of course also write JavaScript code inside a <SCRIPT> tag and call that later in your HTML text. For example, the following segment shows a function for toggling a boolean value and then hooking this up to a checkbox button for toggling wireframe rendering. This works by sending the "set('SHOW_WIREFRAME',value)" command to the TerraVision plugin, where value is found by looking at the state of the checkbox.

<!-- in the HEAD segment of your HTML file>

<SCRIPT LANGUAGE="JavaScript">
function Toggle(opt,val) {
  var cmdstr = "set(" + opt + "," + val + ")";
  document.mytv.cmd( cmdstr );
}
</SCRIPT>

<!-- in the BODY segment of your HTML file>

<FORM NAME="myform">
  <INPUT TYPE="checkbox" NAME="wireframe"
     ONCLICK="Toggle('SHOW_WIREFRAME',document.myform.wireframe.checked)">
  Wireframe Mode
</FORM>

 

 

Copyright ©2000 SRI International. All rights reserved.

For more information, please contact: digital-earth@ai.sri.com.
Last updated: Wednesday, 07-Mar-2001 16:53:21 PST.