SketchEditor - prevent shape rotation?

284
4
Jump to solution
07-26-2019 06:11 AM
SteveMiller4
New Contributor II

I'm using the SketchEditor to create a selection UI. This works great except that when users rotate the map, the rectangular envelope that is created by the SketchEditor rotates as well. Is there some way to prevent the SketchEditor shapes from rotating the shapes it draws, when the map rotates?

0 Kudos
1 Solution

Accepted Solutions
Nicholas-Furness
Esri Regular Contributor

For those that are interested, this question was about dragging a selection rectangle that's always aligned with the screen, regardless of the rotation of the map.

The suggested solution was to use the AGSGeoViewTouchDelegate methods that deal with drag interactions.

  1. Implement didTouchDownAt() and call the completion handler with true. This tells Runtime you want to handle interactions for a bit. The screenPoint will be the fixed corner of a selection rectangle.
  2. Handle didTouchDragToScreenPoint(). This will give you the opposite corner of the rectangle. From the original screen coordinate and the screen coordinate passed in here, you can define the 4 screen coordinates of the rectangle (it's aligned with the screen). Use AGSMapView.screenToLocation() to turn those into map coordinates of a polygon to display as an AGSGraphic on the map view.
  3. On didTouchUpAt(), perform the selection. Once this method returns, Runtime will resume handling map interactions.

View solution in original post

0 Kudos
4 Replies
SuganyaBaskaran1
Esri Contributor

Can you please clarify your question? I don't understand if your question is about the rectangular envelope or just sketch moving along with the map?

SketchEditor is added to the map view, so it sticks to the map while the map rotates. This is intentional since the sketch is usually drawn based on the contents of the map, and we want to maintain that relationship when the map is rotated. 

However, the sketch alone can be rotated, irrespective of the map's rotation. The rectangular envelope around the sketch is responsible for it. You can disable that by setting `sketchEditor.editConfiguration.allowRotate = false`. 

If you can provide further details, I'd be happy to help you. 

0 Kudos
SteveMiller4
New Contributor II

It’s about the rectangular envelope. The sketch is turned into a selection as soon as they finish drawing, so the sketch moving with the map isn’t an issue. The problem is that if the map has been rotated, then the envelope will be rotated as well when it is drawn. What I’m hoping for is some way to control whether the envelope is rotated when it is initially drawn.

0 Kudos
SuganyaBaskaran1
Esri Contributor

Thanks for the clarification. 

Unfortunately, we do not offer the capability right now for the rectangular envelope to be always upright. We can consider that feature for a future release. 

0 Kudos
Nicholas-Furness
Esri Regular Contributor

For those that are interested, this question was about dragging a selection rectangle that's always aligned with the screen, regardless of the rotation of the map.

The suggested solution was to use the AGSGeoViewTouchDelegate methods that deal with drag interactions.

  1. Implement didTouchDownAt() and call the completion handler with true. This tells Runtime you want to handle interactions for a bit. The screenPoint will be the fixed corner of a selection rectangle.
  2. Handle didTouchDragToScreenPoint(). This will give you the opposite corner of the rectangle. From the original screen coordinate and the screen coordinate passed in here, you can define the 4 screen coordinates of the rectangle (it's aligned with the screen). Use AGSMapView.screenToLocation() to turn those into map coordinates of a polygon to display as an AGSGraphic on the map view.
  3. On didTouchUpAt(), perform the selection. Once this method returns, Runtime will resume handling map interactions.

View solution in original post

0 Kudos