After finishing a feature on Web map, I want to update some attribute information before the attribute inspector popup.
What I am doing now is:
(1) initializing Draw toolbar (invisible) after a template is chosen.
(2) Trap the "draw-end" event of Draw once the feature sketch event is done.
The problem I found that: in the "draw-end" handler, I can get the geometry of the created feature. But this feature is not added to its feature class in the "draw-end" handler yet. I want to update some attribute information before the Attribute Inspector popup the information window.
I don't know when this feature is added to its feature class, and how to automatically update information for users before they use the attribute inspector.
Thanks,
Take a look at the Edit without editor widget sample in the ArcGIS API for JavaScript help. This sample shows how to create features using the template picker and draw toolbar.
How to add a new feature with neither the Editor widget and template picker using just graphics?
Richard Moussopo you'll use the same approach outlined in the sample I linked to above. The general idea is that you create a graphic then use the Feature Layer's applyEdits method to add the graphic to the layer.
Thanks for the reply. That's what the way I am doing. The sample works fine. But, in my case, there are two features added into the feature class. First, the feature from the sketch tool is added to the target feature class automatically.
Second, the graphic that I created by using the following code is also added into the target feature class.
var newAttributes = lang.mixin({}, selectedTemplate.template.prototype.attributes);
var newGraphic = new Graphic(evt.geometry, null, newAttributes);
selectedTemplate.featureLayer.applyEdits([newGraphic], null, null);
What I want is to hold the feature before it is added to the feature class and reset the attribute information. I don't know what is wrong in my situation. The sample link works fine. I use the same method, and it does not work for me. I also get two features as I mentioned above.
Thanks,
Do you have a working code sample that shows the problem that you can share?