block by renecnielsen 4d0e94ae403790716d6a

Hello Mapbox GL

Full Screen

hello world

forked from syntagmatic‘s block: Hello Mapbox GL

index.html

<!DOCTYPE html>
<html>
<head>
  <meta charset='utf-8' />
  <title></title>
  <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
  <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
  <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.9.0/mapbox-gl.js'></script>
  <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.9.0/mapbox-gl.css' rel='stylesheet' />
  <style>
    body { margin:0; padding:0; }
    #map { position:absolute; top:0; bottom:0; width:100%; }
  </style>
</head>
<body>

<div id='map'></div>
<script>
mapboxgl.accessToken = 'pk.eyJ1Ijoic3ludGFnbWF0aWMiLCJhIjoiZTFjYjUwNGFkYjcxMjI5OTMwODhjZTY3NjY4YmI3MGUifQ.zbJ-LWjumyIjYTMVjW_yjA';
var map = new mapboxgl.Map({
  container: 'map',
  style: 'light-colors-v7.json',
  center: [41.9, -70.3],
  zoom: 9,
  minZoom: 2
});
</script>

</body>
</html>

light-colors-v7.json

{
  "version": 7,
  "name": "light-colors",
  "constants": {
    "@land": "#eee",
    "@water": "#cfd3d9",
    "@forest": "#cdd7c2",
    "@sand": "#d0bba3",
    "@road-major": "#c9c9c9",
    "@motorway-width": {
      "base": 1,
      "stops": [[3, 0.5], [9, 0.75], [20, 5]]
    }
  },
  "sources": {
    "mapbox": {
      "url": "mapbox://mapbox.mapbox-streets-v6",
      "type": "vector"
    }
  },
  "sprite": "https://www.mapbox.com/mapbox-gl-styles/sprites/sprite",
  "glyphs": "mapbox://fontstack/{fontstack}/{range}.pbf",
  "layers": [{
    "id": "background",
    "type": "background",
    "layout": {
      "visibility": "visible"
    },
    "paint": {
      "background-color": "@land"
    }
  }, {
    "id": "landuse_park",
    "type": "fill",
    "layout": {
      "visibility": "visible"
    },
    "source": "mapbox",
    "source-layer": "landuse",
    "filter": ["all", ["==", "class", "park"], ["==", "$type", "Polygon"]],
    "paint": {
      "fill-color": "@forest"
    }
  }, {
    "id": "landuse_sand",
    "type": "fill",
    "layout": {
      "visibility": "visible"
    },
    "source": "mapbox",
    "source-layer": "landuse",
    "filter": ["all", ["==", "class", "sand"], ["==", "$type", "Polygon"]],
    "paint": {
      "fill-color": "@sand"
    }
  }, {
    "id": "water",
    "type": "fill",
    "source": "mapbox",
    "source-layer": "water",
    "layout": {
      "visibility": "visible"
    },
    "paint": {
      "fill-color": "@water"
    }
  }, {
    "id": "waterway",
    "type": "line",
    "source": "mapbox",
    "source-layer": "waterway",
    "filter": ["all", ["==", "$type", "LineString"], ["in", "class", "river", "canal"]],
    "paint": {
      "line-color": "@water",
      "line-width": {
        "base": 1,
        "stops": [[6, 0.25], [20, 6]]
      }
    }
  }, {
    "id": "road-motorway",
    "type": "line",
    "source": "mapbox",
    "source-layer": "road",
    "minzoom": 0,
    "filter": ["all"],
    "layout": {
      "line-cap": "round",
      "line-join": "round",
      "visibility": "visible"
    },
    "paint": {
      "line-color": "@road-major",
      "line-width": "@motorway-width"
    }
  }]
}