想要在全景中以文字热点的方式实时显示一些数据,不需要刷新。
1、在tour.html中使用js动态生成实时变化的文字内容,这里用了定时器自动增加,在实际应用中可以定时读取相应的数据库中的内容。
<SCRIPT LANGUAGE="JavaScript">
var des = 1;
var krpano = document.getElementById('krpanoSWFObject');//获取krpano 对象
krpano.call("startup();");
function time(){
des++;
console.log(des);
krpano.set("test", des);
}
window.setInterval("time();",1000);
</SCRIPT>
2.在tour.xml文件中使用定时器读取js中的文字。这里先在startup的action中调用krpano中的定时器函数。
<action name="startup" autorun="onstart">
<!-- images为自动浏览标志,调取的全景图序号 -->
set(startscene,get(images));
<!-- hotspot_ons为开启自动浏览打开热点碎片标志-->
set(hotspot_ons,get(hotspot_on));
if(startscene === null OR !scene[get(startscene)], copy(startscene,scene[0].name); );
loadscene(get(startscene), null, MERGE);
<!--定时器-->
setinterval(test, 1.0,
set(hotspot[hs1].html,get(test));
);
</action>
3.设置相应的热点
<hotspot name="hs1" url="%SWFPATH%/plugins/textfield.swf" ath="10" atv="0" children="false" enabled="true" align="top" y="50" autowidth="true" autoheight="true" vcenter="true" zoom="false" distorted="false"
border="false" background="false" backgroundcolor="0x000000" backgroundalpha="0.7" roundedge="5"
css="text-align:center; color:#000000; font-family:Arial; font-weight:bold; font-size:21px;" zorder="1" html="" />
<action name="test">
set(hot,get(test));
</action>