Easiest method to save a graphic layer info.

601
2
02-23-2012 10:47 AM
MarcusC
New Contributor
Hi,

What's the easiest way to store a graphic layer's info? Does the API offer anything?

I'm planning to store the info into a database record and recall it when I need to re-create this layer dynamically.

Thanks.
0 Kudos
2 Replies
derekswingley1
Frequent Contributor
We don't have a method to serialize a graphics layer to JSON. Instead, you have to call toJson() on each graphic.

Feature layers, OTOH, have a toJson() method which generates a feature collection. Once you have a JSON object that represents a feature collection, you can stringify it with dojo.toJson(). You can then store the string in your DB and retrieve it to re-create your feature layer later.
0 Kudos
MarcusC
New Contributor
Thanks! This will do it.
0 Kudos