Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

Zoom to Layer refresh not working

$
0
0
Hi, what im trying to do is to zoom 2 times, with 3 seconds pause between zooms.
Code:

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.

Viewing all articles
Browse latest Browse all 1374

Trending Articles