AnsweredAssumed Answered

How do I allow the user to select a graphic?

Question asked by on Oct 12, 2018
Latest reply on Oct 15, 2018 by

Problem summary: I need to know the best/recommended way to allow a user to select graphics, not query the geometry based on the location they clicked and then select the related graphic.  



We have an application that allows the user to select a graphic and edit its attributes and geometry.  Currently we are using SelectFeaturesAsync with a buffered geometry around the location the user clicks on to select the graphics.  The problem occurs when the user zooms the map in or out because the buffer size when the map is zoomed out is not large enough to account for the scale difference. When a user clicks on the graphic it may not be selected if they do not click close enough to the center for the geometry query to return a result.  From the users perspective they are clicking on the graphic and nothing is happening. I am looking for a recommended approach for adjusting my buffer proportionately to the scale (and also spatial reference since the buffer distance takes spatial reference into account) OR just directly detecting which graphic was actually clicked on by the user. 


The code below is similar to what we are currently doing and is taken from the Select Features section of the guide here.

// Build a buffer (polygon) around a click point var buffer = GeometryEngine.Buffer(queryPoint, 5000);

// Use the buffer to define the geometry for a query var query = new QueryParameters(); query.Geometry = buffer; query.SpatialRelationship = SpatialRelationship.Contains;

// Select features in a feature layer using the query await damageLayer.SelectFeaturesAsync(query, Esri.ArcGISRuntime.Mapping.SelectionMode.New);



The buffer size I'm using is fine at this scale. If the user is zoomed in closer (say street block level) the buffer size may cause several graphics to become selected if they are close together.

But at this scale it will not select the graphic unless the user clicks very close to the center of the graphic.