Hello,
In a widget I create a new Feature Layer from Feature Collection. From web service I want to add features to this Feature Layer. When I fire applyEdits() function to add the features everything goes well without any error message. But the Feature Layer is still empty. I tried to add edits-complete event and it also fired after complete adding features, so everything seems to be good but the Feature Layer is still empty.
My code is almost the same as this sample code Feature collection | ArcGIS API for JavaScript 3.20
But I don't know where could be the problem because the whole code works.
Have anyone an idea?
Thanks for any help.
Solved! Go to Solution.
I was also suprised. I don't know why has the feature layer wkid of 4326 but it has. And probably you were right I tried to change the code in layerDefinition to "spatialReference":{
"wkid":102067
}, and nothing changed.
So do you have any idea how to set the right wkid to the feature layer?
How are you checking the wkid of the layer to know it is 4326?
I printed featureLayer.spatialaReference to thé console
Was this after graphics were added to it or before?
It was after graphics were added
Is it null before you add graphics? Normally when you add the first graphic it's SR is what sets the layers SR. So that means your graphics are getting added as 4326. What do you X,Y values look like?
Robert,
If I create the feature layer without adding any points => graphics parametr of the layer is empty the feature layer has SR wkid 4326 already in this step.
Robert,
I dug a little bit deeper. I created a web map only with this: ortofoto (MapServer) basemap (spatialReference 102067) (hope it's accessible from abroad in our country is open to everyone). In my widget i printed this.map to the console. SR of the whole map is correct 102067. There is an object graphics. It's empty but SR of this object is 4326. Is it alright? There is also an object graphicsLayerIds which contains the layer graphicsLayer1. In _layers.graphicsLayer1.spatialReference property of the map object is also SR 4326. And now I have two questions.
First: Are these values only default for default(empty) graphics and graphicsLayer1 objects and will change if anything is added to the map?
Second: Could these values cause the problem that created Feature Layer have the same SR?
I don't actually know the answer to those questions. What I think is that you are correct that an empty GL has a SR of 4326 and then when graphics are added of another SR the GL will take the graphics SR as its own.
Can you provide a couple of the raw results from your web service (response.response.resultitems) for me to test with?
Robert,
here is the response.