Map reference scale

View inAndroidFormsUWPWPFWinUIiOSView on GitHubSample viewer app

Set the map's reference scale and which feature layers should honor the reference scale.

Image of map reference scale

Use case

Setting a reference scale on a Map fixes the size of symbols and text to the desired height and width at that scale. As you zoom in and out, symbols and text will increase or decrease in size accordingly. When no reference scale is set, symbol and text sizes remain the same size relative to the MapView.

Map annotations are typically only relevant at certain scales. For instance, annotations to a map showing a construction site are only relevant at that construction site's scale. So, when the map is zoomed out that information shouldn't scale with the MapView, but should instead remain scaled with the Map.

How to use the sample

Use the control at the top to set the map's reference scale (1:500,000 1:250,000 1:100,000 1:50,000). Use the menu checkboxes in the layer menu to set which feature layers should honor the reference scale.

How it works

  1. Get and set the reference scale property on the Map object.
  2. Get and set the scale symbols property on each individual FeatureLayer object.

Relevant API

  • FeatureLayer
  • Map

Additional information

The map reference scale should normally be set by the map's author and not exposed to the end user like it is in this sample.

Tags

map, reference scale, scene

Sample Code

MapReferenceScale.xamlMapReferenceScale.xamlMapReferenceScale.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<UserControl x:Class="ArcGISRuntime.WPF.Samples.MapReferenceScale.MapReferenceScale"
             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 Style="{StaticResource BorderStyle}">
            <StackPanel>
                <TextBlock FontWeight="SemiBold" Text="Choose a map reference scale:" />
                <!--  When the user's selection changes, the SelectedItem binding will apply the value to the Map's ReferenceScale property.  -->
                <ComboBox x:Name="ReferenceScaleBox"
                          Margin="0,5,0,5"
                          SelectedItem="{Binding ElementName=MyMapView, Path=Map.ReferenceScale}">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock>
                                <!--  Runs are used to format a plain double to match the convention for writing map scales.  -->
                                <Run Text="1:" />
                                <Run Text="{Binding Path=., StringFormat=n0}" />
                            </TextBlock>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
                <TextBlock FontWeight="SemiBold" Text="Choose layers to apply scale to:" />
                <!--  Binding is used to display the operational layers for the map view's map, no code behind needed.  -->
                <ListView Margin="0,5,0,5" ItemsSource="{Binding ElementName=MyMapView, Path=Map.OperationalLayers}">
                    <ListView.ItemTemplate>
                        <DataTemplate DataType="esri:FeatureLayer">
                            <!--
                                When the user interacts with the checkbox,
                                the two-way binding will update the ScaleSymbols (bool) property automatically.
                            -->
                            <CheckBox Content="{Binding Name}" IsChecked="{Binding ScaleSymbols}" />
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
                <TextBlock>
                    <!--  A run is used to format the label.  -->
                    <Run Text="Current map scale: " />
                    <Run Text="1:" />
                    <Run Text="{Binding ElementName=MyMapView, Path=MapScale, Mode=OneWay, StringFormat=n0}" />
                </TextBlock>
            </StackPanel>
        </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.