Change the Symbol of a selected graphics

502
1
10-23-2012 06:39 PM
HubertLo
New Contributor
I know it can be done in the Silverlight API and I have done that before. Is such capability possible in the JavaScript API?

Let us keep in simple and assume we are dealing with a symbol plotted over a point. Logically I suppose I can change the symbol object of the selected graphics object in the onClick event. But then I need to change it back when the user selects something else.

So the question is: If I stored the graphic object in a variable, how can I find it again in the map.graphics array?

If there is a better way to do it, please let me know. Users like to know what they have selected on the map, it will be the best if we can change the graphics on a selected item.
0 Kudos
1 Reply
StephenLead
Regular Contributor III
This sample shows how to change the symbol of a graphic when it's selected.

> So the question is: If I stored the graphic object in a variable, how can I find it again in the map.graphics array?

The sample shows how to select/unselect all features, which is an approach you could take too.

Another option is to add the graphic(s) to an array when you select them, then process that array to change the symbols when a new feature is selected.
0 Kudos