From 621dd53a4333a29a3e07293f75e4346a27705bbe Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Fri, 21 Jul 2017 16:26:33 +0300 Subject: mapwidget.qml: open current location in Google Maps openLocationInGoogleMaps() now can be used to open a URL in an external browser, triggered by the context menu. Use the same Google Maps URL formating as in main.qml showMap(). Signed-off-by: Lubomir I. Ivanov --- mobile-widgets/qml/MapWidget.qml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mobile-widgets/qml/MapWidget.qml b/mobile-widgets/qml/MapWidget.qml index 13c095a5f..aa5edc5e6 100644 --- a/mobile-widgets/qml/MapWidget.qml +++ b/mobile-widgets/qml/MapWidget.qml @@ -138,6 +138,12 @@ Item { } } + function openLocationInGoogleMaps(latitude, longitude) { + var loc = latitude + " " + longitude + var url = "https://www.google.com/maps/place/" + loc + "/@" + loc + ",5000m/data=!3m1!1e3!4m2!3m1!1s0x0:0x0" + Qt.openUrlExternally(url) + } + MapWidgetContextMenu { id: contextMenu y: 10; x: map.width - y @@ -145,7 +151,7 @@ Item { // TODO: perform action actions switch (action) { case contextMenu.actions.OPEN_LOCATION_IN_GOOGLE_MAPS: - console.log("OPEN_LOCATION_IN_GOOGLE_MAPS"); + openLocationInGoogleMaps(map.center.latitude, map.center.longitude) break; case contextMenu.actions.COPY_LOCATION_DECIMAL: console.log("COPY_LOCATION_DECIMAL"); -- cgit v1.2.3-70-g09d2