Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

attach MouseArea to MapParameter #16656

Open
MahmoudYaser1 opened this issue Nov 26, 2022 · 0 comments
Open

attach MouseArea to MapParameter #16656

MahmoudYaser1 opened this issue Nov 26, 2022 · 0 comments

Comments

@MahmoudYaser1
Copy link

MahmoudYaser1 commented Nov 26, 2022

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"
        }

Clipboarder 2022 11 26-003

QT_5.14
windows platform
QML

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant