JSON to Graphics Layer?

2502
2
12-13-2012 12:12 PM
AndrewDavis
New Contributor
Hi,
I have a need to take a 'aaData' returned JSON object and convert it to a graphics layer.

Does anyone know of an example out there?

my JSON object returned as aaData is below..

[["CityName","State","lat","lon"],["Washington","DC","38.901","-77.043"],["Richmond","VA","37.541","-77.439"],["VirginiaBeach","VA","36.859","-75.983"],["Salisbury","MD","38.36","-75.598"],["Greensboro","NC","36.079","-79.803"],["Raleigh","NC","35.777","-78.639"]]

Andy..
0 Kudos
2 Replies
ZahidChaudhry
Occasional Contributor III
Hi,
I have a need to take a 'aaData' returned JSON object and convert it to a graphics layer.

Does anyone know of an example out there?

my JSON object returned as aaData is below..

[["CityName","State","lat","lon"],["Washington","DC","38.901","-77.043"],["Richmond","VA","37.541","-77.439"],["VirginiaBeach","VA","36.859","-75.983"],["Salisbury","MD","38.36","-75.598"],["Greensboro","NC","36.079","-79.803"],["Raleigh","NC","35.777","-78.639"]]

Andy..


It is simple, just format your json to The way ESRI format a feature..eg
[HTML]{
    "geometry" : {"x" : -118.15, "y" : 33.80}, 
    "attributes" : {
      "OWNER" : "Joe Smith",
      "VALUE" : 94820.37,
      "APPROVED" : true,
      "LASTUPDATE" : 1227663551096
    }
[/HTML]

and then create a featureLayer. Here is a very good example that you can look at it to start...

http://gis.stackexchange.com/questions/8791/featurelayer-creating-in-javascript-arcgis-api

Thanks
0 Kudos
AndrewDavis
New Contributor
It is simple, just format your json to The way ESRI format a feature..eg
[HTML]{
    "geometry" : {"x" : -118.15, "y" : 33.80}, 
    "attributes" : {
      "OWNER" : "Joe Smith",
      "VALUE" : 94820.37,
      "APPROVED" : true,
      "LASTUPDATE" : 1227663551096
    }
[/HTML]

and then create a featureLayer. Here is a very good example that you can look at it to start...

http://gis.stackexchange.com/questions/8791/featurelayer-creating-in-javascript-arcgis-api

Thanks


Thank you Zahid Chaudhry  I think that this will do it.. 

Andy..
0 Kudos