We're having issues with setting the attribution text to visible / invisible.
We're using ArcGIS_Maps_SDK_Qt_Windows_200_7_0, with Qt 6.8.1
In our map model we have a simple Q_INVOKABLE function
void
DisplayMap::toggleAttribution()
{
m_attribution = !m_attribution;
m_mapView->setAttributionTextVisible(m_attribution);
}
Which gets triggered from QML via a Button
Button {
text: "Attribution"
onClicked: model.toggleAttribution()
}
For one, this does not hide the Attribution, it seems to not work at all. Then when clicking it multiple times (basically after "hiding" the attribution, showing it again, and then "hiding" it again) it crashes.
Interestingly enough if we hide the attribution "early", i.e. when the model gets a reference to the map view, hiding the attribution works. Still, enabling it later, disabling, enabling again still causes crashes.
void
DisplayMap::setMapView(MapQuickView* mapView)
{
if (!mapView || mapView == m_mapView)
return;
m_mapView = mapView;
m_mapView->setMap(m_map);
m_mapView->setAttributionTextVisible(false); // This works ...
emit mapViewChanged();
}
Seems like once the map is fully constructed there is no way to change the attribution, and trying so causes the application to crash.
Please find attached a minimalistic example.
Solved! Go to Solution.
Hello imbachb,
Thank you to report this. I was able to reproduce the problem. This is caused by an invalid QSGNode in MapQuickView. We will fix that.
A possible workaround is to clean up manually the nodes used to render the attribution text. For that, create a new class that derives from MapQuickView and override updatePaintNode functions to remove the children nodes of the root node.
class MyView : public MapQuickView {
Q_OBJECT
public:
QSGNode* updatePaintNode(QSGNode* node, UpdatePaintNodeData* data) {
// the QSGNode used to render the map
auto* mapViewNode = MapQuickView::updatePaintNode(node, data);
// clean up children nodes if the attribution text is not visible
if (mapViewNode && !attributionTextVisible()) {
auto* child = mapViewNode->firstChild();
while (child) {
mapViewNode->removeChildNode(child);
delete child;
child = node->firstChild();
}
}
return mapViewNode;
}
};
Let me know if this works for you.
Guillaume
Hello imbachb,
Thank you to report this. I was able to reproduce the problem. This is caused by an invalid QSGNode in MapQuickView. We will fix that.
A possible workaround is to clean up manually the nodes used to render the attribution text. For that, create a new class that derives from MapQuickView and override updatePaintNode functions to remove the children nodes of the root node.
class MyView : public MapQuickView {
Q_OBJECT
public:
QSGNode* updatePaintNode(QSGNode* node, UpdatePaintNodeData* data) {
// the QSGNode used to render the map
auto* mapViewNode = MapQuickView::updatePaintNode(node, data);
// clean up children nodes if the attribution text is not visible
if (mapViewNode && !attributionTextVisible()) {
auto* child = mapViewNode->firstChild();
while (child) {
mapViewNode->removeChildNode(child);
delete child;
child = node->firstChild();
}
}
return mapViewNode;
}
};
Let me know if this works for you.
Guillaume
Instead of using setAttributionTextVisible of GeoView we use your workaround which seems to work. Looking forward to the fix so we can remove this workaround sometime in the future.
Many thanks!