Reply to topic

Setting area and zoom factor to show in marble widget

jnavarro
Registered Member
Posts
5
Karma
0
Hi,

I've almost finished an application relying on the marble widget and now I would like to polish some details to improve the user experience.

This application retrieves from a server a series of points that must be shown simultaneously in the map. From these points, I can retrieve the minimum and maximum longitude and latitude values, and using these, derive (compute) the coordinates of a rectangle that includes the whole set of points.

Then I would like to set the marble widget to show exactly this rectangle (or the minimum rectangle including this one and fitting the dimensions of the widget on the screen). The view (this is easy) should be centered at the centre of the aforementioned rectangle, but I don't know how to tell the widget to show precisely the area of interest, that is, the aforementioned rectangle.

I would appreciate any help to solve this problem. Sample code would also be great!

Thanks!!!!

Jose.
User avatar Earthwings
KDE Developer
Posts
172
Karma
1
OS
We have some convenience methods to achieve this. One is GeoDataLatLonBox::fromLineString() which calculates the bounding rectangle given a set of points. The other one helpful here is MarbleWidget::centerOn(GeoDataLatLonBox). You can combine them like this:

Code: Select all
    MarbleWidget* marbleWidget = ...
   
    // Calculate the bounding rectangle from a set of points
    GeoDataLineString placemarks;
    foreach (const GeoDataCoordinate &coordinate, yourContainerHere) {
        placemarks << data.value<GeoDataCoordinates>();
    }

    // Center on the bounding rectangle
    if ( placemarks.size() > 1 ) {
        marbleWidget->centerOn( GeoDataLatLonBox::fromLineString( placemarks ) );
    } else {
        marbleWidget->centerOn(placemarks.first());
    }
jnavarro
Registered Member
Posts
5
Karma
0
Thank you very much! This is exactly was I was looking for.

Jose.

 
Reply to topic

Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], boudewijn, ChameleonScales, danasenhansen, duns, Exabot [Bot], Google [Bot], jackjo, Kawaii Specter, keyths, peje, Petra-Kathi, polsson, stanleyf, surt, tymond