diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-12-07 16:28:01 +0100 |
---|---|---|
committer | Matthias Rauter <matthias.rauter@qt.io> | 2023-02-20 11:26:58 +0100 |
commit | e770809db4b6c92ee4be22b5ea021ccc505cec8f (patch) | |
tree | 110122860d4e06db68ebe06309bcc5167352382f /examples/location/places/items/MapComponent.qml | |
parent | 51a895b3d280ce5103785e016e82b77676c26c5f (diff) | |
download | qtlocation-e770809db4b6c92ee4be22b5ea021ccc505cec8f.tar.gz |
Update location examples to work with MapView/Handlers
MapView replaces Map in the examples to reintroduce event handling.
Some of the functionality is still in mapview.map and the code has to be
adjusted respectivly.
The following examples are affected: mapviewer, places, places_map.
The mapviewer example has a new menu to draw mapitems.
The places example draws places icons instead of a fixed marker.
Fixes: QTBUG-111005
Change-Id: I15ca2b3d3ecb7c35684b9fd4c2b7a86249add11c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'examples/location/places/items/MapComponent.qml')
-rw-r--r-- | examples/location/places/items/MapComponent.qml | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/examples/location/places/items/MapComponent.qml b/examples/location/places/items/MapComponent.qml index fe282564..90ad0691 100644 --- a/examples/location/places/items/MapComponent.qml +++ b/examples/location/places/items/MapComponent.qml @@ -7,8 +7,8 @@ import QtPositioning import QtLocation import "../helper.js" as Helper -Map { - id: map +MapView { + id: view property bool followme: false property var scaleLengths: [5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000] @@ -41,32 +41,30 @@ Map { scaleText.text = text } - center { + map.center { // The Qt Company in Oslo latitude: 59.9485 longitude: 10.7686 } - gesture.flickDeceleration: 3000 - gesture.enabled: true - onCopyrightLinkActivated: Qt.openUrlExternally(link) + map.onCopyrightLinkActivated: Qt.openUrlExternally(link) - onCenterChanged:{ + map.onCenterChanged: { scaleTimer.restart() if (map.followme) if (map.center !== positionSource.position.coordinate) map.followme = false } - onZoomLevelChanged:{ + map.onZoomLevelChanged: { scaleTimer.restart() if (map.followme) map.center = positionSource.position.coordinate } - onWidthChanged:{ + onWidthChanged: { scaleTimer.restart() } - onHeightChanged:{ + onHeightChanged: { scaleTimer.restart() } @@ -84,7 +82,7 @@ Map { running: false repeat: false onTriggered: { - map.calculateScale() + view.calculateScale() } } @@ -123,12 +121,13 @@ Map { text: "0 m" } Component.onCompleted: { - map.calculateScale(); + view.calculateScale(); } } MapQuickItem { - id: poiTheQtComapny + parent: view.map + id: poiTheQtCompany sourceItem: Rectangle { width: 14; height: 14; color: "#e41e25"; border.width: 2; border.color: "white"; smooth: true; radius: 7 } coordinate { latitude: 59.9485 @@ -139,6 +138,7 @@ Map { } MapQuickItem { + parent: view.map sourceItem: Text{ text: "The Qt Company" color:"#242424" @@ -146,8 +146,8 @@ Map { styleColor: "#ECECEC" style: Text.Outline } - coordinate: poiTheQtComapny.coordinate - anchorPoint: Qt.point(-poiTheQtComapny.sourceItem.width * 0.5,poiTheQtComapny.sourceItem.height * 1.5) + coordinate: poiTheQtCompany.coordinate + anchorPoint: Qt.point(-poiTheQtCompany.sourceItem.width * 0.5,poiTheQtCompany.sourceItem.height * 1.5) } PositionSource{ @@ -155,7 +155,7 @@ Map { active: followme onPositionChanged: { - map.center = positionSource.position.coordinate + view.map.center = positionSource.position.coordinate } } |