Zoom to Layer refresh not working.

659
1
11-09-2013 04:09 AM
DariusDarius
New Contributor
Hi, what im trying to do is to zoom 2 times, with 3 seconds pause between zooms.

   public void ZoomToLayerInTOC(ESRI.ArcGIS.ArcMapUI.IMxDocument mxDocument)
        {
            if (mxDocument == null)
            {
                return;
            }
            ESRI.ArcGIS.Carto.IActiveView activeView = mxDocument.ActiveView;

            // Get the TOC
            ESRI.ArcGIS.ArcMapUI.IContentsView IContentsView = mxDocument.CurrentContentsView;
            ESRI.ArcGIS.Geometry.IEnvelope envelope = activeView.Extent;
           // ESRI.ArcGIS.Geometry.IEnvelope envelope = activeView.Extent;
            envelope.Expand(0.75, 0.75, true);
            activeView.Extent = envelope;
            activeView.Refresh();
            System.Threading.Thread.Sleep(3000);
            envelope.Expand(0.75, 0.75, true);
            activeView.Extent = envelope;
            activeView.Refresh();
            System.Threading.Thread.Sleep(3000);
            // Get the selected layer
            System.Object selectedItem = IContentsView.SelectedItem;
            if (!(selectedItem is ESRI.ArcGIS.Carto.ILayer))
            {
                return;
            }
            ESRI.ArcGIS.Carto.ILayer layer = selectedItem as ESRI.ArcGIS.Carto.ILayer;


            // Zoom to the extent of the layer and refresh the map
            activeView.Extent = layer.AreaOfInterest;
            activeView.Refresh();
        }


And after clicking button i get zoomed in after 6 seconds. Like there's no refresh after first zoom, although map scrollbars gets smaller.
0 Kudos
1 Reply
DominiqueBroux
Esri Frequent Contributor
Looks like you are using the ArcObjects SDK and not the Silverlight API.
I suggest you post your question on the ArcObjects SDK forum.
0 Kudos