Multiple Panos Single javaScript

  • Hi there

    I have an html page with 2 panos on it - each in a different div and with a different id (lets say pano1 and pano2)

    I've got the following in my XML:


    This works fine

    When a pano is clicked the event is raised and I do something.

    In my case I get the x/y of the location clicked at using something like:-


    function krpano_mouseclick() {


    var krpano2 = document.getElementById("Pano2");

    if (krpano2 && krpano2.get)
    {
    krpano2.call("screentosphere(mouse.x, mouse.y, mouseath, mouseatv)");

    var mouse_at_xr = krpano2.get("mouse.x");
    var mouse_at_yr = krpano2.get("mouse.y");


    etc etc


    Obviously this works fine for either Pano1 OR Pano2 - whichever I hard code in the getElementByID method - but because I am loading the panos dynamically I need to be able to detect which pano has been clicked in this javascript (I can't have 2 different events for example).

    So....

    ...is there a way in the xml event to pass back the id of the Pano ? Or is there some other/better way of doing this on the JS side ?

    Hopefully that is clear and makes some kind of sense

    Many thanks in advance

    Steve

  • Hi,

    ...is there a way in the xml event to pass back the id of the Pano ? Or is there some other/better way of doing this on the JS side ?

    automatically not, but you could pass the dom id via "addVariable" during embedding to krpano and then get them again.

    e.g.
    js:

    Code
    var viewer = createPanoViewer();
    viewer.addVariable("xml", "pano1.xml");
    viewer.addVariable("domid", "pano1");
    viewer.embed("pano1");

    xml:

    Code
    js( krpano_mouseclick( get(domid) ) );

    js:

    Code
    function krpano_mouseclick(domid)
    {
      var krpano = document.getElementById(domid);
     ...
    }

    but that's just one solution, I'm sure there are also other possibilities, it depends how you code/system will be structured,

    best regards,
    Klaus

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!