hi i am trying to add graphic to graphicslayer. here is the problem.
i get json result from sketchviewmodel create function which is graphic.
i store this in to new jsonobject. then i try to add this graphic into graphicslayer manually. but its giving error.
here is the json
{
"geometry":{
"spatialReference":{
"latestWkid":3857,
"wkid":102100
},
"x":243208.09643883476,
"y":2940285.766420703,
"z":351.9580905416081
},
"symbol":{
"type":"point-3d",
"symbolLayers":[
{
"type":"Icon",
"material":{
},
"resource":{
"primitive":"kite"
},
"size":15,
"outline":{
"color":[
0,
0,
0
],
"size":2.25
}
}
]
},
"attributes":{
},
"popupTemplate":null
}
this code gives error
const [Graphic] = await loadModules(["esri/Graphic"]);
let g = new Graphic(data); // data which is json i gave.
any adivce ? Thank you.
Assuming you are using
toJSONmethod ofGraphicto generate the json object (in your exampledata). Then the correct way of creating aGraphicfrom the json object is to use the "reverse" methodfromJSON. Something like this should work,ArcGIS API - Graphic fromJSON