Switch between contour lines heights in meters and feet.

Change the units for the altitude of the contour lines, converting from meters to feet. For additional technical information, refer to the Contours schema provided by MapTiler.

The Global Contours schema, created by MapTiler, contains contour lines for locations all around the globe in two widely used unit systems: meters and feet. With its global coverage, MapTiler’s contour lines can be utilized for various purposes, such as outdoor recreation planning, landscape analysis, and cartographic visualization.

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',
  style: MapStyle.OUTDOOR, 
  zoom: 13.42,
  center: [-148.63567, 62.03381],
});

// switching contours units
const changeLayerSource = function(layer_id, source) {
  // get layer definition, remove layer, add layer
  const oldLayers = map.getStyle().layers;
  const layerIndex =  oldLayers.findIndex(l => l.id === layer_id);
  const contourDef = oldLayers[layerIndex];
  const before = oldLayers[layerIndex + 1] && oldLayers[layerIndex +1].id;
  contourDef['source-layer'] = source;
  map.removeLayer(layer_id);
  map.addLayer(contourDef, before);
};

// switch units handler
const units = document.getElementById('units');
units.addEventListener('change', function() {
  changeLayerSource('Contour', this.value);
  changeLayerSource('Contour index', this.value);
  changeLayerSource('Contour labels', this.value);
  changeLayerSource('Glacier contour', this.value);
  changeLayerSource('Glacier contour index', this.value);
  changeLayerSource('Glacier contour labels', this.value);
});
Display a 3D terrain map

3D terrain map

Tutorials

Create and display 3D terrain maps on web pages.

Getting started with AR maps: Display an AR control on your maps

Start with AR maps

Examples

Add an AR control button to map 3D viewports.

Add Contour Lines.

Add Contour Lines

Examples

Add map contour lines generated from a raster-dem source.

Was this helpful?