AnsweredAssumed Answered

Determine points that are under a sketchOverlay in a map

Question asked by rolstonr on Jan 22, 2019
Latest reply on Jan 23, 2019 by JNery-esristaff

I have a map which has a GraphicsOverlay with various points. I have given the user the ability to select a subset of the points by drawing a polygon using the SketchEditor. How can I determine which points have been selected?

Here is a subset of the code to set up the map:

var symbolLow = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Colors.Green, 10d);

private GraphicsOverlay graphicsOverlayLow = new GraphicsOverlay()
{ Renderer = new SimpleRenderer(symbolLow) }; 

foreach (var graphic in graphicListLow)  // graphicListLow is a List of Points   

MyMapView.GraphicsOverlays = new GraphicsOverlayCollection();


// Graphics overlay to host sketch graphics
private GraphicsOverlay _sketchOverlay = new GraphicsOverlay();

I have two buttons, one for starting the drawing of the polygon and one to click when done (this follows the esri example for the SketchEditor). The code for starting is as follows:


private async void SelectButton_Click(object sender, RoutedEventArgs e)
        // Let the user draw on the map view using the chosen sketch mode
        SketchCreationMode creationMode = SketchCreationMode.Polygon;
        Esri.ArcGISRuntime.Geometry.Geometry geometry = await MyMapView.SketchEditor.StartAsync(creationMode, true);
          // Create and add a graphic from the geometry the user drew        
         Graphic graphic = CreateGraphic(geometry);
     catch (TaskCanceledException)
        // Ignore ... let the user cancel drawing
     catch (Exception ex)
        // Report exceptions        
         MessageBox.Show("Error drawing graphic shape: " + ex.Message);

private Graphic CreateGraphic(Esri.ArcGISRuntime.Geometry.Geometry geometry)
    // Create a graphic to display the specified geometry    
    Symbol symbol = null;    
    switch (geometry.GeometryType) 
         // Symbolize with a fill symbol       
         case GeometryType.Envelope: 
         case GeometryType.Polygon:
              symbol = new SimpleFillSymbol()
                  Color = Colors.Red,                    
                  Style = SimpleFillSymbolStyle.Solid,         

Here is the handler for the routine that is called when the user clicks the button signaling that they are done drawing the polygon. This is where I want to determine which points have been selected.


private void CompleteButton_Click(object sender, RoutedEventArgs e)
    // Cancel execution of the sketch task if it is already active
    if (MyMapView.SketchEditor.CancelCommand.CanExecute(null))

Note that I am using the 100.4 SDK for WPF.