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

D. R. Evans doc.evans at gmail.com
Thu Apr 22 18:31:34 CEST 2010

Torsten Rahn said the following at 04/22/2010 09:04 AM :
> 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 :-)

I will, once I've got this simple program working right.

>>>     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 the code:


    QPixmap pix = map->mapScreenShot();
    QLabel label;

    label.setMinimumSize(100, 100); // just to make sure something appears



Maybe that's completely wrong or silly. I spent a bit of time reading the
Qt documentation, and the documentation seemed to indicate that the above
is reasonable (and it does -- mostly -- work). Qt does have good API docs,
but it doesn't seem to have a ton of examples.

>> 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:

See below for current situation :-)

> 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;
> map->setRadius(height/2); 
> - For the flat projection the aspect ratio is always 2:1, so you need to set the 
> width of your map to 

That's very useful information; I didn't see it anywhere until you wrote that.

> map->setWidth( 2 * height )

OK... there is no setWidth() in MarbleMap, so I'm using setSize() instead.

What I have right now (having experimented some more with lots of values,
but not finding the "magic combination") is:


    const unsigned int height = 600;
    map->setRadius(height / 2);

// For the flat projection the aspect ratio is always 2:1,

//    map->setWidth(2 * height);    // no setWidth
    map->setSize(2 * height, height);


The result is attached (I hope that the reflector software won't scrub the
attachment). You can see the unwanted grey area above the map.

It seems that now the width is right, and 360° of longitude is shown.
That's a definite improvement; thank you.

It also looks like 180° of latitude covers 600 pixels of height ... but the
map is not anchored in the top left-hand corner of the window, so the
bottom part of the map disappears off the bottom of the window :-(

Maybe there's something I need to change about the QLabel. The
documentation for Qlabel says that by default images are displayed
left-aligned and vertically centred. But it seems that this image isn't
appearing vertically centred, and I don't know why not.


PS I thought I'd better keep this thread in marble@ since that's where it

Web:  http://www.sff.net/people/N7DR
-------------- next part --------------
A non-text attachment was scrubbed...
Name: map.png
Type: image/png
Size: 847624 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/marble/attachments/20100422/49d7e1bc/attachment-0001.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://mail.kde.org/pipermail/marble/attachments/20100422/49d7e1bc/attachment-0001.sig 

More information about the Marble mailing list