Skip to content

Instantly share code, notes, and snippets.

@yohanboniface
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yohanboniface/55aa837d9c1430eb6468 to your computer and use it in GitHub Desktop.
Save yohanboniface/55aa837d9c1430eb6468 to your computer and use it in GitHub Desktop.

Tilemill and OSM

## Data sources

## Accepted formats:

Details: https://www.mapbox.com/tilemill/docs/manual/adding-layers/

  • psql
  • shp
  • csv
  • geotiff
  • geojson
  • kml
  • sqlite

Prepare data

## Style data

### Anatomy of MSS

#thisisanid, it's unique (only one layer)

.thisiaclass, it can be shared between layers

#myid[field='value'] this is selector

#myid[field='value'][anotherfield='value'] means AND

#myid[field='value'], #myid[anotherfield='value'] means OR

line-color: #123 this is a symbolizer (or rule)

::attachment allow to have more than one selector for the same feature (otherwise, the last to come will win); very often used for casing or glow effects.

outline/line-color: blue is a named instance, like attachment, it allows to have multiple styles of the same type applied on a same feature

'@secondary_line: #9FA9A8;` this is a variable

Selectors can be nested, and rules are inherited.

Painter algorythm: first rule to come, first rule to be drawn (notable exception: labels!), others will be drawn of top (unless you play with *-allow-overlap). Roughly: layer order, then stylesheet order, then order of the selector, then order of the symbolizer, then order in the data source More about this: https://www.mapbox.com/tilemill/docs/guides/symbol-drawing-order/

Labels and icon algorithm:

doing the job

  • main elements: landuse, roads, buildings
  • take zoom into account
  • add icons
  • add labels
  • add custom fonts
  • use variables
  • understand the drawing order
  • understand the text priority drawing order
  • use functions
  • replace strings in names

Export data

  • upload to MapBox for quick and dirty prototyping
  • export to png / jpeg / tiff
  • export to svg
  • export to MBTiles
  • share your styles (sources!)

## Advanced:

  • relief data
  • psql
  • use version control

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment