From 1abc7a0528ea4077196f076e1e9e34170076e0da Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Sun, 24 Nov 2024 18:31:43 +0700 Subject: [PATCH] Add secondary action example (set navigation destination) --- geomapfish.qml | 7 ++++++- main.qml | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/geomapfish.qml b/geomapfish.qml index d19423d..905dc5b 100644 --- a/geomapfish.qml +++ b/geomapfish.qml @@ -22,7 +22,12 @@ Item { "description": "", "score": 1, "group": feature.attribute('layer_name'), - "groupScore":1 + "groupScore":1, + "actions": [{ + "id": 1, + "name": "Set as destination", + "icon": "qrc:/themes/qfield/nodpi/ic_navigation_flag_purple_24dp.svg" + }] }; prepareResult(details); } diff --git a/main.qml b/main.qml index c7f047e..7a2adff 100644 --- a/main.qml +++ b/main.qml @@ -53,5 +53,17 @@ Item { locatorBridge.locatorHighlightGeometry.qgsGeometry = result.userData; locatorBridge.locatorHighlightGeometry.crs = CoordinateReferenceSystemUtils.fromDescription(parameters["service_crs"]); } + + function triggerResultFromAction(result, actionId) { + if (actionId === 1) { + let navigation = iface.findItemByObjectName('navigation') + const centroid = GeometryUtils.reprojectPoint( + GeometryUtils.centroid(result.userData), + CoordinateReferenceSystemUtils.fromDescription(parameters["service_crs"]), + mapCanvas.mapSettings.destinationCrs + ) + navigation.destination = centroid + } + } } }