Search code examples
gisgoogle-earthopenscenegraph

How to load kml files into osgEarth using .earth file?


I want to simply show some kml files with osgearth_viewer.exe.

I've read the osgEarth documentation and get nothing about how to load a lot of KML files by using .earth file with osgearth_viewer.exe.

I know how to load one kml file using comand line parameter --kml , but I wanna to show all kml files once.

Any help would be gratefully appreciated and sorry for my poor English.


Solution

  • The example here: http://code.metager.de/source/xref/osgearth/src/applications/osgearth_kml/osgearth_kml.cpp#63

    Shows pretty clearly how you do it. Just do the

            osg::Node* kml = osgDB::readNodeFile( kmlFile, options.get() );
            if ( kml )
                root->addChild( kml );
    

    steps as many times as you want for as many KML files as you want.