blob: a427b1af17c7d0a15070a0ecbb266c93d270f24d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
/*
* Copyright (C) 2023 - Arseniy Movshev <dodoradio@outlook.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.0
import org.asteroid.controls 1.0
import Nemo.Configuration 1.0
import QtPositioning 5.15
import QtLocation 5.15
import QtSensors 5.3
Item {
ConfigurationValue {
id: mapZoom
key: "/map/view/zoomlevel"
defaultValue: 3.4
}
ConfigurationValue {
id: mapCenterLat
key: "/map/view/location/lat"
defaultValue: ""
}
ConfigurationValue {
id: mapCenterLong
key: "/map/view/location/long"
defaultValue: ""
}
ConfigurationValue {
id: compassMode
key: "/map/view/compassMode"
defaultValue: 0
}
ConfigurationValue {
id: waypointSource
key: "/map/waypointList"
defaultValue: "[]"
onValueChanged: {
mapView.updateWaypoints()
console.log("value changed")
}
Component.onCompleted: mapView.updateWaypoints()
}
Label {
text: "Map Data from OpenStreetMap"
font.pixelSize: parent.width*0.03
anchors.centerIn: parent
z: 0
}
Map {
id: mapView
plugin: mapProvider
anchors.fill: parent
copyrightsVisible: false //this is compensated by showing the copyright when application is loading
color: "#00000000"
z: 1
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() {
mapView.center = positionProvider.position.coordinate
}
}
Connections {
target: compass
function onReadingChanged() {
if (compassMode.value == 2) {
mapView.bearing = compass.reading.azimuth
}
}
}
property MapQuickItem mapItem
function updateWaypoints() {
clearMapItems()
var waypointsList = JSON.parse(waypointSource.value)
console.log(waypointsList)
for(var i = 0, size = waypointsList.length; i < size ; i++){
var currWaypointData = waypointsList[i]
mapItem = waypoint.createObject(mapView)
mapItem.coordinate = QtPositioning.coordinate(currWaypointData[1][0],currWaypointData[1][1])
console.log(mapItem.coordinate)
mapItem.iconName = currWaypointData[0]
console.log(currWaypointData[2])
mapItem.iconColor = currWaypointData[2]
mapItem.index = i
mapView.addMapItem(mapItem)
}
console.log("waypoints updated")
}
}
DefaultMapControls {
id: mapControls
anchors.fill: parent
z: 2
}
SetPointMapControls {
id: setPointControls
anchors.fill: parent
visible: false
z: 2
function primaryButtonAction() {
pageStack.push(setPointPage,{coord: mapView.center})
}
}
function editWaypoint(index) {
pageStack.push(setPointPage,{editMode: true, editIndex: index})
}
Component {
id: waypoint
MapWaypoint {
}
}
Component {
id: setPointPage
SetPointPage {
}
}
}
|