Adding and remove images in a loop with MapImage in 3.29

352
4
09-05-2019 07:27 PM
ChristopherHollis
New Contributor

I'm trying to create a radar loop of PNG images that are georeferenced using MapImage and MapImageLayer in version 3.29. From looking at the page here:
https://community.esri.com/thread/210261-overlay-georeferenced-image-with-arcgis-javascript-46

You can't do this in version 4 yet so I am trying 3.29.

The problem I have is that the imagery flickers:
http://tropicalatlantic.com/historical/radars/2019/dorian/bahamas/

I use MapImageLayer to add a layer. Then I use MapImage. I use addImage, and then removeImage image, to add and remove imagery in the loop. The problem is that before the new image shows, the old image is removed. Sometimes once everything has loaded it starts flickering less, but with over 1,000 images in the loop, it always flickers to some extent. I was looking for a way to determine if something is still being drawn and after the new image has been drawn, remove the old one. What I have tried hasn't worked so far.

Another alternative would be to create over a 1,000 layers and add an image to each one. Then control the opacity of each one as I loop through, with only the one I want currently visible, but that seems like it would probably crash with over 30 megabytes of images. I'll probably try that next though to see how it goes.

I can't use another method of serving the imagery. I have another project with radar imagery and it too will work the same, PNG images for which I have coordinates for the extent.

0 Kudos
4 Replies
BenElan
Esri Contributor

Have you tried wrapping the removeImage in a update-end event handler?

0 Kudos
ChristopherHollis
New Contributor

I had tried it on the layer. Here is a simple example trying it on the layer:

https://jsfiddle.net/yq60Lsph/ 

Check that with the console open. I can get the opacity event handler to fire but not anything related to updating.

Do I need to do something specific to "removeImage"? Or something else different?

0 Kudos
ChristopherHollis
New Contributor

I see posts here that say GraphicsLayer doesn't fire "update-end" even though it is in the documentation. Does "MapImageLayer" also work like that maybe?

0 Kudos
ChristopherHollis
New Contributor

I would like to know if it is possible with "update-end", but for now I tried something different. I put each image in its own layer. Then I toggle the visibility of each layer as I loop through. I didn't see any way to toggle individual images in a single layer. It means that in my initial example I create about 1,300 layers, but that can do for now. It won't flicker after the initial load.

0 Kudos