Created
April 8, 2018 16:33
-
-
Save h4k1m0u/24ec2daf6866c809e69a44906b3118f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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