Skip to content

Instantly share code, notes, and snippets.

Last active September 24, 2015 21:15
Show Gist options
  • Save jeromegv/cb64bc2c9777794e80af to your computer and use it in GitHub Desktop.
Save jeromegv/cb64bc2c9777794e80af to your computer and use it in GitHub Desktop.
Tilestache on XSCE stack
<title>Sample: Adding Tilestache to Leaflet</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="" />
<!--[if lte IE 8]><link rel="stylesheet" href="" /><![endif]-->
<script src=""></script>
<script src="" type="text/javascript" charset="utf-8"></script>
var map = new L.Map('map').setView([28.6135,84.1992], 5);
//change IP to your schoolserver IP
var tileLayer = L.tileLayer('{z}/{x}/{y}.png',{opacity: 0.8});
//path if using tilestream
//var tileLayer = L.tileLayer('http://localhost:8888/v2/Nepal/{z}/{x}/{y}.png',{opacity: 0.8});
<div id="map" style="width: 1000px; height: 750px"></div>
#install tilestache
sudo easy_install -Z tilestache
#dependency for tilestache that is missed by the installer
sudo yum install numpy
sudo mkdir /var/www/html/mbtiles
#move all the .mbtiles files in there. They must be referenced into tilestache.cfg
#this is what launches the tile server with wsgi
sudo vi /var/www/html/tilestache.wsgi
#copy paste the content of tilestache.wsgi in there
#this is the config of tilestache, where all layers at various zooms are configured and optionally the cache
sudo vi /var/www/html/tilestache.cfg
#copy paste the content of tilestache.cfg in there
#this is the apache config to associate /tilestache with the tilestache wsgi
cd /etc/httpd/conf.d
sudo vi tilestache.conf
#copy paste the content of tilestache.conf in there
#restart apache
sudo apachectl restart
#tiles will be available at http://IP_OF_SCHOOLSERVER/tilestache/composite/{z}/{x}/{y}.png
#example of leaflet client-side frontend integration included with index.html
"cache": {"name": "Test"},
"layers": {
"tiles013": {
"provider": {
"name": "mbtiles",
"tileset": "/var/www/html/mbtiles/Nepal013.mbtiles"
"tiles1415": {
"provider": {
"name": "mbtiles",
"tileset": "/var/www/html/mbtiles/Nepal1415.mbtiles"
"class": "TileStache.Goodies.Providers.Composite:Provider",
{"src": "tiles013"},
{"src": "tiles1415"}
#Tilestache Apache2 configuration file
WSGIScriptAlias /tilestache /var/www/html/tilestache.wsgi
import os, TileStache
application = TileStache.WSGITileServer('/var/www/html/tilestache.cfg')
Copy link

Feedback from Tim: This looks great and not overly complex. XSCE uses one convention that you are probably not aware of and that is that we put data in /library, in this case probably /library/osm or tilestache or some combination.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment