Add hillshading

To improve the visual appeal of a map, this demonstration incorporates raster hillshading. This is achieved by integrating the MapTiler Terrain-DEM raster tileset, as a raster-dem source for the hillshade layer. By doing so, the map gains a realistic representation of terrain elevation and shading.

NPM module setup


npm install --save @maptiler/sdk
import { Map, MapStyle, config } from '@maptiler/sdk';
import '@maptiler/sdk/dist/maptiler-sdk.css';

config.apiKey = 'YOUR_MAPTILER_API_KEY_HERE';
const map = new Map({
  container: 'map',
  zoom: 0.3,
  center: [0, 20],
  style: MapStyle.BASE.LIGHT
});

map.on('load', function () {
  map.addSource("terrain", {
    "type": "raster-dem",
    "url": `https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json`
  });

  map.addLayer(
    {
      'id': 'hillshading',
      'source': 'terrain',
      'type': 'hillshade'
    },
    'Residential'
  );
});
Add dynamic hillshading

Add dynamic hillshading

Examples

Adjust hillshade lighting dynamically to simulate sun movement.

Display a 3D terrain map

3D terrain map

Tutorials

Create and display 3D terrain maps on web pages.

Show raster image on the map

Raster layer

Tutorials

Add a raster image overlay to the map.

Was this helpful?