How do i select a graphic and change the symbol color for that graphic?

5553
3
04-23-2013 12:21 PM
SethCrotchett
New Contributor
I am wanting to select a graphic and when selected change the color of the symbol, how do i do this.

Here is my code i use to add the graphic.

                var graphic = new esri.Graphic(geometry, symbol);
                this.map.graphics.add(graphic);
0 Kudos
3 Replies
JohnGravois
Frequent Contributor
select how?  onClick? onMouseOver?

have you seen this sample?  it demonstrates how to define a new symbol and pass an existing graphic to display in the map (on top of the existing graphics layer created from QueryTask results)

var highlightSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 3), new dojo.Color([125,125,125,0.35]));
...
dojo.connect(countiesGraphicsLayer, "onMouseOver", function(evt) {
            map.graphics.clear();  //use the maps graphics layer as the highlight layer
            //pass the event graphic geometry and second symbol
            var highlightGraphic = new esri.Graphic(evt.graphic.geometry,highlightSymbol);
            map.graphics.add(highlightGraphic);
          });
0 Kudos
SethCrotchett
New Contributor
I am actually wanting to select it from a list.  On the right side of my screen i have a list of the items and will select one and i want it to highlight the associated graphic.  Ideas?
0 Kudos
JohnGravois
Frequent Contributor
well... selecting a graphic and selecting something associated with a graphic aren't exactly the same thing. 🙂

do you have a simplified code sample pointing at public services you can share?
0 Kudos