You are not logged in.

1

Wednesday, November 21st 2018, 12:37am

Get array of every hotspot via Javascript

Hi,

I am trying to get an array of every hotspot that is present in a tour regardless of which scene it belongs to. So for example krpano.get("scene") will give me an array of every scene but need an equivalent for hotspots.

I would also like to establish the parent scene of each hotspot.

Any suggestions as to the best way forward?

Thanks
GK

2

Wednesday, November 21st 2018, 4:48pm

.....Although I just found a similar question in https://krpano.com/forum/wbb/index.php?p…d&threadID=9355

I therefore assume this is still the case ?

3

Monday, November 26th 2018, 11:39pm

GeoK,

As you can see the post, the hotspots are generated on-the-fly when scene is created. (Pro: same hotspotnames for different scenes, loading Just In Time).

Apparently I will face to the same issue and I see following scenarios:
a) create my own xml tag with hotspot attributes and scenename and load the particular hotspots on the onstart event of the scene;

b) create all hotspots outside the <scene /> tag and add the attribute scenename=parent_scene to each hotspot. On onstart event of the scene just set enabled=true for the hostposts where the scenename=currentscene.
(Cons: performance and memory issue when big image hotspots).

Has anybody a better idea?
Thank all of you,
Pavel

4

Tuesday, November 27th 2018, 11:13am

you need to understand that :
- you can access all scene properties by scene[x].property
- but there is only one scene content active at a time

that means you cannot access the hotspots defined in any scene,
only the ones of the active loaded scene.

so either you parse all scenes xml manually by using scene[x].content
or you build your hotspot information as an array outside the scenes,
and then add them dynamically onxmlcomplete or onnewscene for each scene

5

Tuesday, November 27th 2018, 3:30pm

For my purposes I have gone down the parsing scene content route.

Thanks
GK

6

Monday, December 3rd 2018, 5:09pm

I suppose by way of a feature request - it would be useful to have access to the full XML. Parsing the xml text is fine albeit a bit clumsy and I would hazard a guess that eventually, parsing may fail due to future version changes in the xml - naming conventions, syntax changes, etc....?