Set Initial Center and Scale

Download Samples Repository

Description

Shows how to set the initial center and scale of the map (Map.InitialViewpoint).

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

Sample Code

<UserControl x:Class="ArcGISRuntime.Samples.Desktop.SetInitialCenterAndScale"
             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">
			<esri:Map>
				<esri:Map.InitialViewpoint>
					<!--Center on San Diego, at scale 1:50,000, using coordinates in WGS84 spatial reference (4326)-->
					<esri:ViewpointCenter X="-117.15" Y="32.705" Scale="50000" SpatialReferenceID="4326" />
				</esri:Map.InitialViewpoint>
				<esri:ArcGISTiledMapServiceLayer 
                    ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
            </esri:Map>
        </esri:MapView>
    </Grid>
</UserControl>
using System.Windows.Controls;

namespace ArcGISRuntime.Samples.Desktop
{
	/// <summary>
	/// Shows how to set the initial center and scale of the map (Map.InitialViewpoint).
	/// </summary>
	/// <title>Set Initial Center and Scale</title>
	/// <category>Mapping</category>
	public partial class SetInitialCenterAndScale : UserControl
    {
		public SetInitialCenterAndScale()
        {
            InitializeComponent();

			// Note: uncomment the following to set the initial center/scale of the map in code.
			//MyMapView.Map.InitialViewpoint = new Esri.ArcGISRuntime.Controls.Viewpoint(new MapPoint(-117.15,32.705,SpatialReferences.Wgs84), 50000); 
        }
    }
}
Feedback on this topic?