forked from syntagmatic's block: Hello Mapbox GL
Created
September 8, 2015 07:39
-
-
Save renecnielsen/4d0e94ae403790716d6a to your computer and use it in GitHub Desktop.
Hello Mapbox GL
This file contains 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
<!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://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.9.0/mapbox-gl.js'></script> | |
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.9.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.eyJ1Ijoic3ludGFnbWF0aWMiLCJhIjoiZTFjYjUwNGFkYjcxMjI5OTMwODhjZTY3NjY4YmI3MGUifQ.zbJ-LWjumyIjYTMVjW_yjA'; | |
var map = new mapboxgl.Map({ | |
container: 'map', | |
style: 'light-colors-v7.json', | |
center: [41.9, -70.3], | |
zoom: 9, | |
minZoom: 2 | |
}); | |
</script> | |
</body> | |
</html> |
This file contains 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
{ | |
"version": 7, | |
"name": "light-colors", | |
"constants": { | |
"@land": "#eee", | |
"@water": "#cfd3d9", | |
"@forest": "#cdd7c2", | |
"@sand": "#d0bba3", | |
"@road-major": "#c9c9c9", | |
"@motorway-width": { | |
"base": 1, | |
"stops": [[3, 0.5], [9, 0.75], [20, 5]] | |
} | |
}, | |
"sources": { | |
"mapbox": { | |
"url": "mapbox://mapbox.mapbox-streets-v6", | |
"type": "vector" | |
} | |
}, | |
"sprite": "https://www.mapbox.com/mapbox-gl-styles/sprites/sprite", | |
"glyphs": "mapbox://fontstack/{fontstack}/{range}.pbf", | |
"layers": [{ | |
"id": "background", | |
"type": "background", | |
"layout": { | |
"visibility": "visible" | |
}, | |
"paint": { | |
"background-color": "@land" | |
} | |
}, { | |
"id": "landuse_park", | |
"type": "fill", | |
"layout": { | |
"visibility": "visible" | |
}, | |
"source": "mapbox", | |
"source-layer": "landuse", | |
"filter": ["all", ["==", "class", "park"], ["==", "$type", "Polygon"]], | |
"paint": { | |
"fill-color": "@forest" | |
} | |
}, { | |
"id": "landuse_sand", | |
"type": "fill", | |
"layout": { | |
"visibility": "visible" | |
}, | |
"source": "mapbox", | |
"source-layer": "landuse", | |
"filter": ["all", ["==", "class", "sand"], ["==", "$type", "Polygon"]], | |
"paint": { | |
"fill-color": "@sand" | |
} | |
}, { | |
"id": "water", | |
"type": "fill", | |
"source": "mapbox", | |
"source-layer": "water", | |
"layout": { | |
"visibility": "visible" | |
}, | |
"paint": { | |
"fill-color": "@water" | |
} | |
}, { | |
"id": "waterway", | |
"type": "line", | |
"source": "mapbox", | |
"source-layer": "waterway", | |
"filter": ["all", ["==", "$type", "LineString"], ["in", "class", "river", "canal"]], | |
"paint": { | |
"line-color": "@water", | |
"line-width": { | |
"base": 1, | |
"stops": [[6, 0.25], [20, 6]] | |
} | |
} | |
}, { | |
"id": "road-motorway", | |
"type": "line", | |
"source": "mapbox", | |
"source-layer": "road", | |
"minzoom": 0, | |
"filter": ["all"], | |
"layout": { | |
"line-cap": "round", | |
"line-join": "round", | |
"visibility": "visible" | |
}, | |
"paint": { | |
"line-color": "@road-major", | |
"line-width": "@motorway-width" | |
} | |
}] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment