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

D. R. Evans doc.evans at gmail.com
Sat May 1 00:17:03 CEST 2010


I'm not sure that this ever made it to the reflector (I never saw a
response). I think maybe the attachment was too large, so I have removed it
and placed the file at: http://www.sff.net/people/N7DR/tmp/map.jpeg

----

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
    label.setPixmap(pix);

    label.show();

----

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.

*** Note: I think the attachment was too large; the file is is now located
at: http://www.sff.net/people/N7DR/tmp/map.jpeg.

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.

  Doc

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

-- 
Web:  http://www.sff.net/people/N7DR


-------------- 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/20100430/1172fb52/attachment.sig 


More information about the Marble mailing list