Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to add objects to a map? (in QML and Mobility 1.1)
QtWS25 Last Chance

How to add objects to a map? (in QML and Mobility 1.1)

Scheduled Pinned Locked Moved Mobile and Embedded
7 Posts 4 Posters 3.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SimonJudge
    wrote on last edited by
    #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

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dalaing
      wrote on last edited by
      #2

      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-support

      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.

      David Laing
      Location API team
      Qt Mobility

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jano
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SimonJudge
          wrote on last edited by
          #4

          Jano

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

          Simon

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jano
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • J Offline
              J Offline
              Jano
              wrote on last edited by
              #6

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

              Thanks

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sivabalan
                wrote on last edited by
                #7

                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., coordList

                function 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

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved