Skip to content

Instantly share code, notes, and snippets.

@tristen
Created May 7, 2016 04:11
Show Gist options
  • Save tristen/5f807d44726b401b727f3ab06c7ed864 to your computer and use it in GitHub Desktop.
Save tristen/5f807d44726b401b727f3ab06c7ed864 to your computer and use it in GitHub Desktop.
Two styled lineStrings
Display the source blob
Display the rendered blob
Raw
Loading
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='https://api.tiles.mapbox.com/mapbox-gl-js/v0.18.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.18.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.eyJ1IjoidHJpc3RlbiIsImEiOiJiUzBYOEJzIn0.VyXs9qNWgTfABLzSI3YcrQ';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v8',
center: [-79.4140, 43.6523],
zoom: 16
});
map.on('load', function () {
map.addSource('route', {
type: 'geojson',
data: 'data.geojson'
});
map.addLayer({
id: 'route-foo',
type: 'line',
source: 'route',
layout: {
'line-join': 'round',
"line-cap": 'round'
},
paint: {
'line-color': 'blue',
'line-opacity': 0.5,
'line-width': 5
},
filter: ['==', 'type', 'foo']
});
map.addLayer({
id: 'route-bar',
type: 'line',
source: 'route',
layout: {
'line-join': 'round',
"line-cap": 'round'
},
paint: {
'line-color': 'red',
'line-opacity': 0.5,
'line-width': 15
},
filter: ['==', 'type', 'bar']
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment