I am trying to see if there is a better way to highlight a graphic in the map when you click on it. I currently have a layer of railroad tracks in the US and the project is to come up with a way to calculate the distance in the highlighted path. Right now, I have it set up so that you can click on a segment of track, click a button to save it, and it will store the information about the segment while keeping it highlighted. In that same list, I want to be able to click on a row in the list and have it change that track segment to a different color. As far as I am aware, the graphics are being stored on the main GraphicsLayer when using map.graphics.add(). The problem is that when it changes the color on the one graphic, any future graphics made get set to that same color. I'm able to reset the color on the graphic (without it visibly changing on the map) as a workaround, but there has to be a better way to do this.

var g = map.graphics.graphics[idx];
var originalColor = g.symbol.color;
g.symbol.setColor(new dojo.Color([0, 0, 0, 1]));
  • Shoot, when was the last 3.x question asked. Mar 8, 2019 at 18:13
  • 3
    They're referring to the ArcGIS JavaScript 3.x API, not ArcView.
    – KHibma
    Mar 8, 2019 at 18:20

1 Answer 1


If you want to have different type of graphics, the best way is to have different GraphicsLayer objects on the map. Each map contains a GraphicsLayer by default, accessible using the Map.graphics property, but you can create your own graphics layers and add them to the map.

You have the default one and a special one: with a special color, etc. Then you just need to add the required feature to the new graphics layer, depending on your requirements. For example:

var specialGraphicsLayer = new GraphicsLayer();
specialGraphicsLayer.add(new Graphic(geometry, symbol));

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .