I want to populate a Qml Map with map elements (like MapCircle, ...) from a QAbstractListModel. There seem to be two Qml tools suitable for this, MapItemView [1] and Repeater [2]. The Repeater is more powerful (e.g. it allows nested models) - so is there any reason to use the MapItemView instead of a Repeater?
Regards,
[1] http://doc.qt.io/qt-5/qml-qtlocation-mapitemview.html
[2] http://doc.qt.io/qt-5/qml-qtquick-repeater.html
MapItemView source: http://code.qt.io/cgit/qt/qtlocation.git/tree/src/location/declarativemaps/qdeclarativegeomapitemview.cpp
Repeater source: http://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/quick/items/qquickrepeater.cpp
You should use MapItemView for that.
Using Repeater works only when you create the Map, if you add elements in your model afterwards, no delegate will be added to the Map.
The fact that it works at first with Repeater but not afterwards is because:
Repeater parents his delegate to his parent which is the MapMap object then scans its child items once when it's created (in a c++ function equivalent to Component.onCompleted)MapItem-derived objects are added to the map like when manually calling Map.addMapItem()Repeater are just parented to the Map but not really "added" to it.Since MapItemView is aware of the Map it can add the delegates to the Map when it creates them.
One of the limitation of MapItemView is that it only works with QAbstractItemModel and derived. That means it can work with a ListModel or a c++ model, but not with a "dumb" model like a js array or an integer as a model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With