Skip to content

Display a globe with a vector map

Replicates the MapLibre example Display a globe with a vector map.

Drag to spin the globe
display-a-globe-with-a-vector-map.yaml
# yaml-language-server: $schema=https://docs.maplibre-yaml.org/schema/latest/map.schema.json
# Gallery twin of https://maplibre.org/maplibre-gl-js/docs/examples/display-a-globe-with-a-vector-map/
# Upstream calls setProjection in a style.load handler; here it is one key.
type: map
id: display-a-globe-with-a-vector-map
config:
center: [0, 0]
zoom: 2
mapStyle: "https://demotiles.maplibre.org/style.json"
projection:
type: globe
  • Upstream calls map.setProjection in a style.load handler; here projection: { type: globe } is a document-root key in the style spec’s own shape, and it exports to the style.json root projection.
  • Globe needs maplibre-gl 5.0.0 or later. On 4.x the document warns once and renders in mercator, so it never fails silently.