Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to combine Map and MouseArea

How to combine Map and MouseArea

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 671 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mihaill
    wrote on last edited by
    #1

    Hi!
    I use this code: https://stackoverflow.com/questions/49344638/adding-markers-places-to-qt-qml-maps
    If I add MouseArea, I can't move the map. Please tell me how to move the card and receive a signal from MouseArea?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mihaill
      wrote on last edited by
      #2

      It's works:

              Map {
                      id: mapview
                      anchors.fill: parent
                      plugin: plugin
                      center: QtPositioning.coordinate(59.91, 10.75)
                      zoomLevel: 14
      
                      MapItemView{
                          model: markerModel
                          delegate: mapcomponent
                      }
      
                      MouseArea {
                          anchors.fill: parent
                          onPressAndHold:  {
                              var coordinate = mapview.toCoordinate(Qt.point(mouse.x,mouse.y))
                              markerModel.addMarker(coordinate)
                          }
                      }
                  }
      
              Component {
                      id: mapcomponent
                      MapQuickItem {
                          id: marker
                          anchorPoint.x: image.width/4
                          anchorPoint.y: image.height
                          coordinate: position
      
                          sourceItem: Image {
                              id: image
                              source: "qrc:/Images/Images/markerRed.png"
                          }
                      }
                  }
      
      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved