TL;DR
My problem is, that after creating a feature in the EditorWidget the Feature is not shown in the map. It is not queried. In another identical ap (clone) but different deployment it works just fine.
You can find a table about differences below.
What am I missing and how do I fix it or work around?
Long Version
In our app (called B) we are using a simple EditorWidget:
const mapView = await this._mapViewPromise;
this._activeEditor = new Editor({
view: mapView,
container: this.canvasId
});
After drawing and typing data into the form and clicking so save it, the Feature is created.
But: Its not visible until I refresh the whole page.
Checking the network tab shows, that there is no query sent to retrieve the created feature.
After pressing F5, all Features appear:
payload of applyEdits with adds-object nested in edits-object:
Since we copied the app code from another app (called A) and modified some other things I tried the same there and:
The other app immediately is showing the new feature and I can see a query in the network tab.
payload of applyEdits with adds-object:
So both apps, being clones but used in different deployments do different things.
What are the differences I recognize so far?
A | B (clon of A) |
automatically queries the new Feature | no query after applyEdits |
thus shows new feature on map directly | F5 needed to show new Features |
uses a hosted FeatureService from its own ArcGIS Portal | uses a FeaturesService from its own ArcGIS Portal but connected to Enterprise GeoDB (so not shown as "hosted" in the portal) |
directy uses 'adds'-object in payload | nests the 'adds'-object inside an 'edits'-object also containing nested 'edits' and 'deletes' with null |
RequestURL: https://myA.local/server1/rest/services/Hosted/MyAService/FeatureServer/2/applyEdits | RequestURL: https://shgdi-myB.local/server/rest/services/myB/MyBService/FeatureServer/applyEdits |
Layers are added like map.add(new WFSLayer(props) | Layers added automatically via WebMap: const map = new WebMap(...) new MapView(..., map, ....) |
Regarding the different request URL I found these two different docs about applyEdits:
https://developers.arcgis.com/rest/services-reference/enterprise/apply-edits-feature-service/
https://developers.arcgis.com/rest/services-reference/enterprise/apply-edits-feature-service-layer/
It seems that when applyEdits on FeaturesServer does not run the query afterwards while the applyEdits on FeatureServer/Layer does.
Since I am out of ideas I am wondering whether:
- this is a bug in FeatureServer-applyEdits
- this is intended for some reason
- it is due to some different configuration (like a flag to decide to not to run the query afterwards).
Any ideas and info are welcome.
As workaround I tried to simply query the new feature during interceptor after part:
const creationSuccessfulInterceptor: __esri.RequestInterceptor = {
urls: layerUrls,
after: async (response) => {
// iterate over response.data + response.data[].addResults
// take the layerId from data and take the objectId from addResults
const objectIdByLayerIdMap = this.retrieveObjectIdsAndLayerId(response);
// get the layer object
const layer = this.retrieveLayerFromView(objectIdByLayerIdMap);
// query new features from that layer
layer.queryFeatures({objectIds: objectIds});
}
}
But only querying it did not bring it visible. Am I missing something?
What works better is to just refresh the full layer. But instead of a single smooth feature query, many geometry queries are performed returning all current visible features of that layer.
At least the new Feature is shown now!
// call refresh instead querying a single feature
layer.refresh();
I still hope for better ideas to clarify whether there is a bug in applyEdits or how to get it working correctly without the need of an interceptor.
We just found out, that this behaviour also appears within ExperienceBuilderApps. Using the editor widget does not show the Feature unless one forces a query by either reloading or heavy zooming.
Guess thats a BUG though.