From a8f6c99fc0f519760c0632626b4d52eac8d2410d Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Thu, 20 Jul 2017 00:22:52 +0300 Subject: 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 --- mobile-widgets/qml/MapWidget.qml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'mobile-widgets/qml/MapWidget.qml') diff --git a/mobile-widgets/qml/MapWidget.qml b/mobile-widgets/qml/MapWidget.qml index 17b93c773..83ed48c4a 100644 --- a/mobile-widgets/qml/MapWidget.qml +++ b/mobile-widgets/qml/MapWidget.qml @@ -25,6 +25,7 @@ Item { readonly property var defaultCenter: QtPositioning.coordinate(0, 0) readonly property var defaultZoomIn: 17.0 + readonly property var defaultZoomOut: 2.0 property var newCenter: defaultCenter property var newZoom: 1.0 @@ -86,11 +87,15 @@ Item { } } - function centerOnMapLocation(mapLocation) { - map.newCenter = mapLocation.coordinate - map.zoomLevel = 2 - map.newZoom = map.defaultZoomIn + function animateMapTo(coord, zoom) { + map.newCenter = coord + map.newZoom = zoom mapAnimation.restart() + } + + function centerOnMapLocation(mapLocation) { + map.zoomLevel = map.defaultZoomOut + animateMapTo(mapLocation.coordinate, map.defaultZoomIn); mapHelper.model.selectedUuid = mapLocation.uuid } } -- cgit v1.2.3-70-g09d2