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
Qt 6.11 is out! See what's new in the release blog

QML MapRectangle

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
9 Posts 2 Posters 4.9k 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.
  • saitejS Offline
    saitejS Offline
    saitej
    wrote on last edited by saitej
    #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 last edited by A Former User
      #2

      Hi! See Rotation QML Type.

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

      saitejS 1 Reply Last reply
      0
      • ? A Former User

        Hi! See Rotation QML Type.

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

        saitejS Offline
        saitejS Offline
        saitej
        wrote on 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 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
          • saitejS Offline
            saitejS Offline
            saitej
            wrote on last edited by saitej
            #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
            0
            • saitejS saitej

              @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 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
              • saitejS Offline
                saitejS Offline
                saitej
                wrote on 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
                0
                • saitejS saitej
                  • 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 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.

                  saitejS 1 Reply Last reply
                  0
                  • ? A Former User

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

                    saitejS Offline
                    saitejS Offline
                    saitej
                    wrote on 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

                    • Login

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