Select to view content in your preferred language

Zooming to Full Extent through code?

6037
6
Jump to solution
04-03-2013 11:45 AM
GeorgeFaraj
Frequent Contributor
What's the best way to zoom to the full extent through code?
0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor
I want to zoom to the full extent of all the layers that I have currently loaded.

You can get the full extent af all layers by code like MyMap.Layers.GetFullExtent()

This is working well if all of your layers use the same spatial reference. If some layers are not in the same spatial reference as the map you will have to project the layer extents and to union them by code.

View solution in original post

0 Kudos
6 Replies
DominiqueBroux
Esri Frequent Contributor
If you are talking about the full extent of a layer, you can look at this legend sample, the 'ZoomToFullExtent' method is wired up the Layer.Initialized event and zoom to the full extent of that layer once the map spatial reference is known.
A geometry service may be used to project the layer full extent to the map spatial reference.
0 Kudos
GeorgeFaraj
Frequent Contributor
I want to zoom to the full extent of all the layers that I have currently loaded.
0 Kudos
RobertBorchert
Honored Contributor
Hit the Full Extent button in the Tools Toolbar.  It looks like a little globe.

If that is taking you out to far you can right click on your most extensive feature and click zoom to layer.

You can manually adjust it to where you want to be. Right click on the Data Frame header.  Defaults to Layers.  Open the Data Frame Tab and click on the Other and Specify Extent button.  Then choose Current Visible Extent.

Save your MXD.  Then every time you click on the Full Extent Button it will take you to the same spot.


I want to zoom to the full extent of all the layers that I have currently loaded.
0 Kudos
GeorgeFaraj
Frequent Contributor
I think you're in the wrong place. This is the ArcGIS Runtime SDK forum. I need code that zooms the map to its full extent (of all layers).
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I want to zoom to the full extent of all the layers that I have currently loaded.

You can get the full extent af all layers by code like MyMap.Layers.GetFullExtent()

This is working well if all of your layers use the same spatial reference. If some layers are not in the same spatial reference as the map you will have to project the layer extents and to union them by code.
0 Kudos
aymantoubasi
Deactivated User
use this code using C#:

MyMap.ZoomTo(MyMap.Layers.GetFullExtent());
0 Kudos