Skip to content

Custom tile source #92

Answered by p-lr
MikhailShavykin asked this question in Q&A
Aug 14, 2023 · 3 comments · 1 reply
Discussion options

You must be logged in to vote

Here is a complete example (note that OSM blocks some user-agents):

/**
 * Shows how MapCompose behaves with remote HTTP tiles.
 */
class HttpTilesVM : ViewModel() {
    private val tileStreamProvider = makeTileStreamProvider()

    private val lvlCnt = 8  // avoid using level higher than 16
    private val mapSize = mapSizeAtLevel(lvlCnt - 1, tileSize = 256)
    val state: MapState by mutableStateOf(
        MapState(lvlCnt, mapSize, mapSize, workerCount = 16).apply {
            addLayer(tileStreamProvider)
            scale = 0f
        }
    )
}

/**
 * A [TileStreamProvider] which performs HTTP requests.
 */
private fun makeTileStreamProvider() =
    TileStreamProvider { row, col, zo…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@p-lr
Comment options

Answer selected by p-lr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants