mapwidget.qml: implement some map animation

When calling centerOnCoordinates() the map will now animate over a
period of 3 seconds the zoom level and over 2 seconds the center
of the map.

Can be tweaked and improved later on.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-07-17 01:16:27 +03:00 committed by Dirk Hohndel
parent 5f2e60142a
commit 0678e5936c

View file

@ -23,13 +23,34 @@ Item {
plugin: mapPlugin
zoomLevel: 1
property var newCenter: QtPositioning.coordinate(0, 0);
Component.onCompleted: {
map.activeMapType = map.supportedMapTypes[esriMapTypeIndexes.SATELLITE];
}
ParallelAnimation {
id: mapAnimation
CoordinateAnimation {
target: map
property: "center"
to: map.newCenter
duration: 2000
}
NumberAnimation {
target: map
property: "zoomLevel"
to: 17
duration: 3000
easing.type: Easing.InCubic
}
}
function centerOnCoordinates(latitude, longitude) {
map.center = QtPositioning.coordinate(latitude, longitude);
map.zoomLevel = map.maximumZoomLevel * 0.9;
map.newCenter = QtPositioning.coordinate(latitude, longitude);
map.zoomLevel = 2;
mapAnimation.restart();
}
}
}