QML MapRectangle
-
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 } }
-
Hi!
See Rotation QML Type.Edit: Sorry, I thought MapRectangle would inherit from Item QML Type.
-
Hi!
See Rotation QML Type.Edit: Sorry, I thought MapRectangle would inherit from Item QML Type.
@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 -
Yeah, that's because
MapRectangle
doesn't inherit fromItem
and thus doesn't have thetransform
property. -
@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!!
-
@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!!
@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. -
-
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
-
-
-
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
@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. -
-
@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.