Create a 3D choropleth map of Europe with countries extruded

This map of Europe presents a 3D choropleth map representation, where countries are visually extruded based on data provided by an external dataset. The fill-extrusion-height paint property is employed to assign data-driven values to the polygons of different countries within the fill-extrusion layer.

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: 3,
    center: [19.43, 49.49],
    pitch: 60,
    style: MapStyle.BASE,
    hash: false
});

  map.on('load', function () {
    map.addSource('countries', {
      'type': 'geojson',
      'data': 'https://docs.maptiler.com/sdk-js/assets/Mean_age_of_women_at_first_marriage_in_2019.geojson',
    });

    map.addLayer(
      {
        'id': 'eu-countries',
        'source': 'countries',
        'type': 'fill-extrusion',
        'paint': {
          'fill-extrusion-color': [
            'interpolate',
            ['linear'],
            ['get', 'age'],
            23.0,
            '#fff5eb',
            24.0,
            '#fee6ce',
            25.0,
            '#fdd0a2',
            26.0,
            '#fdae6b',
            27.0,
            '#fd8d3c',
            28.0,
            '#f16913',
            29.0,
            '#d94801',
            30.0,
            '#8c2d04'
          ],
          'fill-extrusion-opacity': 1,
          'fill-extrusion-height': ['*', ['get', 'age'], 5000]
        }
      }, 'Airport labels'
    );

    //Hide country borders for better visualization
    map.setLayoutProperty('Other border', 'visibility', 'none');
    map.setLayoutProperty('Disputed border', 'visibility', 'none');
    map.setLayoutProperty('Country border', 'visibility', 'none');

  });
Polygon layer (polygon helper)

Polygon layer (polygon helper)

Examples

Add minimal polygon layer using MapTiler polygon helper.

How to create a choropleth Map from GeoJSON

Choropleth GeoJSON

Tutorials

Create a styled choropleth map using a GeoJSON overlay.

How to display an interactive choropleth map legend control

Choropleth legend

Tutorials

Implement an interactive legend control for a choropleth map.

Show multiGeometry data from GeoJSON on the map

GeoJSON multiGeometry layer

Tutorials

Add a GeoJSON MultiGeometry overlay to your map application.

Was this helpful?