How to clear and redraw path on map using MapPoltline
Unsolved
QtWebEngine
-
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.qmlimport 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: { } } } } } }