<!--
{
  "availability" : [
    "MapKit JS: 5.45.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MapKitJS",
  "identifier" : "/documentation/MapKitJS/LineGradient/addColorStopAtIndex",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "MapKit JS"
    ],
    "preciseIdentifier" : "instm/mapkit.LineGradient/addColorStopAtIndex"
  },
  "title" : "addColorStopAtIndex(index, color)"
}
-->

# addColorStopAtIndex(index, color)

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

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

## Parameters

`index`

A valid index into a polyline’s [`points`](/documentation/MapKitJS/PolylineOverlay/points).

`color`

The CSS color at the index point.

## Discussion

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

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)