Select to view content in your preferred language

Refreshing an Imagery Layer

328
0
07-24-2023 06:51 PM
MichaelBell
New Contributor III

I'm currently adjusting an Imagery Layer's mosaicRule using a widget. I can set it, but I don't seem to be able to refresh the Imagery Layer so it shows what I want it to show - it just continues showing the same image with no change. Code is:

    let mosaicRule = new MosaicRule({
      where: "acquisitiondate >= '2023-06-18' AND acquisitiondate <= '2023-06-22'"
    });
    jimuMapView.view.map.findLayerById("Sentinel2_2968").mosaicRule = mosaicRule;
   
 console.log(jimuMapView.view.map.findLayerById("Sentinel2_2968").mosaicRule)
    jimuMapView.view.map.findLayerById("Sentinel2_2968").refresh();

Something I CAN do is apply this same mosaicRule to a new layer and add that to the map - however I'd really not like to have to go through the map and find the layer, destroy it, and add a new one every time the user wants to make this change:

    let mosaicRule = new MosaicRule({
      where: "acquisitiondate >= '2023-06-18' AND acquisitiondate <= '2023-06-22'"
    });
    const layer = new ImageryLayer ({
      url: "https://myserver.com/portal/sharing/servers/itemid/rest/services/Sentinel2/ImageServer",
      format: "jpgpng"
    })
    layer.mosaicRule = mosaicRule
    jimuMapView.view.map.add(layer)

Any idea how I can refresh the existing layer rather than having to create it all over again every time we change anything?

0 Kudos
0 Replies