Marble 0.10.0 has been released as a major update last week together with KDE SC 4.5. As a user you might be interested in our Visual ChangeLog which is also available in spanish over at muylinux.com.
But Marble is also a library. So it can be used as a widget in other applications. Today I'd like to show you how.
Creating a weather map
Again MarbleWidget provides a convenient way to make these changes to the overall look and feel of the map.
By default Marble shows a few info boxes: Overview Map, Compass and ScaleBar. But the size for the widget is very limited. Therefore we want to shrink the compass. And we want to get rid of all the clutter, so we turn off the Overview Map and the ScaleBar. In the source code the class AbstractFloatItem is used to display all kinds of Info Boxes. All the Info Boxes are derived from the AbstractFloatItem class. Now we get a list of all the float items that are known to MarbleWidget and we go through it. Once we reach the float item which has got the name id compass we make all the changes we want to it (this has been simplified in Marble pre-0.11.0 where you will be able to access AbstractFloatItems directly via their nameId):
using namespace Marble;
int main(int argc, char** argv)
// Create a Marble QWidget without a parent
// Load the Satellite View map
mapWidget->setProjection( Mercator );
// Enable the cloud cover and enable the country borders
// Hide the FloatItems: Compass and StatusBar
foreach ( AbstractFloatItem * floatItem, mapWidget->floatItems() )
// Put the compass onto the left hand side
mapWidget->resize( 400, 300 );
Save the code above as marble_weather.cpp and compile it:
Instead of calling the compiler directly you can also create a qmake project file:
Store it as marble_weather.pro in the same directory and call
If things go fine, execute ./marble_weather and you end up with a map application that displays clouds on top of a flat map:
That's all for today. In our third chapter we'll show how to load KML and GPX files into Marble. So stay tuned. If you need help join us on our mailing list [email protected] or on #marble (IRC on Freenode). If you want to obtain the latest Marble source code have a look at Marble's website.
If you are interested in more news about Marble then join us and feel welcome in our Marble Facebook Group!