In Qt6, Map just shows a static map, while MapView allows for zooming, moving, etc.
This commit is contained in:
Tobias Fella
2023-10-23 20:36:27 +02:00
parent cfc5202645
commit 19e197e0ec
5 changed files with 53 additions and 27 deletions

View File

@@ -33,13 +33,13 @@ ApplicationWindow {
onClicked: root.destroy() onClicked: root.destroy()
} }
Map { MapView {
id: map id: mapView
anchors.fill: parent anchors.fill: parent
center: root.liveLocationModel ? QtPositioning.coordinate(root.liveLocationModel.boundingBox.y, root.liveLocationModel.boundingBox.x) map.center: root.liveLocationModel ? QtPositioning.coordinate(root.liveLocationModel.boundingBox.y, root.liveLocationModel.boundingBox.x)
: QtPositioning.coordinate(root.latitude, root.longitude) : QtPositioning.coordinate(root.latitude, root.longitude)
zoomLevel: 15 map.zoomLevel: 15
plugin: OsmLocationPlugin.plugin map.plugin: OsmLocationPlugin.plugin
LocationMapItem { LocationMapItem {
latitude: root.latitude latitude: root.latitude
longitude: root.longitude longitude: root.longitude
@@ -53,8 +53,12 @@ ApplicationWindow {
model: root.liveLocationModel model: root.liveLocationModel
delegate: LocationMapItem {} delegate: LocationMapItem {}
} }
onCopyrightLinkActivated: {
Qt.openUrlExternally(link) Connections {
target: mapView.map
function onCopyrightLinkActivated() {
Qt.openUrlExternally(link)
}
} }
} }

View File

@@ -25,16 +25,15 @@ MessageDelegate {
id: liveLocationModel id: liveLocationModel
eventId: root.eventId eventId: root.eventId
} }
Map { MapView {
id: map id: mapView
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: root.contentMaxWidth / 16 * 9 Layout.preferredHeight: root.contentMaxWidth / 16 * 9
center: QtPositioning.coordinate(liveLocationModel.boundingBox.y, liveLocationModel.boundingBox.x) map.center: QtPositioning.coordinate(liveLocationModel.boundingBox.y, liveLocationModel.boundingBox.x)
zoomLevel: 15 map.zoomLevel: 15
plugin: OsmLocationPlugin.plugin map.plugin: OsmLocationPlugin.plugin
onCopyrightLinkActivated: Qt.openUrlExternally(link)
MapItemView { MapItemView {
model: liveLocationModel model: liveLocationModel
@@ -53,6 +52,12 @@ MessageDelegate {
acceptedButtons: Qt.RightButton acceptedButtons: Qt.RightButton
onTapped: openMessageContext("") onTapped: openMessageContext("")
} }
Connections {
target: mapView.map
function onCopyrightLinkActivated() {
Qt.openUrlExternally(link)
}
}
} }
Component { Component {
id: fullScreenMap id: fullScreenMap

View File

@@ -33,9 +33,9 @@ Components.AbstractMaximizeComponent {
} }
] ]
content: Map { content: MapView {
id: map id: map
plugin: Plugin { map.plugin: Plugin {
name: "osm" name: "osm"
PluginParameter { PluginParameter {
name: "osm.useragent" name: "osm.useragent"
@@ -81,5 +81,11 @@ Components.AbstractMaximizeComponent {
} }
} }
} }
Connections {
target: mapView.map
function onCopyrightLinkActivated() {
Qt.openUrlExternally(link)
}
}
} }
} }

View File

@@ -36,16 +36,15 @@ MessageDelegate {
required property string asset required property string asset
bubbleContent: ColumnLayout { bubbleContent: ColumnLayout {
Map { MapView {
id: map id: mapView
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: root.contentMaxWidth / 16 * 9 Layout.preferredHeight: root.contentMaxWidth / 16 * 9
center: QtPositioning.coordinate(root.latitude, root.longitude) map.center: QtPositioning.coordinate(root.latitude, root.longitude)
zoomLevel: 15 map.zoomLevel: 15
plugin: OsmLocationPlugin.plugin map.plugin: OsmLocationPlugin.plugin
onCopyrightLinkActivated: Qt.openUrlExternally(link)
LocationMapItem { LocationMapItem {
latitude: root.latitude latitude: root.latitude
@@ -68,6 +67,12 @@ MessageDelegate {
acceptedButtons: Qt.RightButton acceptedButtons: Qt.RightButton
onTapped: openMessageContext("") onTapped: openMessageContext("")
} }
Connections {
target: mapView.map
function onCopyrightLinkActivated() {
Qt.openUrlExternally(link)
}
}
} }
Component { Component {
id: fullScreenMap id: fullScreenMap

View File

@@ -17,16 +17,16 @@ Kirigami.Page {
padding: 0 padding: 0
Map { MapView {
id: map id: mapView
anchors.fill: parent anchors.fill: parent
plugin: OsmLocationPlugin.plugin map.plugin: OsmLocationPlugin.plugin
center: { map.center: {
let c = LocationHelper.center(LocationHelper.unite(locationsModel.boundingBox, liveLocationsModel.boundingBox)); let c = LocationHelper.center(LocationHelper.unite(locationsModel.boundingBox, liveLocationsModel.boundingBox));
return QtPositioning.coordinate(c.y, c.x); return QtPositioning.coordinate(c.y, c.x);
} }
zoomLevel: LocationHelper.zoomToFit(LocationHelper.unite(locationsModel.boundingBox, liveLocationsModel.boundingBox), map.width, map.height) map.zoomLevel: LocationHelper.zoomToFit(LocationHelper.unite(locationsModel.boundingBox, liveLocationsModel.boundingBox), mapView.width, mapView.height)
MapItemView { MapItemView {
model: LocationsModel { model: LocationsModel {
@@ -49,8 +49,14 @@ Kirigami.Page {
Kirigami.PlaceholderMessage { Kirigami.PlaceholderMessage {
text: i18n("There are no locations shared in this room.") text: i18n("There are no locations shared in this room.")
visible: map.mapItems.length === 0 visible: mapView.mapItems.length === 0
anchors.centerIn: parent anchors.centerIn: parent
} }
Connections {
target: mapView.map
function onCopyrightLinkActivated() {
Qt.openUrlExternally(link)
}
}
} }
} }