I would like to load a Map component in background with a Loader only when the visible Map property is true. Moreover, I need to access the Map center property. How can create a property alias to the Map center property when the Map is loaded with a Loader?
Map2.qml:
import QtQuick 2.0
import QtQuick.Controls 1.3
import QtLocation 5.5
import QtPositioning 5.3
Item {
id: root
property alias center: ?????
Loader {
anchors.fill: parent
id: mapLoader
active: root.visible
sourceComponent: cMap
}
Component {
id: cMap
Item {
anchors.fill: parent
Slider {
id: zoomSlider;
z: map.z + 3
minimumValue: map.minimumZoomLevel;
maximumValue: map.maximumZoomLevel;
anchors.margins: 10
anchors.bottom: parent.bottom
anchors.top: parent.top
anchors.right: parent.right
orientation : Qt.Vertical
value: map.zoomLevel
onValueChanged: {
map.zoomLevel = value
}
}
Map {
id: map
anchors.fill: parent
plugin: osmPlugin
zoomLevel: 7
}
Plugin {
id: osmPlugin
name: "osm"
}
}
}
}
import QtQuick 2.0
import QtQuick.Controls 1.3
import QtLocation 5.5
import QtPositioning 5.3
Item {
id: root
property alias center: ?????
Loader {
anchors.fill: parent
id: mapLoader
active: root.visible
sourceComponent: cMap
}
Component {
id: cMap
Item {
anchors.fill: parent
Slider {
id: zoomSlider;
z: map.z + 3
minimumValue: map.minimumZoomLevel;
maximumValue: map.maximumZoomLevel;
anchors.margins: 10
anchors.bottom: parent.bottom
anchors.top: parent.top
anchors.right: parent.right
orientation : Qt.Vertical
value: map.zoomLevel
onValueChanged: {
map.zoomLevel = value
}
}
Map {
id: map
anchors.fill: parent
plugin: osmPlugin
zoomLevel: 7
}
Plugin {
id: osmPlugin
name: "osm"
}
}
}
}
To copy to clipboard, switch view to plain text mode
Using on another qml:
...
Map2 {
visible: cbMap.checked
center: QtPositioning.coordinate(1.759767, 1.864124)
}
Map2 {
visible: cbMap.checked
center: QtPositioning.coordinate(1.759767, 1.864124)
}
To copy to clipboard, switch view to plain text mode
...
Bookmarks