JS API 4.5 new Graphic geometry set to null

470
4
Jump to solution
11-09-2017 04:38 PM
KyleDunaway1
New Contributor II

var tmpGraphic = new Graphic({
  attributes: {
    "objectid": someObjectID
    "someAttribute" : someAtrribute
  }
});

featureLayer.applyEdits({
  updateFeatures: [tmpGraphic]
}).then....

The applyEdits request shows the geometry for the graphic as null, thus overwriting the geometry on the feature layer.

I assume this is new as it hasn't been happening before...

Any ideas?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ThomasSolow
Regular Contributor

Instead of passing in a Graphic to apply Edits, try just passing in an object like:

let graphicObj = {
  attributes: {
    objectId: 1,
    attr1: 5,
    attr2: "hi"
  }
}

featureLayer.applyEdits({
  updateFeatures: [graphicObj]
}).then(...)

You could also try getting the object by doing let json = graphic.toJSON() and then delete json.geometry.

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Kyle,

   ??? Why would not not get the actual graphic and just update the properties and then applyEdits that way the geometry is not null?

0 Kudos
KyleDunaway1
New Contributor II

Because I have 1000+ features in a table and am using a select to change an attribute.  No geometry, so getting the actually geometry would require returning it in the query and that would be wasteful performance wise.

0 Kudos
ThomasSolow
Regular Contributor

Instead of passing in a Graphic to apply Edits, try just passing in an object like:

let graphicObj = {
  attributes: {
    objectId: 1,
    attr1: 5,
    attr2: "hi"
  }
}

featureLayer.applyEdits({
  updateFeatures: [graphicObj]
}).then(...)

You could also try getting the object by doing let json = graphic.toJSON() and then delete json.geometry.

KyleDunaway1
New Contributor II

Thanks, passing just an object worked.  I assumed it had to be a Graphic object.

0 Kudos