Show Map Scale

Download Samples Repository

Description

This sample demonstrates the map scale changing when you zoom in and out. The XAML textblock is bound to the MapView.Scale property to display the current map scale at the bottom of the display.

"Desktop" "Store" "Phone" Available for Desktop, Store, Phone

Sample Code

<UserControl x:Class="ArcGISRuntime.Samples.Desktop.ShowMapScale"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="300"
             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
             >
    <Grid>
        <esri:MapView x:Name="MyMapView" WrapAround="True">
            <esri:Map>
                <esri:ArcGISTiledMapServiceLayer
                    ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
            </esri:Map>
        </esri:MapView>

        <Border Background="White" BorderBrush="#FF999999" BorderThickness="1" Padding="5" 
                HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="10" >
            <TextBlock Name="MapScaleTextBlock" HorizontalAlignment="Center" VerticalAlignment="Bottom" Foreground="Black">
                <Run>Map Scale: 1:</Run>
                <TextBlock Text="{Binding ElementName=MyMapView, StringFormat={}{0:0}, Path=Scale}" FontSize="12" FontWeight="Bold" Foreground="Black"/>
            </TextBlock>
        </Border>
    </Grid>
</UserControl>
using System.Windows.Controls;

namespace ArcGISRuntime.Samples.Desktop
{
    /// <summary>
    /// This sample demonstrates the map scale changing when you zoom in and out. The XAML textblock is bound to the MapView.Scale property to display the current map scale at the bottom of the display.
    /// </summary>
    /// <title>Show Map Scale</title>
	/// <category>Mapping</category>
	public partial class ShowMapScale : UserControl
    {
        public ShowMapScale()
        {
            InitializeComponent();
        }
    }
}
Feedback on this topic?