Skip to content

Instantly share code, notes, and snippets.

@tristen
Created July 26, 2016 00:36
Show Gist options
  • Save tristen/1f708402d46823051126a65c1ee30776 to your computer and use it in GitHub Desktop.
Save tristen/1f708402d46823051126a65c1ee30776 to your computer and use it in GitHub Desktop.
Polygon overlay bug
<!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.21.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.21.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 geojson = {
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[
-180,
90
],
[
180,
90
],
[
180,
-90
],
[
-180,
-90
],
[
-180,
90
]
]
],
"type": "Polygon"
}
};
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v9',
center: [-97, 42],
zoom: 3
});
map.on('load', function() {
map.addSource('overlay', {
type: 'geojson',
data: geojson
});
map.addLayer({
id: 'route',
type: 'fill',
source: 'overlay',
paint: {
'fill-color': '#088'
}
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment