Unsolved Trouble with MapPolyLine and ListModel
-
I have a ListModel with some coordinates. When I assign this model to the "path" property of the MapPolyLine, no line displays. I can use the addCoordinate to add points manually and that does draw the line. The code below is inside my Map{}.
Pointers would be welcome, perhaps also pointer to good book on QML that would explain/stop problems like this.
ListModel { id: assetsPolylineList ListElement { latitude: -28.9 longitude: 25.1 } ListElement { latitude: -28.2 longitude: 25.3 } ListElement { latitude: -28.4 longitude: 25.5 } ListElement { latitude: -28.6 longitude: 25.7 } } MapPolyline { id: assetsPolyline line.color: "red" line.width: 5 visible : true path : assetsPolylineList }
-
-
@Mikkie UPDATE: I was able to play with some code in order to get a simple QML list from the ListModel. Here's a snippet of my working code:
Map { id: map anchors.fill: parent plugin: mapPlugin center: QtPositioning.coordinate(-28.2, 25.3) zoomLevel: 8 function assetsPolylineListAsList() { var list = [] for(var i = 0; i < assetsPolylineList.count; ++i) { list.push( { latitude: assetsPolylineList.get(i).latitude, longitude: assetsPolylineList.get(i).longitude } ); } return list } MapPolyline { id: assetsPolyline line.color: "blue" line.width: 3 visible : true path : map.assetsPolylineListAsList() }