Skip to content

Instantly share code, notes, and snippets.

@edwardgalligan
Created November 21, 2016 22:31
Show Gist options
  • Save edwardgalligan/ea1d22149245e4c6bc0872eb96f76f37 to your computer and use it in GitHub Desktop.
Save edwardgalligan/ea1d22149245e4c6bc0872eb96f76f37 to your computer and use it in GitHub Desktop.
Mapbox GL
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Mapbox GL</title>
<link rel="stylesheet" href="https://api.tiles.mapbox.com/mapbox-gl-js/v0.28.0/mapbox-gl.css" />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id="map"></div>
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v0.28.0/mapbox-gl.js"></script>
<script>
(function() {
mapboxgl.accessToken = 'pk.eyJ1IjoiZWRnYWxsaWdhbiIsImEiOiJZUzQ4dE9RIn0.TaaSiRg9r1wCtghbgQ0FOQ';
var mapOptions = {
container: document.getElementById('map'),
scrollZoom: false,
failIfMajorPerformanceCaveat: true, // avoid crashing old phones
hash: true, // put #zoom/lng/lat/bearing/pitch in the address bar
style: 'mapbox://styles/mapbox/dark-v9',
center: [-6.26790,53.34487],
zoom: 16.66,
pitch: 54,
bearing: -29.6
};
var map = new mapboxgl.Map(mapOptions);
map.on('load', function() {
map.addControl(new mapboxgl.NavigationControl())
map.addControl(new mapboxgl.GeolocateControl())
map.addLayer({
id: '3d-buildings',
source: 'composite',
'source-layer': 'building',
filter: ['==', 'extrude', 'true'],
type: 'fill-extrusion',
minzoom: 15,
paint: {
'fill-extrusion-color': '#f27',
'fill-extrusion-height': {
type: 'identity',
property: 'height'
},
'fill-extrusion-base': {
type: 'identity',
property: 'min_height'
},
'fill-extrusion-opacity': .6
}
});
});
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment