QML Map: Large Number of Displayed Items

I have a performance issue when displaying large volumes of MapItems on a map provided by the QML location module. I already asked a question here ( https://forum.qt.io/topic/79229/large-amount-of-qml-mapitems ), but nobody could help me, so I wanted to try it here once. I also found this question ( How do I use the QML / QtLocation module to display a lot of offline data on a map? ), But before adding another dependency, I wanted to make sure my code could be improved so that QML could handle this situation without any help.

I am currently trying to plot a large number of items on a QML map (30,000 - 120,000 points). These elements should update based on the position of the QSlider. The performance drops a lot from about 1000 pips up, when I use 30,000 it takes a few minutes until the QML map displays all the data and is responsive again. I have a machine that is absolutely capable of doing this task in general, so I think the problem is with QML. I am using Qt 5.8.

Is there a way to improve this performance, or is it just not possible with a QML Map to display so many MapItems at once? I tried MapCircles, Polylines, Polygons, and MapQuickItems with images, but it seems to me that the performance issue only occurs when adding this number of MapItems, since I did not see a significant difference in processing time between these types.

I have more data in the rendered map that shouldn't be refreshed every time the QSlider is moved. Although I tried to just clear all MapItems and add new ones for performance tests, even that did not improve performance.

My code (a bit abstracted) looks like this:

///-------------- Widget.cpp-----------------///
void ProcessInput(int qslider_pos) {
      QVariantList lat_vec;
      QVariantList lon_vec;

      // Fill vectors with lateral and longitudinal positions
      // ...

      // Clean current points on map and draw new ones
      SendToQmlFuncRemovePoints();
      SendToQmlFuncAddPoints(lat_vec, lon_vec);
}

void QmlConnector::SendToQmlFuncRemovePoints()
{
    QVariant returnedValue;
    QMetaObject::invokeMethod(QmlMapSingleton::instance()->GetRoot(), "remove_points",
        Q_RETURN_ARG(QVariant, returnedValue));
}

void QmlConnector::SendToQmlFuncAddPoints(QVariantList input_one, QVariantList input_two)
{
    QVariant returnedValue;
    QMetaObject::invokeMethod(QmlMapSingleton::instance()->GetRoot(), "add_points",
        Q_RETURN_ARG(QVariant, returnedValue),
        Q_ARG(QVariant, QVariant::fromValue(input_one)), Q_ARG(QVariant, QVariant::fromValue(input_two)));
}

      

...

///-------------- Map.qml -----------------///

Map {
     anchors.fill: parent
     property variant points: ({})
     property int pointCounter: 0

     Plugin
     {
        id: osmplugin
        name: "osm"
        PluginParameter { name: "osm.mapping.highdpi_tiles"; value: true }
     }

     Component.onCompleted: {
         points = new Array();
     }
    id: map
    plugin: osmplugin

    //Javascript functions
    function add_points(array_lat, array_lon) {
        var myArray = new Array()
        var component = Qt.createComponent("mapcircle.qml");
        for (var i=0; i<array_lat.length; i++)
        {
            var object = component.createObject(map, { "center": QtPositioning.coordinate(array_lat[i], array_lon[i]})
            map.addMapItem(object)
            myArray.push(object)
        }
        map.points = myArray
    }

    function remove_points() {
        var count = map.points.length
        for (var i = 0; i<count; i++){
            map.removeMapItem(map.points[i])
            map.points[i].destroy()
        }
        map.points = []
    }
}

      

...

///-------------- mapcircle.qml -----------------///
import QtQuick 2.0
import QtLocation 5.6

MapCircle {
      radius: 1
      border.width: 0
      color: 'green'
}

      

+3


source to share


1 answer


Qt says performance decreases with the number of items added to the map. You need all points to be visible on the map at the same time if you cannot play with visibility. Can't you use QQuickPaintedItem

to draw points in C ++ and wrap it in MapQuickItem

if you have a lot of polygons for example? But there are also some limitations, you cannot display large images.
If you need all the points, perhaps you can have different points based on the zoom level of the map and reduce the number of points added to the map at a small zoom level as recommended in another group ...



0


source







All Articles