Select to view content in your preferred language

MapImageLayer Graphic's layer is null

307
1
02-13-2024 01:59 AM
average_geo_97
Emerging Contributor

In my application, I have some custom logic that runs when layers are added to / removed from the scene. One such piece of logic involves checking whether features in the popup are from the removed layer. My existing (and working) code is basically this:

if (feature.layer.id === removedLayer.id) {
  // logic here
}

However, after we added a map image layer to the scene, this logic causes an error, because for map image layer features in the popup, the Graphic object's layer field is null, instead of being the MapImageLayer instance, which is the case for most other layers (FeatureLayer, GraphicsLayer, SceneLayer etc). Inspecting the Browser Debugger, I instead see an undocumented sourceLayer property in the Graphic object that correctly points to the MapImageLayer. 

Is this intended? Would it be possible to make MapImageLayer consistent with the rest of the layers so i wouldn't need to special-case this?

0 Kudos
1 Reply
Noah-Sager
Esri Regular Contributor

Hi @average_geo_97, thanks for posting your question here. MapImageLayer is a bit different from other layer types. Typically, you'll want to work with Sublayers.

Can you share a simplified repro app that shows what's happening?

0 Kudos