MapLayersManager

class MapLayersManager(dispatchers: CoroutineDispatchers, httpClient: HttpClient, mapPrefs: MapPrefs, layersDir: Path = mapLayersDirectory(), fileSystem: FileSystem = mapLayerFileSystem())(source)

Owner of the imported map-layer list, its on-disk persistence, and the import plumbing.

Common code because every host imports layers: both Android flavours and the desktop app observe mapLayers and render it their own way. This class is the single home for everything that is not the final overlay draw.

Layers persist as files under mapLayersDirectory; hidden and network state lives in MapPrefs. Nothing here touches a platform URI type — an import arrives as a PickedMapFile whose bytes the caller already knows how to read, which is what lets one implementation serve a ContentResolver and a plain file path alike.

Constructors

Link copied to clipboard
constructor(dispatchers: CoroutineDispatchers, httpClient: HttpClient, mapPrefs: MapPrefs, layersDir: Path = mapLayersDirectory(), fileSystem: FileSystem = mapLayerFileSystem())

Properties

Link copied to clipboard
val mapLayers: StateFlow<List<MapLayerItem>>

Functions

Link copied to clipboard
fun addGeoJsonLayer(name: String, geoJson: String)

Import a GeoJSON string (e.g. handed back by the Site Planner headless bridge) as a visible local overlay, reusing the same storage-backed layer plumbing as file imports.

Link copied to clipboard

Import a file the user picked. Unsupported types and unreadable sources are logged and skipped.

Link copied to clipboard

Returns an error message if name/url are invalid, or null on success. Adds a persisted network layer.

Link copied to clipboard
suspend fun readLayerBytes(layerItem: MapLayerItem): ByteArray?

The layer's bytes: fetched for a network layer, read from storage otherwise.

Link copied to clipboard
fun refreshMapLayer(layerId: String)

Bump a layer's MapLayerItem.refreshToken so renderers re-read it (used for network-layer refresh).

Link copied to clipboard
fun removeMapLayer(layerId: String)
Link copied to clipboard