I have a WPF Map control whose extent I would like to restrict to a certain area (e.g. to the full extent of some layer). That is, a user should not be able to zoom out too far, or shift the map to an area outside that full extent.
How can I restrict Map display to a certain extent?
This is my code:
<esri:Map x:Name="Map" SizeChanged="Map_SizeChanged">
<esri:ArcGISTiledMapServiceLayer x:ID="LB" ... />
...
</esri:Map>
And here is the code-behind (this code does not work):
void Map_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (currentExtent > Map.Zoom(Map.Layers["LB"].FullExtent)) // check the current extent of the map. If currentExtent is more than FullExtent
{
// jump back to full extent
Map.Zoom(Map.Layers["LB"].FullExtent);
}
}
I'd like to get something like that:
private void Map_SizeChanged(object sender, SizeChangedEventArgs e)
{
… // get current extent of the map
… // check the current extent of the map.
// if currentExtent is more than FullExtent jump back to full extent
}
I'm using the ESRI API for WPF and C# in Visual Studio 2010.