Last active
September 24, 2015 21:15
-
-
Save jeromegv/cb64bc2c9777794e80af to your computer and use it in GitHub Desktop.
Tilestache on XSCE stack
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> | |
<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> |
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
#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 |
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
{ | |
"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"} | |
] | |
} | |
} | |
} | |
} | |
} |
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
#Tilestache Apache2 configuration file | |
WSGIScriptAlias /tilestache /var/www/html/tilestache.wsgi |
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
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
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.