There are several ways to embed the krpano viewer into a HTML page,
but the swfkrpano.js script is the current default and most functional embedding
method provided by krpano.
The script does many things automatically and it fixes a lot
of browser and system related issues. This makes the embedding
easy and simple.
The script is based on the SWFObject 1.5
and the krpano swfkrpanomousewheel.js script, both scripts can also be used separately and without the additional
krpano functions.
Automatic checking if Javascript is enabled⇒ if not it shows a warning.
Automatic checking if there is a Flashplayer installed and if the installed version is okay.
Automatic checking for iPhone, iPad or iPod Touch devices and loading the
alternative krpano Javascript viewer (krpanoJS / krpanoiphone.js).
It allows generating a single Javascript file which has all other Javascript files embedded (swfkrpano.js + krpanoiphone.js + license).
When using the krpano make pano droplets with the setting embedlicenses=true this will be done automatically.
It enables the usage of the Mouse wheel for zooming on Mac OSX systems.
It fixes the mouse wheel usage on the HTML page - don't scroll the page when zooming inside the pano.
It fixes the mouse behaviors when using the Flashplayer wmode = transparent / opaque settings
(in detail - it enables the mouse wheel usage and fixes the mouse release outside the pano window).
It enables the usage of the Flashplayer Fullscreen Mode automatically.
Easy and simple usage of the embedding code.
It provides additional helper functions (passing parameters).
var viewer = createPanoViewer(parametersobject);
viewer.embed();
or:embedPanoViewer(parametersobject);
or simply:embedpano(parametersobject);
The createPanoViewer function creates and preparses the pano object for embedding.
The embedding object will be returned for addtional settings. With calling the embed
function the viewer will be finally embedded.
The embedPanoViewer and embedpano functions (both the same) are directly
creating and embedding the viewer.
The parametersobject is a Javascript Object with the following attributes:
swf(optional)
Name and path to the swf file (relative to the html file). The default is "krpano.swf".
xml(optional)
Name and path to the pano xml file (relative to the html file). By default the name of the swf file (="krpano.xml" without swf setting).
target
The ID of the HTML object where the viewer should be embedded. Can be overwritten in the embed() function.
id(optional)
The ID of the viewer object in the HTML DOM.
Get the krpano Javascript Interface from this object.
The default ID is "krpanoSWFObject".
width(optional)
Width of the Viewer object, can be a absolute pixel value or a relative percent value.
Default = "100%".
height(optional)
Height of the Viewer object, can be a absolute pixel value or a relative percent value.
Default = "100%".
var viewer = createswf(swffile, id, width, height, bgcolor);
or:
var viewer = createkrpanoSWFviewer(swffile, id, width, height, bgcolor);
or: (for the krpanoJS HTML5/iPhone/iPad viewer only)
var viewer = createkrpanoJSviewer(id, width, height);
The createswf and createkrpanoSWFviewer functions are the same (just different names)
and they create the object for embedding the pano. They will automatically use the krpanoJS
Viewer when necessary (on the iPhone/iPad).
The createkrpanoJSviewer function on the other side uses always the krpanoJS viewer.
Parameters:
swffile
Name and path to the swf file (relative to the html file).
id(optional)
ID of the Flash object in the HTML DOM.
Get the krpano Javascript Interface from this object.
The default ID is "krpanoSWFObject".
width(optional)
Width of the Flash object, can be a absolute pixel value or a relative percent value.
Default = "100%".
height(optional)
Height of the Flash object, can be a absolute pixel value or a relative percent value.
Default = "100%".
bgcolor(optional)
Default Background color of the Flash object.
Default = "#000000" (=Black).
viewer.addVariable(variable, value);
set krpano variables
either set the krpano startup variables here
(e.g. the "xml" or "path" variable for the path / name of the startup xml file) or ...
... set any other krpano variable here.
the variables set here, will be set when xml file was loaded and parsed,
so these variables can be used to overwrite variables / settings from the xml.
viewer.addParam(parameter, value);
set Flashplayer parameters
The only parameters that make sense in krpano are allowFullscreen,
allowScriptAccess and wmode, where allowFullscreen will
be automatically set to true by the swfkrpano.js script.
viewer.passQueryParameters();
Passes automatically all query parameters from the html to the swf file.
Here all default values will be used: "krpano.swf" as name for the flash viewer file,
"krpano.xml" as default xml file, "krpanoSWFObject" as viewer id and 100% as size.
Only the target where the pano should be embedded must be set.
<script>
var swf = createswf("krpano.swf");
swf.embed("krpanoDIV");
</script>
In this example the krpano "default loading" is used.
When no xml file is specified a .xml file which is named like the .swf will be loaded.
e.g. a krpano.swf will load the krpano.xml.