[SOLVED] QGeoMapPixmapObject zooming in/out changes location on screen



  • Good day
    I'm using a QGraphicsGeoMap inherited class, I'm able to add objects thru addMapObject function, but my problem is when zooming in/out the coordinates of that object is not reflected correctly on the new view.

    @void MapWidget::addLocation(double lat, double lon/, QString title, QString desc/)
    {
    QGeoCoordinate coord(lat, lon);
    QPixmap map = QPixmap(":/qml/mapExample/Location_pin.png");
    QGeoMapPixmapObject *pen = new QGeoMapPixmapObject(coord,QPoint(0,0),map);
    addMapObject(pen);
    }
    @

    Whenever I zoom in or out, the location of this object is changed.

    What do you think is the problem and/or what is the soultion, I've attached a sample photos on how it looks

    I'm using this class with QML project as well.

    (If I use QML Map api, it works OK, but I need this for 5th edition devices as well)

    Notice the pin image and street 30 on the 3 images.

    !http://i45.tinypic.com/298jye.jpg!



  • the solution was with the offset value, instead of 0,0 it has to be changed based on the image used.
    for example in case of the pin image I used I had to offset x by -17 (width of image/2) and y by -53 (height of the image

    @ void MapWidget::addLocation(double lat, double lon/, QString title, QString desc/)
    {
    QGeoCoordinate coord(lat, lon);
    QPixmap map = QPixmap(":/qml/mapExample/Location_pin.png");
    QGeoMapPixmapObject *pen = new QGeoMapPixmapObject(coord,QPoint(-17,-53),map);
    addMapObject(pen);
    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.