Line dash pattern symbol (polyline helper)
In this example, we will explore the process of incorporating a line layer with a dash pattern symbol into the map by utilizing the polyline layer helper. You can access the sample data by downloading the Amphitheater Lake trail sample data.
By following this approach, we can successfully incorporate a visually appealing dash pattern symbol into our line layer, enhancing its overall appearance and functionality on the map.
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: 14,
center: [-110.75926, 43.72683],
style: MapStyle.OUTDOOR
});
map.on('load', async function () {
await helpers.addPolyline(map, {
data: 'YOUR_MAPTILER_DATASET_ID_HERE',
outline: true,
lineDashArray: "___ _ ",
lineColor: "#F1175D"
});
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex">
<title>Line dash pattern symbol (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.