mapwidget.qml: add the animateMapTo() helper function

To be used to center the map on a dive location or reset the map
if a dive from the dive list doesn't have GPS coordinates.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-07-20 00:22:52 +03:00 committed by Dirk Hohndel
parent 033eec9500
commit a8f6c99fc0

View file

@ -25,6 +25,7 @@ Item {
readonly property var defaultCenter: QtPositioning.coordinate(0, 0) readonly property var defaultCenter: QtPositioning.coordinate(0, 0)
readonly property var defaultZoomIn: 17.0 readonly property var defaultZoomIn: 17.0
readonly property var defaultZoomOut: 2.0
property var newCenter: defaultCenter property var newCenter: defaultCenter
property var newZoom: 1.0 property var newZoom: 1.0
@ -86,11 +87,15 @@ Item {
} }
} }
function centerOnMapLocation(mapLocation) { function animateMapTo(coord, zoom) {
map.newCenter = mapLocation.coordinate map.newCenter = coord
map.zoomLevel = 2 map.newZoom = zoom
map.newZoom = map.defaultZoomIn
mapAnimation.restart() mapAnimation.restart()
}
function centerOnMapLocation(mapLocation) {
map.zoomLevel = map.defaultZoomOut
animateMapTo(mapLocation.coordinate, map.defaultZoomIn);
mapHelper.model.selectedUuid = mapLocation.uuid mapHelper.model.selectedUuid = mapLocation.uuid
} }
} }