Select to view content in your preferred language

Feature Layer from Feature Collection applyEdits don't work

3333
20
Jump to solution
04-20-2017 03:45 AM
ZdeněkSoldán
Occasional Contributor

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.

0 Kudos
20 Replies
ZdeněkSoldán
Occasional Contributor

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?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

How are you checking the wkid of the layer to know it is 4326?

0 Kudos
ZdeněkSoldán
Occasional Contributor

I printed featureLayer.spatialaReference to thé console

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Was this after graphics were added to it or before?

0 Kudos
ZdeněkSoldán
Occasional Contributor

It was after graphics were added

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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?

0 Kudos
ZdeněkSoldán
Occasional Contributor

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. 

0 Kudos
ZdeněkSoldán
Occasional Contributor

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?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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?

0 Kudos
ZdeněkSoldán
Occasional Contributor

Robert,

here is the response.

  1. [0 … 99]
    1. 0:Object
      1. age:"1131 days"
      2. fullname:"- (dříve Spěváček-převedeno do EAS) (1AX1686)"
      3. id:"cc_17074"
      4. locality:"Teplice, Zelená"
      5. name:"- (dříve Spěváček-převedeno do EAS)"
      6. position:Object
        1. proj:"JTSK"
        2. x:"976284.23"
        3. y:"776323.99"
        4. __proto__:Object
      7. topgroup:"CarControl"
      8. __proto__:Object
    2. 1:Object
      1. age:"59 min."
      2. fullname:"Bakaj Petr (3AX8551)"
      3. id:"cc_27788"
      4. locality:"Troubsko, U Lednice"
      5. name:"Bakaj Petr"
      6. position:Object
        1. proj:"JTSK"
        2. x:"1162677.97"
        3. y:"605975.26"
        4. __proto__:Object
      7. topgroup:"CarControl"
      8. __proto__:Object
    3. 2:Object

 

0 Kudos