diff --git a/src/qml/LocationChooser.qml b/src/qml/LocationChooser.qml index 7138585d8..82c8bb7dd 100644 --- a/src/qml/LocationChooser.qml +++ b/src/qml/LocationChooser.qml @@ -36,9 +36,30 @@ Components.AbstractMaximizeComponent { icon.name: "snap-bounding-box-center-symbolic" onTriggered: mapView.map.fitViewportToMapItems([mapView.locationMapItem]) enabled: root.location !== undefined + }, + Kirigami.Action { + text: i18nc("@action:intoolbar Determine the device's location", "Locate") + icon.name: "mark-location-symbolic" + enabled: positionSource.valid + onTriggered: positionSource.update() } ] + PositionSource { + id: positionSource + + active: false + + onPositionChanged: { + const coord = position.coordinate; + mapView.gpsMapItem.latitude = coord.latitude; + mapView.gpsMapItem.longitude = coord.longitude; + + mapView.map.addMapItem(mapView.gpsMapItem); + mapView.map.fitViewportToMapItems([mapView.gpsMapItem]) + } + } + content: MapView { id: mapView map.plugin: OsmLocationPlugin.plugin @@ -60,6 +81,15 @@ Components.AbstractMaximizeComponent { author: null } + readonly property LocationMapItem gpsMapItem: LocationMapItem { + latitude: 0.0 + longitude: 0.0 + isLive: true + heading: NaN + asset: "" + author: null + } + Connections { target: mapView.map function onCopyrightLinkActivated(link: string) {