Tilestache on XSCE stack
<html> | |
<head> | |
<title>Sample: Adding Tilestache to Leaflet</title> | |
<meta charset="utf-8" /> | |
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" /> | |
<!--[if lte IE 8]><link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" /><![endif]--> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script> | |
<script src="http://code.jquery.com/jquery-1.11.3.js" type="text/javascript" charset="utf-8"></script> | |
<script> | |
$(document).ready(function(){ | |
var map = new L.Map('map').setView([28.6135,84.1992], 5); | |
//change IP to your schoolserver IP | |
var tileLayer = L.tileLayer('http://192.168.1.18/tilestache/composite/{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}); | |
map.addLayer(tileLayer); | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="map" style="width: 1000px; height: 750px"></div> | |
</body> | |
</html> |
#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" | |
} | |
}, | |
"composite": | |
{ | |
"provider": | |
{ | |
"class": "TileStache.Goodies.Providers.Composite:Provider", | |
"kwargs": | |
{ | |
"stack": | |
[ | |
{"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') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
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.