Printlet
Generate static map images from TileJSON configuration and draw stuff on top with GeoJSON.
Printlet supports an extended version of TileJSON for declaring custom map projections. The specification resides here.
Intended for use as a library Printlet also comes with a thin HTTP API as an example of implementation but also for practical use.
var printlet = render = ; ;
Getting started
Installing dependencies on OS X using Homebrew
$ brew install cairo --without-x
Note: This might cause some problems. Please report issues if Printlet wont build after this step.
Troubleshooting problems with libpng (on OS X 10.7.5):
# For freetype
export LIBPNG_CFLAGS=`/usr/local/opt/libpng/bin/libpng-config --cflags`
export LIBPNG_LDFLAGS=`/usr/local/opt/libpng/bin/libpng-config --ldflags`
# For cairo
brew link libpng --force
brew install --env=std cairo --without-x
brew link cairo --force
brew link pixman --force
brew link freetype --force
Installing dependencies on Ubuntu
$ sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
Installing dependencies on Fedora
$ sudo yum --enablerepo=updates-testing install npm cairo-devel
Drop "--enablerepo=updates-testing" if you're on F19 or greater.
Installing Printlet using NPM
$ npm install -g printlet
Running the HTTP server
$ printlet
Now point your browser to http://localhost:41462/12/11.95/57.7/800x600.png and get a nice view of Göteborg using a default OSM TileJSON.
With custom TileJSON
Grab your favorite TileJSON and point Printlet to it. There is an example TileJSON with a custom projection to try out here.
$ printlet 41462 your/tile.json
Open browser to same URL as previous step to check it out.
Building Printlet for developers
$ git clone https://github.com/kartena/printlet.git
$ cd printlet
$ npm install
Examples of using Printlet as a lib
There is a minimalistic map image generator in the examples folder to get the basic gist of the Printlet lib.
Also there is a more advanced implementation using the GeoJSON drawing capabilities as a HTTP server.
Drawing GeoJSON features
At the moment styles for GeoJSON is defined in the properties
attribute of
a GeoJSON feature as a dictionary called style
. The keys under style
are the same as the HTML5 canvas API for styling shapes.
Exceptions to the canvas properties is marker
which is possible to define for
geometry type Point
and describes how points are drawn with images, text or a
circle.