Reputation: 1153
I'm using QtLocation QML Map to display a big amount of items on a map. As with the number of items visible on the map the performance decreases, i would like to set visible only the items actually visible on the viewport. For this it would be handy to just calculate the visibility based on whether the item's coordinate is within the viewport, like:
visible: mapBase.visibleRegion.contains(model.item.coordinate)
But unfortunately the visibleRegion property is non-NOTIFYable, as stated in the documentation at http://doc.qt.io/qt-5/qml-qtlocation-map.html#visibleRegion-prop.
Is there any specific reason (like performance-issues) to not implement a notify signal for this property? Is there any way to workaround this, and set the visibility of a map item based on whether it's within the viewport?
Upvotes: 2
Views: 345
Reputation: 521
I suppose the reason could be that it's expensive to calculate. But visibleRegion changes when one of the following properties change: zoomLevel, center, bearing, tilt, fieldOfView. You could, for example, define your own "property var visRegion", and update it when reacting on those properties above by fetching visibleRegion and assigning it to visRegion.
Upvotes: 1