Hi Tourvista,
Great the context menu to activate the Coordinates finder
Perhaps you would edit your first post for tell about this change ... (the first time I has returned to the link, I was not able to see the cursor

)
Ideally I would like to show the coordinates all the time without the hassle of clicking all the time.
This can be done using the onviewchange event...
|
Source code
|
1
|
<events onviewchange="action(buildtext);"/>
|
A really cool alternative would be to show a little box with the coordinates when he click twice somewhere on the panorama, but I have no idea how to achieve that!
This can be done too

... an onDoubleClick event can be simulated using JavaScript. See this thread for more info:
OnDoubleClick -- MoveTo() -- ScreenToSphere()
So, using the explained above, a possible code would be:
Add the following JavaScript code inside your html file:
|
Source code
|
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
26
27
28
29
30
31
|
<script type="text/javascript">
// <![CDATA[
function krpano() {
return document.getElementById("krpanoSWFObject");
}
function krpanodbclick(arg) {
setTimeout("numclick = 0",300);
numclick = numclick + 1;
if (numclick == 2) {
eval(arg);
}
}
function movetoscreentosphere() {
var mousex = krpano().get("mouse.x");
var mousey = krpano().get("mouse.y");
var hvs = krpano().get("screentosphere("+mousex +","+mousey +")");
var hva = hvs.split(",");
var ath = Number( hva[0] );
var atv = Number( hva[1] );
krpano().call("moveto("+ ath +","+ atv +")");
}
// ]]>
</script>
|
Add the xml file would be:
|
Source code
|
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
<!-- ***************** HOT SPOTS EDITOR ********************** -->
<contextmenu fullscreen="false">
<item name="coord_finder"
caption="Coordinates finder - ON"
onclick="action(run_hs_editor); "
/>
</contextmenu>
<action name="run_hs_editor">
copy(Back_onviewchange,events.onviewchange);
copy(Back_onclick,events.onclick);
set(events.onviewchange,action(buildtext););
set(events.onclick,js(krpanodbclick(movetoscreentosphere())););
addplugin(hs_editor);
set(plugin[hs_editor].url,%HTMLPATH%/images/cross.png);
set(plugin[hs_editor].zorder,5);
set(plugin[hs_editor].align,center);
set(plugin[hs_editor].handcursor,false);
set(plugin[hs_editor].keep,true);
addplugin(click);
set(plugin[click].url,%HTMLPATH%/images/click.png);
set(plugin[click].zorder,10);
set(plugin[click].align,center);
set(plugin[click].keep,true);
set(plugin[click].edge,topleft);
set(plugin[click].x,20);
set(plugin[click].y,20);
set(plugin[click].onclick,action(close_hs_editor););
set(contextmenu.item[coord_finder].caption,Coordinates finder - OFF);
set(contextmenu.item[coord_finder].onclick,action(close_hs_editor));
action(buildtext);
</action>
<action name="close_hs_editor">
set(events.onviewchange,get(Back_onviewchange));
set(events.onclick,get(Back_onclick));
removeplugin(hs_editor);
removeplugin(click);
removeplugin(hs_coordinates);
set(contextmenu.item[coord_finder].caption,Coordinates finder - ON);
set(contextmenu.item[coord_finder].onclick,action(run_hs_editor));
</action>
<data name="coordinates"></data>
<action name="buildtext">
mod(hdistance,get(view.hlookat),360);
roundval(hdistance,0);
set(vdistance,get(view.vlookat));
roundval(vdistance,0);
set(fovdistance,get(view.fov));
roundval(fovdistance,0);
txtadd(data[coordinates].content, get(hdistance), ' <br/> ', get(vdistance), ' <br/> ', get(fovdistance) );
addplugin(hs_coordinates);
set(plugin[hs_coordinates].url,%SWFPATH%/plugins/textfield.swf);
set(plugin[hs_coordinates].html,data:coordinates);
set(plugin[hs_coordinates].css,p{font-family:Arial;font-weight:bold;font-size:14;text-align:center;});
set(plugin[hs_coordinates].width,40);
set(plugin[hs_coordinates].height,50);
set(plugin[hs_coordinates].zorder,11);
set(plugin[hs_coordinates].background,false);
set(plugin[hs_coordinates].align,center);
set(plugin[hs_coordinates].x,135);
set(plugin[hs_coordinates].y,45);
set(plugin[hs_coordinates].keep,true);
</action>
|
Some explanation of the xml...
changes for the contextmenu to make an
Coordinates finder on/off :
line 5 -- changed the caption for the contextmenu item : Coordinates finder
- ON
lines 35 -- setting the caption for the contextmenu item : Coordinates finder
- OFF
lines 36 -- setting the onclick for the contextmenu item : action(
close_hs_editor)
lines 51 -- setting the caption for the contextmenu item : Coordinates finder
- ON
lines 52 -- setting the onclick for the contextmenu item : action(
run_hs_editor)
changes inside the action(run_hs_editor):
lines 12 --
Back_onviewchange... a variable to retrieve the value of event onviewchange if already exist...
lines 13 --
Back_onclick... a variable to retrieve the value of event onclick if already exist...
lines 15 -- set the event onviewchange to call the
action(buildtext); on each view change...
lines 16 -- set the event onclick to call the javascript
js(krpanodbclick(movetoscreentosphere())); that simulate an ondoubleclick...
lines 33 -- change the onclick to close the
Coordinates finder instead of display the coordinates...
lines 35,36 --
see above contextmenu
lines 38 -- caling the action(buildtext); to force displaying the coordinates at first...
Added a new action to close the
Coordinates finder --
action(close_hs_editor):
line 44 -- set back the event onviewchange...
line 45 -- set back the event onclick...
lines 47-49 -- removing the plugings of the
Coordinates finder
lines 51,52 --
see above contextmenu
OUF !!! That's all

. I think all it's correct. Comments are welcome...
SAlut.