---
title: "Add a KML Line layer (polyline helper) | JavaScript maps SDK"
description: "Add KML line layer using MapTiler polyline helper."
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Add a KML Line layer (polyline helper)

This example shows the process of incorporating a KML line layer into the map by utilizing the polyline layer helper. You can download the [KML track sample data](./track.kml) for this example.

### NPM module setup

```bash
npm install --save @maptiler/sdk
```

#### main.js

```js
import { Map, MapStyle, config, helpers } from '@maptiler/sdk';
import '@maptiler/sdk/dist/maptiler-sdk.css';

config.apiKey = 'YOUR_MAPTILER_API_KEY_HERE';
const map = new Map({
    container: 'map',
    zoom: 18,
    center: [2.3101528, 48.7299456],
    style: MapStyle.BASE
});

map.on('load', async function () {
  await helpers.addPolyline(map, {
    data: 'https://docs.maptiler.com/sdk-js/examples/helper-polyline-kml/track.kml',
    outline: true,
    lineColor: '#3A1888'
  });
});
```

#### index.html

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="robots" content="noindex">
  <title>Add a KML Line layer (polyline helper) | NPM example</title>
  <link rel="stylesheet" href="./style.css">
</head>
<body>
  <div id="map"></div>
  <script type="module" src="./main.js"></script>
</body>
</html>
```

#### style.css

```css
body {margin: 0; padding: 0;}
#map {position: absolute; top: 0; bottom: 0; width: 100%;}
```

### Basic JavaScript setup

```html
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Polyline helper</title>
  <script src="https://cdn.maptiler.com/maptiler-sdk-js/v4.2.0/maptiler-sdk.umd.min.js"></script>
  <link href="https://cdn.maptiler.com/maptiler-sdk-js/v4.2.0/maptiler-sdk.css" rel="stylesheet" />
  <style>
    body {
      margin: 0;
      padding: 0;
    }

    #map {
      position: absolute;
      top: 0;
      bottom: 0;
      width: 100%;
    }
  </style>
</head>

<body>
  <div id="map"></div>

  <script>
    maptilersdk.config.apiKey = 'YOUR_MAPTILER_API_KEY_HERE';
    const map = new maptilersdk.Map({
      container: 'map',
      zoom: 18,
      center: [2.3101528, 48.7299456],
      style: maptilersdk.MapStyle.BASE
    });

    map.on('load', async function () {
      await maptilersdk.helpers.addPolyline(map, {
        data: 'https://docs.maptiler.com/sdk-js/examples/helper-polyline-kml/track.kml',
        outline: true,
        lineColor: '#3A1888'
      });
    });

  </script>
</body>

</html>
```

## Related examples

### [Line layer (polyline helper)](https://docs.maptiler.com/sdk-js/examples/helper-polyline-minimal/)

Examples

Add minimal line layer using MapTiler polyline helper.

### [Add a GPX Line layer (polyline helper)](https://docs.maptiler.com/sdk-js/examples/helper-polyline-gpx/)

Examples

Add GPX line layer using MapTiler polyline helper.

### [Line outline glow blur symbol (polyline helper)](https://docs.maptiler.com/sdk-js/examples/helper-polyline-blur/)

Examples

Add glowing outline to line layer using helper.

### [GeoJSON line layer](https://docs.maptiler.com/sdk-js/examples/geojson-line/)

Tutorials

Add a GeoJSON line overlay to the map application.
