From de2b3d293d97eb85dc920e6facec684e79c69d43 Mon Sep 17 00:00:00 2001 From: Arseniy Movshev Date: Sun, 27 Nov 2022 12:38:32 +0000 Subject: Add functionality to center view button --- src/DefaultMapControls.qml | 1 + src/MainMapView.qml | 6 ++++++ src/main.qml | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/DefaultMapControls.qml b/src/DefaultMapControls.qml index b6a35de..9698d21 100644 --- a/src/DefaultMapControls.qml +++ b/src/DefaultMapControls.qml @@ -30,6 +30,7 @@ Item { width: height iconColor: "blue" z: 2 + onClicked: positionProvider.update() } IconButton { iconName: "ios-menu-outline" diff --git a/src/MainMapView.qml b/src/MainMapView.qml index 39a4b8e..5042d24 100644 --- a/src/MainMapView.qml +++ b/src/MainMapView.qml @@ -36,6 +36,12 @@ Item { Component.onCompleted: { zoomLevel = mapZoom.value; center.latitude = mapCenterLat.value; center.longitude = mapCenterLong.value; console.log(mapCenterLat.value,mapCenterLong.value)} onZoomLevelChanged: mapZoom.value = zoomLevel onCenterChanged: {mapCenterLat.value = center.latitude; mapCenterLong.value = center.longitude; console.log(center)} + Connections { + target: positionProvider + function onPositionChanged() { + center = positionProvider.position.coordinate + } + } } DefaultMapControls { id: mapControls diff --git a/src/main.qml b/src/main.qml index 12ca9de..49abcb6 100644 --- a/src/main.qml +++ b/src/main.qml @@ -17,6 +17,9 @@ Application { id: mapProvider name: "osm" } + PositionSource { + id: positionProvider + } LayerStack { id: pageStack anchors.fill: parent -- cgit v1.2.3-70-g09d2