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

Tuesday, April 14th 2015, 11:09am

Action to change hotspot URL based on JS variable

Hi,

Firstly thank you for this great combination of technology.



I am working on integration krpano into Articulate Storyline. I have everything setup and working as I need to between SL and krpano.

One important item from a UX point of view is to change the hotspot to a different graphic and make it visible based on JS variables.
I have an action in the pano.xml that fires a JS function in pano.html when a user clicks on a hotspot. This function gets and sets variables in SL>

Based on these variables I would like to change the url and alpha value of a given hotspot.

Can I access the JS variables from the pano.xml and have an action to change the URL and Alpha?

Please let me know if you need more information.

panomaster

Intermediate

Posts: 277

Location: Kobyłka, Poland

Occupation: Virtual Tours - Spherical Panoramas - Krpano developer

  • Send private message

2

Tuesday, April 14th 2015, 12:41pm

Something like this?

KRPano hotspot (xml file)

Source code

1
<hotspot name="hs1" url="icon.jpg" alpha="0.5" ... onclick="js(changeHotspot(get(name)))"/>


javascript:

Source code

1
2
3
4
function changeHotspot(hsname) {
    krpano.call("set(hotspot[" + hsname + "].url, newImage.jpg);");
    krpano.call("set(hotspot[" + hsname + "].alpha, 1);");
}


You have to initiate krpano object before start using javascript interface (http://krpano.com/docu/js/#usage)

3

Tuesday, April 14th 2015, 1:35pm

Yes Panomaster, that is exactly what I am looking for.
I will implement and report back.

Thank you!. *smile*

4

Monday, April 20th 2015, 12:28pm

Works like a charm.

Thanks again for your help.

5

Monday, April 20th 2015, 4:25pm

"Works like a charm.

Thanks again for your help."

Sorry I spoke too soon.

The krpano.call is not working from the javascript function in pano.html. The function breaks at this point.
I setup my file to use the code verbatim except for the url off course.

I can get everything to work from the pano xml but I need to store the state in my use, pano.html gets reloaded after a user views the content for a given hotspot and returns to the panorama. So I would like to make sure the hotspot shows the visited version of the image.

I am troubleshooting and trying alternatives.

6

Monday, April 20th 2015, 6:10pm

I missed the line about initiating in your post *whistling* :
You have to initiate krpano object before start using javascript interface (http://krpano.com/docu/js/#usage)



working on this.

7

Tuesday, August 4th 2015, 11:37am

my code does not work,

Source code

1
krpano.call("set(autorotate.enabled,true);");



why...?