Method to know if the map Rendered

974
2
01-25-2012 08:22 AM
jonataspovoas
Regular Contributor
Hi,

In my application I need to get a new image of the my map every time it is updated (zoom or pan funcionalities). I'm using the Map.ExtentChanged Event, but Sometimes the Image is shot before the Whole map is Shown. Is there any event or property that could show me the exact moment that the map finishes rendering?

MyMap.ExtentChanged += (s, e) =>
{
 WriteableBitmap imagem = new WriteableBitmap(MyMap, null);
 mapImagePreview.Source = imagem;
 mapImagePreview.HorizontalAlignment = HorizontalAlignment.Center;
 mapImagePreview.VerticalAlignment = VerticalAlignment.Center;
 mapImagePreview.Stretch = Stretch.Uniform;
 imagem.Render(MyMap, null);
};
0 Kudos
2 Replies
JenniferNery
Esri Regular Contributor
Have you tried running the code inside Dispatcher.BeginInvoke()? I don't know if that will make a difference but I think you can also use either LayoutUpdated or SizeChanged event. http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.layoutupdated%28v=vs.95%29.a.... You can subscribe to this event only if Map.ExtentChanged.
0 Kudos
jonataspovoas
Regular Contributor
Have you tried running the code inside Dispatcher.BeginInvoke()? I don't know if that will make a difference but I think you can also use either LayoutUpdated or SizeChanged event. http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.layoutupdated%28v=vs.95%29.a.... You can subscribe to this event only if Map.ExtentChanged.


Hi,

None of the above worked. I've made some progress since I posted my question. It still need improvement, but using the Map.Progress event managed to get the final view of the map in 80 to 85% of the time, like this:

MyMap.Progress += (s, e) =>
{
 if (e.Progress == 100)
 {
  WriteableBitmap imagem = new WriteableBitmap(paginaImressaoRetratoA4, null);
  this.visualizacaoDaPagina.Source = imagem;
 }
};


It still bugs some times, showing the map incomplete.
0 Kudos