OSGEarth隱藏顯示tif圖層

目錄

一、.earth文件中加載tif文件

二、C++代碼實現實時顯示與隱藏

顯示圖層

 隱藏圖層


在OSGEarth中,爲了實現對tif圖層的智能化管理,有時需要實現tif圖層的實時顯示與隱藏。

一、.earth文件中加載tif文件

在.earth文件中加入下列代碼即可實現對example.tif文件的加載。

注:注意設置name,才能通過name實現對tif圖層的顯示與隱藏。

	<image name="example" driver="gdal">
		<transparent_color>0 0 0 0</transparent_color>
		<url>example.tif</url>
	</image>

二、C++代碼實現實時顯示與隱藏

顯示圖層

void osgCoreLib::showImage() {
	example= map->getImageLayerByName("example");
	example->setVisible(true);
}

 隱藏圖層

void osgCoreLib::hideImage() {
	example= map->getImageLayerByName("example");
	example->setVisible(false);
}

 

 

 

發佈了277 篇原創文章 · 獲贊 222 · 訪問量 48萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章