Nominate our 2022 Qt Champions!

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.



  • The QML bindings for maps in Mobility 1.1 are incomplete - see:

    Unfortunately 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.

  • 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.

  • Jano

    No I didn't. The only thing I was able to do was pre-create objects and set them visible later.


  • 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

  • I just thought: How you pre-create map objects.


  • This works for me for drawing a Map polyline object,

    id: mapItem

            id: lineComponent

    // Assuming you have list of Coordinate objects(can be created in the same way as mentioned
    // below) ie., coordList

    function drawLine(){
    var lineObj=lineComponent.createObject(null); //Giving mapItem as parent here does not work!
    for (var i=0; i<coordList.length; i++)


    You could use the z property of objects for setting their order of being drawn on the map.


Log in to reply