I want to draw a MapPolygon
in QML based on some coordinates. I extract my coordinates from a file and put them in a QVariantList
by the name of yellowPointsQML
and send this QVariantList
to QML. So I use these codes (these coordinates come from a file):
in *.cpp file:
yellowPoints.append(QVariant::fromValue(QGeoCoordinate(38.613931, 50.842588)));
yellowPoints.append(QVariant::fromValue(QGeoCoordinate(38.613489, 50.838962)));
yellowPoints.append(QVariant::fromValue(QGeoCoordinate(38.612465, 50.837600)));
yellowPoints.append(QVariant::fromValue(QGeoCoordinate(38.610743, 50.840475)));
yellowPoints.append(QVariant::fromValue(QGeoCoordinate(38.611564, 50.843286)));
and in *.qml
MapPolygon{
id: yellowCover
color: '#ffff6f'
opacity: 0.7
}
...
yellowCover.path = yellowPointsQML
and every thing is OK and my polygon is convex. But if I change the sort of these coordinates, the result will be sloppy. Since in my input file I just have some coordinates without any order, so I don't know how can I set the order of the coordinates to drawing a convex polygon.