Krpano 動態傳參/Javacript調用/關聯action

效果解釋:點擊熱點1,觸發顯示或隱藏熱線2。html

例:在熱點hotspot的onclick事件下觸發。ide

參考資料:code

  • https://krpano.com/docu/xml/#action
  • http://www.krpano360.com/krpano-1-19qianruhtmlyemian/
  • https://www.cnblogs.com/tianyajuanke/p/5843164.html

JavaScript方式:xml

<hotspot name="spot8" style="point_hotspotstyle" ath="-40.231047" atv="30.013785" tooltip="地塊標記2" value="0" onclick="delayedcall(0, show_hide_dk('spot5'));"/>
		<hotspot name="spot5" keep="false" visible="false" capture="false" > 
			<point ath="-59.231047" atv="38.013785" />
			<point ath="-40.724703" atv="20.316996" />
			<point ath="-34.629793" atv="30.977534" />
			<point ath="-35.981462" atv="30.756996" />
			<point ath="-38.941133" atv="34.388267" />
			<point ath="-46.442973" atv="35.996213" />
		</hotspot> 

======================================= 割鹿刀 ==============================================

<!-- 觸發顯示或隱藏 -->
<action name="show_hide_dk" type="Javascript">
	alert(args[1]);
</action>

 

沒什麼用的方法:htm

hotspot等標籤容許編寫自定義屬性,這裏直接設置自定義屬性爲dk=spot6,點擊spot7,顯示或隱藏spot6。blog

action方法體中,直接引用get(dk)便可得到對應的屬性值。事件

<hotspot name="spot7" style="point_hotspotstyle" ath="8.234451" atv="16.783737" tooltip="地塊標記" value="0" dk="spot6" onclick="show_hide_point()"/>
<hotspot name="spot6" keep="true" visible="false" capture="false" > 
		<point ath="2.234451" atv="16.783737" />
		<point ath="18.937711" atv="15.35975" />
		<point ath="25.056067" atv="25.345991" />
		<point ath="3.322098" atv="27.186262" />
</hotspot> 

======================================= 可愛的分割線 ===============================================

  <!-- 觸發顯示或隱藏 -->
  <action name="show_hide_point">
  	toggle(hotspot[get(dk)].visible);
  </action>
  <action name="show_dk">
  	set(hotspot[get(dk)].visible, true);
  </action>
  <action name="hide_dk">
  	set(hotspot[get(dk)].visible, false);
  </action>
  <action name="show_hide_dkm">
  	toggle(layer[get(dkm)].visible);
  </action>
相關文章
相關標籤/搜索