Giter Club home page Giter Club logo

raptorswing / mapgraphics Goto Github PK

View Code? Open in Web Editor NEW
163.0 163.0 77.0 248 KB

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.

License: Other

C++ 98.11% C 0.15% QMake 1.73%

mapgraphics's People

Contributors

raptorswing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mapgraphics's Issues

Software license is missing

I'm curious to know your view on software licenses in regard to MapGraphics. Could you add some notes on this to the readme?

Map Flicking

First of all : Your work is so nice, and so performant ! well done !

When you zoom In and Zoom Out, there is a flicking (white screen) appear very quickly and it so strange. I try to remove it without success, and I would like to know if you have any tips to try removing it ?

In fact, what i would like is to let the previous _tileobjects shown util the new set is ready to be painted. I hope you see what i mean :)

Thanks a lot

Change map CRS (Coordinate Reference Systems) support.

Hi,
Thank for sharing. It's very helpful to me.
Is there possibility for me to:
+) change CRS of map.
+) measure distance of any two points.
+) draw moving objects on map (by using image)
+) use vector layer (*.shp files)

Any help would be appreciated.

Thanks in advance,

Tuan

Image could not be redrawn

Hi there,

I write a class VehicleObject, like CircleObject, inherited from MapGraphicsObject, to mark a vehicle position/state on map. The class will load a png file and paint in OSM tile map.

void VehicleObject::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(option)
    Q_UNUSED(widget)

    painter->setRenderHint(QPainter::Antialiasing,true);
    painter->setPen(_fillColor);
    painter->drawPixmap(_img->rect(), *_img);
    qDebug() << "drawing: " << _img->rect() << "," << _img->size();
}

private member _img is declared as QPixmap*. Then I write a member function, like CircleObject class setRadius(qreal radius)

void VehicleObject::setVehicleState(VehicleState state, int direction) {
    QString png_file = QString(":/res/") + QString::number(state) + QString::number(direction) + QString(".png");
    _img->load(png_file); // load from resource file
    // here to fire redrawRequested()
    this->redrawRequested();
}

In TestApp, I prepare a timer to change VehicleObject state, like this

    QTimer* myTimer = new QTimer(this);
    MapGraphicsObject * vehicle = new VehicleObject();
    vehicle->setLatitude(40.9936234);
    vehicle->setLongitude(-112.202442);
    scene->addObject(vehicle);

    VehicleObject* vehicleCls = dynamic_cast<VehicleObject*>(vehicle);
    connect(myTimer, &QTimer::timeout, vehicleCls, [=](){
        int st = vehicleCls->state();
        if (st > VehicleIsWorking) st = VehicleIsIdle;
        else st++;

        int direction = vehicleCls->direction();
        if (direction > 350) direction = 0;
        else direction += 10;

        vehicleCls->setVehicleState(VehicleState(st), direction);
    });

    myTimer->start(1000);

In result, the png cannot be updated with timer's timeout event. However, the png file will change with mousewheel movement.
Next, I use CircleObject to set with same logic except to change circle radius every 1 second, it works.

    CircleObject* circleCls = dynamic_cast<CircleObject*>(circle);
    connect(myTimer, &QTimer::timeout, circleCls, [=](){
        qreal r = circleCls->radius();
        qDebug() << "Current radius: " << r;
        circleCls->setRadius(r + 100);
    });

Any advice appreciated. Thanks.

TestApp is not working - URL changed

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!

Zoom the map with the mouse wheel

Zoom the map with the mouse wheel works strangely. It is extremely difficult to do this with the help of two fingers on the trackpad :(

Error compilation with Qt 6

I've tried to integrate in an application compilet with Qt 6.2.3 but there are some Issues due to API modification.

new QMutex(QMutex::Recursive); 
error C2039: 'Recursive': is not a member of 'QMutex'

QWheelEvent *event
event->delta() is not a member of QWheelEvent 
QRegExp not found

I can modify the code in order to adapt for the new API Qt6 and I want to contribute to this interesting project.

Have you got some suggestion in order to maintain the retro compatibility of the code with Qt 5?

LineObject is not positioned properly on the map

I tried to draw a line that connects two points 200 km apart. But one of ends of line was about 7 km to south of the first point, so the line did not pass through the point.

Code fragment:

void CustomMapGraphicsView::updatePointDirection(int id)
{
    QPointF location = _matchesManager->getCameraLocation();
    QPointF pointLocation = _matchesManager->getPointLocation(id);

    MapGraphicsObject* line = new LineObject(location, pointLocation);
    scene()->addObject(line);
}

It’s good written code.

Sir, I am beginner of Qt. i am trying to add some position icon on center. But it doesn’t visible on MapGraphicView widget. How can i add it. Help me

using maker and drawing points

hi.
it's not actually an issue . after a lot searching i found your code vary suitable for my job because,
1- it can saves the tiles and use the map without network.
2- it's simple
3- it's written in c++ and Qt(my code is in Qt too)

so, is there any possibility i can
1- use marker when i double click some where in map .??
2- draw some color points in map with it's coordinate ??

ow can i get the coordinate of the point in map where i double click on it ??

any help would be great.

thanks in advance.
MA.

PolygonObject painting as if open, Only repainting at certain zoom levels

First off, this library is excellent. It's exactly what I've been looking for for my application. However I'm experiencing some unexpected behavior and I'm not sure if it's working as intended or it's a bug.

  1. I create a PolygonObject by clicking a few places on the map and saving the longitude/latitude as points in a QVector then creating a QPolygonF from that vector and finally building a PolygonObject from that polygon. I know the points are being saved correctly since once it paints it's painting the vertices in the correct places, my issue is that it's not just filling the polygon, it's filling the entire map. And on top of this, the fill behavior gets really wonky if the angles become too acute or if I try to draw something like a chevron.
  2. Is there anyway to force it to repaint immediately? If I'm zoomed in at like level 10, once I draw an object, I have to zoom out for it to draw, otherwise it doesn't display. Once it's drawn I have no trouble and it scales correctly, but in order to get it to populate I need to zoom out

Thanks again!

SSL Error

When I start the test app, I get the error "qt.network.ssl: QSslSocket: cannot resolve EVP_PKEY_base_id". How can I resolve this?

qt.network.ssl: QSslSocket: cannot resolve EVP_PKEY_base_id
qt.network.ssl: QSslSocket: cannot resolve SSL_get_peer_certificate
qt.network.ssl: QSslSocket: cannot call unresolved function SSL_get_peer_certificate
Network Error: "SSL handshake failed"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.