How to add objects to a map? (in QML and Mobility 1.1)
-
How do I dynamically add objects to a Map in QML? I know how to add MapRectangle, MapCircle etc declaratively but I want to add dynamically (to correspond to dynamic data).
I have read about MapObjectView but can't figure out how to use it (also is this in mobility 1.2 anyway so wouldn't be able to use it?). There aren't any examples. Alternatively, I could create declarative "visible: false" objects and make them visible later but it seems a bit of a kludge.
Thanks
Simon
-
The QML bindings for maps in Mobility 1.1 are incomplete - see:
http://doc.qt.nokia.com/qtmobility-1.1.0/location-overview.html#qml-supportUnfortunately anything you end up doing to support adding map objects dynamically with Mobility 1.1 will be a bit of a kludge.
If you can get away with creating the objects early and making them visible later it's probably going to be one of the better kludges.
-
-
Jano
No I didn't. The only thing I was able to do was pre-create objects and set them visible later.
Simon
-
This works for me for drawing a Map polyline object,
@
Map{
id: mapItem
}Component{ id: lineComponent MapPolyline{} }
// Assuming you have list of Coordinate objects(can be created in the same way as mentioned
// below) ie., coordListfunction drawLine(){
var lineObj=lineComponent.createObject(null); //Giving mapItem as parent here does not work!
for (var i=0; i<coordList.length; i++)
{
lineObj.addCoordinate(coordList[i]);
}
mapItem.addMapObject(lineObj);
}@
You could use the z property of objects for setting their order of being drawn on the map.
HTH,
Siva