Restrict layers to certain spatial references
Basemap layer
For single basemap layers you can configure the spatial reference systems (SRS) in which these layers should be displayed.
There are occasions where it makes sense to have several versions of the same map layer for different SRSs of the map. For example, you might set up a cached map service for the SRS with the well-known ID (WKID) 3857 and a dynamic map service for other SRSs. The benefit from this setup is that most users, who only use the default reference system 3857, are served by a fast responding cached map service. For users that switch to an SRS other than 3857, there’s the dynamic web service in place. However, when the SRS is 3857, the dynamic web service should not be visible.
To achieve this, you can extend the layer configuration of the basemap layers in your app.json
with the visibleForWkids
property.
This is a list of WKIDs for which the layer should be visible.
If the current SRS of the map is not included in that list, the layer will not be visible.
The following sample configuration shows how to define a basemap
that contains two layers that are displayed or hidden depending on the map’s reference system:
{
"id": "depends_on_wkid",
"title": "depends on wkid",
"selected": true,
"basemap": {
"type": "GROUP",
"layers": [
{
"id": "wmsnwalkis",
"url": "https://www.wms.nrw.de/geobasis/wms_nw_dvg?",
"type": "WMS",
"title": "WMS NW DVG",
"description": "This layer will be used when spatial reference system is set to 3857",
"visibleForWkids": [3857]
},
{
"title": "Liegenschaftskarte NRW",
"url": "https://www.wms.nrw.de/geobasis/wms_nw_alkis",
"description": "This layer will be used when spatial reference system is set to 25832 or 25833",
"type": "WMS",
"id": "nrwwmsalkis",
"visibleForWkids": [25832, 25833]
}
]
}
}
Non-basemap layer
In addition to being able to restrict the layers of the basemaps, you can configure this for any layer of your map configuration. This can be done by extending the configuration of a layer, as described in the basemaps section above.
However, this imposes restrictions on the use of the table of content (TOC). This is because restricting a layer results in automatic visibility updates when the spatial reference of the map changes. Therefore, the user cannot control the visibility of the layer in a consistent manner. For this reason, layers that are restricted to a certain SRS are hidden from the TOC. You can circumvent this issue by adding the layers that are mutually exclusive with regard to their SRSs, to a common group layer. This group layer will be displayed in the TOC and you can then control the visibility of both sublayers through the group layer.