Multiple Map Layers

The "Roads" layer can only be defined when customising map settings. However, it is possible to overlay data from multiple sources on top of each other using a "Group" layer. This is useful where background data is stored in a Tile Service but additional layers are only available in a separate WMS service.

Group Layers are also likely to be needed when working with local vector or raster data as one would typically not want to show all layers at all zoom levels.

The group layer sets overall properties that are shared between layers within that group and also determines the zoom levels at which different layers are displayed. A typical configuration for a Group layer might look like this:

{
    "roads":{
        "type": "Group",
        "projection": "EPSG:27700",
        "projectionDef": "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs +nadgrids=ostn02 ",
        "attribution": "(c) Crown Copyright",
        "maxExtent": [290000,190000,510000,410000],
        "resolutions" : [
            33.866734, 
            16.933367, 
            8.466684,  
            4.233342,  
            2.11667,   
            1.058335,  
            0.5291675, 
            0.264584,   
            0.132292,  
            0.066146
        ],
        "layers": {
            "Overview" : {
                "minimumResolution": 2.11667,
                "order": 1,
                "type": "GeoPackageTile",
                "url": "raster.gpkg",
                "table": "overview"
            },
            "Place Labels" : {
                "maximumResolution": 0.264584,
                "order": 3,
                "type": "GeoPackageFeature",
                "url": "labels.gpkg",
                "table": "CartographicText",
                "column": "geometry",
                "style": {
                    "label": "${textstring}",
                    "labelAlign": "cm"
                }
            },
            "Features" : {
                "maximumResolution": 1.058335,
                "order": 2,
                "type": "GeoPackageFeature",
                "url": "areas.gpkg",
                "table": "TopographicArea",
                "column": "geometry",
                "style": {
                    "fillColor": "orange",
                    "fillOpacity": 0.5, 
                    "strokeOpacity": 0.2, 
                    "strokeWidth": 1
                },
                "styleBy": "featurecode",
                "styles": {
                    "10021": {"fillColor": "red"},
                    "10053": {"fillColor": "brown"},
                    "10172": {"fillColor": "grey"},
                    "10111": {"fillColor": "green"}
                },
                "info": "Feature Type: ${featurecode}"
            }
        }
    }
}

"type":

This value must be set to "Group"

"projection":

The projection for all of the layers in the Group. Note that all layers must share the same projection. Refer to Projections page for details.

"projectionDef":

Refer to Projections page for details.

"maxExtent"

"resolutions"

"maxResolution"

"numZoomLevels":

These settings are determined by the layers that are contained within the group and must be consistent for all layers in the Group. Typically, if the group contains a Tile Service then the settings from the tile service should be used. If only local SQLite maps are being used then it is possible to simply specify the "maxExtent" and "numZoomLevels".

"layers":

This contains the list of layers that are contained within the group, enclosed in curly brackets {}. Each layer should be given a unique name, followed by a colon and then the specific settings for that layer.

In addition, the following settings can also be specified for each layer:

"minimumResolution"

"maximumResolution":

These determine when the layer is switched on and off as the user zooms in and out.

Values represent the number of metres to show per pixel on the current zoom scale. In other words the more detailed map you have the lower the setting you should use. For example:

"minimumResolution": 0.0 will never turn off the layer no matter how far in you zoom.

"maximumResoltuion": 5.0 would show items until the user zooms out beyond 5 metres per pixel. This equates to an approximate scale of 1:20000 (1 metre screen size = 20000 distance to the ground) on a 96dpi device.

"order":

Use the "order" to control which layers appear on top if more than one can be displayed at a time (e.g. draw labels on top of areas). The layer with the highest order appears on top.