Skip to content

Instantly share code, notes, and snippets.

@dnomadb
Created March 29, 2018 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnomadb/99a1625cabc86cefcea597dcd4ada1d5 to your computer and use it in GitHub Desktop.
Save dnomadb/99a1625cabc86cefcea597dcd4ada1d5 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Add hillshading</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.1/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.1/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.eyJ1IjoidmluY2VudHNhcmFnbyIsImEiOiJjaW4xMGJya2MwYXM5dmxtNDEzbWhia200In0.k5k8j7ZO4o_WVYoJv5E2Xw';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v9',
center: [-79.5, 36.5],
zoom: 9,
hash: true
});
map.on('load', () => {
map.addSource('dem', {
"type": "raster-dem",
'tiles': ['https://a.tiles.mapbox.com/v4/vincentsarago.cqor34yg/{z}/{x}/{y}@2x.pngraw?access_token=pk.eyJ1IjoidmluY2VudHNhcmFnbyIsImEiOiJjaW4xMGJya2MwYXM5dmxtNDEzbWhia200In0.k5k8j7ZO4o_WVYoJv5E2Xw'],
"bounds": [-80.00013888888888, 35.999861111111116, -78.9998611111111, 37.00013888888889]
});
map.addLayer({
"id": "hillshading",
"source": "dem",
"type": "hillshade",
"paint": {
"hillshade-exaggeration": 1,
"hillshade-shadow-color": 'rgb(29, 187, 117)',
"hillshade-highlight-color": 'rgb(217, 80, 29)',
"hillshade-accent-color": 'rgb(244, 39, 200)'
}
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment