4.12: MapImageLayer sometimes not displayed initially

111
0
08-27-2021 12:09 AM
fabianmue
New Contributor II

Hi

Note: this question applies to ArcGIS JS Api 4.12. I am aware that the version is outdated, but due to BUG-000132900 I cannot use a newer version.

I am developping an (Angular-) Application using ArcGIS JS Api 4.12. I have a MapView with a map, which contains a basemap (with a WMTS layer and a MapImageLayer) and a few additional MapImageLayers.

One of the (additional) MapImageLayers is supposed to be displayed initially. My problem is that sometimes, the Layer is only visible after the view is somehow manipulated (drag, zoom, resize). If that happens, no export request for the corresponding layer can be seen in the network tab of the dev tools.

The weird thing is that this only happens sometimes. I think it could be timing related, but I struggle to figure out what could potentially be happening in the wrong order.

For reference, here is a description of how I am creating the view and adding the layers:

1. create the additional MapImageLayers from a url

2. watch for the layers "sublayers". In The callback when sublayers.length > 0, iterate of the layers .allSublayers and change some of the sublayers properties (.visible, .definitionExpression, .title)

3. create a new MapView() with a new Map() (in an Angular Service), where the Basemap is added but the additional MapImageLayers are not yet

4. watch for the views "ready". In the callback when ready is true, add the additional MapImageLayers

5. assign a HTMLDivElement to view.container

The watch callbacks (2. and 4.) seem to be executed after 5. happened (guess that makes sense).

Is the order in which I am initializing the view generally correct? Is this potentially a known issue I am unaware of? Are there any workarounds to always have the layer displayed initially?

Thank you very much for your help.

Regards, Fabian

0 Kudos
0 Replies