summaryrefslogtreecommitdiffstats
path: root/examples/location/places_map
diff options
context:
space:
mode:
Diffstat (limited to 'examples/location/places_map')
-rw-r--r--examples/location/places_map/main.cpp2
-rw-r--r--examples/location/places_map/places_map.pro7
-rw-r--r--examples/location/places_map/places_map.qml30
-rw-r--r--examples/location/places_map/places_map_resource.qrc6
4 files changed, 34 insertions, 11 deletions
diff --git a/examples/location/places_map/main.cpp b/examples/location/places_map/main.cpp
index b93cac43..40b8bc2b 100644
--- a/examples/location/places_map/main.cpp
+++ b/examples/location/places_map/main.cpp
@@ -45,7 +45,7 @@ int main(int argc, char **argv)
{
QGuiApplication app(argc,argv);
QQuickView view;
- view.setSource(QUrl::fromLocalFile("places_map.qml"));
+ view.setSource(QUrl(QStringLiteral("qrc:///places_map.qml")));
view.show();
return app.exec();
}
diff --git a/examples/location/places_map/places_map.pro b/examples/location/places_map/places_map.pro
index 7f4bf81b..05adf54d 100644
--- a/examples/location/places_map/places_map.pro
+++ b/examples/location/places_map/places_map.pro
@@ -4,10 +4,9 @@ TEMPLATE = app
QT += quick qml network
SOURCES = main.cpp
-qmlcontent.files += $$files(*.qml) \
- marker.png
+RESOURCES += \
+ places_map_resource.qrc
target.path = $$[QT_INSTALL_EXAMPLES]/location/places_map
-qmlcontent.path = $$[QT_INSTALL_EXAMPLES]/location/places_map
+INSTALLS += target
-INSTALLS += target qmlcontent
diff --git a/examples/location/places_map/places_map.qml b/examples/location/places_map/places_map.qml
index bb65a113..7cf6e379 100644
--- a/examples/location/places_map/places_map.qml
+++ b/examples/location/places_map/places_map.qml
@@ -59,15 +59,36 @@ Rectangle {
}
//! [Initialize Plugin]
+ //! [Current Location]
+ PositionSource {
+ id: positionSource
+ property variant lastSearchPosition: locationBrisbane
+ active: true
+ updateInterval: 120000 // 2 mins
+ onPositionChanged: {
+ var currentPosition = positionSource.position.coordinate
+ map.center = currentPosition
+ var distance = currentPosition.distanceTo(lastSearchPosition)
+ if (distance > 500) {
+ // 500m from last performed pizza search
+ lastSearchPosition = currentPosition
+ searchModel.searchArea = QtPositioning.circle(currentPosition)
+ searchModel.update()
+ }
+ }
+ }
+ //! [Current Location]
+
//! [PlaceSearchModel]
+ property variant locationBrisbane: QtPositioning.coordinate(-27.47, 153.025)
PlaceSearchModel {
id: searchModel
plugin: myPlugin
searchTerm: "Pizza"
- //Brisbane
- searchArea: QtPositioning.circle(QtPositioning.coordinate(-27.46778, 153.02778))
+ //initially show Brisbane
+ searchArea: QtPositioning.circle(locationBrisbane)
Component.onCompleted: update()
}
@@ -78,10 +99,7 @@ Rectangle {
id: map
anchors.fill: parent
plugin: myPlugin;
- center {
- latitude: -27.47
- longitude: 153.025
- }
+ center: locationBrisbane
zoomLevel: 13
MapItemView {
diff --git a/examples/location/places_map/places_map_resource.qrc b/examples/location/places_map/places_map_resource.qrc
new file mode 100644
index 00000000..22395296
--- /dev/null
+++ b/examples/location/places_map/places_map_resource.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>marker.png</file>
+ <file>places_map.qml</file>
+ </qresource>
+</RCC>