AnsweredAssumed Answered

JSON to Graphic to Map

Question asked by ndorman on Apr 17, 2014
Latest reply on Apr 18, 2014 by ndorman
Hey guys,
I was wondering if the documentation on website API is up to date or if I'm just missing something. I'm trying to add a graphic to my map by creating a graphic using JSON by the format and parameters stated in the API.

validation checked w/ jsonlint.com
var json = {"geometry":{"points":[[608647.8,2368271.8],[608252.7,2368339.2],[600298.56,2384759.5],[598867.1,2384862],[597231.44,2384743.2],[599478.1,2384728.8],[598811.1,2384355.5],[599798.75,2384646.2],[600041.44,2384662.5],[598171.25,2389613.5],[598431.3,2389301],[595302.94,2388870],[600176.1,2375361.8],[599342.7,2382036.5],[594301.56,2382029.8],[603859.9,2381974],[594440.3,2382028.8],[602758.9,2381808.2],[594808.5,2381696.8],[599076.9,2377178.8]],"spatialReference":{"wkid":26904,"latestWkid":26904}},"symbol":{"color":[120,255,120,64],"size":20,"angle":0,"xoffset":0,"yoffset":0,"type":"esriSMS","style":"esriSMSX","outline":{"color":[0,0,0,255],"width":5,"type":"esriSLS","style":"esriSLSSolid"}}}


var graphic = new Graphic(json);
// This doesn't work
map.getLayers("graphicsLayer").add(graphic);

/* this also doesn't work
map.graphics.add(graphic);
*/
// I also call graphic.toJson() and console.log(map) to check their validity

When I inspect the HTML, I do see that the graphics layer element under "#content_layers > svg >" g does exist and just contains:
<g id="series_layer" transform="matrix(1.00000000,0.00000000,0.00000000,1.00000000,25.00000000,85.00000000)" style="display: block;"><g></g></g>

I thought it might be an ordering issue, but I made my only dynamic map layer transparent, which had no effect.

I also checked to make sure that map was not undefined, and I'm sure that all my references do exist.

I'm on JS API v3.8 and did try 3.9.

Any suggestions? I feel like I'm close, but can't figure it out.

Thanks,

Outcomes