Reseting extent

2300
7
Jump to solution
04-29-2013 10:17 AM
LuisGarcia2
Occasional Contributor II
I have a map with a specific layer that I want my users to be able to reset the extent to. So I basically added a little button that on the click event has this:

 GraphicsLayer l = (GraphicsLayer)this.map1.Layers["MY_LAYER_ID"];                                 this.map1.Extent = l.FullExtent; 


That works fine as long as the window is Maximized. If the window that holds the map is in any other size then it only shows whatever part of the viewing area is shown at that moment. What I'd like to happen is that the map resets to the extent the layer has but that the layer in question if shown entirely in the current viewing area. Is there an example of that somewhere? How can I accomplish this?
Thanks!
0 Kudos
1 Solution

Accepted Solutions
LuisGarcia2
Occasional Contributor II
The solution for this, in case someone is interested, has been to increase the extent by a small percentage of its Maximum and Minimums. That opens the zoom enough for it to show at the right place. It still cuts some markers from view; but in general it handles real well.
Hope that helps someone else.

View solution in original post

0 Kudos
7 Replies
LuisGarcia2
Occasional Contributor II
A picture says more than 1K words. So, I am attaching some pics now :). Screen shot "reset_extent_maximized.JPG" shows the full extent when the window is Maximized. Screen shot "reset_extent_not_maximized.JPG" shows the same thing when the window containing the map is NOT maximized. I basically want my clients to see the same thing all the time like in the "maximized" window example. It is like a zoom setting??
thanks!
0 Kudos
LuisGarcia2
Occasional Contributor II
I tried this:

this.map1.ZoomTo(l.FullExtent);


And get the same result. there has to be a way to take into consideration the viewing area at the specific moment...
0 Kudos
dotMorten_esri
Esri Notable Contributor
There shouldn't be any difference based on the size of the map.however a smaller map needs to zoom out more to a different scale to fit the same extent. Could it be you have some max/min zoom limitations (either explicitly or caused by a cached layers levels), SnapToLevels etc enabled?
0 Kudos
LuisGarcia2
Occasional Contributor II
Morten thanks for your reply. I need to check those. I have no idea at this point.
0 Kudos
LuisGarcia2
Occasional Contributor II
There shouldn't be any difference based on the size of the map.however a smaller map needs to zoom out more to a different scale to fit the same extent. Could it be you have some max/min zoom limitations (either explicitly or caused by a cached layers levels), SnapToLevels etc enabled?


Morten, I found this in my XAML map definition:

                <i:Interaction.Behaviors>
                    <esri:MaintainExtentBehavior />
                </i:Interaction.Behaviors>


But if I understand the documentation well, that works only when re-sizing the map.
0 Kudos
dotMorten_esri
Esri Notable Contributor
That could definitely cause issues, since this'll take over handling the map extent in certain scenarios. I assume it works if you take it out?
0 Kudos
LuisGarcia2
Occasional Contributor II
The solution for this, in case someone is interested, has been to increase the extent by a small percentage of its Maximum and Minimums. That opens the zoom enough for it to show at the right place. It still cuts some markers from view; but in general it handles real well.
Hope that helps someone else.
0 Kudos