Polygon fill pattern (polygon helper)

This example shows how to add a polygon layer with a fill pattern to the map using the polygon layer helper. To replicate this example, download the Swiss sample data and the cheese image.

By following this example, users can successfully integrate the desired polygon layer, complete with a unique fill pattern, into their maps using the polygon layer helper tool.

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: 6.62,
    center: [8.224, 46.823],
    style: MapStyle.DATAVIZ.DARK
});

map.on('load', async function () {
  await helpers.addPolygon(map, {
    data: 'YOUR_MAPTILER_DATASET_ID_HERE',
    pattern: "cheese512.png",
    outline: true,
    outlineWidth: 3,
    outlineColor: "white",
    outlineDashArray: "_ ",
    fillOpacity: 0.7,
  });
});
Polygon layer (polygon helper)

Polygon layer (polygon helper)

Examples

Add minimal polygon layer using MapTiler polygon helper.

Polygon color ramp symbol (polygon helper)

Polygon color ramp symbol (polygon helper)

Examples

Style polygon fill color based on zoom level.

Show polygon data from GeoJSON on the map

GeoJSON polygon layer

Tutorials

Add GeoJSON polygon overlay to your web map application.

Show polygon information on click

Show polygon information on click

Examples

Display a popup when a user clicks a polygon.

Was this helpful?