How to pass an array to a plugin

  • I’ve written a Javascript plugin. I need to pass an array of arrays (array of latitude/longitude pairs) to it. In Javascript it looks like this:

    Code
    var locData = [
        [59.62856947827632, 3.944420249288397],
        [59.62814600635401, 3.944630157340777],
        [59.62779724440824, 3.944840256674767],
        [59.62757954693874, 3.944887326777842],
        // many more
    ];

    What is the best way to pass that from a krpano xml <plugin> element?

  • How do you want to store the data in the xml file?

    Yes, that is the question. I’m experienced in JavaScript, but new to krpano Script.

    Converting everything into XML nodes with strings, passing it and then parsing it into floats and recreating the array structure seems a bit laborious.

    I tried this:

    But it does not work. The action is not called before passing the attributes to the plugin, so all I get is the string "calc(getPolyCoordinates());".

  • Just set them directly - here 'one' possibility (there would be also many other ones):

    That action will be executed before the plugin is loaded, so the data will be already there when it starts.

Participate now!

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