Sie sind nicht angemeldet.

1

Dienstag, 27. Januar 2015, 10:29

Create hotspots on mouse click event

Hi all krpano fans,
I'm new in KRpano, and I want to add a panoramic view in a website,
I already managed to do that for the 'user-view', now I try to add an admin page for my panorama,
where I will add/remove hotspot with onclick event of the mouse.
I found the editor plugin but it didn't do exactly what I want, so I started to develop my own plugin in Javascript.
My problem is, when I try to get the mouse coordinates of the click event when I add hotspot,
In my plugin :

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function edithotspot(callingObject)
    {
        krpano.call("screentosphere(mouse.x,mouse.y,m_ath,m_atv);");
        var posX = krpano.get('m_ath');
        var posY = krpano.get('m_atv');
        krpano.trace(1,posX);
        krpano.trace(1,posY);
        if (callingObject == 'mouse') { 
            if (addclicked) {
                var uniqname = "hs" + Date.now();
                krpano.trace(1, 'add hotspot');
                krpano.call("addhotspot(" + uniqname + ");");
                krpano.call("set(hotspot[" + uniqname + "].ath," + posX + ");");
                krpano.call("set(hotspot[" + uniqname + "].atv, " + posY + ");");
                krpano.call("hotspot[" + uniqname + "].loadstyle('hotspot_ani_white');")
                krpano.call("set(hotspot[" + uniqname + "].onclick,openplugin();");
            }
        } else {
            if (delclicked) {
                krpano.trace(1, "del hotspots");
                krpano.trace(1, callingObject);
                krpano.call("removehotspot(" + callingObject + ");");
            }
        }
    }


and in my XML I have :

Quellcode

1
<events onclick="plugin[myplugin].edithotspot('mouse')" />


But when I try that the coordinates show in the logs have one click late,
first clic : null, null
second click : ath of first click, atv of first click
third click : ath of second click, atv of second click
...

Anybody knows where I'm wrong ?

Note :
in the code addclicked/delclicked are two boolean variables activate when I click on "add hotspot" or "remove hotspot" buttons

Thanks for help
sorry if my english is bad I'm french

2

Dienstag, 27. Januar 2015, 14:17

Hi,

the 'call' interface isn't synchronous, that means it's not guaranteed that the given actions will be directly processed after calling.

But you can call screentosphere() function also directly in plugins - see here:
http://krpano.com/docu/plugininterface/#krpanointerface

e.g.

Quellcode

1
2
3
4
var mx = krpano.get("mouse.x");
var my = krpano.get("mouse.y");
var pt = krpano.screentosphere(mx,my);
krpano.trace(1, "mouse="+mx+"/"+my+" pano="+pt.x+"/"+pt.y);


Best regards,
Klaus

3

Dienstag, 27. Januar 2015, 15:47

Thanks for this fast answer

I tried and it works !! ^^

Now I can make lots of flashing point over the screen *thumbup*

Thanks for your help

4

Donnerstag, 12. Februar 2015, 17:00

sequel to the hotspot creation plugin

Hi guys,

I returned after a little period of work with Krpano
it's really a nice tool

I add some new ideas to my plugin but one keep blocking me,

I though of a way for the user to add hotspot dynamically with mouse clicks,
all the hotspots added/removed are stored in an multi-dim array with all their parameters (position, name, style,...), this array is transfered to a php script and I modify the XML file with DOM to create/remove hotspots.
But currently the onclick parameter need to be set in the XML file (loadscene(...)) a la mano,

a simple idea to me was to popup a combobox on mouse position with the list of all scenes, so the user can choose which one to open with the created hotspot

I already manage to create a combobox (with jQuery) and pop it on mouse position,
the problem is when I need to specify the onclick action inside my <option> tag,
I cannot reference one of my plugin methods because they are private

so my question is :
Can we (by any means) call a plugin methods outside the panorama xml or plugin.js file ?


I tried the combobox.js plugin with krpano, and this can be a great answer to my jquery combobox problem
but I can't manage to pop the combobox on my mouse cursor

Thanks for help
and tell me if more informations is needed