Style a GeoJSON Line layer (polyline helper)

This example demonstrates the process of incorporating and customizing a GeoJSON line layer on the map by utilizing the polyline layer helper. In this specific case, we will generate a line that is purple and has a border in gray. You can access the sample data by downloading the Blue Hills sample data.

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: 13,
    center: [-110.75926, 43.72683],
    style: MapStyle.DATAVIZ.DARK
});

map.on('load', async function () {
  await helpers.addPolyline(map, {
    data: 'https://docs.maptiler.com/sdk-js/examples/helper-polyline-simple/blue_hills.geojson',
    outline: true,
    lineColor: "purple",
    lineWidth: 6,
    outlineColor: "#D3DBEC", // mid gray
    outlineWidth: 10,
  });
});
Line layer (polyline helper)

Line layer (polyline helper)

Examples

Add minimal line layer using MapTiler polyline helper.

Line dash pattern symbol (polyline helper)

Line dash pattern symbol (polyline helper)

Examples

Add dash pattern to line layer using helper.

Line outline glow blur symbol (polyline helper)

Line outline glow blur symbol (polyline helper)

Examples

Add glowing outline to line layer using helper.

Show line data from GeoJSON on the map

GeoJSON line layer

Tutorials

Add a GeoJSON line overlay to the map application.

Was this helpful?