Map Layers
The map layers are the geospatial data types supported by Mapfish Print. Map layers are typically defined in the request JSON as part of the map attribute. Since map layers are essentially attribute data specific to the map attribute, they follow the same pattern as all other attributes in that they have attribute values.
The documentation below describes each map layer listing its required and optional attributes. Here is an example of a map attribute with map layers defined.
Example request.json
{
"attributes": {
"map": {
"layers": [
{
"geoJson": "http://host.org/data.geojson",
"type": "geojson"
},
{
"baseURL": "http://host.org/tiles",
"type": "OSM",
"imageExtension": "png"
}
],
"projection": "EPSG:3857",
"dpi": 128,
"scale": 100000,
"center": [
-8233518.5005945,
4980320.4059228
]
}
},
"layout": "A4 landscape"
}
Geo Json Layer¶
Type: geojson
Configuration
parser
Inputs
failOnError
geoJson
- A geojson formatted string or url to the geoJson or the raw GeoJSON data.
The url can be a file url, however if it is it must be relative to the configuration directory.
name
opacity
renderAsSvg
- Indicates if the layer is rendered as SVG.
(will default to
Configuration.defaultToSvg
).
style
- The style name of a style to apply to the features during rendering. The style name must map to a style in the template or the configuration objects.
If no style is defined then the default style for the geometry type will be used.
Geotiff Layer¶
Type: geotiff
Inputs
failOnError
name
opacity
style
url
required
Gml Layer¶
Type: gml
Configuration
parser
Inputs
failOnError
name
opacity
renderAsSvg
- Indicates if the layer is rendered as SVG.
(will default to
Configuration.defaultToSvg
).
style
- The style name of a style to apply to the features during rendering. The style name must map to a style in the template or the configuration objects.
If no style is defined then the default style for the geometry type will be used.
url
required- An url to the gml or the raw Gml data.
The url can be a file url, however if it is it must be relative to the configuration directory.
Grid Layer¶
Type: grid
Example
Configuration
parser
Inputs
failOnError
font
formatDecimalSeparator
- The character used to separate the decimal part (for example ","). This parameter is only used if
valueFormat
is used. The default is the character of the default locale.
formatGroupingSeparator
- The character used for the thousands separator (for example "'"). This parameter is only used if
valueFormat
is used. The default is the character of the default locale.
gridColor
- The color of the grid points or lines. Default is gray ("gray")
gridType
- The type of grid to render.
Can be LINES or POINTS. Default is LINES.
haloColor
- The color of the halo around grid label text. The color is defined the same as colors in CSS. Default is white ("#FFF")
haloRadius
- The size of the halo around the Grid Labels. The default is 1.
horizontalYOffset
indent
- The number of pixels to indent the grid labels from the end of the map. The default is 5.
labelColor
- The color of the grid label text. Default is dark gray ("#444")
labelFormat
- The formatting string used to format the label (for example "%1.2f %s"). By default the label is formatted according to the unit and label value. For the format syntax, see java.util.Formatter. If
labelFormat
is set,valueFormat
,unitFormat
and custom separator characters will be ignored.
labelProjection
- The projection code to use for the labels. The value should be the string
authority:code
form identifying the projection. By default it will be the same projection as the map.
longitudeFirst
name
numberOfLines
required- The x,y number of grid lines.
The x is the number of lines that run vertically along the page.
opacity
origin
- The x,y point of grid origin.
This is required if
spacing
is defined.
pointsInLine
- The number of points that will be in the grid line (if the gridType is LINES). If the line will be curved (for certain projections) then the more points the smoother the curve.
The default number of points is 10000.
renderAsSvg
- Indicates if the layer is rendered as SVG.
(will default to
Configuration.defaultToSvg
).
rotateLabels
spacing
required- The x,y spacing between grid lines.
Either
spacing
ornumberOfLines
If spacing is defined then
origin
must also be defined
style
- The style name of a style to apply to the features during rendering. The style name must map to a style in the template or the configuration objects.
If no style is defined then the default grid style will be used. The default will depend if the type is point or line and will respect
gridColor
andhaloColor
andhaloRadius
. IfgridType
isGridType.POINTS
then the style will be crosses with a haloRadius sized halo around the cross. IfGridType.LINES
then the style will be a dashed line with no halo.
unitFormat
- The formatting string used to format the unit part of a label (for example " %s"). This parameter is ignored if
labelFormat
is set.valueFormat
must be set to use this parameter. For the format syntax, see java.util.Formatter.
valueFormat
- The formatting string used to format the decimal part of a label (for example "###,###"). This parameter is ignored if
labelFormat
is set. For the format syntax, see DecimalFormat.
verticalXOffset
Image Layer¶
Type: image
Inputs
baseURL
required
extent
required
failOnError
imageFormat
name
opacity
style
Osm Layer¶
Type: osm
Example
Inputs
baseURL
required- The URL used for the tile requests.
Supported formats:
- The base part of the URL, for example 'http://tile.openstreetmap.org'. This results in an URL like 'http://tile.openstreetmap.org/12/123/456.png'.
- An URL template with the placeholders '{x}', '{y}' or '{-y}', and '{z}'. For example:
'http://tile.openstreetmap.org/{z}/{x}/{y}.png'.
The placeholder '{-y}' provides support for OSGeo TMS tiles.
customParams
- Custom query parameters to use when making http requests.
customParams
.The json should look something like:
{
"param1Name": "value",
"param2Name": ["value1", "value2"]
}
dpi
failOnError
imageExtension
maxExtent
- The maximum extent of the osm layer. Must have 4 coordinates, minX, minY, maxX, maxY
Default: [-20037508.34, -20037508.34, 20037508.34, 20037508.34]
name
opacity
rasterStyle
resolutionTolerance
resolutions
tileSize
- The size of each tile. Must have 2 values: width, height
Default: [256, 256]
Tiled Wms Layer¶
Type: tiledwms
Example
Inputs
baseURL
required
customParams
- Custom query parameters to use when making http requests. These are related to
mergeableParams
except they are the parameters that will prevent two layers from the same server from being merged into a single request with both layers. SeemergeableParams
for a more detailed example of the difference betweenmergeableParams
andcustomParams
.The json should look something like:
{
"param1Name": "value",
"param2Name": ["value1", "value2"]
}
failOnError
imageFormat
layers
required- The wms layer to request in the GetMap request. The order is important. It is the order that they will appear in the request.
As with the WMS specification, the first layer will be the first layer drawn on the map (the bottom/base layer) of the map. This means that layer at position 0 in the array will covered by layer 1 (where not transparent) and so on.
mergeableParams
- Custom query parameters that can be merged if multiple layers are merged together into a single request.
The json should look something like:
For example in WMS the style parameter can be merged. If there are several wms layers that can be merged except they have different style parameters they can be merged because the style parameter can be merged.{
"param1Name": "value",
"param2Name": ["value1", "value2"]
}Compare that to DPI parameter (for QGIS wms mapserver). if two layers have different DPI then the layers cannot be merged. In this case the DPI should NOT be one of the
mergeableParams
it should be one of thecustomParams
.
method
- The HTTP verb to use for fetching the images. Can be either "GET" (the default) or "POST".
In case of "POST", the parameters are send in the body of the request using an "application/x-www-form-urlencoded" content type. This can be used when the parameters are too long. Tested only with GeoServer.
name
opacity
rasterStyle
serverType
styles
- The styles to apply to the layers. If this is defined there should be the same number as the layers and the style are applied to the layer in the
layers
field.
tileBufferSize
tileSize
required
useNativeAngle
version
WMTS Layer¶
Type: wmts
Example
Inputs
baseURL
required- The ‘ResourceURL’ available in the WMTS capabilities.
Example (for
requestEncoding: "KVP"
):Example (forbaseUrl: "http://domain.com/wmts"
requestEncoding: "REST"
):The following URL template variables are replaced:baseUrl: "http://domain.com/wmts/roads/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.png"
- {Layer}
- {style}
- {TileMatrixSet}
- {TileMatrix}
- {TileRow}
- {TileCol}
- {[DIMENSION.IDENTIFIER]}
customParams
- Custom query parameters to use when making http requests. These are related to
mergeableParams
except they are the parameters that will prevent two layers from the same server from being merged into a single request with both layers. SeemergeableParams
for a more detailed example of the difference betweenmergeableParams
andcustomParams
.The json should look something like:
{
"param1Name": "value",
"param2Name": ["value1", "value2"]
}
dimensionParams
dimensions
- The "sample" dimensions or image color bands to retrieve.
This can be null, if so then the default dimensions will be returned. If specified they must be dimensions supported by the server.
These are keys to the
dimensionParams
.
failOnError
imageFormat
layer
required
matrices
required- Array of matrix ids.
Example:
[{
"identifier": "0",
"matrixSize": [1, 1],
"scaleDenominator": 4000,
"tileSize": [256, 256],
"topLeftCorner": [420000, 350000]
}, ...]
matrixSet
required
mergeableParams
- Custom query parameters that can be merged if multiple layers are merged together into a single request.
The json should look something like:
For example in WMS the style parameter can be merged. If there are several wms layers that can be merged except they have different style parameters they can be merged because the style parameter can be merged.{
"param1Name": "value",
"param2Name": ["value1", "value2"]
}Compare that to DPI parameter (for QGIS wms mapserver). if two layers have different DPI then the layers cannot be merged. In this case the DPI should NOT be one of the
mergeableParams
it should be one of thecustomParams
.
name
opacity
rasterStyle
requestEncoding
- The way to make the requests. Either
KVP
orREST
(default).
style
version
Wms Layer¶
Type: wms
Inputs
baseURL
required
customParams
- Custom query parameters to use when making http requests. These are related to
mergeableParams
except they are the parameters that will prevent two layers from the same server from being merged into a single request with both layers. SeemergeableParams
for a more detailed example of the difference betweenmergeableParams
andcustomParams
.The json should look something like:
{
"param1Name": "value",
"param2Name": ["value1", "value2"]
}
failOnError
imageFormat
layers
required- The wms layer to request in the GetMap request. The order is important. It is the order that they will appear in the request.
As with the WMS specification, the first layer will be the first layer drawn on the map (the bottom/base layer) of the map. This means that layer at position 0 in the array will covered by layer 1 (where not transparent) and so on.
mergeableParams
- Custom query parameters that can be merged if multiple layers are merged together into a single request.
The json should look something like:
For example in WMS the style parameter can be merged. If there are several wms layers that can be merged except they have different style parameters they can be merged because the style parameter can be merged.{
"param1Name": "value",
"param2Name": ["value1", "value2"]
}Compare that to DPI parameter (for QGIS wms mapserver). if two layers have different DPI then the layers cannot be merged. In this case the DPI should NOT be one of the
mergeableParams
it should be one of thecustomParams
.
method
- The HTTP verb to use for fetching the images. Can be either "GET" (the default) or "POST".
In case of "POST", the parameters are send in the body of the request using an "application/x-www-form-urlencoded" content type. This can be used when the parameters are too long. Tested only with GeoServer.
name
opacity
rasterStyle
serverType
styles
- The styles to apply to the layers. If this is defined there should be the same number as the layers and the style are applied to the layer in the
layers
field.
useNativeAngle
version