Users Manual
Javascript API
It is possible for worldKit to respond to certain commands from Javascript, and for worldKit to send commands to Javascript. This allows for interesting integrations within web applications.

For Javascript-Flash communication in either direction, make sure that swLiveConnect="true" is set in the embed HTML tag.

It is highly recommended that applications needing Javascript communication use the latest worldKit and require Flash Player 8, as it fixes browser inconstencies.

Javascript to worldKit Communication
Javascript communicates with Flash by calling the SetVariable function on worldKit embedded in the browser. "document.worldkit" refers to the "id" and "name" assigned in the <object> and <embed> tags.
These are variables worldKit monitors and responds to: For example, here are snippets of Javascript and HTML using "JSubComm" and "JLayComm" that create a checkbox to switch "layers" on and off, in a GIS style, and a link to activate a category of points.
function activate(args) {
function layerSwitch(args) {
<input type="checkbox" name="restaurant" checked onMouseUp="javascript:layerSwitch('restaurant')">
<a href="javascript:activate('restaurant')"><font color="#FFFF44">Restaurants</font></a>
worldKit to Javascript Communication
User clicks on annotations, or clicks in annotation-input mode, can trigger Javascript code, rather than opening a URL. Javascript callbacks can also be set for zoom/pan, new RSS items, or RSS items expired by "fading". This is useful for filling out forms, loading pictures, etc. without reloading the browser, or precisely controlling the parameters of a new window, or many other tight integrations with web applications.

In each case, worldKit will call a specified function with one argument, args, a string containing kay/value pairs URI encoded.

The example code below demonstrates how to receive (myCallback) and parse (parseArgs) messages from worldKit. In the config.xml, <window> would be set to "_javascript:myCallback".

<script language="Javascript">
function parseArgs(args) {
  var AO = new Object();
  var AA = args.split("&");
  var TA = new Array();
  for (var i=0; i<AA.length; i++) {
    TA = AA[ i ].split("=");
    AO[ TA[0] ] = unescape( TA[1] );
  return AO;

function myCallback(args) {
  var ArgObject = parseArgs(args);
  //do what you will...
  alert (ArgObject["lat"] + "," + ArgObject["long"]);