Reputation: 428
I have a map (OpenStreetMaps) displayed using Map.qml ( Window { ... Map {...} } ) I have a Marker.qml file (based on MapQuickItem). All is OK, when I place this marker statically to my map: Map { ... Marker { params } }.
I want to place N markers (that, sure, have coords and other params). Markers params defined in somefile.txt and this file is parsed using C++.
The question is how to proper/faster/correctly instantiate and place parsed points to Map? Should I do method in Map.qml like a addMarker(position, name) { map.addMapItem( ? ) }? Or should I place this marker using only C++, like get Map container and invoke addMapItem on some "map-projected" class?
Please, help me to understand pipeline of this.
Upvotes: 1
Views: 1439
Reputation: 5207
I think what you are looking for is MapItemView
.
Your C++ code would provide the marker info (location, name, etc) via a model which is then used as input to the MapItemView
.
The view then creates a map view item for each entry in the model and places it on its parent map.
See http://doc.qt.io/qt-5/location-places-qml.html#display-search-results-using-a-mapitemview for an example.
Your C++ code can modify the model during runtime in anyway it sees fit, e.g. adding or removing entries, modifying data of entries.
Upvotes: 2