1

in my QT application I have a QML module with a map. I have also a point A and a point B; I know the position of this 2 points in terms of geo coordinates (latitude and longitude).

Now, I simply want draw a line between this 2 points.

For some reason (the element should be inside a MapQuickItem and under this one the Polyline doesn't work) I cannot use the map Polyline, so I choosen a rectangle 1-pixel height. This is the schema:

A(x,y) ---------------- B(x,y)

and this is my code:

MapQuickItem {
     anchorPoint.x: 0
     anchorPoint.y: 0
     coordinate: QtPositioning.coordinate(A.x, A.y)
     sourceItem: Rectangle {
         color: "red"
         height: 1
         width: coordB.x - coordA.x
     }
}

The problem is, as you can see, that the width ask for pixel and the distance that I have is express in coords; due to this reason the expression coordB.x - coordA.x is wrong and I have to change it in something like convertFromCoordInPixel(coordB.x - coordA.x); so I ask:

How can I convert the position of this 2 points from geo coordinates to pixel, in order to calculate the distance of point A from point B?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Archimede
  • 699
  • 3
  • 15
  • 28

0 Answers0