Select to view content in your preferred language

How to Change Position of Polygon/Polyline graphic in ArcGIS java

1786
3
Jump to solution
01-27-2020 11:52 PM
FuzailSiddiqui
Occasional Contributor

I am working on a map based application using ArcGIS java SDK 100.7.0. I'm working on drawing and editing graphics. My question is very simple. Is there a way that we can change the center point of the extent of a polygon or a polyline graphic. I am required to give my user the ability to drag and move a graphic on MapView when on edit mode. How can i achieve this in java.

0 Kudos
1 Solution

Accepted Solutions
Rachael_Ellen
Esri Contributor
Hello,
Utilitising the Sketch Editor, a user can click and drag a geometry (currently supporting polygon/polyline/point/multipoint) once it has been added to e.g. a graphics overlay. See the Sketch On Map sample for an example of how to use this functionality.
Programmatically, this happens via capturing the graphic's geometry and passing it into the sketchEditor.start() function. This allows the user to click on the graphic, and click and drag it to move the whole graphic, or click and drag individual vertexes on the graphic to edit individual segments. See for example the following code snippet from the Sketch On Map sample:
if (!graphicsOverlay.getSelectedGraphics().isEmpty()) {
      graphic = graphicsOverlay.getSelectedGraphics().get(0);
      sketchEditor.start(graphic.getGeometry());
    }
Hope this helps,
Rachael

View solution in original post

3 Replies
Rachael_Ellen
Esri Contributor
Hello,
Utilitising the Sketch Editor, a user can click and drag a geometry (currently supporting polygon/polyline/point/multipoint) once it has been added to e.g. a graphics overlay. See the Sketch On Map sample for an example of how to use this functionality.
Programmatically, this happens via capturing the graphic's geometry and passing it into the sketchEditor.start() function. This allows the user to click on the graphic, and click and drag it to move the whole graphic, or click and drag individual vertexes on the graphic to edit individual segments. See for example the following code snippet from the Sketch On Map sample:
if (!graphicsOverlay.getSelectedGraphics().isEmpty()) {
      graphic = graphicsOverlay.getSelectedGraphics().get(0);
      sketchEditor.start(graphic.getGeometry());
    }
Hope this helps,
Rachael
FuzailSiddiqui
Occasional Contributor

Thank you for your response. I have seen the usage of SketchEditor. Though my question was to know specifically that if there is any way to programmatically change the position of a polygon/polyline by shifting it from it's geometry, however your response confirms that there isn't any way to do that apart from the SketchEditor, which is why i'm going to accept this as the correct answer. The problem i am facing is that right now, my application gives the user the ability to draw different shapes (including Square, Rectangle and circles which are not currently supported by the SDK but are drawn using polygon geometry programmatically by me). In order to edit those unsupported shapes, the SketchEditor must support them too. I'm trying to avoid editing shapes using the SketchEditor due to this rigid scenario. Starting the SketchEditor with a circle polygon may probably ruin the shape. Can i even ask you when is the team going to add support for more shape geometries plus SketchEditor just like the Team has done with C# SDK.

0 Kudos
Rachael_Ellen
Esri Contributor

Thank you for your feedback on the SketchEditor functionality: as you say, these shapes are currently missing from SketchEditor in the Java SDK. We are however considering them for a future release. 

Kind regards,

Rachael

0 Kudos