how can I save map and layers settings in a cookie

1367
2
08-01-2012 12:44 AM
JosephDaood
New Contributor
I am using Arcgis Javascript 3.0 with TOC to make a tree structure of layers and I want to save client user settings in a cookie, to make it easy for the user to follow up next day . Is there an easy way to do that?
That is my first question.

My second question is that I have problem with TOC tree layers structure. I have to reload my page in order to get the TOC to work and display the layers tree structure. Can anybody tell me why?

var toc = new agsjs.dijit.TOC({
        map: map,
        layerInfos: layerInfosTemp,
        closable: true
    }, 'layersGrouped');
    toc.startup();
0 Kudos
2 Replies
ReneRubalcava
Frequent Contributor
Well, for your first question, you can store some basic data in a cookie.
Dojo has a cookie module you can use.
http://dojotoolkit.org/reference-guide/1.7/dojo/cookie.html

You wouldn't want to store too much stuff, I think cookies have a 4kb limit, but that's plenty to store some config information.

As for your second question, not sure. Are you waiting for the "onLayersAdd" event?
0 Kudos
JosephDaood
New Contributor
Hi
I already use cookie from dojo to store map extent as bookmark. I thought that saving user map setting are used almost in any web application, and there is a standard way to do that in arcgis JS. Maybe I am wrong, so if I have to code the map Save Setting function by myself, can you tell me how to get a list of all active layers and sub layers from the map object.
As for my second question. I am not using or waiting for "onLayersAdd" event.  And there are others that have the same problem. Look at the last comment in forum

http://forums.arcgis.com/threads/60570-Using-AGSJS-TOC-with-ArcGIS-Javascript-3.0?highlight=agsjs
0 Kudos