[Marble-devel] API and loading of KML files

Thomas 'Tom' Malkus tom at dl7bj.de
Sat Sep 27 13:51:07 UTC 2014


Hi,

I have found a solution. Could it been, that the view is reseted after 
loading the KML data and the data is loading as a own thread in the 
background?

If I add a delay of 1 second before calling show() the view is correct
zoomed and positioned.

Is there a possibilty to get a message, if the KML data is complete loaded?

#include <QtGui/QApplication>
#include <QtCore/QFileInfo>
#include <QtCore/QDebug>
#include <marble/MarbleWidget.h>
#include <marble/GeoDataDocument.h>
#include <marble/GeoDataTreeModel.h>
#include <marble/MarbleModel.h>

using namespace Marble;

void delay()
{
     QTime dieTime= QTime::currentTime().addSecs(1);
     while( QTime::currentTime() < dieTime )
     QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}

int main(int argc, char** argv)
{
     QApplication app(argc,argv);
     MarbleWidget *mapWidget = new MarbleWidget();

     mapWidget->resize(800,600);
     mapWidget->setWindowTitle("CQRLOG DXCC Map");
     mapWidget->setMapThemeId("earth/bluemarble/bluemarble.dgml");
 
mapWidget->model()->addGeoDataFile("/home/tom/projects/Qt/dxcc/dxcc.kml"); 


     delay();

     mapWidget->setZoom(1200);
     GeoDataCoordinates 
position(8.545486,53.106076,0.0,GeoDataCoordinates::Degree);
     mapWidget->centerOn(position);

     mapWidget->show();
     return app.exec();
}

Thanks,
Tom
-- 
DARC OV I18|DL-QRP-AG #1186|G-QRP #14624|FISTS #15933|AGCW #2737|ARRL
http://dl7bj.org                            https://twitter.com/dl7bj


More information about the Marble-devel mailing list