raptorswing / MapGraphics

A tile-based "slippy map" library written in/for C++/Qt. It's meant to enable C++/Qt developers to easily add nice, interactive maps to their applications. Supports zooming, rotating, interactive custom map objects, transparency, etc. It is a Qt map widget that can use tiles from MapQuest, Openstreetmap, or a custom source you define.
Other
164 stars 77 forks source link

TestApp is not working - URL changed #24

Closed xuniuer closed 2 years ago

xuniuer commented 3 years ago

Hi there,

I try to use project to see what happened, but the TestApp cannot work. I trace the URL, it doesn't work now. Could you fix it?

In fact I want to load a image as marker on the map, But I find it could not load correctly. In https://hub.fastgit.org/raptorswing/MapGraphics/blob/5abf53449707985ef4754f9cc172fa99ea6c70fe/TestApp/WeatherManager.cpp#L170

    const int imgWidth = img.width();
    const int imgHeight = img.height();

    const qreal widthLon = imgWidth * pair.first.x();
    const qreal heightLat = imgHeight * pair.first.y();

    const QPointF centerLonLat(pair.second.x() + widthLon / 2.0,
                               pair.second.y() - heightLat / 2.0);

    const qreal lonPerMeter = Conversions::degreesLonPerMeter(centerLonLat.y());
    const qreal latPerMeter = Conversions::degreesLatPerMeter(centerLonLat.y());

    const QRectF metersRect(0, 0,
                            widthLon / lonPerMeter,
                            heightLat / latPerMeter);

    WeatherImageObject * imgObj = _getImageObject(reqString);
    imgObj->setWeather(img, metersRect, centerLonLat);
    _scene->addObject(imgObj);

There is a complicated transform. Because the testapp doesn't work, I could guess what happens.

However, I just use the following code to add a marker:

    GPSImageObject* devObj = new GPSImageObject(QImage(), QRectF(0,0,32,32));
    QImage*img = new QImage();
    img->load(":/icons/devstatus/work/10.png"); // The image is 32*32
    QRectF rect(0,0,32,32);
    devObj->setGPStatus(*img, rect);
    devObj->setPos(ll); // `ll` is a QPiontF with lon/lat value.

    _scene->addObject(devObj);

But I find the image is loaded to downside. If I paint a text below the image, the text is also mirrored. Strange!

Any comments appreciated!

raptorswing commented 2 years ago

It seems that the weather radar tiles that I used to make the weather example work are no longer available. I added a giant red circle as an example in 2766180a8922f4e4a60799bf12d237202947537c, instead. It's more boring but I don't have time to do anything cooler right now.

I can't guess why your GPSImageObject isn't rendering the way you want without seeing the whole .cpp and .h files. You may want to take a look at https://github.com/raptorswing/FlightPlanner, which uses MapGraphics, as an example of how to build/interact with more complicated types of MapGraphicsObjects.

Sorry for the delay... I don't have time to tinker with this code much any more.