openLayer

inline suspend fun <T : Layer> ContentManager.openLayer(contentKey: String, cachePolicy: CachePolicy = CachePolicy.UNBOUNDED): T?

Open contentKey as a layer narrowed to T. Returns null when the key is absent, unregistered, backed by an elevation coverage (use openElevationCoverage), or the materialized type doesn't match T.

Typical usage:

val wms: TiledImageLayer? = cm.openLayer("WMS_Neo")          // any image-type
val mvt: MvtVectorLayer? = cm.openLayer("MVT_Versatiles") // exact subtype
val any: Layer? = cm.openLayer("SomeKey") // any layer

To open in strict cache-only mode, chain setOfflineOnly: cm.openLayer<TiledImageLayer>(key)?.also { it.setOfflineOnly() }.

For bulk-open-by-category use open with a CacheCategory key.