How to add objects to a map? (in QML and Mobility 1.1)
-
wrote on 2 Feb 2011, 14:42 last edited by
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
-
wrote on 2 Feb 2011, 23:09 last edited by
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.
-
wrote on 4 Jul 2011, 10:04 last edited by
Hi Simon,
Did you find any solution how to dynamically add object in Qt Mobility 1.1 ?
I want to show some icons (objects) around current positions. I have model and in there are some locations with lat and long and im not sure how to show them on Map.
-
wrote on 4 Jul 2011, 10:07 last edited by
Jano
No I didn't. The only thing I was able to do was pre-create objects and set them visible later.
Simon
-
wrote on 4 Jul 2011, 10:11 last edited by
Hi Simon,
Would you please post code example how u did it? I'm new in QML world.
Im not even sure about LandMarkModel. I don't know where landmark model gets landmarks.
Many Thanks for your help
-
wrote on 4 Jul 2011, 10:37 last edited by
I just thought: How you pre-create map objects.
Thanks
-
wrote on 19 Jul 2011, 17:25 last edited by
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