Skip to content

Instantly share code, notes, and snippets.

@h4k1m0u
Created April 8, 2018 16:33
Show Gist options
  • Save h4k1m0u/24ec2daf6866c809e69a44906b3118f2 to your computer and use it in GitHub Desktop.
Save h4k1m0u/24ec2daf6866c809e69a44906b3118f2 to your computer and use it in GitHub Desktop.
<script>
// mapbox token
mapboxgl.accessToken = '<token>';
// parse passed multipolygon geojson string
var multipolygon = JSON.parse('{{ multipolygon | safe }}');
// show map
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v9',
center: [-2.1580, 51.9923],
zoom: 12
});
// show geojson multipolygon on mapbox
map.on('load', function () {
map.addLayer({
'id': '0',
'type': 'fill',
'source': {
'type': 'geojson',
'data': multipolygon
},
'paint': {
'fill-color': '#00f',
'fill-opacity': 0.8
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment