1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00
sdrangel/plugins/feature/vorlocalizer/map/map.qml

154 lines
4.5 KiB
QML
Raw Normal View History

2020-11-29 19:30:18 -05:00
import QtQuick 2.12
import QtQuick.Window 2.12
import QtLocation 5.12
import QtPositioning 5.12
Item {
id: qmlMap
property int vorZoomLevel: 11
property string mapProvider: "osm"
property variant mapPtr
property string requestedMapType
property variant guiPtr
2020-11-29 19:30:18 -05:00
function createMap(pluginParameters, requestedMap, gui) {
requestedMapType = requestedMap
guiPtr = gui
var paramString = ""
for (var prop in pluginParameters) {
var parameter = 'PluginParameter { name: "' + prop + '"; value: "' + pluginParameters[prop] + '"}'
paramString = paramString + parameter
}
var pluginString = 'import QtLocation 5.12; Plugin{ name:"' + mapProvider + '"; ' + paramString + '}'
var plugin = Qt.createQmlObject (pluginString, qmlMap)
if (mapPtr) {
// Objects aren't destroyed immediately, so don't call findChild("map")
mapPtr.destroy()
mapPtr = null
}
mapPtr = actualMapComponent.createObject(page)
mapPtr.plugin = plugin
mapPtr.forceActiveFocus()
return mapPtr
2020-11-29 19:30:18 -05:00
}
Item {
id: page
2020-11-29 19:30:18 -05:00
anchors.fill: parent
}
2020-11-29 19:30:18 -05:00
Component {
id: actualMapComponent
2020-11-29 19:30:18 -05:00
Map {
id: map
objectName: "map"
anchors.fill: parent
plugin: mapPlugin
center: QtPositioning.coordinate(51.5, 0.125) // London
zoomLevel: 10
2022-12-20 06:14:32 -05:00
gesture.enabled: true
gesture.acceptedGestures: MapGestureArea.PinchGesture | MapGestureArea.PanGesture
2020-11-29 19:30:18 -05:00
MapItemView {
model: vorModel
delegate: vorRadialComponent
}
2020-11-29 19:30:18 -05:00
MapStation {
id: station
objectName: "station"
stationName: "Home"
}
2020-11-29 19:30:18 -05:00
MapItemView {
model: vorModel
delegate: vorComponent
2020-11-29 19:30:18 -05:00
}
onZoomLevelChanged: {
if (zoomLevel > 11) {
station.zoomLevel = zoomLevel
vorZoomLevel = zoomLevel
} else {
station.zoomLevel = 11
vorZoomLevel = 11
}
}
onSupportedMapTypesChanged : {
for (var i = 0; i < supportedMapTypes.length; i++) {
if (requestedMapType == supportedMapTypes[i].name) {
activeMapType = supportedMapTypes[i]
}
}
}
}
2020-11-29 19:30:18 -05:00
}
Component {
id: vorRadialComponent
MapPolyline {
line.width: 2
line.color: 'gray'
path: vorRadial
}
}
Component {
id: vorComponent
MapQuickItem {
id: vor
anchorPoint.x: image.width/2
anchorPoint.y: bubble.height/2
coordinate: position
zoomLevel: vorZoomLevel
sourceItem: Grid {
columns: 1
Grid {
horizontalItemAlignment: Grid.AlignHCenter
verticalItemAlignment: Grid.AlignVCenter
columnSpacing: 5
layer.enabled: true
layer.smooth: true
Image {
id: image
source: vorImage
MouseArea {
anchors.fill: parent
hoverEnabled: true
onDoubleClicked: (mouse) => {
selected = !selected
}
}
}
Rectangle {
id: bubble
color: bubbleColour
border.width: 1
width: text.width + 5
height: text.height + 5
radius: 5
Text {
id: text
anchors.centerIn: parent
text: vorData
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onDoubleClicked: (mouse) => {
selected = !selected
}
}
}
}
}
}
}
}