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

Torsten Rahn tackat at t-online.de
Thu Apr 22 17:04:46 CEST 2010

On Thursday 22 April 2010 16:12:51 D. R. Evans wrote:
> > Have you read the (admittedly small) tutorial?
> Yes.

Cool, if you feel like extending it with the experience you've made don't 
hesitate to do so :-)
> Right, so isn't that telling me that since I *don't* want any interaction,
> then I want a MarbleMap?? That's why I used a MarbleMap instead of a
> MarbleWidget.

Ok, then using MarbleMap might be your best choice indeed!

> >     mapWidget->setShowCompass( false );
> >     mapWidget->setShowOverviewMap( false );
> >     mapWidget->setShowScaleBar( false );
> OK, that gets rid of those item (thanks very much), but I still end up with
> the big grey area where they were. I think there's something I'm not
> understanding about the way sizing works.

What are you using as a "surface" / paintdevice for rendering the map? Are you 
rendering the MarbleMap on top of another widget? Or onto a pixmap? 
> Here's what I have:
>     map->setSize(1200, 600);
>     map->setMapThemeId("earth/srtm/srtm.dgml");  // the atlas view
>     map->setProjection(Equirectangular);
> the resulting image has two problems I can't seem to resolve:
> 1. The big grey area above the map, which I want to remove

Without the screenshot I can only guess that the grey area above the map is 
either the background of a widget that you are using as a parent or an 
uninitialized pixmap. 

> 2. I see more than 360° of longitude

Right now you need to manually prevent that you see more than 360 degs:

It basically works like this:

- Assuming that the height of your map is supposed to be height=160 pixels: You 
need to set the "radius" of the map to 

int height = 160;

- For the flat projection the aspect ratio is always 2:1, so you need to set the 
width of your map to 

map->setWidth( 2 * height )

(for mercator it's just 1:1, so you wouldn't need the factor 2 for mercator)

If you want to allow for dynamic resizing of the map then you need to do this in 
a resizeEvent. 

Hm, it would be nice if we had a method in MarbleMap and MarbleWidget which 
would do this for you. 
So far this is only done manually in the world clock plasmoid code:

in void WorldClock::resizeMap(bool changeAspect)

which is using MarbleMap as well.

> I am impressed at how easy it was to get this far.

Great to hear :-)

>   Doc

More information about the Marble mailing list