News Examples Documentation Download Buy Forum Contact



XML Extensions


Third Party Software
for krpano

NOTE: This page is from an older version, see the latest version here.

krpano Javascript Interface Version 1.18

To get access to krpano from Javascript the krpano Javascript-Interface object will be required.

This object can be get either
  • by using the onready callback-function of the embedding script (the recommended way)
  • or by using the Javascript call: document.getElementById(id)
    The id parameter is the unique id of the viewer (which is "krpanoSWFObject" by default) and can be also set in the embedding script.

The krpano Javascript-Interface object

The interface object provides these Javascript functions:
  • set(variable,value) - set the given krpano variable to the given value.
  • get(variable) - return the value of the given krpano variable.
  • call(action) - call and execute any krpano action code.
  • spheretoscreen(h,v) - directly call the spheretoscreen action.
  • screentosphere(x,y) - directly call the screentosphere action.
The spheretoscreen / screentosphere functions will return an object with x, y properties.

Usage Example

Get the krpano HTML DOM Element:
var krpano = document.getElementById("krpanoSWFObject");

Get and set a variable:
var fov = Number( krpano.get("view.fov") );
fov += 10.0;
krpano.set("view.fov", fov);

Call a krpano action, e.g. to load an other pano."loadpano('pano2.xml',null,MERGE,BLEND(1));");


These examples were also included in the krpano viewer download package in the folder "examples/javascript-interface/".

  • loadpano() Example
    Shows how to call krpano and load other panos on Javascript clicks.
  • Mouse Position Example
    Get and show the current mouse position in pixels and spherical coordinates.
  • Get Link Example
    Get a link to the current Pano and the current view.
  • Sync Example
    Syncing two krpano viewers via Javascript.
  • Splitscreen Example
    Syncing two krpano viewers via Javascript and use different viewing areas to simulate a splitscreen.