AnsweredAssumed Answered

How to refresh esri Map in code

Question asked by nviot64 on Apr 30, 2014
Latest reply on Apr 30, 2014 by nviot64
Hi everyone,

I'm trying to do a screenshot of a part of MyMap and this is how I proceed :
(MyMap is esri Map)


  • hide all layers

  •             var screenShotLayer = MyMap.Layers["ScreenShotLayer"] as GraphicsLayer;             var regionsLayer = MyMap.Layers["RegionsLayer"] as GraphicsLayer;             var puitsLayer = MyMap.Layers["PuitsLayer"] as GraphicsLayer;             var linesLayer = MyMap.Layers["LinesLayer"] as GraphicsLayer;             var blocksLayer = MyMap.Layers["BlocksLayer"] as GraphicsLayer;             var bufferPuitsLayer = MyMap.Layers["BufferPuitsLayer"] as GraphicsLayer;             var topoMapLayer = MyMap.Layers["TopoMapLayer"] as ArcGISLocalTiledLayer;             var topoMapLayer2 = MyMap.Layers["TopoMapLayer2"] as ArcGISLocalTiledLayer;              regionsLayer.Visible = false;             puitsLayer.Visible = false;             linesLayer.Visible = false;             blocksLayer.Visible = false;             bufferPuitsLayer.Visible = false;             topoMapLayer.Visible = false;             topoMapLayer2.Visible = false;


  • Save Map Extent

  • var oldExtent = MyMap.Extent;


  • Add graphics that I want to screenshot in a specific layer

  • screenShotLayer.Graphics.AddRange(ListGraphicCopy);


  • Get the extent of my screenshotlayer

  • MyMap.Extent = screenShotLayer.FullExtent;


  • Do screenshot and revert all changes

  •             //On fait le screenshot             var image = Helper.BitmapHelper.CreateScreenShot(MyMap);             //On supprime les graphics ajouté au layer screenshot             foreach (var graphic in ListGraphicCopy) screenShotLayer.Graphics.Remove(graphic);             //On remet l'ancien cadrage qu'avait la map             MyMap.Extent = oldExtent;              //On rend tous les layers visible             regionsLayer.Visible = true;             puitsLayer.Visible = true;             linesLayer.Visible = true;             blocksLayer.Visible = true;             bufferPuitsLayer.Visible = true;             topoMapLayer.Visible = true;             topoMapLayer2.Visible = true;

The mather is that the map doesn't refresh without UserInterface asked her so the result is the basic view and not the one I create for screenshot.

Can anyone help me on this?

Thanks in advance.

Outcomes