Display a globe with a vector map
Display a globe with a vector map.
import * as maplibregl from 'https://unpkg.com/maplibre-gl@6.2.0/dist/maplibre-gl.mjs';
const map = new maplibregl.Map({
container: 'map',
style: 'https://demotiles.maplibre.org/style.json',
zoom: 2,
center: [0, 0],
});
map.on('style.load', () => {
map.setProjection({
type: 'globe', // Set projection to globe
});
});
<!DOCTYPE html>
<html lang="en">
<head>
<title>Display a globe with a vector map</title>
<meta property="og:description" content="Display a globe with a vector map." />
<meta property="og:category" content="Globe" />
<meta property="og:order" content="1" />
<meta property="og:created" content="2025-06-25" />
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel='stylesheet' href='https://unpkg.com/maplibre-gl@6.2.0/dist/maplibre-gl.css' />
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script type="module">
import * as maplibregl from 'https://unpkg.com/maplibre-gl@6.2.0/dist/maplibre-gl.mjs';
const map = new maplibregl.Map({
container: 'map',
style: 'https://demotiles.maplibre.org/style.json',
zoom: 2,
center: [0, 0],
});
map.on('style.load', () => {
map.setProjection({
type: 'globe', // Set projection to globe
});
});
</script>
</body>
</html>