Skip to content

Instantly share code, notes, and snippets.

@almccon
Last active March 25, 2018 20:48
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 almccon/2dbd9323833b2d9e06d3fe08154e3de9 to your computer and use it in GitHub Desktop.
Save almccon/2dbd9323833b2d9e06d3fe08154e3de9 to your computer and use it in GitHub Desktop.
WWSD #3: Getting started Mapbox-gl
license: mit
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!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="//d3js.org/d3.v3.min.js"></script>
<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.eyJ1IjoibWFwcGluZ21hc2h1cHMiLCJhIjoiV3FPMW01ayJ9.T4MWb-43AlNKowzsTFmrhw';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mappingmashups/cjf78si473rkh2rnxleegwa6s',
center: [-120, 33],
zoom: 3
});
map.on('load', function () {
var url = "https://gist.githubusercontent.com/almccon/2dbd9323833b2d9e06d3fe08154e3de9/raw/70a778b97168f75822e1564879d95a69b906e521/2.5_day.geojson"
d3.json(url, function(err, earthquakes) {
map.addSource('earthquakes', {
'type': 'geojson',
'data': earthquakes
});
map.addLayer({
'id': 'earthquakes',
'type': 'circle',
'source': 'earthquakes',
'layout': {},
'paint': {
'circle-radius': {
"base": 0.2,
"type": "exponential",
"property": "mag",
"stops": [
[0, 0.5],
[2, 6],
[5, 9],
[9, 20]
]
},
'circle-color': 'red'
}
});
})
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment