A friendly step-by-step guide to serving up your own slippy web map tiles with tilehut.js
Joey Lee /
github: @joeyklee /
twitter: @leejoeyk
Prepared for FOSS4G, Boston, Aug. 2017
CSV Data processed → group-by → routed using GraphHopper → to geojson:
+ 'start station id'
+ 'start station name'
+ 'start station latitude'
+ 'start station longitude'
+ 'end station id'
+ 'end station name'
+ 'end station latitude'
+ 'end station longitude'
+ 'count'
+ 'total_duration' (in seconds)
http://hubwaydatachallenge.org/submission/28/
http://hubwaydatachallenge.org/submission/41/
Install Tippecanoe, navigate into the directory and run:
tippecanoe -o hubway-routed.mbtiles -maximum-zoom 13 -l hubwayRouted 201701_hubway_routes_all.geojson
Download Tilehut.js → npm install → npm start
# change into the tilehut directory
cd tilehut
# this installs all the dependencies
npm install
# this starts the server
node server.js
# check in your browser: http://localhost:8000/tiles-world-simple/map/
Make sure tilehut is running and go to:http://localhost:8000/tiles-world-simple/map/
Since we're going to be working with vector tiles, let's have a look at the `examples/simplemap_vector` directory. Navigate over and double-click on `index.html`. you should see something like this:
With tilehut.js running → check the meta data of the mbtiles in the data folder by:
"http://0.0.0.0:8000/the-name-of-your-mbtile-file/meta.json"
The response will be a JSON:
{
"scheme": "tms",
"basename": "tiles-world-vector.mbtiles",
"id": "tiles-world-vector",
"filesize": 1703936,
"name": "tiles-world-vector.mbtiles",
"description": "tiles-world-vector.mbtiles",
"version": "2",
//... MORE USEFUL PROPERTIES...
}
# We're first going to initialize the repository with:
git init
# next we will add all the files we want to be tracked by git:
git add .
# last, we commit all of our files, in our initial commit:
git commit -m "initial commit"
you will be asked for your email and password
heroku login
create an app which I will call `hubway-tiles` (you'll have to come up with another name since Heroku won't accept duplicates... get creative!):
# heroku create {name of your app}
heroku create hubway-tiles
# Send it!
git push heroku master
# this will print out the logs from the heroku server
heroku logs
map.addSource('tilehut-hubway-routes', {
"type": "vector",
"tiles": [
"http://localhost:8000/hubway-routed/{z}/{x}/{y}.pbf"
]
});
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
map.addSource('tilehut-hubway-routes', {
"type": "vector",
"tiles": [
"https://hubway-tiles.herokuapp.com/hubway-routed/{z}/{x}/{y}.pbf"
]
});
Many thanks to moovel Lab & FOSS4G!