目錄
在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);
}