How to add a (x, y) coord. to feature layer without using Editor and Drawing tools

1795
7
Jump to solution
01-22-2013 05:33 PM
xiannianchen
New Contributor II
Hi, friends,

I have many points in xml format. I can read this xml file in Flex.
My goal is to add these points to a feature layer which is served in Feature Server with Feature Access enabled.
The scenario is: first, read x, y coordinate from external file; second, convert the x, y coordinate to a MapPoint; thirdly, add this MapPoint to a layer in a Feature Service served through ArcGIS Server with Feature Access enabled.

All the samples use Editor tool and/or Drawing tool. How can I add  to these x,y coordinates to a Feature Layer without using Editor and/or Drawing tool?

Thanks,
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
xiannian,

   You have to be use Feature Access is enable in ArcGIS Manager and that your SDE data is versioned.

View solution in original post

0 Kudos
7 Replies
IvanBespalov
Occasional Contributor III
Parse xml (the ArcGIS Flex Viewer is a big sample of how to do it)
Create MapPoints from readed data, and existing layer SpatialReference
Create array of Graphics with created geometries and required(not nullable) attributes
applyEdits()
0 Kudos
xiannianchen
New Contributor II
Thank for the reply.

Basically, that is what my understanding. I have done like this. That confirms that I am on the right direction. But, so far, no any success yet.

I successfuly creates the graphic array based on the xml file.  Then, I have the program called the addFeatureArrayToFeatureLayer function. I created two event listners. But the EDITS_COMPLETE listner never return me anything while EDITS_STARTING listener does give me feedbacks. And I don't know what's going after I called the method of ApplyEdits() function. ArcGIS Server Manager log section has no further information.

I have tested my fecture service on ArcGIS.com. I can add features to the layer on ArcGIS.com. That means my feature service has no problem. Right?

Thanks,


main body
{
var fs:Array = new Array();

for each ( pt in pts) {
  var graphic:Graphic = new Graphic(WebMercatorUtil.geographicToWebMercator(tweet.twtPoint));
  graphic.attributes = {
   "User": pt.AuthorName,
   "ID": pt.Tid,
   "XY": pt.LocationXY,
   "Datetime": pt.PublishDate
  };
      
  fs.push(graphic);
}

addFeatureArrayToFeatureLayer(fs);     
}

protected function addFeatureArrayToFeatureLayer(fs:Array):void
{
var fLayer:FeatureLayer = new FeatureLayer("http://url/arcgis/rest/services/myMap/myService/FeatureServer/0");

fLayer.addEventListener(FeatureLayerEvent.EDITS_COMPLETE,addFeatureDone);
fLayer.addEventListener(FeatureLayerEvent.EDITS_STARTING,addFeatureStarting);
fLayer.applyEdits(fs,null,null);
}

private function addFeatureStarting(e:FeatureLayerEvent):void
{
Alert.show("Starting");
}

private function addFeatureDone(e:FeatureLayerEvent):void
{
Alert.show("Succeed");
}

Parse xml (the ArcGIS Flex Viewer is a big sample of how to do it)
Create MapPoints from readed data
Create array of Graphics with created geometries and required(not nullable) attributes
applyEdits()
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Xiannian,

   Make sure you are passing graphics with all required attributes (as Ivan Mentioned) as an array.
If it is a single graphic use code like this (all the items in red are required):
FeatureLayer.applyEdits([ptGraphic],null,null,true,null);
0 Kudos
xiannianchen
New Contributor II
Robert,

Thanks for the reply.

What do you mean all required attributes? The attributes I attached to the Graphic variable is the direct copy of the field list of my feature class which is stored in a Workgroup SDE database. OK, except the ObjectID and GlobalID fields. Do I need to populate some numerical value for this field?

Also, the FeatureServer service that I am using works fine in ArcGIS.com. Without editing any attributes in ArcGIS.com platform, I can add new features into the same layer which I am using in the ArcGIS Flex API environment.

Thanks again,

Xiannian

Xiannian, 

Make sure you are passing graphics with all required attributes (as Ivan Mentioned) as an array. 
If it is a single graphic use code like this (all the items in red are required): 
FeatureLayer.applyEdits([ptGraphic],null,null,true,null);
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Xiannian,

   Just like Ivan mentioned non nullable attributes. No you do not need to populate the OID or GlobalID fields. Not sure what problem you are having as I do editing this way all the time.
0 Kudos
xiannianchen
New Contributor II
Robert and Ivan,

Thanks for the replies. I have found that the isEditable property of my FeatureLayer variable is false.

Is this the reason of my problem? Since this property is readonly, what should I do if I need to make it true?

Thanks,

Xiannian

Xiannian, 

Just like Ivan mentioned non nullable attributes. No you do not need to populate the OID or GlobalID fields. Not sure what problem you are having as I do editing this way all the time.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
xiannian,

   You have to be use Feature Access is enable in ArcGIS Manager and that your SDE data is versioned.
0 Kudos