Programmatically move feature(s) client side

1888
4
Jump to solution
02-08-2017 09:58 AM
AlexMagruder
New Contributor III

I need to be able to move one or more features based on an angle and distance offset. I'm not sure how to approach this. The Edit toolbar allows for moving one feature through mouse interaction, which does not match my workflow. Is there a tool in the geometryEngine that supports this operation? Is there a method on the Geometry class? Ideally the solution is client side but I could support an async operation on the server.

User Story: User can nudge (move a small distance in a set direction) one or many features based on button click or keyboard input

Thanks!

0 Kudos
1 Solution

Accepted Solutions
AlexMagruder
New Contributor III

I've created a module to provide this functionality. It takes a geometry, distance (meters), and angle and returns a new geometry at that offset. To move lines and polygons it moves each vertex by the offset amount. It works, but I haven't created any unit tests to check all scenarios , so use at your own risk. Attached is the AMD module.

View solution in original post

0 Kudos
4 Replies
thejuskambi
Occasional Contributor III

You could use the offset method in the GeometryEngine to achieve this.

esri/geometry/geometryEngine | API Reference | ArcGIS API for JavaScript 3.19 

0 Kudos
AlexMagruder
New Contributor III

This would work for points but not polygons. For a polygon the offset method is similar to the buffer tool, returning a geometry that is inside or surrounding the original feature by the offset amount. 

0 Kudos
thejuskambi
Occasional Contributor III

I think it will work for both point and polyline, if the problem is only for polygon, then you can loop through all the points within the polygon and offset them.

0 Kudos
AlexMagruder
New Contributor III

I've created a module to provide this functionality. It takes a geometry, distance (meters), and angle and returns a new geometry at that offset. To move lines and polygons it moves each vertex by the offset amount. It works, but I haven't created any unit tests to check all scenarios , so use at your own risk. Attached is the AMD module.

0 Kudos