Created
November 28, 2016 16:59
-
-
Save joeyklee/383f361c0ebb39f968f54fe786cf8e87 to your computer and use it in GitHub Desktop.
Stamen Raster tiles in Mapboxgl.js - based on https://bl.ocks.org/danswick/a4de5c170c04fdd38bb4
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
<html> | |
<head> | |
<meta charset='utf-8' /> | |
<title></title> | |
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> | |
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.11.4/mapbox-gl.js'></script> | |
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.11.4/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.eyJ1IjoiZGFuc3dpY2siLCJhIjoieUZiWmwtVSJ9.0cPQywdbPVmvHiHJ6NwdXA'; | |
var map = new mapboxgl.Map({ | |
container: 'map', // container id | |
style: { | |
"version": 8, | |
"sources": { | |
"simple-tiles": { | |
"type": "raster", | |
// point to our third-party tiles. Note that some examples | |
// show a "url" property. This only applies to tilesets with | |
// corresponding TileJSON (such as mapbox tiles). | |
"tiles": [ | |
// "http://a.tile.openstreetmap.org/{z}/{x}/{y}.png", | |
// "http://b.tile.openstreetmap.org/{z}/{x}/{y}.png" | |
"http://tile.stamen.com/toner/{z}/{x}/{y}.png" | |
], | |
"tileSize": 256 | |
} | |
}, | |
"layers": [{ | |
"id": "simple-tiles", | |
"type": "raster", | |
"source": "simple-tiles", | |
"minzoom": 0, | |
"maxzoom": 22 | |
}] | |
}, | |
center: [-74.50, 40], // starting position | |
zoom: 2 // starting zoom | |
}); | |
map.addControl(new mapboxgl.Navigation()); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
n.b. dont need your key in this, and might want to take it of github anyways.