Notes, sketches, and frameworks inspired by October 2011 map styling workshop held in SF
Question: Core bits should be universal. Extras should be wrapped in a Carto 2.0 designator?
===
NOTE: Extensions might include data formats (csv, shp in zip), data statistics (count, min, max), data locations (local/remote/offline), experimental styling keywords (feature class heigherachy ala scalemaster.org?), styles with absolute and relative values (gradients, choropleth/quantiles/nat'lbreaks/etc, lighter, darker, smaller text, larger text), and rendering (like for shields?), interactivity (one layer, multiple layers).
CSS target: marker, stroke, fill, text, shield, and ¿data? and ¿interactivity?.
Note: reimagined a bit from basic HTML CSS and Cascadenik, Carto.
Marker is new in 1.0 (was `point`, for a while `anchor`).
Text is more consistent in 1.0 and powerful in 2.0.
Interactivity and data formalized 2/3/4? Separate but parellel formats?
Size by: markers, strokes, and labels have a 2d extrusion measurement (eg: 2px)
For images, the size is implied by a non-repeat dimension of the source image.
Others are determined by default style CSS. Continues from Cascadenik/Carto 1.0.
Note: Lines can end either with or without semicolons at block ends, per CSS spec. Cascadenik (2.3.0)
Ink with for color (mask) areas (extrusion of stroke, or fill): rgb, cmyk, hsv, gradient, image (with repeat options).
Note: All color spaces/images/gradient are coallpsed in "ink" verb in Carto 2.0?
1.0: `color:#rgb` and `color:#rrggbb` with `opacity:1.0`
2.0: Other color spaces. See below.
3.0: gradients as colors? see **gradients on strokes** section far below.
Object geometry type filter: point, line, polygon, continuous-field aka raster.
New in 2.0
Object geometry component filter: The component polys, rings, & vertex.
New in 4.0
Rendering target: (pivots off geometry type) registration, edge, interior, LABEL, DATA, INTERACTIVITY.
New in 4.0. With optional masks and positioning/attachment hints.
text-name:[fieldname]
where the [fieldname] grabs attributes per feature on render. This is extended either with ::
layer attachements or keyword-attachments
to gain multiple text labels, shield symbolizers, etc.anchor
? Marker is more widely supported in Gmaps world. Mapnik's point
should be hidden in this generic spec. JL, NVK and NVK on 25 May and 29 May.geom_type_selector.classname { ... }
.classname geom_type_selector { ... }
!important
, but for not showing stuff, regardless of other rules. Speeds up stylesheets by ignoring unused elements in renderer specific export.display:none;
::
are a repeated version of the exact selection, but with a different appearance styling on a new virtual layer. Useful for applying multiple labels, shields, or graphic styles. OR should we move away to a procedure versus declarative? See also, "repeated properties" below./
similar to nested styles, but within the same original layer. .roads name { text-size:12px; text-color:#000; }
and .roads ref { shield... }
are a repeated version of the exact selection, but with a different appearance styling on a new virtual layer. Useful for applying multiple labels, shields, or graphic styles.::
), see above. Extremely advanced bits (Mappy CSS 4.0)
&&
depend on the previous bits being rendered in that selection. Useful for text labels to require the anchor symbolization being placed. eg: point&&text.geom_type_selector.classname { ... }
or .classname _geom_type_selector { ... }
(which is less CSS like, but more like the sketches below) Advanced: tests per feature for feature type, important for GeoJSON etc. THIS IS THE ONLY SHOW STOPPER.WARNING: if the defaults.mss file is included, the default for layer visibilty becomes ON instead of off.
Text -> geom_centroid -> Registration/Text:
.class * { text-size:12px; text-color:#000000; text-face:Arial; text-placement: [point, line, centroid, etc?] }
Marker -> Point -> Registration:
.class Point { stroke-width:2px; stroke-color:#000000; cap:round; }
Stroke -> Line -> Edge:
.class Line { stroke-width:1px; stroke-color:#000000; cap:square; }
Fill -> Polygon -> Interior:
.class Polygon { fill-color:#eeeeee; }
Raster Pixels -> Point > Registration:
.class Raster { ... }
Per pixel colored by the RGB channel values. Kinda like a RGB #hex gradient per 0-255 values?
CSS tk tk tk.
MML for the datasources and their layering. See below.
NOTE 1: Mappy CSS MML spec can embed the MSS part rather than linking to external file (the default).
NOTE 2: Mappy CSS MML spec can be implemented in either XML (Cascadenik) or [JSON]() (Carto) formats.
Overview
Map object with several properties including:
srs string --- for the projection, usually web mercator but can be any proj4 string.
background-color: #rrggbb etc.
background-image (should be background-color: url(...); ?)
buffer: 20px;
base:path/subdir/
font-directory: path/subdir
Stylesheet usually as an external (local) include. Inline MSS is allowed.
See above for spec.
Layer definitions with properties:
"class": "name1",
"id": "value2",
"name": "name3",
"srs": "+proj=latlong +ellps=WGS84 +datum=WGS84 +no_defs",
"Datasource": {
"file": "world_borders",
"type": "shape"
}
XML: Used by Cascadenik.
<?xml version="1.0" encoding="utf-8"?>
<Map srs="+proj=latlong +ellps=WGS84 +datum=WGS84 +no_defs">
<Stylesheet><![CDATA[
Map
{
map-bgcolor: #69f;
}
Layer
{
line-width: 1;
line-color: #696;
polygon-fill: #6f9;
}
]]></Stylesheet>
<Layer srs="+proj=latlong +ellps=WGS84 +datum=WGS84 +no_defs">
<Datasource>
<Parameter name="type">shape</Parameter>
<Parameter name="file">world_borders</Parameter>
</Datasource>
</Layer>
</Map>
Use XML when any of these are important:
1. Allows multi-line DB queries in MML where JSON does not allow unescaped line breaks. This creates more legible code.
2. Can add inline comments using standard XML <!-- comment --> syntax. This allows notes to now self and future self and for collaborators.
3. Can temporarily disable a block of code, also using <!-- disabled --> syntax.
4. DataSourcesConfig, see below.
JSON: Used by Carto.
{
"srs": "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over",
"Stylesheet": [{"id":"style.mss","data":"Map {\n background-color: #fff;\n}\n\n#world {\n line-color: #ccc;\n line-width: 0.5;\n polygon-fill: #eee;\n}"}],
"Layer": [{
"id": "world",
"name": "world",
"srs": "+proj=latlong +ellps=WGS84 +datum=WGS84 +no_defs",
"Datasource": {
"file": "world_borders",
"type": "shape"
}
}]
}
NOTE 3: Data source definition can be inline or an import in the MML. Cascadnik now. Easy in XML format, harder in JSON?
Local versus remote data files.
Supported by: Carto, Cascadenik
Carto does this as of the 0.2.0 release via separate millstone.
DataSourcesConfig an XML tag similar to the Stylesheet tag that allows you to externalize elements in an easy to manage format. More info »
Supported by: Cascadenik via native XML property. Hard to accomplish in Carto's JSON format?
[DEFAULT]
natural_earth_110m_base_url = http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m
[natural_earth_land_110m]
file = %(natural_earth_110m_base_url)s/physical/110m-land.zip
interactivity templates: should apply both to full vector and UTF8 grid approximations.
Supported by: UTFGRID spec, passed thru by Carto and Cascadenik?
Note: Carto supports passthru of the interactivity templates in TileMill, but doesn't support it explicately.
The interactivity spec Carto wraps is utfgrid-spec.
Syntax details, implementation recommendations, avoids, demos, open questions, housekeeping, quotes, display:none, carto 1.x nitpicks, more questions.
Basic:
Medium:
Complex:
Extended examples:
WARNING: the .layer interior {marker-image: url() }
example below is incorrect. It should show markers just inside the polygon, with none spilling outside. More like a mask or a polygon-fill: url()
? Or is there a slight difference?