Select to view content in your preferred language

Add features successfully but the added features were not actually added.

844
2
Jump to solution
12-15-2022 09:56 AM
lochd
by
Emerging Contributor

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!

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MarkBaird
Esri Regular Contributor

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

View solution in original post

2 Replies
MarkBaird
Esri Regular Contributor

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

lochd
by
Emerging Contributor

Thank you MarkBaird. You are right. I forget a ApplyEdit call. It is working now.

0 Kudos