[resolved] when does hotspot[name].onloaded gets fired in javascript

  • Hello,

    I am trying to draw polygons after getting data from server (geometry points). When I try following rows it doesn't fire test() function:

    Test case:
    function test(){
    console.log("fired");
    }
    krpano().call("addhotspot(testhotspot)");
    krpano().set("hotspot[testhotspot].onloaded","js(test())");

    When I can exactly know if hotspot is loaded to put it's points or it's picture? If I try to put its points right after addhotspot() function with:

    krpano().set("hotspot[testhotspot].point[0].ath","22").....
    it doesn't accepts these points all the time.

    I need to know a time when it is safe to put hotspot's colour, points etc but unfortunately onloaded function doesn't get fired.

    edit: If you let me know when krpano does exactly fire "onloaded" event, I can put that property after creating hotspot then add the other properties at onloaded callback. Otherwise adding properties creates inconsistency and this problem doesn't seem to be solved with setTimeouts or setIntervals in javascript.

  • As an example these codes doesn't work right after krpano().call('loadxml(... row, after that when I check console I see spotTest hotspot is placed but point coordinates weren't:


    krpano().call("wait(LOAD)");
    krpano().call("addHotSpot(spotTest)");

    krpano().set("hotspot[spotTest].point[0].ath", 35);
    krpano().set("hotspot[spotTest].point[0].atv", 35);
    krpano().set("hotspot[spotTest].point[1].ath", 37);
    krpano().set("hotspot[spotTest].point[1].atv", 37);
    krpano().set("hotspot[spotTest].point[2].ath", 39);
    krpano().set("hotspot[spotTest].point[2].atv", 39);
    krpano().set("hotspot[spotTest].point[3].ath", 45);
    krpano().set("hotspot[spotTest].point[3].atv", 45);
    krpano().set("hotspot[spotTest].point[4].ath", 55);
    krpano().set("hotspot[spotTest].point[4].atv", 55);
    krpano().set("hotspot[spotTest].point[5].ath", 35);
    krpano().set("hotspot[spotTest].point[5].atv", 35);
    krpano().set("hotspot[spotTest].fillalpha", 0);
    krpano().set("hotspot[spotTest].fillcolor", "0xFF0000");
    krpano().set("hotspot[spotTest].distorted", false);
    krpano().set("hotspot[spotTest].fillcolorhover", "0xFF1111");
    krpano().set("hotspot[spotTest].borderwidth", 2);
    krpano().set("hotspot[spotTest].borderwidthhover", 2);
    krpano().set("hotspot[spotTest].borderalpha", 1);
    krpano().set("hotspot[spotTest].bordercolorhover", "0xFF1111");
    krpano().set("hotspot[spotTest].bordercolor", "0xFF1111");
    krpano().set("hotspot[spotTest].visible", true);

    console output:

    krpano().get("hotspot[spotTest].name")
    "spottest"
    krpano().get("hotspot[spotTest].point.count")
    0

  • Hi,

    are you maybe using the HTML5 viewer?

    If yes - there polygonal hotspots are not supported yet.

    About the onloaded event - this is basically only needed for image hotspots, for polygonal hotspots there is nothing to load.

    Best regards,
    Klaus

  • I found the issue, the problem was in the next pano photograph hotspots were coming earlier than picture load. now problem is solved after binding hot spot loading function to events.onloadcomplete.

    Thanx for the help.

Participate now!

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