summaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qml
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-04-02 22:48:23 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-04-02 13:47:43 -0700
commit48c032bb8ee3c2493783f3db3691f7f067f7782f (patch)
treed6ee0828231f801e31c7ca2f5a85dc1aa71a5bbe /mobile-widgets/qml
parent2700f02dcd83d6ffebb22975b80999dd96cd79c2 (diff)
downloadsubsurface-48c032bb8ee3c2493783f3db3691f7f067f7782f.tar.gz
mapwidget-mobile: do not animate the first selection
centerOnLocationHard() is added in MapPage.qml so that on `firstRun` the map is hard panned to the desired location without animation. This affects the selection of a new "Dive details" -> "Map it" or when opening a GPS location in the map. The idea behind this change is to avoid starting the map animation from an arbitrary location such as [0,0] or London. Also, to not start the map zoomed out completely and then zoom in on a selected dive. For this change to work, add the helper getCoordinatesForUUID() to qmlmapwidgethelper.cpp/.h and use it to obtain the QGeoCoordinates for a dive site UUID. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'mobile-widgets/qml')
-rw-r--r--mobile-widgets/qml/MapPage.qml18
1 files changed, 18 insertions, 0 deletions
diff --git a/mobile-widgets/qml/MapPage.qml b/mobile-widgets/qml/MapPage.qml
index ee1e99dc2..fdfcfa213 100644
--- a/mobile-widgets/qml/MapPage.qml
+++ b/mobile-widgets/qml/MapPage.qml
@@ -12,6 +12,7 @@ Kirigami.Page {
topPadding: 0
rightPadding: 0
bottomPadding: 0
+ property bool firstRun: true
MapWidget {
id: mapWidget
@@ -40,10 +41,27 @@ Kirigami.Page {
console.warn("main.qml: centerOnDiveSiteUUI(): uuid is undefined!")
return
}
+ // on firstRun, hard pan/center the map to the desired location so that
+ // we don't start at an arbitrary location such as [0,0] or London.
+ if (firstRun) {
+ var coord = mapWidget.mapHelper.getCoordinatesForUUID(uuid)
+ centerOnLocationHard(coord.latitude, coord.longitude)
+ firstRun = false
+ } // continue here as centerOnDiveSiteUUID() also does marker selection.
mapWidget.mapHelper.centerOnDiveSiteUUID(uuid)
}
function centerOnLocation(lat, lon) {
+ if (firstRun) {
+ centerOnLocationHard(lat, lon)
+ firstRun = false
+ return // no need to animate via centerOnCoordinate().
+ }
mapWidget.map.centerOnCoordinate(QtPositioning.coordinate(lat, lon))
}
+
+ function centerOnLocationHard(lat, lon) {
+ mapWidget.map.zoomLevel = mapWidget.map.defaultZoomIn
+ mapWidget.map.center = QtPositioning.coordinate(lat, lon)
+ }
}