Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML MapRectangle
Forum Updated to NodeBB v4.3 + New Features

QML MapRectangle

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
9 Posts 2 Posters 3.0k Views 1 Watching
  • 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
    saitej
    wrote on 11 Aug 2016, 14:09 last edited by saitej 8 Nov 2016, 14:47
    #1

    I have added a Maprectangle but I need to be able to rotate the rectangle on the topleft corner and get the new coordinates.
    Is there a way to rotate the Maprectangle ?

     MapRectangle{
            id: mapRect
            color: 'green'
            border.width: 3
            opacity: 0.5
            visible: false
           // Drag: true
            MouseArea {
                id: mouseAreaOfMapRectangle
                anchors.fill: mapRect
                drag.target: mapRect
    
            }
    
        }
    
    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on 11 Aug 2016, 20:52 last edited by A Former User 8 Nov 2016, 21:06
      #2

      Hi! See Rotation QML Type.

      Edit: Sorry, I thought MapRectangle would inherit from Item QML Type.

      S 1 Reply Last reply 12 Aug 2016, 03:26
      0
      • ? A Former User
        11 Aug 2016, 20:52

        Hi! See Rotation QML Type.

        Edit: Sorry, I thought MapRectangle would inherit from Item QML Type.

        S Offline
        S Offline
        saitej
        wrote on 12 Aug 2016, 03:26 last edited by
        #3

        @Wieland

        I tried to add transform in the MapRectangle.

         MapRectangle{
                id: landingRect
                color: 'green'
                border.width: 3
                opacity: 0.5
                visible: false
                Drag.active: mouseAreaOfMapRectangle
                transform: Rotation{
                    origin: landingRect.topLeft //line1
                    axis:{
                        x: 0.0; y: 0.0; z: 1.0 //line2
                    }
                }
        
                MouseArea {
                    id: mouseAreaOfMapRectangle
                    anchors.fill: landingRect
                    drag.target: landingRect
                }
        
        
            }
        

        It gives this error:

        Unable to assign int to QVector3D on line 2
        Unable to assign QGeoCoordinate to QVector3D on line 1

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on 12 Aug 2016, 09:06 last edited by
          #4

          Yeah, that's because MapRectangle doesn't inherit from Item and thus doesn't have the transform property.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            saitej
            wrote on 12 Aug 2016, 11:39 last edited by saitej 8 Dec 2016, 11:40
            #5

            @Wieland

            Is it possible if I have the Maprectangle as a Mapquickitem's sourceitem?

            I have made the following changes:

            • I have created a Mapquickitem in the following way
            
            //landingitem.qml
            MapQuickItem{
                id: landingRectangle
            
            
                sourceItem: MapRectangle{
                    id: rect
                    color: 'green'
                    border.color: 'black'
                    border.width: 2
                    opacity: 0.5
                    topLeft: landingRectangle.parent.homepositioncoordinate
                    bottomRight: landingRectangle.parent.landingcoordinate
                    visible: true
            
                }
            
                MouseArea{
                    id: mouseAreaOfMapRectangle
                    anchors.fill: landingRectangle
                    drag.target: landingRectangle
                }
            
                Drag.active: mouseAreaOfMapRectangle
                Drag: true
                visible:true
            }
            
            

            I am trying add this on the map with a click with the following code:

            function addlandingitem(){
            
            var landingItemcomponent = Qt.createComponent("LandingItem.qml")
                    var litem;
                    if(landingItemcomponent.status ===Component.Ready){
                        litem = landingItemcomponent.createObject(_map);
                        litem.coordinate = homepositioncoordinate
            
                    }
            _map.addMapItem(litem)
            }
            

            I am already following this for adding many dynamic items on the map but here it doesn't add the maprectangle.

            • If the addition works, then can the transform be added in to the MapQuickItem ?

            Thanks!!

            ? 1 Reply Last reply 12 Aug 2016, 13:28
            0
            • S saitej
              12 Aug 2016, 11:39

              @Wieland

              Is it possible if I have the Maprectangle as a Mapquickitem's sourceitem?

              I have made the following changes:

              • I have created a Mapquickitem in the following way
              
              //landingitem.qml
              MapQuickItem{
                  id: landingRectangle
              
              
                  sourceItem: MapRectangle{
                      id: rect
                      color: 'green'
                      border.color: 'black'
                      border.width: 2
                      opacity: 0.5
                      topLeft: landingRectangle.parent.homepositioncoordinate
                      bottomRight: landingRectangle.parent.landingcoordinate
                      visible: true
              
                  }
              
                  MouseArea{
                      id: mouseAreaOfMapRectangle
                      anchors.fill: landingRectangle
                      drag.target: landingRectangle
                  }
              
                  Drag.active: mouseAreaOfMapRectangle
                  Drag: true
                  visible:true
              }
              
              

              I am trying add this on the map with a click with the following code:

              function addlandingitem(){
              
              var landingItemcomponent = Qt.createComponent("LandingItem.qml")
                      var litem;
                      if(landingItemcomponent.status ===Component.Ready){
                          litem = landingItemcomponent.createObject(_map);
                          litem.coordinate = homepositioncoordinate
              
                      }
              _map.addMapItem(litem)
              }
              

              I am already following this for adding many dynamic items on the map but here it doesn't add the maprectangle.

              • If the addition works, then can the transform be added in to the MapQuickItem ?

              Thanks!!

              ? Offline
              ? Offline
              A Former User
              wrote on 12 Aug 2016, 13:28 last edited by
              #6

              @saitej said:

              If the addition works, then can the transform be added in to the MapQuickItem ?

              I have no idea if this might work or not. After reading a bit of the relevant documentation I'd suggest to just use a MapPolygon with 4 vertices and transform their coordinates to achieve a rotation.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                saitej
                wrote on 12 Aug 2016, 13:44 last edited by
                #7
                • Any reason why the addition to the map is not working?

                • Even if use Mappolygon, I will not be able rotate it interactively (with a mouse) as mappolygon and maprectangle are simiar in most ways.

                • In this link , they use something called MapMouseArea . I could not find any details about it nor I could use it? Any information on it would be helpful

                ? 1 Reply Last reply 12 Aug 2016, 13:48
                0
                • S saitej
                  12 Aug 2016, 13:44
                  • Any reason why the addition to the map is not working?

                  • Even if use Mappolygon, I will not be able rotate it interactively (with a mouse) as mappolygon and maprectangle are simiar in most ways.

                  • In this link , they use something called MapMouseArea . I could not find any details about it nor I could use it? Any information on it would be helpful

                  ? Offline
                  ? Offline
                  A Former User
                  wrote on 12 Aug 2016, 13:48 last edited by
                  #8

                  @saitej said:

                  Even if use Mappolygon, I will not be able rotate it interactively (with a mouse) as mappolygon and maprectangle are simiar in most ways.

                  Why not? It has this property path. To interactively rotate the polygon simply assign a new value to path.

                  S 1 Reply Last reply 12 Aug 2016, 14:07
                  0
                  • ? A Former User
                    12 Aug 2016, 13:48

                    @saitej said:

                    Even if use Mappolygon, I will not be able rotate it interactively (with a mouse) as mappolygon and maprectangle are simiar in most ways.

                    Why not? It has this property path. To interactively rotate the polygon simply assign a new value to path.

                    S Offline
                    S Offline
                    saitej
                    wrote on 12 Aug 2016, 14:07 last edited by
                    #9

                    @Wieland

                    If I can get a new value, I can also reassign the top and bottom coordinates of the Maprect. My whole problem lies in determining the the coords after rotation since I am only able to drag it and not rotate it along a vertex.

                    1 Reply Last reply
                    0

                    5/9

                    12 Aug 2016, 11:39

                    • Login

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