Hi!
I have a GeoJSONlayer which I need to update occasionally with new features from a fetch-request, triggered by the user. Using version 4.19.
---------------
const response = await fetch(
'MyURL' +$.param(params_gj),
{
method: 'POST',
body: JSON.stringify(body),
headers: headers_gj,
})
const response_json = await response.json()
---------------
The fetch response is also a GeoJSON which I can make into a GEOJSONlayer with the following:
-------------
const blob = new Blob([JSON.stringify(response_json)], {type: 'application/json',})
const url = URL.createObjectURL(blob)
var MyNewGeoJSONlayer = new GeoJSONLayer({ url })
------------
However, I do not wish do make a new layer from the fetch response. I want to update my original GeoJSON layer with the features contained in the response. So I use applyEdits according to the following:
----------------
const promise = OriginalLayer.applyEdits({ addFeatures: response_json.features});
promise.then(console.log("Features added") )
----------------
However, this does not work and the javascript console gives no clues. To be honest, I am not sure whether to use response_json, response_json.features or some variation of my "blob". I tried a lot of variations but it seems that the geographic information is lost somehow.
I have a working workaround, which is to create the NewGeoJSONLayer (which I don't want), query all features from that layer (which seems unnecessary since I want all features in my response_json) and then do the applyEdits with featureSet.features.
So, how can I use my response_json with applyEdits on my original layer directly? Thanks in advance for any help!