---
title: "addColorStopAtIndex(index, color)"
framework: mapkitjs
role: symbol
role_heading: Instance Method
path: mapkitjs/linegradient/addcolorstopatindex
---

# addColorStopAtIndex(index, color)

Adds a color transition at the index point in the list of points within a polyline.

## Declaration

```data
addColorStopAtIndex(index: number, color: string): void;
```

## Parameters

- `index`: A valid index into a polyline’s doc://com.apple.mapkitjs/documentation/MapKitJS/PolylineOverlay/points.
- `color`: The CSS color at the index point.

## Discussion

Discussion If the index is invalid, MapKit JS logs a warning to the console, but doesn’t change the object.

## See Also

### Creating a Line Gradient

- [new LineGradient(colorStops)](mapkitjs/linegradient/linegradientconstructor.md)
- [addColorStop(offset, color)](mapkitjs/linegradient/addcolorstop.md)
