MapSnippets logo MapSnippets logo

Globe Projection

Display the map as a 3D globe with atmosphere effects. Each library takes its own approach, compared side by side below.

Quick recommendations

MapLibre GL JS: A strong fit when you need full control over globe projection settings, atmosphere blend, and the transition zoom level to Mercator.

MapTiler SDK: Works best for the simplest globe setup, since the SDK wraps the same MapLibre projection API with built-in MapTiler style support.

At a glance

MapLibre SDK
Coordinates [lng, lat] [lng, lat]
Rendering WebGL (GPU, 60fps) WebGL (GPU, 60fps)
Bundle size ~300 KB gzipped ~360 KB gzipped (includes MapLibre)
Learning curve Moderate (source/layer model, expressions) Easy (MapLibre API with convenience helpers)
3D support Full: terrain, fill-extrusion, globe, sky Full (same as MapLibre)
Code lines 10 8

Code snippets

Click a library to expand its code. Each snippet shows only the core logic: the scaffold handles HTML boilerplate.

MapLibre GL JS 10 lines Show code
Full example
const map = new maplibregl.Map({
  container: 'map',
  style: 'https://api.maptiler.com/maps/satellite/style.json?key=YOUR_MAPTILER_KEY',
  center: [0, 20],
  zoom: 1.2
});
map.addControl(new maplibregl.NavigationControl());
map.on('style.load', () => {
  map.setProjection({ type: 'globe' });
});
MapTiler SDK 8 lines Show code
Full example
maptilersdk.config.apiKey = 'YOUR_MAPTILER_KEY';
const map = new maptilersdk.Map({
  container: 'map',
  style: maptilersdk.MapStyle.SATELLITE,
  center: [0, 20],
  zoom: 1.2,
  projection: 'globe'
});

Things to know

Implementation-specific details that matter for globe projection.

MapLibre GL JS

Globe projection must be set via map.setProjection() after the style.load event when using external style URLs, not in the constructor.

MapTiler SDK

Same setProjection() timing requirement as MapLibre, so call it after load when using URL-based styles.

Which library to use?

Build maps with AI

Generate code like these examples using mapping library skills in your IDE.