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 for this example.
NPM module setup
npm install --save @maptiler/sdk
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'
});
});
<!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>
body {margin: 0; padding: 0;}
#map {position: absolute; top: 0; bottom: 0; width: 100%;}
Related examples
Line outline glow blur symbol (polyline helper)
ExamplesAdd glowing outline to line layer using helper.