Select to view content in your preferred language

2.0 Beta: <esri:Editor> - "handle" on a created feature

1358
3
05-06-2010 03:51 AM
SteveTest
Deactivated User
Looking for some hints/samples on how you would go about getting a handle or ID of some sort on a newly
created feature with the Editor.  This would be used to relate the new feature to existing business tables.

Thanks
Steve
Tags (2)
0 Kudos
3 Replies
SarthakDatt
Frequent Contributor
Hey,

There are number of ways in which you can get access to the newly created feature:

- The editor internally uses the drawTool to create features, the drawTool is exposed as a property on the editor. So you listen to the drawEnd event on it and access the feature

- The out-of-the-box-behavior with the editor is such, that whenever you create a new feature, its automatically selected, if in your case that is the only selected feature, you can look at the featureLayer.selectedFeatures.

- you can listen to graphicAdd on the featureLayer, fired every time you add a graphic(feature) to it

Hope that helps.

--Sarthak Datt
0 Kudos
SteveTest
Deactivated User
Thanks Sarthak that helps a lot but following some experiments there are still some issues to resolve:

1.  When the DRAW_END event fires from the drawtool, the feature has not yet been selected. So there is a timing issue in trying to get to the newly created feature. In other words, at the point in time when this event fires, myfeature.selectedfeature.length = 0;

2. graphicAdd on the feature layer also fires when an existing feature is selected so how to tell if this is a new feature?


I actually got the process to work by having DRAW_END set a boolean that is then checked and cleared
by the graphicAdd event. Doesn't seem like a very good solution: is there a better way ?

Thanks!
Steve
0 Kudos
SarthakDatt
Frequent Contributor
Hey Steve,

You can also do this: when a new feature is created it is selected for you automatically, if you look at the featureLayer, it fires selectionComplete whenever a selection is made, you can get to the selected(in your case newly created feature) listening to that event.

Also, the editor uses the AttributeInspector to show the attributes of the feature, which is exposed as a property and you can then access the activeFeature property on the attributeInspector.

Lemme know if this works better for you.

--Sarthak
0 Kudos