Select to view content in your preferred language

EditTool and Extent

888
4
08-05-2010 05:26 AM
BernadetteSorenson
Emerging Contributor
I am using the DrawTool to draw an Extent object on the map. When I attempt to move the Extent graphic using EditTool, the graphic won't move. I understand that some of the Extent properties are read only, but I was wondering if anyone has any advice on what to do.  Thanks.
Tags (2)
0 Kudos
4 Replies
SarthakDatt
Frequent Contributor
Hey,

How are you 'activating' the EditTool on the newly created extent?

This is how it should be done:

// ActionScript

var myEditTool : EditTool = new EditTool(myMap)  // make sure you pass in the map object
myEditTool.activate(EditTool.MOVE, [myGraphic]);

//where myGraphic is the newly created graphic(in your case with an extent geometry) 


// MXML and Actionscript


<!-- EditTool, again making sure you pass in the map object -->
<esri:EditTool id="myEditTool" map="{myMap}"/>

myEditTool.activate(EditTool.MOVE, [myGraphic]);  


You can look at : http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/tools/EditTool.html#activate()

Lemme know if that helps.
0 Kudos
BernadetteSorenson
Emerging Contributor
Yes, I am activating the edit tool:

mapEditTool.activate(EditTool.MOVE|EditTool.EDIT_VERTICES, [Graphic(event.target)]);

and I've tested it with Polyline, Polygon and Extent. My Extent object is the only one that won't work with the EditTool.
0 Kudos
SarthakDatt
Frequent Contributor
Hey Bernadette,

Yes you are right, It looks like the EditTool does not work with Extent geometries for now. It expects the geometry to be either point, line or polygon. I will push in a fix for this.
For the time being as a workaround, try converting your extent to a polygon before passing it to the EditTool.

Something like :

var extent : Extent =  Graphic(event.target).geometry as Extent;

const arrPoints:Array = [
     new MapPoint(extent.xmin, extent.ymin),
     new MapPoint(extent.xmin, extent.ymax),
     new MapPoint(extent.xmax, extent.ymax),
     new MapPoint(extent.xmax, extent.ymin),
     new MapPoint(extent.xmin, extent.ymin)
];

var polygon:Polygon = new Polygon();
polygon.addRing(arrPoints);
polygon.spatialReference = extent.spatialReference;

Graphic(event.target).geometry = polygon;

mapEditTool.activate(EditTool.MOVE|EditTool.EDIT_V ERTICES, [Graphic(event.target)]); 


Lemme know if this works for you.
0 Kudos
BernadetteSorenson
Emerging Contributor
Sarthak,

I did something similar to your suggestion, using a Polyline. It would be nice to have the EditTool work with the Extent geometries. Thanks again for your help!

Bernadette
0 Kudos