private async void MapView_Tapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e) { // Clear any existing selection. _damageLayer.ClearSelection(); // Reconfigure the button. DeleteButton.IsEnabled = false; DeleteButton.Text = "Delete feature"; try { // Perform an identify to determine if a user tapped on a feature. IdentifyLayerResult identifyResult = await MyMapView.IdentifyLayerAsync(_damageLayer, e.Position, 5, false); // Do nothing if there are no results. if (!identifyResult.GeoElements.Any()) { return; } // Otherwise, get the ID of the first result. long featureId = (long)identifyResult.GeoElements.First().Attributes["objectid"]; // Get the feature by constructing a query and running it. QueryParameters qp = new QueryParameters(); qp.ObjectIds.Add(featureId); FeatureQueryResult queryResult = await _damageLayer.FeatureTable.QueryFeaturesAsync(qp); _tappedFeature = queryResult.First(); // Select the feature. _damageLayer.SelectFeature(_tappedFeature); // Update the button to allow deleting the feature. ConfigureDeletionButton(_tappedFeature); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } }
private async void MapView_Tapped(object sender, GeoViewInputEventArgs e) { // Clear any existing selection. _damageLayer.ClearSelection(); // Dismiss any existing callouts. _myMapView.DismissCallout(); try { // Perform an identify to determine if a user tapped on a feature. IdentifyLayerResult identifyResult = await _myMapView.IdentifyLayerAsync(_damageLayer, e.Position, 8, false); // Do nothing if there are no results. if (!identifyResult.GeoElements.Any()) { return; } // Otherwise, get the ID of the first result. long featureId = (long)identifyResult.GeoElements.First().Attributes["objectid"]; // Get the feature by constructing a query and running it. QueryParameters qp = new QueryParameters(); qp.ObjectIds.Add(featureId); FeatureQueryResult queryResult = await _damageLayer.FeatureTable.QueryFeaturesAsync(qp); Feature tappedFeature = queryResult.First(); // Select the feature. _damageLayer.SelectFeature(tappedFeature); // Show the callout. ShowDeletionCallout(tappedFeature); } catch (Exception ex) { ShowMessage(ex.ToString(), "There was a problem."); } }