Skip to content
Add a Multidirectional Hillshade Layer

Add a Multidirectional Hillshade Layer

Add a multidirectional hillshade layer that simulates light from multiple angles.

const API_KEY = 'toursprung';

    const map = new maptoolkit.Map({
        container: 'map',
        style: {
            version: 8,
            sources: {
                'dem': {
                    type: 'raster-dem',
                    tiles: [`https://vtc-cdn.maptoolkit.net/terrain/{z}/{x}/{y}.webp?api_key=${API_KEY}`],
                    tileSize: 256,
                    minzoom: 5,
                    maxzoom: 12,
                    encoding: 'terrarium'
                }
            },
            layers: [{
                id: 'hillshading',
                type: 'hillshade',
                source: 'dem',
                paint: {
                    'hillshade-method': 'multidirectional',
                    'hillshade-highlight-color': ['#FF4000', '#FFFF00', '#40ff00', '#00FF80'],
                    'hillshade-shadow-color': ['#00bfff', '#0000ff', '#bf00ff', '#FF0080'],
                    'hillshade-illumination-direction': [270, 315, 0, 45],
                    'hillshade-illumination-altitude': [30, 30, 30, 30]
                }
            }]
        },
        center: [11.39085, 47.27574],
        zoom: 10,
        attributionControl: { compact: false }
    });
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Add a Multidirectional Hillshade Layer – Maptoolkit Maps JS</title>
    <meta property="og:description" content="Add a multidirectional hillshade layer that simulates light from multiple angles." />
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://unpkg.com/@maptoolkit/maps@11.0.0-beta.2/dist/maptoolkit.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/@maptoolkit/maps@11.0.0-beta.2/dist/maptoolkit.css" />
    <style>
        html, body { width: 100%; height: 100%; margin: 0; padding: 0; }
        #map { width: 100%; height: 100%; }
    </style>
</head>
<body>
<div id="map"></div>
<script>
    const API_KEY = 'toursprung';

    const map = new maptoolkit.Map({
        container: 'map',
        style: {
            version: 8,
            sources: {
                'dem': {
                    type: 'raster-dem',
                    tiles: [`https://vtc-cdn.maptoolkit.net/terrain/{z}/{x}/{y}.webp?api_key=${API_KEY}`],
                    tileSize: 256,
                    minzoom: 5,
                    maxzoom: 12,
                    encoding: 'terrarium'
                }
            },
            layers: [{
                id: 'hillshading',
                type: 'hillshade',
                source: 'dem',
                paint: {
                    'hillshade-method': 'multidirectional',
                    'hillshade-highlight-color': ['#FF4000', '#FFFF00', '#40ff00', '#00FF80'],
                    'hillshade-shadow-color': ['#00bfff', '#0000ff', '#bf00ff', '#FF0080'],
                    'hillshade-illumination-direction': [270, 315, 0, 45],
                    'hillshade-illumination-altitude': [30, 30, 30, 30]
                }
            }]
        },
        center: [11.39085, 47.27574],
        zoom: 10,
        attributionControl: { compact: false }
    });
</script>
</body>
</html>