close panorama

jAddress2 | Direct links to panoramas and views jaddress.min.js
by Digisfera -


jAddress is a javascript plugin which allows direct links to panoramas and views inside tours. It can also change the browser URL so that it links to the scene that the user is currently viewing. It is similar to SWFAddress but has fewer features. On the other hand it is, in my opinion, easier to setup.

jAddress requires krpano or higher!


Here are links to an example virtual tour that uses jAddress. Note that the URL is updated when you change panorama (you can change it using the thumbnails on the bottom left). Note also that the panorama and view will change when you change the URL in the address bar.

Normal link to the tour:

Link directly to a panorama inside the tour:!startscene=scene_pan2

Link directly to a view inside the tour:!startscene=scene_pan2&ath=100&atv=20&fov=50


This plugin costs 10€, which includes future updates. It can be bought from share-it.

Buy the jAddress plugin

Getting started

Include jaddress on your html file:

    <script src="jaddress-min.js" type="text/javascript"></script>

To start a tour, there is usually an action which calls loadscene(), like this:

    <action name="startup">
      loadscene(pano1, null, MERGE, BLEND(2));
    </action >

To use jAddress, you can either (1) replace action by a call to the ja-start() krpano action or (2) remove this action and call the jaddress.start() Javascript function after embedding krpano. Any of these will retrieve the initial scene and view from the URL and load it:

    start(defaultInitialScene, flags, blend)

    <!-- (1) krpano method -->

    <action name="startup">
    </action >

    <action name="startup">
      ja-start(pano1, MERGE, BLEND(2));
    </action >

    // (2) Javascript method

    embedpano({ ... });

    embedpano({ ... });
    jaddress.start("pano1", "MERGE", "BLEND(2)");

If no scene is defined on the URL and no default is set, this action will load the first scene defined in krpano.

XML mode

By default, jAddress uses krpano scenes (loaded with loadscene()), but it can also use XML files (loaded with loadpano()). In this mode, the URL contains the XML filename without the extension.

The easiest way to use the XML mode is to load the file jaddress.xmlmode.min.js instead of jaddress.min.js. Alternatively, you may call the jaddress.xmlMode() Javascript function.

On XML mode, a default initial file must always be passed to jaddress.start()

URL updating

jAddress updates the browser URL bar to link to the current scene. This behaviour can be changed by calling the jaddress.autoUpdateUrl() Javascript function or the ja-autoUpdateUrl() krpano action:

    // Javascript

    <!-- krpano -->

Flags and blend on URL change

When the user manually changes the URL or presses the back/forward buttons, jAddress will load the scene referenced in the new URL. By default, it uses the default flags and blend mode. This may be changed by calling the loadOptions() Javascript function or the ja-loadOptions() krpano action.

    // Javascript
    jaddress.loadOptions(MERGE, BLEND(2));

    <!-- krpano -->
    ja-loadOptions(MERGE, BLEND(2));

Link to current scene/view

You can retrieve the URL for the current scene/view by calling the jaddress.url() Javascript function or ja-url(krpanoVarName) krpano action:

    jaddress.url()  //

    jaddress.url(true)  //

    jaddress.url('nofov')  //

    <!-- krpano -->
    ja-url(samplevar, nofov)
    trace(samplevar) <!-- -->

Alternative scene names

jAddress uses the name property of a scene to identify it. If a scene also has a urlname property, then jAddress will use that

    <scene name="foo"> 
      <!-- (...) -->
    <!-- URL is -->

    <scene name="foo" urlname="bar"> 
      <!-- (...) -->
    <!-- URL is -->

Advanced customization

Besides scene and xml mode, other custom modes can be defined. To do so, you must override two funcions:

  • currentSceneFun() retrieves the current scene name from krpano
  • setLoadFun(sceneName) defines how a scene with a certain name should be loaded

The following methods are available to override these functions:

    jaddress.setCurrentSceneFun(function() { return 'someName'; })

    jaddress.setLoadFun(function(sceneName) { return [ 'loadscene', sceneName ] })