I am testing a Java client to add a feature into a feature layer on AGOL. When I run the client, it prints 'DONE add' (Please see the code logic) -> It means that the feature was added into the feature layer successfully, but I go to the Feature layer on AGOL to verify the added feature, I don't see the features that I added via the client.
// featureTable
ServiceFeatureTable featureTable = new ServiceFeatureTable(
"https://services5.arcgis.com/IOshH1zLrIieqrNk/arcgis/rest/services/TestFeature2/FeatureServer/0?token=XXXXXXXXXX");
featureTable.addDoneLoadingListener(() -> {
if (featureTable.getLoadStatus() == LoadStatus.LOADED) {
// Feature attributes
Map<String, Object> attributes = new HashMap<>();
attributes.put("Name", "Record-" + System.currentTimeMillis());
// Create a feature record with a Point
Feature feature = featureTable.createFeature(attributes, new Point(-95, 40));
// If can add?
if (featureTable.canAdd()) {
// Add feature
featureTable.addFeatureAsync(feature).addDoneListener(() -> {
System.out.println("DONE add");
});
} else {
System.out.println("CAN'T add");
}
} else {
System.out.println(featureTable.getLoadStatus());
}
});
// Load featureTable
featureTable.loadAsync();Please helps. Thanks!
Solved! Go to Solution.
I think you are missing an ApplyEdits step.
If you take a look at this sample code you will see what needs to be done.
Does this help?
Mark
Thank you MarkBaird. You are right. I forget a ApplyEdit call. It is working now.