pramodharithsa

Graphic layer visibility

Discussion created by pramodharithsa on Aug 14, 2012
Latest reply on Aug 16, 2012 by geos_rfleet
I have few static graphic layers which are created on load by running few queries.
var countiesGraphicsLayer = new esri.layers.GraphicsLayer();
                //QueryTask returns a featureSet.
                for (var i = 0, il = featureSet.features.length; i < il; i++) {
                     //Feature is a graphic 
                    var graphic = featureSet.features[i];
                    graphic.setSymbol(symbol);
                    graphic.setInfoTemplate(infoTemplate);
                    var ext = graphic.geometry.getExtent();
                    map.setExtent(ext);
                    var length = graphic.geometry.paths[0].length;
                    var pointxy = graphic.geometry.paths[0][(length / 2) - 1];
                    var point = new esri.geometry.Point(pointxy[0], pointxy[1], new esri.SpatialReference({ wkid: 102100 }));
                    //var simpleMarkerSymbol = new esri.symbol.PictureMarkerSymbol('image/E1BA914F.png', 32, 32);
                    var simpleMarkerSymbol = new esri.symbol.PictureMarkerSymbol({
                        "type": "esriPMS",
                        "url": "image/E1BA914F.png",
                        "contentType": "image/png",
                        "color": null,
                        "width": 32,
                        "height": 32,
                        "angle": 0,
                        "xoffset": 16,
                        "yoffset": 8
                    });

                    var balloon = new esri.Graphic(point, simpleMarkerSymbol);
                    
                    countiesGraphicsLayer.add(balloon);
                }
                map.addLayer(countiesGraphicsLayer);

similarly i have 2 more graphic layer.
I want to toggle their visibility using a check box. How can i proceed?

Outcomes