private async void OnButtonClick(object sender, RoutedEventArgs e)
{
// Get .Content from the selected item
Button myButton = sender as Button;
var selectedMapTitle = myButton.Content.ToString();
switch (selectedMapTitle)
{
case "Geometry":
// Set Viewpoint using Redlands envelope defined above and a padding of 20
await MyMapView.SetViewpointGeometryAsync(_redlandsEnvelope, 20);
break;
case "Center and Scale":
// Set Viewpoint so that it is centered on the London coordinates defined above
await MyMapView.SetViewpointCenterAsync(_londonCoords);
// Set the Viewpoint scale to match the specified scale
await MyMapView.SetViewpointScaleAsync(_londonScale);
break;
case "Animate":
// Navigate to full extent of the first baselayer before animating to specified geometry
await MyMapView.SetViewpointAsync(
new Viewpoint(MyMapView.Map.Basemap.BaseLayers.First().FullExtent));
// Create a new Viewpoint using the specified geometry
var viewpoint = new Viewpoint(_edinburghEnvelope);
// Set Viewpoint of MapView to the Viewpoint created above and animate to it using a timespan of 5 seconds
await MyMapView.SetViewpointAsync(viewpoint, TimeSpan.FromSeconds(5));
break;
default:
break;
}
}
}