mapwidget.qml: add the function centerOnCoordinates()

This function can be called to center the map on a specific coordinates.
For the C++ version call it via QMetaObject::invokeMethod() in
centerOnDiveSite().

TODO: add QML property animations.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-07-17 00:25:19 +03:00 committed by Dirk Hohndel
parent 5cc2c02dfb
commit 5f2e60142a
2 changed files with 9 additions and 0 deletions

View file

@ -26,5 +26,10 @@ Item {
Component.onCompleted: {
map.activeMapType = map.supportedMapTypes[esriMapTypeIndexes.SATELLITE];
}
function centerOnCoordinates(latitude, longitude) {
map.center = QtPositioning.coordinate(latitude, longitude);
map.zoomLevel = map.maximumZoomLevel * 0.9;
}
}
}

View file

@ -15,4 +15,8 @@ void MapWidgetHelper::centerOnDiveSite(struct dive_site *ds)
qreal longitude = ds->longitude.udeg / 1000000.0;
qreal latitude = ds->latitude.udeg / 1000000.0;
QMetaObject::invokeMethod(m_map, "centerOnCoordinates",
Q_ARG(QVariant, latitude),
Q_ARG(QVariant, longitude));
}