summaryrefslogtreecommitdiffstats
path: root/examples/location/places_map
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2015-02-03 16:39:05 +0100
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-02-06 09:11:49 +0000
commit73de5f12a329b155b888b6aa42d059408e1e5202 (patch)
tree5fe273d89b71aaf89085fe80060b03effddff4b8 /examples/location/places_map
parent36fc20de2450da3f5e2fdb4e454c02efc785bdff (diff)
Fix places_map example
1.) Use qrc to avoid errors where the binary is started from outside its binary directory and cannot find the png and qml files. 2.) Use OSM as place provider to avoid non-working example due to missing Nokia credentials 3.) Improve documentation 4.) Add locality element to the example. This shifts the search area to the current location rather than Brisbane/Australia. Brisbane is still the default location. 5.) Avoid that Brisbane is shown but the pizza search is done at the GoldCoast. Change-Id: I4845de04abd8ea4be2081bb24bdae27e470cb918 Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
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>