birds-mpbx-gljs

Creating your first Mapbox map

This tutorial will guide you to creating your first map powered by Mapbox GL JS using the Mapbox interactive tutorial.

Creating a mapbox account

Creating a blank html page

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>My test page</title>
  </head>
  <body>
    <h1>test</h1>
  </body>
</html>

Creating your first Mapbox map

<script src='https://api.mapbox.com/mapbox-gl-js/v1.1.1/mapbox-gl.js'></script>
<link href='https://api.mapbox.com/mapbox-gl-js/v1.1.1/mapbox-gl.css' rel='stylesheet' />

<div id='map' style='width: 400px; height: 300px;'></div>
<script>
  mapboxgl.accessToken = <your_access_token>;
  var map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/streets-v11'
  });
</script>

Congratulations you have just made you first Mapbox map!