Skip to content

Commit

Permalink
Add secondary action example (set navigation destination)
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Nov 24, 2024
1 parent e425ca0 commit 1abc7a0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion geomapfish.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 12 additions & 0 deletions main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}

0 comments on commit 1abc7a0

Please sign in to comment.