private void OnViewpointsButtonTouch(object sender, EventArgs e)
{
// Initialize an UIAlertController
UIAlertController viewpointAlert = UIAlertController.Create(
"Select viewpoint", "", UIAlertControllerStyle.Alert);
// Add actions to alert. Selecting an option set the new viewpoint
viewpointAlert.AddAction(UIAlertAction.Create(titles[0], UIAlertActionStyle.Default,
async (action) =>
{
// Set Viewpoint using Redlands envelope defined above and a padding of 20
await _myMapView.SetViewpointGeometryAsync(RedlandsEnvelope, 20);
}));
viewpointAlert.AddAction(UIAlertAction.Create(titles[1], UIAlertActionStyle.Default,
async (action) =>
{
// 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);
}));
viewpointAlert.AddAction(UIAlertAction.Create(titles[2], UIAlertActionStyle.Default,
async (action) =>
{
// 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));
}));
PresentViewController(viewpointAlert, true, null);
}