Skip to content

Instantly share code, notes, and snippets.

@AlanPew
Created July 10, 2015 13:20
Show Gist options
  • Save AlanPew/460b936e924ecfa293d1 to your computer and use it in GitHub Desktop.
Save AlanPew/460b936e924ecfa293d1 to your computer and use it in GitHub Desktop.
javascript test
<!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.8.1/mapbox-gl.js'></script>
<script src='maps.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.8.1/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 = 'dontneedatokenwithothermaps';
var map = new mapboxgl.Map({
container: 'map',
style: simple,
zoom: 1,
center: [35, -14]
});
map.addControl(new mapboxgl.Navigation());
</script>
</body>
</html>
var simple = {
"version": 7,
"constants": {
"@land": "#41afa5",
"@water": "#3887be",
"@ocean": "#ffffff"
},
"sources": {
"osm": {
"type": "vector",
"tiles": ["https://vector.mapzen.com/osm/all/{z}/{x}/{y}.mapbox"]
},
"test": {
"type": "vector",
"tiles": ["http://tile.openstreetmap.us/vectiles-water-areas/{z}/{x}/{y}.mvt"]
}
},
"layers": [{
"id": "background",
"type": "background",
"paint": {
"background-color": "@land"
}
}, {
"id": "water",
"type": "fill",
"source": "osm",
"source-layer": "water",
"paint": {
"fill-color": "@water"
}
},{
"id": "river",
"source": "osm",
"source-layer": "water",
"type": "line",
"min-zoom": 6,
"filter": ["all", ["==", "$type", "LineString"], ["==", "kind", "river"]],
"layout": {
"line-cap": "round",
"line-join": "round"
},
"paint": {
"line-color": "@water",
"line-width": {
"base": 1.2,
"stops": [[8, 0.75], [20, 15]]
}
}
},
{
"id": "water-polygon",
"source": "osm",
"source-layer": "water",
"type": "fill",
"filter": ["all",["==", "$type", "Polygon"],["==", "kind", "ocean"]],
"paint": {
"fill-color": "@ocean"
}
}]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment