Keep feature layer labels visible while zooming map

1163
0
10-11-2019 03:12 AM
Status: Open
DziugasPocius
New Contributor II

In ArcGIS API for Javascript version 4.x, when feature layer has defined labeling info and when map is zoomed in or out, labels disappear during zoom animation. They appear again once the animation is complete. Video showing this issue: https://streamable.com/ceor3. In this video after application loads, I zoom map using mouse scrollwheel and it is visible how labels disappear and reappear after some time. Here is a sample app to check this issue: JS Bin - Collaborative JavaScript Debugging .

Expected behavior in this situation is to keep labels visible during zoom animation and only hide those labels, which start colliding with other labels after zoom.

Notes after looking more into this issue: it seems like the cause of this issue is in esri/views/2d/engine/webgl/brushes/WGLGeometryBrushLabel class drawGeometry function. In that function there is a check to only render labels once required zoom level to display labels is strictly equal to the current level of data tile being rendered.
Code line looks like this:
...
if (e.requiredLevel === t.key.level || p) {
...

But when zooming map, those zoom level are not always equal during animation and that is when labels are not visible.
Here is another sample app, which includes workaround to this issue: JS Bin - Collaborative JavaScript Debugging . This app is the same as the first one, except there is added monkey-patched WGLGeometryBrushLabel.default.prototype.drawGeometry function, making those two zoom levels always equal. This change fixes described issue.

I have already reported this issue in my.esri.com support (case number 02412498), but bug or enhancement was refused to be logged, because this behavior "is as per design of JS API 4.x version", so I was directed to the ArcGIS ideas to report this issue here.