close panorama

jAddress2 | Direct links to panoramas and views jaddress.min.js
by Digisfera - m.cabral@digisfera.pt

Description

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 1.0.8.14 or higher!

Examples

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:
demo.digisfera.pt/jaddress2-demo/scenes/tour.html

Link directly to a panorama inside the tour:
demo.digisfera.pt/jaddress2-demo/scenes/tour.html#!startscene=scene_pan2

Link directly to a view inside the tour:
demo.digisfera.pt/jaddress2-demo/scenes/tour.html#!startscene=scene_pan2&ath=100&atv=20&fov=50

Buy

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

Buy the jAddress plugin
10€

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">
      ja-start();
    </action >

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

    // (2) Javascript method

    embedpano({ ... });
    jaddress.start();

    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
    jaddress.autoUpdateUrl(false)

    <!-- krpano -->
    ja-autoUpdateUrl(false)
    

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()  // http://touraddress.com#startscene=foo

    jaddress.url(true)  // http://touraddress.com#startscene=foo&ath=100&atv=-5&fov=50

    jaddress.url('nofov')  // http://touraddress.com#startscene=foo&ath=100&atv=30

    <!-- krpano -->
    ja-url(samplevar, nofov)
    trace(samplevar) <!-- http://touraddress.com#startscene=foo&ath=100&atv=30 -->
    

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"> 
      <!-- (...) -->
    </scene>
    <!-- URL is http://touraddress.com#startscene=foo -->

    <scene name="foo" urlname="bar"> 
      <!-- (...) -->
    </scene>
    <!-- URL is http://touraddress.com#startscene=bar -->
    

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 ] })