easy way to access to a pano ?

  • Hi nelk,

    Yes, there is a way to do using javascript to retrieve a variable from the URL...
    Ex: http://YourDomain.com/PanoTour[color=#ff0000]?pano=panoToBeLoaded[/color]

    I have used, as the base to illustrate the following, the scene example that come with Krpano_1.0.8 download.
    In the scene.xml example, there is an action(onstart) called by the Krpano.onstart argument...
    The action(onstart) is as follow:

    Code
    <action name="onstart">
       loadscene(scene1, null, MERGE);
    </action>


    This action loads the scene to be loaded...
    Then, using a javascript that retrieve the variable pano from the URL, in the scene.html file we go to change dynamically the content of this action with the scene we need to be loaded.
    Like this: so.addVariable("action[onstart].content", "loadscene(" + pano + ", null, MERGE);");

    The resulting scene.html file will be:


    Lines 5 to 18 are the javascript code that retrieve the variables from the URL...
    Note the line 6.... here you set the default value to the variable pano if it is not set on the URL.
    Line 47... this is the line that change the action[onstart].content

    That's all. *wink*


    note: this thread Banner without XML has helped me to get this code.

    Salut.

    Edited once, last by michel (September 15, 2009 at 9:44 PM).

  • Salut *smile*

    Thanks for your answer

    I've few questions :


    - For the code between line 7 and line 17 : I assume that arrVariableActual[0] is equal to pano ?

    (I don't really understand javascript ...)


    - on line 46 you have

    Code
    so.addVariable("xml", "scenes.xml");

    I had never see xml before in a variable.

    Is there a difference between pano and xml ? Is variable xml more like include ?

  • Hi nelk,

    Quote

    - For the code between line 7 and line 17 : I assume that arrVariableActual[0] is equal to pano ?


    I am not an expert... But I am going to explain what I understand here... *whistling*

    Ex: http://YourDomain.com/PanoTour[color=#ff0000]?pano=panoToBeLoaded&var2=value[/color]&var3=value&etc....

    Code line 7 : searchVariables = location.search.substring(1,location.search.length);
    result: searchVariables = pano=panoToBeLoaded&var2=value&var3=value&etc....


    Code line 9 : arrVariables = searchVariables.split("&");
    result: arrVariables[0] = pano=panoToBeLoaded
    arrVariables[1] = var2=value
    arrVariables[2] = var3=value
    arrVariables[3] = etc....

    Code line 10 : for (i=0; i<arrVariables.length; i++) {
    going to make a buckle for each existing arrVariables[X]

    Code line 11 : arrVariableActual = arrVariables.split("=");
    result: arrVariableActual[0] = pano when on the first buckle
    arrVariableActual[1] = panoToBeLoaded when on the first buckle
    .....
    arrVariableActual[0] = var2 when on the second buckle
    arrVariableActual[1] = value when on the second buckle (edited: when on the first buckle)
    and so on.....

    Code line 13 :eval(arrVariableActual[0]+"='"+unescape(arrVariableActual[1])+"';");
    this line is the one declare the variable=value
    result:pano = panoToBeLoaded

    Now, we have the variable pano to use in :
    so.addVariable("action[onstart].content", "loadscene(" + pano + ", null, MERGE);");


    Basically, this is what the javascript code dones....


    Quote

    - on line 46 you have .....

    Code
    1 so.addVariable("xml", "scenes.xml");

    This is the code KLAUS use on his scene.html code ....

    Hope I am understandable.... *blink* *g* (Really bad English)

    Salut.

    Edited 2 times, last by michel (September 17, 2009 at 4:09 AM).

  • Hi,

    I would like to achieve this (so.addVariable("action[onstart].content", "loadscene(" + pano + ", null, MERGE);");) with swfobject 2.2.

    I tried this (line 5):

    Code
    swfobject.embedSWF("krpano.swf", "panoramaDiv", 
    "100%", "100%", "9.0.28", 
    "basis/expressInstall.swf", 
    {pano:"pano/heuvel.xml"},
    {"action[onstart].content":"loadscene(" + pano + ", null, MERGE);"},
    {allowfullscreen:true, bgcolor:"#000000"}, 
    {id:'panoramaDiv', name:'panoramaDiv'});

    ...but it doesn't work. Any ideas?


    Edit: already found out. Has to be like this:

    Code
    swfobject.embedSWF("krpano.swf", "panoramaDiv", 
    "100%", "100%", "9.0.28", 
    "basis/expressInstall.swf", 
    {pano:"pano/heuvel.xml", "action[onstart].content":"loadscene(" + pano + ", null, MERGE);"},
    {allowfullscreen:true, bgcolor:"#000000"}, 
    {id:'panoramaDiv', name:'panoramaDiv'});
  • Hi photo40,

    edited: Forget this... see edited above.
    Perhaps you can try in this way (just an idea, I have not tried):

    Code
    {pano:"pano/heuvel.xml?action[onstart].content=loadscene(' + pano + ', null, MERGE);"},

    SAlut.

    Edited once, last by michel (January 15, 2010 at 7:31 PM).

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!