You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Friday, September 23rd 2016, 11:28am

krpano Javascript Interface

Hello to all.

I just want to get second set of mind for a few questions I have:

1. when using embedpano() with the onready callback I found that the onready is fired too soon -> I create a JS file with the function that has to be called when the krpano is loaded and ready, but when I try to log out the krpano instance object it doesn't exist -> but available after 500ms setTimeout - I think the onready callback function is triggered to quick, even before the krpano is really ready.

2. No way to add and "id" property to the layer that gets created when constructing a layer with xml - did anybody find a way to do something like this ? So that the created layer/div is easy to access from external JS.

Hope this gets answered.

Regards,

Nejc

2

Tuesday, September 27th 2016, 9:42pm

Hi,
1. when using embedpano() with the onready callback I found that the onready is fired too soon -> I create a JS file with the function that has to be called when the krpano is loaded and ready, but when I try to log out the krpano instance object it doesn't exist -> but available after 500ms setTimeout - I think the onready callback function is triggered to quick, even before the krpano is really ready.
The onready event will be called from the viewer itself once it is ready for working. It can't be to early or 'too quick'.

But note - a ready viewer doesn't mean it had already loaded the xml file or anything further, for this there are other events (e.g. onxmlcomplete).


2. No way to add and "id" property to the layer that gets created when constructing a layer with xml - did anybody find a way to do something like this ? So that the created layer/div is easy to access from external JS.
You could use a JS action to assign an id to a layer - e.g.:

Source code

1
2
3
4
5
<action name="assign_dom_id" type="Javascript">
  caller.sprite.id = args[1];
</action>

<layer ... onloaded="assign_dom_id('layer1');" />


See also here:
http://krpano.com/docu/xml/#action.js
http://krpano.com/docu/xml/#layer.sprite

Best regards,
Klaus