Drag and drop a polygon graphic

2717
4
Jump to solution
02-01-2012 06:29 PM
StephenLead
Regular Contributor III
Derek Swingley provided some sample code for dragging and dropping a graphic point. What is the best procedure for dragging and dropping a graphic polygon? (I'm happy to limit this to a rectangular shape if that's easier than working with a complex polygon.)

Given that the transformation is shown in page units, do I need to:

  • get the xmin,xmax,ymin,ymax of the original graphic in map units

  • generate the 4 corners as individual Point objects in map units

  • convert these points to page units

  • apply the transformation to each point in page units

  • convert the points back to map units

  • generate a new geometry from the new points

  • apply this geometry to the polygon

This seems a bit convoluted. Is there a faster way to obtain the coordinates of the graphic after it's been dropped?

Thanks,
Steve
1 Solution

Accepted Solutions
EdSaunders
Occasional Contributor
Steve, in the graphics samples there's a context menu example which includes the move option.  You could just initialize the move functionality using dojo.connect when the graphic is added to the map.  You don't need an edit toolbar or an editing session, you're just using the edit toolbar functionality.

View solution in original post

4 Replies
EdSaunders
Occasional Contributor
Steve, what do you want to achieve that's different from using the edit toolbar functionality in the samples?
0 Kudos
StephenLead
Regular Contributor III
Hi Ed,

Good suggestion - but I'm looking for something a lot simpler, like the polygon in the Overview map, where you can just pick it up and move it. I don't want to create a feature layer, start an edit session, etc.

I've got a workaround using the method above - I'm just wondering whether there's a more efficient way to do it.

Cheers,
Steve
0 Kudos
EdSaunders
Occasional Contributor
Steve, in the graphics samples there's a context menu example which includes the move option.  You could just initialize the move functionality using dojo.connect when the graphic is added to the map.  You don't need an edit toolbar or an editing session, you're just using the edit toolbar functionality.
StephenLead
Regular Contributor III
Sounds like just the shortcut I was looking for - thanks!

For reference the Context Menu sample is here if anyone else needs it.