Search code examples
qtqtlocation

Qt Location - Map interaction


My goal is to write a simple desktop route planner in Qt. The user needs to be able to plot a route on the map and edit it. I've got a map up and running using the QML Map/Openstreetmap plugin and have been looking at the MapPolyLine type.

But I cannot see anyway of getting map events, specifically when a user clicks on a map location or a map object such as a MapPolyLine.

Is there a way I can extend the Map type to add some new slots to deal with this?


Solution

  • Ok it's easy using a MouseArea

    MouseArea {
           anchors.fill: parent
           onClicked: console.log('HERE '+mouseX + ':'+ mouseY)
       }