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.
You have couple of issues in your json object. Please see the code below with comments.
var graphic = {
"geometry":{
"type": "point", // You must set your geometry type.
"spatialReference":{
"latestWkid":3857,
"wkid":102100
},
"x":243208.09643883476,
"y":2940285.766420703,
"z":351.9580905416081
},
"symbol":{
"type":"point-3d",
"symbolLayers":[{
"type":"icon", // Types are case sensitvie. This should be lower case icon
"material":{ },
"resource":{
"primitive":"kite"
},
"size":75,
"outline":{
"color":[255,0,0],
"size":2.25
}
}]
},
"attributes":{},
"popupTemplate":null
}