I'm creating a web service that will be passed a list of objects that include the Lat/Long coordinates and some other data such as Speed. When I use the ArcGISRuntime library to add the features to my map service that is running, the Geometry will appear but none of the attributes ever will. Here is my code:

            foreach (GPSLocation loc in aLocationsToStore)
                var theLatLongPoint = new MapPoint(loc.Longitude, loc.Latitude, SpatialReferences.Wgs84);
                var theProjectedPoint = GeometryEngine.Project(theLatLongPoint, theSpatialReference);
                var theDateTime = Convert.ToDateTime(loc.DateTime);

                //Feature gpsFeature = new GeodatabaseFeature(gpsLocFeatureTable.Schema);
                var gpsFeature = gpsLocFeatureTable.CreateNew();
                gpsFeature.Geometry = theProjectedPoint;
                var attributes = gpsFeature.Attributes;
                attributes["SPEED"] = loc.Speed;

                await gpsLocFeatureTable.AddAsync(gpsFeature);
            var result = await gpsLocFeatureTable.ApplyEditsAsync(true);

After running this, in the map service I can see the MapPoints in the feature layer, but all of the attribute values of the point are 'null' Any idea what I'm doing wrong or how I can get the attributes to sync?

EDIT: I tried sniffing the network data using WireShark and this is what I get for the adds value:

      }    } ]

It seems as though it is overriding all of the attributes that I explicitly define when I call AddAsync. Any ideas on how to get attributes in the attributes object?


Alright I figured out what the problem was. For some reason the ServiceFeatureTable that is returned from the OpenAsync method doesn't have the OutFields defined and we must explicitly add each attribute to the list in order for the data to sync to the server.

This code snippet shows how this can be done:

        var gpsLocFeatureTable = await ServiceFeatureTable.OpenAsync(AGGPS_FEATURE_URI);
        if (gpsLocFeatureTable.OutFields == null)
            gpsLocFeatureTable.OutFields = new Esri.ArcGISRuntime.Tasks.Query.OutFields();

        foreach (FieldInfo fieldInfo in gpsLocFeatureTable.Schema.Fields)

After this you can create a Feature from the ServiceFeatureTable and edit the attributes like this:

                GeodatabaseFeature gpsFeature = new GeodatabaseFeature(gpsLocFeatureTable.Schema);
                gpsFeature.Geometry = theProjectedPoint;
                gpsFeature.Attributes[COMMENTS_KEY] = "This property will be synced to the server";
                await gpsLocFeatureTable.AddAsync(gpsFeature);
                var result = await gpsLocFeatureTable.ApplyEditsAsync(true);

This is obviously a problem that ESRI needs to fix, if we receive the schema and feature class info from the server, the OutFields should automatically be populated as needed.

Helped guide the answer: https://geonet.esri.com/thread/127699

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.