Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [SOLVED] QGeoMapPixmapObject zooming in/out changes location on screen
Qt 6.12 LTS is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 1 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yazwas
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • Y Offline
      Y Offline
      yazwas
      wrote on last edited by
      #2

      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);
      }
      @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt
      • Unsolved