I SetViewpointGeometryAsync and then screenshot code follow, but the image of screenshot is uncomleleted, some of image is backgound ,I think this is due to the mapview can't change immediately, but how to solve this ? code and image show bellow
You can subscribe to DrawStatusChanged to be able to grab the image when all layers are rendered.
EventHandler<SPAN class="operator token"><</SPAN>DrawStatusChangedEventArgs<SPAN class="operator token">></SPAN> onDrawStatusChanged <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">async</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">OnSetView</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">object</SPAN> sender<SPAN class="punctuation token">,</SPAN> RoutedEventArgs e<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">try</SPAN> <SPAN class="punctuation token">{</SPAN> MyMapView<SPAN class="punctuation token">.</SPAN>DrawStatusChanged <SPAN class="operator token">-</SPAN><SPAN class="operator token">=</SPAN> onDrawStatusChanged<SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> geometry <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">await</SPAN> MyMapView<SPAN class="punctuation token">.</SPAN>SketchEditor<SPAN class="punctuation token">.</SPAN><SPAN class="token function">StartAsync</SPAN><SPAN class="punctuation token">(</SPAN>SketchCreationMode<SPAN class="punctuation token">.</SPAN>Rectangle<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">await</SPAN> MyMapView<SPAN class="punctuation token">.</SPAN><SPAN class="token function">SetViewpointGeometryAsync</SPAN><SPAN class="punctuation token">(</SPAN>geometry<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> onDrawStatusChanged <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">async</SPAN> <SPAN class="punctuation token">(</SPAN>s<SPAN class="punctuation token">,</SPAN> a<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>a<SPAN class="punctuation token">.</SPAN>Status <SPAN class="operator token">==</SPAN> DrawStatus<SPAN class="punctuation token">.</SPAN>Completed<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> MyMapView<SPAN class="punctuation token">.</SPAN>DrawStatusChanged <SPAN class="operator token">-</SPAN><SPAN class="operator token">=</SPAN> onDrawStatusChanged<SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> image <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">await</SPAN> MyMapView<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ExportImageAsync</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Window</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> Content <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Image</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> Source <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">await</SPAN> image<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToImageSourceAsync</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">ShowDialog</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">;</SPAN> MyMapView<SPAN class="punctuation token">.</SPAN>DrawStatusChanged <SPAN class="operator token">+</SPAN><SPAN class="operator token">=</SPAN> onDrawStatusChanged<SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">catch</SPAN><SPAN class="punctuation token">(</SPAN>TaskCanceledException<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">catch</SPAN><SPAN class="punctuation token">(</SPAN>Exception ex<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> MessageBox<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Show</SPAN><SPAN class="punctuation token">(</SPAN>ex<SPAN class="punctuation token">.</SPAN>Message<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Hi, Antti
I wonder if that data is requested (and draw) as I navigate the map to other extents, then which compeleted comes first, the navigate compeleted or the draw compeleted? thanks.
Is the MapView (actually the layers) still requesting the data at that point? You might need to use arcgis-runtime-samples-dotnet/src/WPF/ArcGISRuntime.WPF.Samples/Samples/MapView/DisplayDrawingStatus at master · Esri/ar… to make sure that the drawing is finished before taking the screenshot.
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.