How to display a map with custom projections

This example shows how to configure Equal Earth and Equirectangular projections using the SDK JS preview build.

Warning

The features demonstrated here rely on a preview build of the JS SDK.

You can choose between pure projections (applied at all zoom levels) and presets (which automatically transition to Mercator on deep zoom). Set the type property to "equal" or "geodetic" for the adaptive presets, or use "equal-earth" and "equirectangular" for the pure projections.

NPM module setup


npm install --save @maptiler/sdk@4.0.3-projection.alpha.1
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.STREETS,
  center: [0, 20],
  zoom: 1.5
});

map.on("style.load", () => {
  // 'equal', 'equal-earth', 'geodetic', 'equirectangular'
  map.setProjection({ type: 'equal' });
});
How to turn on the globe projection

Globe projection

Examples

Enable the 3D globe map projection in your application.

How to switch map projection programmatically

Switch between “mercator” and “globe”

Examples

Programmatically switch between Mercator and globe map projections.

Projection control how to toggle the map between mercator and globe projection

Projection control (globe)

Tutorials

Toggle between Mercator and globe projections using map controls.

Was this helpful?