This repository was archived by the owner on Jan 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMapPage.qml
157 lines (129 loc) · 4.75 KB
/
MapPage.qml
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import QtQuick 2.0
import QtPositioning 5.0
import "Theme.js" as Theme
Page {
id: page;
property alias deviceLat: map.currentPositionLat
property alias deviceLon: map.currentPositionLon
property alias mapWidget: map;
property bool pageActive: true;
property bool map_visible: false;
signal showDetail(string name, string description, url icon, double lat, double lon);
Flickable {
anchors.fill: parent;
contentHeight: map_visible ? page.height : (pageHeader.height + listColumn.height)
PageHeader {
id: pageHeader;
//% "Places"
title: qsTrId("map-title")
MouseArea {
anchors.fill: parent;
onClicked: {
map_visible = !map_visible;
}
}
}
Column {
id: listColumn
anchors.top: pageHeader.bottom;
visible: !map_visible;
width: page.width
Repeater {
model: map.places;
delegate: BackgroundItem {
id: delegate;
width: page.width
height: Math.max(placesDelegate.height, placesDelegateTitle.paintedHeight) + Theme.paddingSmall
Image {
id: placesDelegate
anchors.left: parent.left;
anchors.verticalCenter: parent.verticalCenter;
anchors.margins: Theme.paddingSmall;
source: model.icon;
smooth: true
fillMode: Image.PreserveAspectFit
width: 0.5 * dpix;
height: 0.5 * dpiy;
}
Image {
anchors.centerIn: placesDelegate;
source: "qrc:/images/marker-icon.png"
visible:( placesDelegate.status !== Image.Ready)
width: placesDelegate.width;
height: placesDelegate.height;
fillMode: Image.PreserveAspectFit
}
Text {
id: placesDelegateTitle
anchors.left: placesDelegate.right
anchors.right: parent.right;
anchors.top: parent.top;
anchors.bottom: parent.bottom;
verticalAlignment: Text.AlignVCenter;
color: delegate.highlighted ? Theme.primary_color_highlight : Theme.primary_color
font.pointSize: Theme.primary_pointSize
wrapMode: Text.Wrap;
text: model.name;
}
onClicked: {
showDetail(model.name, model.description, model.icon, model.lat, model.lon);
map.setCenterLatLon(lat, lon)
}
}
}
}
PinchMap {
id: map
anchors.top: pageHeader.bottom;
anchors.left: parent.left;
anchors.right: parent.right;
anchors.bottom: parent.bottom;
clip: true;
visible: map_visible;
pageActive: map_visible && page.pageActive;
// && (page.status !== PageStatus.Inactive)
onMapItemClicked: {
showDetail(name, description, icon, lat, lon);
}
}
}
Button {
id: switchToListBtn
image: map_visible ? "./images/ic_list_white_48dp.png" : "./images/ic_map_white_48dp.png"
anchors.bottom: parent.bottom;
anchors.right: parent.right;
onClicked: {
map_visible = !map_visible;
}
}
Button {
visible: map_visible;
image: "./images/ic_gps_fixed_white_48dp.png"
anchors.right: switchToListBtn.left;
anchors.bottom: parent.bottom
onClicked: {
map.setCenterLatLon(map.currentPositionLat, map.currentPositionLon);
}
}
PositionSource {
id: positionSource
updateInterval: 1000
active: map_visible;
onPositionChanged: {
var coord = position.coordinate;
map.currentPositionLat = coord.latitude;
map.currentPositionLon = coord.longitude;
map.currentPositionValid = position.latitudeValid
}
}
function reload(d) {
if (d.places !== undefined) {
map.places.clear();
var places = d.places;
for (var i = 0; i < places.length; i++) {
var item = places[i];
map.places.append(item);
}
}
}
}