Save map as png

259
2
06-09-2011 06:56 AM
BerendVeldkamp
Occasional Contributor II
Hi,

I created an extension that listens to the CollectFeaturesTask.CollectionCompleted event, and checks if a feature meets certain requirements. In some cases, an email must be sent, including an image of the map.
I have this almost working now: When I click on "Finish", the map image is created and the email is sent, but the image shows the map as it was before the last feature was added to it: The feature that was just being edited does not show.

I tried this code, but the map is only refreshed after the mapview becomes active again.
var map = MobileApplication.Current.Map;
map.CenterAt(feature.Geometry.GetExtent().GetCenter());
map.InvalidateVisual();
SaveMapImage(map);


Does anyone know how to force a refresh on the map (This is a WPF map, so I do not have the GetMapImage(), Refresh() or Invalidate() methods)?
0 Kudos
2 Replies
MelindaFrost
Occasional Contributor
Guessing the CollectFeaturesTask.CollectionCompleted event must fire before map control event is triggered to update the display. You could do your validation in CollectionCompleted and set a flag of true/false and then see if using say- FeatureLayer event DataChanged or maybe the map event LayersDrawingCompleted to get image and send email if validation is true.
0 Kudos
BerendVeldkamp
Occasional Contributor II
Melinda,

Thanks for your suggestion, I think this should be the way to go. Unfortunately reality is tougher, and I couldn't find an event that is triggered 'at the right moment'.
I ended up drawing the feature's swatch manually on top of the generated image. Since in my case they are always point features, that's not too hard.
0 Kudos