HOW TO ADD A GRAPHIC IN MAP  AS A LAYER IN AGSJS TOC?

1020
7
05-03-2013 12:40 PM
Gerardo_AngelMac_Gaul
New Contributor
Hi! I draw graphics in the map using de Draw Toolbar. How can i add these as layers in the agsjs toc?

The part of the code tah add the grapchic is:

"....
var graphic = new esri.Graphic(geometry, symbol);
map.graphics.add(graphic);
...."



thanks!!
0 Kudos
7 Replies
StephenLead
Regular Contributor III
var graphic = new esri.Graphic(geometry, symbol);
map.graphics.add(graphic);


At the very least, I suspect you'll need to add that graphic to a graphicsLayer rather than the map itself. That way you'll have access to the whole layer of graphics, which you may be able to hook up to the agsjs TOC. I haven't used that myself so I'm not sure how, but hopefully this will give you some pointers.
0 Kudos
Gerardo_AngelMac_Gaul
New Contributor
At the very least, I suspect you'll need to add that graphic to a graphicsLayer rather than the map itself. That way you'll have access to the whole layer of graphics, which you may be able to hook up to the agsjs TOC. I haven't used that myself so I'm not sure how, but hopefully this will give you some pointers.


thanks, I'll try with this method... then I'll tell you..
0 Kudos
Gerardo_AngelMac_Gaul
New Contributor
thanks, I'll try with this method... then I'll tell you..


I have added the graphic to a map grapchicLayer, but i'm still not found the way to add this layer as a new layer item visible in TOC
0 Kudos
VinayBansal
Occasional Contributor II
Have you tried by creating the blank graphicslayer and then calling the map.addlayers function to add your map service layer and graphics layers. And then initializing the TOC on onLayersAddResult event and passing the graphics layer in layer infos.

Vinay Bansal
0 Kudos
Gerardo_AngelMac_Gaul
New Contributor
Have you tried by creating the blank graphicslayer and then calling the map.addlayers function to add your map service layer and graphics layers. And then initializing the TOC on onLayersAddResult event and passing the graphics layer in layer infos.

Vinay Bansal


Thanks! I'm studying this method....
0 Kudos
Gerardo_AngelMac_Gaul
New Contributor
Thanks! I'm studying this method....

Hi! I created the TOC, and I've added the graphiclayer array, but only i see in TOC the parent name. The array show me the length of childrens, but I don't see the childrens in the toc, under the parent. What have I missed? Some sample code to do this? Thanks!!
0 Kudos
NianweiLiu
Occasional Contributor II
GraphicsLayer is not supported. Do not have time to added it any time soon. If someone wants to give a shot you are welcomed to do so. Basically you need to use esri.symbol.getShapeDescriptors() to get graphics context and use dojo's graphics library to draw the symbol in a node of TOC.
0 Kudos