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).
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%".
bgcolor(optional)
The background color of the viewer (in HTML Color Format).
Default = "#000000" (=Black).
useHTML5(optional)
Directly set the useHTML5 setting.
vars(optional, embedpano() only)
A Javascript Object that can contain krpano variables that should be set.
wmode(optional, embedpano() only)
Directly set the wmode parameter.
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).
either set the krpano startup variables here.
(e.g. the "xml" or "pano" 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.
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.
There are some special variable for embedding the viewer. These variables will not directly passed to the viewer - they have a special meaning for the embedding itself:
xml or pano
With the xml or pano variable (both the same) it's possible to specify the path / name
of the startup xml file.
When no xml or pano variable will set then the 'default loading' will happen, which tries to load
a xml file which has the same 'basename' as the swf file (e.g. krpano.swf ⇒ krpano.xml or pano.swf ⇒ pano.xml
or tour.swf ⇒ tour.xml and so on ...).
license
By default and when no license is embedded then the krpano Flash viewer tries to load a license file which
has the same 'basename' as the swf file (e.g. krpano.swf ⇒ krpano.license or pano.swf ⇒ pano.license
or tour.swf ⇒ tour.license and so on ...).
But with the license variable it's possible to set a custom path / name of the license file.
simulatedevice
The krpano viewer detects on which device (Desktop, iPhone, iPad, Android, ...) it is running, even with changed User-Agent of the Browser.
This was done to load the right images regardless of the User-Agent - on Desktop the bigger Desktop images will be loaded, on iPhone/iPod 3 the smaller <mobile>
images and on iPhone/iPod 4 and iPad the middle-sized <tablet> images. Addtionally there is an automatic internal scaling on the iPhone/iPod devices.
So to allow testing the iPhone / iPad / Android images and scalings also on Desktop there is the simulatedevice setting.
Possible settings are:
"iphone" - simulate the iPhone/iPod (krpanoJS only, <mobile> images and downscaled layout)
"ipad" - simulate the iPad (krpanoJS only, <tablet> images)
"useragent" - simulate the device depending on the User-Agent (krpanoJS only, Desktop, iPhone or iPad)
"androidmobile" - simulate an Android Mobile device (Flash only)
"android" or "androidtablet" - simulate an Android Tablet device (Flash only)
The krpano iPhone/iPad Simulator (included in the viewer download package) is using that setting together with an iPhone / iPad background and an original sized viewing window.
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.