Unfolding maps, tilemill and streaming tiles: howto
in
Share your Work
•
2 years ago
Hi guys,
I'm doing a project where I need an detailed worldmap and stumbled my way into the amazing unfolding maps library. I created a simple addon so you can directly stream tiles from TileMill to processing. I was looking for something like this for ages and I'd like to share it with you :).
I'm doing a project where I need an detailed worldmap and stumbled my way into the amazing unfolding maps library. I created a simple addon so you can directly stream tiles from TileMill to processing. I was looking for something like this for ages and I'd like to share it with you :).
Step 0: If you are lazy: a sample sketch will be at the end of my post :).
Step 1: Download the
Unfolding Maps library,
GlGraphics library and install
TileMill. You can choose to install TileMill locally on your mac or on a powerful
Ubuntu 10.10/11.04 server if available.
Step 2: Import the following classes to your sketch:
- import processing.opengl.*;
- import codeanticode.glgraphics.*;
- import de.fhpotsdam.unfolding.*;
- import de.fhpotsdam.unfolding.core.*;
- import de.fhpotsdam.unfolding.geo.*;
- import de.fhpotsdam.unfolding.utils.*;
- import de.fhpotsdam.unfolding.providers.*;
Copy my class to add support for tile streaming:
- class streamProvider extends MapBox.MapBoxProvider {
- String hostname, mapname;
- streamProvider(String _hostname, String _mapname){
- hostname = _hostname;
- mapname = _mapname;
- }
- public String[] getTileUrls(Coordinate coordinate) {
- String url = "http://"+hostname+":8889/1.0.0/"+mapname+"/"
- + getZoomString(coordinate) + ".png";
- return new String[] {
- url
- };
- }
- }
And initialise your map:
- map = new de.fhpotsdam.unfolding.Map(this, new streamProvider("localhost", "control-room"));
The class takes 2 variables. The host of the TileMill server and the name of the map it should stream. You can find the map name in the URL after clicking a project.
Step 3: Profit! You can edit (and don't forget to save) the map style and it will be directly streamed to your processing sketch. Just zoom in and out a bit to get rid of the cached tiles :).
Step 4, the lazy bastard step: here's a
demo. It has some US cities in it to fill the screen a bit. Fire up TileMill and you should be set.
Enjoy and an enormous thanks to the creators of Unfolding Maps & TileMill!