Fix maps
In Qt6, Map just shows a static map, while MapView allows for zooming, moving, etc.
This commit is contained in:
@@ -33,13 +33,13 @@ ApplicationWindow {
|
||||
onClicked: root.destroy()
|
||||
}
|
||||
|
||||
Map {
|
||||
id: map
|
||||
MapView {
|
||||
id: mapView
|
||||
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)
|
||||
zoomLevel: 15
|
||||
plugin: OsmLocationPlugin.plugin
|
||||
map.zoomLevel: 15
|
||||
map.plugin: OsmLocationPlugin.plugin
|
||||
LocationMapItem {
|
||||
latitude: root.latitude
|
||||
longitude: root.longitude
|
||||
@@ -53,8 +53,12 @@ ApplicationWindow {
|
||||
model: root.liveLocationModel
|
||||
delegate: LocationMapItem {}
|
||||
}
|
||||
onCopyrightLinkActivated: {
|
||||
Qt.openUrlExternally(link)
|
||||
|
||||
Connections {
|
||||
target: mapView.map
|
||||
function onCopyrightLinkActivated() {
|
||||
Qt.openUrlExternally(link)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,16 +25,15 @@ MessageDelegate {
|
||||
id: liveLocationModel
|
||||
eventId: root.eventId
|
||||
}
|
||||
Map {
|
||||
id: map
|
||||
MapView {
|
||||
id: mapView
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: root.contentMaxWidth / 16 * 9
|
||||
|
||||
center: QtPositioning.coordinate(liveLocationModel.boundingBox.y, liveLocationModel.boundingBox.x)
|
||||
zoomLevel: 15
|
||||
map.center: QtPositioning.coordinate(liveLocationModel.boundingBox.y, liveLocationModel.boundingBox.x)
|
||||
map.zoomLevel: 15
|
||||
|
||||
plugin: OsmLocationPlugin.plugin
|
||||
onCopyrightLinkActivated: Qt.openUrlExternally(link)
|
||||
map.plugin: OsmLocationPlugin.plugin
|
||||
|
||||
MapItemView {
|
||||
model: liveLocationModel
|
||||
@@ -53,6 +52,12 @@ MessageDelegate {
|
||||
acceptedButtons: Qt.RightButton
|
||||
onTapped: openMessageContext("")
|
||||
}
|
||||
Connections {
|
||||
target: mapView.map
|
||||
function onCopyrightLinkActivated() {
|
||||
Qt.openUrlExternally(link)
|
||||
}
|
||||
}
|
||||
}
|
||||
Component {
|
||||
id: fullScreenMap
|
||||
|
||||
@@ -33,9 +33,9 @@ Components.AbstractMaximizeComponent {
|
||||
}
|
||||
]
|
||||
|
||||
content: Map {
|
||||
content: MapView {
|
||||
id: map
|
||||
plugin: Plugin {
|
||||
map.plugin: Plugin {
|
||||
name: "osm"
|
||||
PluginParameter {
|
||||
name: "osm.useragent"
|
||||
@@ -81,5 +81,11 @@ Components.AbstractMaximizeComponent {
|
||||
}
|
||||
}
|
||||
}
|
||||
Connections {
|
||||
target: mapView.map
|
||||
function onCopyrightLinkActivated() {
|
||||
Qt.openUrlExternally(link)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,16 +36,15 @@ MessageDelegate {
|
||||
required property string asset
|
||||
|
||||
bubbleContent: ColumnLayout {
|
||||
Map {
|
||||
id: map
|
||||
MapView {
|
||||
id: mapView
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: root.contentMaxWidth / 16 * 9
|
||||
|
||||
center: QtPositioning.coordinate(root.latitude, root.longitude)
|
||||
zoomLevel: 15
|
||||
map.center: QtPositioning.coordinate(root.latitude, root.longitude)
|
||||
map.zoomLevel: 15
|
||||
|
||||
plugin: OsmLocationPlugin.plugin
|
||||
onCopyrightLinkActivated: Qt.openUrlExternally(link)
|
||||
map.plugin: OsmLocationPlugin.plugin
|
||||
|
||||
LocationMapItem {
|
||||
latitude: root.latitude
|
||||
@@ -68,6 +67,12 @@ MessageDelegate {
|
||||
acceptedButtons: Qt.RightButton
|
||||
onTapped: openMessageContext("")
|
||||
}
|
||||
Connections {
|
||||
target: mapView.map
|
||||
function onCopyrightLinkActivated() {
|
||||
Qt.openUrlExternally(link)
|
||||
}
|
||||
}
|
||||
}
|
||||
Component {
|
||||
id: fullScreenMap
|
||||
|
||||
@@ -17,16 +17,16 @@ Kirigami.Page {
|
||||
|
||||
padding: 0
|
||||
|
||||
Map {
|
||||
id: map
|
||||
MapView {
|
||||
id: mapView
|
||||
anchors.fill: parent
|
||||
plugin: OsmLocationPlugin.plugin
|
||||
map.plugin: OsmLocationPlugin.plugin
|
||||
|
||||
center: {
|
||||
map.center: {
|
||||
let c = LocationHelper.center(LocationHelper.unite(locationsModel.boundingBox, liveLocationsModel.boundingBox));
|
||||
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 {
|
||||
model: LocationsModel {
|
||||
@@ -49,8 +49,14 @@ Kirigami.Page {
|
||||
|
||||
Kirigami.PlaceholderMessage {
|
||||
text: i18n("There are no locations shared in this room.")
|
||||
visible: map.mapItems.length === 0
|
||||
visible: mapView.mapItems.length === 0
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
Connections {
|
||||
target: mapView.map
|
||||
function onCopyrightLinkActivated() {
|
||||
Qt.openUrlExternally(link)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user