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

attach MouseArea to MapParameter #16656

Open
@MahmoudYaser1

Description

@MahmoudYaser1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions