summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Rauter <matthias.rauter@qt.io>2023-01-24 14:24:33 +0100
committerMatthias Rauter <matthias.rauter@qt.io>2023-01-31 12:52:17 +0100
commitbc834c4b40adf8263f60d422681d9c0b7bae21d8 (patch)
tree29163555ef52f3fdef0dd6b11ac5ac6c8dca4f97
parent5ef3e454c7903e4b8e0db41aea87cfaf21c641e8 (diff)
Fix small inconsistencies in the example places_map
Change the search radius in example places_map to get a reasonable amount of results. Replace search term pizza with food to get a reasonable amount of results within 1km radius. Cleaned up some code and replaced static values with bindings. Pick-to: 6.5 Change-Id: I51aedadaf46a1576d033178ec8c0b94222dffca7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--examples/location/places_map/doc/src/places_map.qdoc8
-rw-r--r--examples/location/places_map/places_map.qml23
2 files changed, 12 insertions, 19 deletions
diff --git a/examples/location/places_map/doc/src/places_map.qdoc b/examples/location/places_map/doc/src/places_map.qdoc
index 7c6f3c1c..c8d5b715 100644
--- a/examples/location/places_map/doc/src/places_map.qdoc
+++ b/examples/location/places_map/doc/src/places_map.qdoc
@@ -35,8 +35,8 @@
\image places_map.png
The example displays a map of the current location or, if no position is
- available, it uses Brisbane/Australia. Subsequently a search for places
- matching the term "pizza" is performed and each result shown on the map.
+ available, it uses Oslo/Norway. Subsequently a search for places
+ matching the term "food" is performed and each result shown on the map.
\include examples-run.qdocinc
@@ -75,9 +75,9 @@
\snippet places_map/places_map.qml Places MapItemView
Finally, a \c PositionSource is used to reset the map to the curent
- location and find "pizza" places in the new area. The position information
+ location and find "food" places in the new area. The position information
is updated every 2 minutes and if the new position is more than 500 meters
- away from the last pizza search area the place search is retriggered.
+ away from the last food search area the place search is retriggered.
\snippet places_map/places_map.qml Current Location
*/
diff --git a/examples/location/places_map/places_map.qml b/examples/location/places_map/places_map.qml
index 66fcab18..61e845f3 100644
--- a/examples/location/places_map/places_map.qml
+++ b/examples/location/places_map/places_map.qml
@@ -71,34 +71,27 @@ Rectangle {
//! [Current Location]
PositionSource {
id: positionSource
- property variant lastSearchPosition: locationOslo
+ property variant lastSearchPosition: QtPositioning.coordinate(59.93, 10.76) //Initialized/Fallback to Oslo
active: true
updateInterval: 120000 // 2 mins
onPositionChanged: {
- var currentPosition = positionSource.position.coordinate
- map.center = currentPosition
- var distance = currentPosition.distanceTo(lastSearchPosition)
+ var distance = lastSearchPosition.distanceTo(position.coordinate)
if (distance > 500) {
- // 500m from last performed pizza search
- lastSearchPosition = currentPosition
- searchModel.searchArea = QtPositioning.circle(currentPosition)
- searchModel.update()
+ // 500m from last performed food search
+ lastSearchPosition = positionSource.position.coordinate
}
}
}
//! [Current Location]
//! [PlaceSearchModel]
- property variant locationOslo: QtPositioning.coordinate( 59.93, 10.76)
-
PlaceSearchModel {
id: searchModel
plugin: myPlugin
- searchTerm: "Pizza"
- searchArea: QtPositioning.circle(locationOslo, 500000 /* 5 km radius */)
-
+ searchTerm: "food"
+ searchArea: QtPositioning.circle(positionSource.lastSearchPosition, 1000 /* 1 km radius */)
Component.onCompleted: update()
}
//! [PlaceSearchModel]
@@ -108,8 +101,8 @@ Rectangle {
id: map
anchors.fill: parent
plugin: myPlugin;
- center: locationOslo
- zoomLevel: 5
+ center: positionSource.lastSearchPosition
+ zoomLevel: 13
MapItemView {
model: searchModel