Hi, we are using runtime sdk 100 and Kotlin. How can we do rectangular polygon drawing with SketchEditor?
Can not draw with the code above.
private val sketchEditor = SketchEditor()private fun drawRect() { mapView.sketchEditor = sketchEditor sketchEditor.start(SketchCreationMode.POLYGON) }
Hi - I'm afraid that sketching Envelopes with the sketch editor is not currently supported. (Envelopes are always aligned with the axes of the spatial reference, so works well on web mercator and similar systems, but can have some pretty weird effects in some cases.) Let us know what your use case is for sketching envelopes - you can't store them in geodatabases, so are you creating envelope graphics, or something else? Or are you interested in creating shapes that are not actually the GeometryType.ENVELOPE? You might want to head over to ArcGIS Ideas and post your suggestion there along with information about how you'd want to use this.
Sorry for not being clearer earlier, what we basically want to achive is to draw a rectangular and show all the features in it. In order to do that we want to draw rectangular and query with this extent.
No problem. Sounds like perhaps what you're asking for is similar to click-dragging a rectangle with a mouse - a rectangle in screen coordinates, the sides being aligned with the sides of the screen? The SketchEditor doesnt have anything that can draw a rectangle like that - it works with geometries in map coordinates, so a rectangle aligned with the screen would not always be the same as an Envelope geometry in map coords aligned with spatial reference.
If this indeed what you were wanting to do, I'd suggest writing a custom touch listener for the MapView, and working screen coordinates there. You'd have to draw the rectangle shape yourself - I've used very simple solution before of resizing a child View on top of the MapView to represent a user touch location, but there's various ways to achieve something similar I think, I'd probably start on StackOverflow!
Alternatively if you want something simple and can be flexible on the search geometry, using the standard or freehand polygon sketch modes in the SketchEditor for users to sketch a rough map area they want to search can be a good idea. Another approach is just to prompt the user to resize the map to show the area they want to use for the search.
Hope this helps somewhat,
Shelly