attach MouseArea to MapParameter
MahmoudYaser1 opened this issue · 0 comments
MahmoudYaser1 commented
i want to display geojson file on maps and make these shapes clickable to show more details about a building for example.
what i get is just a coordinate ... i need to get geojson object of building clicked
Map {
id: map
anchors.fill: parent
plugin: Plugin {
name: "mapboxgl"
PluginParameter {
name: "mapboxgl.access_token"
value:"***"
}
MouseArea {
acceptedButtons: Qt.LeftButton | Qt.RightButton
anchors.fill: parent
onClicked: {
mouse.accepted=true
if (mouse.button == Qt.LeftButton) {
var coord = map.toCoordinate(Qt.point(mouse.x,mouse.y));
console.log(coord.latitude, coord.longitude)
console.log(JSON.stringify(mouse) )
}
}
DynamicParameter {
type: "source"
property var name: "buildingSource"
property var sourceType: "geojson"
property var data: ":building.json"
}
DynamicParameter {
type: "layer"
property var name: "buildingLayer"
property var layerType: "fill"
property var source: "buildingSource"
}
DynamicParameter {
type: "paint"
property var layer: "buildingLayer"
property var fillColor: "#bbb"
}
QT_5.14
windows platform
QML