Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. How to clear and redraw path on map using MapPoltline

How to clear and redraw path on map using MapPoltline

Scheduled Pinned Locked Moved Unsolved QtWebEngine
1 Posts 1 Posters 465 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.
  • S Offline
    S Offline
    Srsirsat
    wrote on last edited by
    #1

    I have MapPolyline on my map and want to clear that polyline and redraw new polyline when user click on mouseclick area. I am using clearMapItem() to clear MapPolyline. The problem is I'm unable to redraw MapPolyline once it clear. Also I used removeCoordinate() function to remove cooedinate one by one from path but gets same problem.
    main.qml

      import QtQuick 2.9
      import QtLocation 5.6
      import QtPositioning 5.5
      import QtQuick.Controls 2.5
    
    
    ApplicationWindow {
    visible: true
    width: 1000
    height: 1000
    
    title: qsTr("GroundControl System")
    property alias mapAreaClick: mapAreaClick
    
    
    
    Item {
        visible: true
        width: 1756
        height: 900
    
        Plugin{
             id: hereMaps
             name: "here"
             PluginParameter { name: "here.app_id"; value: "oBB4FivcP23m2UZQCj8K" }
             PluginParameter { name: "here.token"; value: "P-D8XRRGeVt0YphUuOImeA" }
         }
    
        Map {
            id: mapOfWorld
            anchors.verticalCenterOffset: 10
            anchors.horizontalCenterOffset: 21
            anchors.rightMargin: -21
            anchors.bottomMargin: -10
            anchors.leftMargin: 0
            anchors.topMargin: 10
            anchors.centerIn: parent;
            anchors.fill: parent
            zoomLevel: 10
             plugin: hereMaps
         center: QtPositioning.coordinate(19.997454, 73.789803)//KORD
    
           MapPolyline {
                id:polylineId
                 antialiasing: true
                            line.width: 5
                            line.color: 'green'
                            path: []
    
            }
            /*----------------------- Mouse Click Area-----------------------*/
            MouseArea {
                id: mapAreaClick
                anchors.rightMargin: 669
                anchors.bottomMargin: -18
                anchors.leftMargin: -8
                anchors.topMargin: 21
                anchors.fill: parent
                    onClicked:  {
                      var cordinate = mapOfWorld.toCoordinate(Qt.point(mouse.x,mouse.y))
                      var poly= polylineId.addCoordinate(cordinate);
    
                    }
                    Button {
                        id: button2
                        x: 45
                        y: 29
                        text: qsTr("Clear")
                        onClicked: {
                          //  Lists.clearData();
                            mapOfWorld.clearMapItems(polylineId);
           // for (var index = 0; index <= polylineId.pathLength(); index++)  
          //{                                 
           // polylineId.removeCoordinate(polylineId.pathLength[index]);
             //              }
    
                          }
                    }
    
                    Button {
                        id: button3
                        x: 45
                        y: 94
                        text: qsTr("Button")
                        onClicked: {
    
                        }
                    }
            }
           }
          }
           }
    
    1 Reply Last reply
    0

    • Login

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