subsurface/mobile-widgets/qml/MapWidget.qml
Lubomir I. Ivanov 0678e5936c 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>
2017-07-28 07:31:11 -07:00

56 lines
996 B
QML

import QtQuick 2.0
import QtLocation 5.3
import QtPositioning 5.3
import org.subsurfacedivelog.mobile 1.0
Item {
readonly property var esriMapTypeIndexes: { "STREET": 0, "SATELLITE": 1 };
Plugin {
id: mapPlugin
name: "esri"
}
MapWidgetHelper {
id: mapHelper
map: map
}
Map {
id: map
anchors.fill: parent
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.newCenter = QtPositioning.coordinate(latitude, longitude);
map.zoomLevel = 2;
mapAnimation.restart();
}
}
}