I want to draw a circle dynamically (through C++) on a QML
Map, But depending on the the zoomLevel, the circle may not be visible. MapCircle
does not have a zoomLevel property. So I am first creating a MapQuickItem
and trying to put a MapCircle
as its sourceItem
. in QML I have
function add_point(lat, lng){
var circle = Qt.createQmlObject('import QtLocation 5.3; MapCircle { }', map, "dynamic");
circle.center = QtPositioning.coordinate(lat, lng);
circle.radius = 5.0;
circle.color = 'blue';
circle.border.width = 1;
var item = Qt.createQmlObject('import QtLocation 5.3; MapQuickItem{}', map, "dynamic");
item.anchorPoint.x = 2.5;
item.anchorPoint.y = 2.5;
item.coordinate = QtPositioning.coordinate(lat, lng);
item.sourceItem = circle;
item.zoomLevel = 19.0
map.addMapItem(item);
map.points.push(item);
return true;
}
If I just draw the MapCircle
a circle is visible on the map, However with the above code nothing appears on screen on any zoomLevel
, I have tried removing the zoomLevel
property, but still nothing appears.