async void MyMapView_GeoViewTapped(System.Object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { // Clear any currently visible callouts, route graphics, or selections MyMapView.DismissCallout(); _routeGraphicsOverlay.Graphics.Clear(); _placesGraphicsOverlay.ClearSelection(); // Get the place under the tap IdentifyGraphicsOverlayResult idResult = await MyMapView.IdentifyGraphicsOverlayAsync(_placesGraphicsOverlay, e.Position, 12, false); Graphic clickedElement = idResult.Graphics.FirstOrDefault(); if (clickedElement != null) { // Select the place to highlight it; get name and address clickedElement.IsSelected = true; string name = clickedElement.Attributes["Name"].ToString(); string address = clickedElement.Attributes["Address"].ToString(); // Create a callout definition that shows the name and address for the place; set the element as a tag CalloutDefinition definition = new CalloutDefinition(name, address); definition.Tag = clickedElement; // Handle button clicks for the button on the callout // This event receives the value assigned as the CalloutDefinition.Tag // ** Fix API ref for this! // https://developers.arcgis.com/net/latest/wpf/api-reference/html/P_Esri_ArcGISRuntime_UI_CalloutDefinition_OnButtonClick.htm definition.OnButtonClick = new Action <object>(async(tag) => { // Get the geoelement that represents the place GeoElement poiElement = tag as GeoElement; if (poiElement == null) { return; } // Call a function in the viewmodel that will route to this location var routeGraphic = await _viewModel.RouteToPoiAsync(_deviceLocation, poiElement.Geometry as MapPoint, MyMapView.SpatialReference); // Add the route graphic to the map view and zoom to its extent _routeGraphicsOverlay.Graphics.Add(routeGraphic); await MyMapView.SetViewpointGeometryAsync(routeGraphic.Geometry, 30); }); // Set the button icon and show the callout at the click location definition.ButtonImage = WalkIcon; MyMapView.ShowCalloutAt(e.Location, definition); } }