[Marble] simple example of displaying just the map, using MarbleMap?

Torsten Rahn tackat at t-online.de
Thu Apr 22 09:15:20 CEST 2010


On Thursday 22 April 2010 02:25:09 D. R. Evans wrote:
> From the documentation, I thought that a MarbleMap would produce a map
> without any control mechanisms -- well, it does seem to do that, but
> instead of just showing a map, it shows a compass rose and the little box
> that one could use to control the viewport (except that of course it's
> non-functional) and takes up a chunk of the display surface with a grey
> background that is placed above the map. How do I display JUST the map??
> 
> This is in C++. (This is also my first foray into Qt in general and marble
> in particular.)
> 
>   Doc

Hi Doc,

Have you read the (admittedly small) tutorial?

http://techbase.kde.org/Projects/Marble/MarbleCPlusPlus

The difference between MarbleWidget and MarbleMap is actually this:

MarbleMap provides all the features of MarbleWidget except for the methods that 
allow you to interact with the map (like mouse events, keyboard events, etc.).

So usually you want to use MarbleWidget instead of MarbleMap.

You should be able to switch off the compass rose and the overview like this:


#include <QtGui/QApplication>
#include <marble/MarbleWidget.h>
 
using namespace Marble;
 
int main(int argc, char** argv)
{
    QApplication app(argc,argv);
 
    // Create a Marble QWidget without a parent
    MarbleWidget *mapWidget = new MarbleWidget();
 
    // Load the OpenStreetMap map
    mapWidget->setMapThemeId("earth/openstreetmap/openstreetmap.dgml");
 
    mapWidget->setShowCompass( false );
    mapWidget->setShowOverviewMap( false );
    mapWidget->setShowScaleBar( false );

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

Alternatively you could also disable the plugins which are responsible for 
drawing these items but I guess the above should do already.

Best Regards,
Torsten





More information about the Marble mailing list