Set max extent

View inFormsWPFWinUIView on GitHubSample viewer app

Limit the view of a map to a particular area.

Image of set max extent

Use case

When showing map information relevant to only a certain area, you may wish to constrain the user's ability to pan or zoom away.

How to use the sample

The application loads with a map whose maximum extent has been set to the borders of Colorado. Note that you won't be able to pan far from the Colorado border or zoom out beyond the minimum scale set by the max extent. Use the control to disable the max extent to freely pan/zoom around the map.

How it works

  1. Create a Map object.
  2. Create an envelope of the extent.
  3. Set the map to a MapView object.
  4. Set the maximum extent of the map with map.MaxExtent = extentEnvelope.
  5. Set MaxExtent to null to disable the maximum extent of the map.

Relevant API

  • Envelope
  • Map

Tags

extent, limit panning, map, mapview, max extent, zoom

Sample Code

SetMaxExtent.xamlSetMaxExtent.xamlSetMaxExtent.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<UserControl x:Class="ArcGISRuntime.WPF.Samples.SetMaxExtent.SetMaxExtent"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
    <Grid>
        <esri:MapView x:Name="MyMapView" />
        <Border MaxWidth="180" Style="{StaticResource BorderStyle}">
            <CheckBox x:Name="MaxExtentCheckBox"
                      VerticalAlignment="Center"
                      VerticalContentAlignment="Center"
                      Checked="MaxExtentCheckBoxChanged"
                      Unchecked="MaxExtentCheckBoxChanged">
                <Label Content="Max Extent Enabled" />
            </CheckBox>
        </Border>
    </Grid>
</UserControl>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close