From bc834c4b40adf8263f60d422681d9c0b7bae21d8 Mon Sep 17 00:00:00 2001 From: Matthias Rauter Date: Tue, 24 Jan 2023 14:24:33 +0100 Subject: 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 --- .../location/places_map/doc/src/places_map.qdoc | 8 ++++---- examples/location/places_map/places_map.qml | 23 ++++++++-------------- 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 -- cgit v1.2.1