Select features within a drawing area

1853
6
Jump to solution
02-12-2020 11:56 PM
SerhiiKyrylenko
New Contributor III

There is need to be able to draw a polygon/rectangle on the map in order to select intersecting features with that drawing. I can see from the Feature Layer Selection Runtime SDK for .NET example:

The sample uses the MapView.RequestShapeAsync method to allow the user to draw a selection rectangle intersecting features that he would like to manage.Once the selection rectangle is returned, a SpatialQueryFilter is used to spatially select features in the feature layer using FeatureLayer.

Specifically 

var rect = await MyMapView.Editor.RequestShapeAsync(DrawShape.Rectangle);

I can't find any similar Editor of the MapView for the iOS version of the SDK.

Feature Layer Selection Runtime SDK for iOS example only provides the solution how to select feature by tap point but not by drawing graphics area.

I want to achieve basic functionality as this dashboard provides. User can select features not only by point but also by rectangle, lasso, circle and line. Is there any solution or starting point for this?

Example of selection by rectangle area

example of selected features by rectangle selection

0 Kudos
1 Solution

Accepted Solutions
MarkDostal
Esri Contributor

Thank you for your question!  Take a look at the "Sketch on the map" sample. It demonstrates how you can use the sketch editor to draw point, line, or polygon geometries.  You can get the geometry from the sketch to use in your feature layer selection call.

Hope that helps!  If you have further questions, let us know!

Mark

View solution in original post

6 Replies
SerhiiKyrylenko
New Contributor III

Currently I'm leveraging on AGSGeoViewTouchDelegate. Specifically on didTouchDownAtScreenPoint and other methods in order to manually draw geometry on the map. Since there are a lot of map points received by delegate method, they are normalised to rectangle instead of polygon.

Also worse to mention, in order to draw the user's choice rectangle in real time, AGSGraphics object is repeatedly deleting and adding from AGSGraphicsOverlay object during the each  didTouchDragToScreenPoint method call like so:

        graphicsOverlay.graphics.removeAllObjects()
        graphicsOverlay.graphics.add(polygonGraphic)

...where polygonGraphic is normalised rectangle (4 AGSPoint objects)

It works, but my concern is about CPU usage. During creating selection rectangle on the map, CPU usage can be up to 30% for my current iOS device. It's not that big in comparison if the user scales or moving area of the map that will use 80+% of CPU.

0 Kudos
MarkDostal
Esri Contributor

Thank you for your question!  Take a look at the "Sketch on the map" sample. It demonstrates how you can use the sketch editor to draw point, line, or polygon geometries.  You can get the geometry from the sketch to use in your feature layer selection call.

Hope that helps!  If you have further questions, let us know!

Mark

SerhiiKyrylenko
New Contributor III

Thank you, that is exactly I'm looking for. CPU performance is pretty the same, but there is helpful addition like undo manager. The only concern is how to tweak color/style of the geometries? For example while creating graphics manually, I'm able to tweak AGSSimpleFillSymbol style, color and outline.

0 Kudos
MarkDostal
Esri Contributor

I'm glad that worked for you!  If you want to change the symbology used to render the geometry, take a look at the AGSSketchEditor.style property.  It is of type AGSSketchStyle, which lets you change the symbols for pretty much every geometry the sketch editor displays.  You can find the doc here:  ArcGIS Runtime SDK for iOS: AGSSketchStyle Class Reference.

Mark

SerhiiKyrylenko
New Contributor III

Thank you, I was briefly looking at AGSSketchEditor.style property at first without success. It turns out I should look for feedbackFillSymbol and feedbackFillSymbol properties to achieve my needs.

Narenkrishnaar
New Contributor II

Hi @MarkDostal , This is the exact requirement we have. There is a feature on the map that allows you to select a certain area in the existing map using a poly line or any using other options. We need to show the layer details within the selected area. Some APIs, such as identifyLayers, require screen point values to be supplied. Will we be able to access the layer details if we only supply the geometry value? Please assist me in this matter.

 

https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/attempting-to-extract-the-layer-o...

0 Kudos