[Moved] QML Map Centre
-
I am using the QML Map (http://doc.qt.nokia.com/qtmobility/qml-map.html). When I change the map.center, the map doesn't move to the new coordinate. How can I force the map to redraw with the new coordinate?
Thanks
Simon
-
Can you post some code which demonstrates the problem?
-
I have an Item containing a Map. The item has its own property center. The map.center correctly gets initialised to Item.center. When I change the Item.center, the Item.onCenterChanged gets called correctly (as tested by console.log) but the Map center doesn't change (visually).
@Item {
id: mapControl
focus : true
width: parent.width
height: parent.heightproperty int zoomLevel: 16 property Coordinate center property ListModel mapItems Map { id: map plugin : Plugin { name : "nokia" } size.width: parent.width size.height: parent.height zoomLevel: mapControl.zoomLevel center: mapControl.center } onCenterChanged: { map.center = mapControl.center console.log("Map Centre changed") }
}@
-
Hi SimonJudge,
I've got the same problem, did you solve it?[quote author="SimonJudge" date="1297246075"]I am using the QML Map (http://doc.qt.nokia.com/qtmobility/qml-map.html). When I change the map.center, the map doesn't move to the new coordinate. How can I force the map to redraw with the new coordinate?
Thanks
Simon[/quote]
-
Hi,
you have to use ToCoordinate method to tell Map to center to new position.
But I also found it strange that if I state:
Text {
text: map.center.longitude
}I will render coordinates for the center but console log will keep telling me about text loop detected...
-
i got a workground, we can create an qml object on the fly:
@ function setPosition(lat, lon) {
var coord = Qt.createQmlObject('import QtMobility.location 1.1; Coordinate{latitude:' + lat + ';longitude:' + lon + ';}', container, "coord");
map.center = coord;
barLocation.coordinate=coord;
}@