Map Rotation

Download Samples Repository

Description

This sample shows how to rotate a map using the MapView.Rotation property.The slider control in the top right corner of the map controls the rotation angle of the map view.

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

Sample Code

<UserControl x:Class="ArcGISRuntime.Samples.Desktop.MapRotation"
             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 WrapAround="True" x:Name="MyMapView">
			<esri:Map>
                <esri:ArcGISTiledMapServiceLayer
                    ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
            </esri:Map>
        </esri:MapView>

		<Border Background="White" BorderBrush="Black" BorderThickness="1"
				HorizontalAlignment="Right" VerticalAlignment="Top"
				Margin="30" Padding="20">
			<Border.Effect>
				<DropShadowEffect/>
			</Border.Effect>
			<StackPanel>
                <TextBlock Text="{Binding ElementName=rotationSlider, Path=Value, StringFormat='Rotation: {0:0.0}'}" 
                         Margin="4,0"  FontWeight="Bold" />

                <Slider x:Name="rotationSlider" Margin="4" ValueChanged="rotationSlider_ValueChanged"
                        Orientation="Horizontal" Width="100" IsSnapToTickEnabled="True" 
						Value="{Binding Rotation, ElementName=MyMapView, Mode=OneWay, Delay=50}"
                        TickPlacement="BottomRight" TickFrequency="5"
                        Minimum="0" Maximum="360" />
            </StackPanel>
        </Border>
    </Grid>
</UserControl>
using System.Windows.Controls;

namespace ArcGISRuntime.Samples.Desktop
{
    /// <summary>
    /// This sample shows how to rotate a map using the MapView.Rotation property.  The slider control in the top right corner of the map controls the rotation angle of the map view.
    /// </summary>
    /// <title>Map Rotation</title>
	/// <category>Mapping</category>
	public partial class MapRotation : UserControl
    {
        public MapRotation()
        {
            InitializeComponent();
        }

		private void rotationSlider_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e)
		{
			MyMapView.SetRotation(e.NewValue);
		}
    }
}
Feedback on this topic?