Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mattdanielbrown/fe144b1942b91a69f2ce396acb1e955e to your computer and use it in GitHub Desktop.

Select an option

Save mattdanielbrown/fe144b1942b91a69f2ce396acb1e955e to your computer and use it in GitHub Desktop.
Display a globe on a webpage
<div id="map"></div>
mapboxgl.accessToken = 'pk.eyJ1IjoibWF0dGRhbmllbGJyb3duIiwiYSI6ImNqZHEyeDB1ZzF0d2gzM280bWx5bXdieHAifQ.Mv8GUhLb-OgANr1CRfBcVQ';
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/satellite-streets-v11',
zoom: 1.5,
center: [30, 50],
projection: 'globe'
});
map.on('load', () => {
// Set the default atmosphere style
map.setFog({});
});
<script src="https://api.mapbox.com/mapbox-gl-js/v2.9.2/mapbox-gl.js"></script>
body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: 100%; }
<link href="https://api.mapbox.com/mapbox-gl-js/v2.9.2/mapbox-gl.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment