---
title: "Download map tiles within a polygonal area - Kotlin SDK | Mobile sdk | Mobile sdk android | Android"
description: "Offline API allows you to download tiles within a polygonal area defined by a GeoJSON Polygon."
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Download map tiles within a polygonal area - Kotlin SDK

The MapTiler SDK for Kotlin provides a powerful Offline Pack API that allows you to download tiles within a polygonal area defined by a GeoJSON Polygon for use without an active internet connection.

Before you begin, ensure you have followed the [Android getting started with offline pack API](https://docs.maptiler.com/mobile-sdk/android/examples/offline-get-started/) to set up your project and obtain your API key.

## Offline Pack for a Polygon (GeoJSON Polygon)

```kotlin
import com.maptiler.maptilersdk.offline.MTOfflineManager
import com.maptiler.maptilersdk.offline.MTOfflineRegionDefinition
import com.maptiler.maptilersdk.offline.MTOfflineRegionGeometry
import com.maptiler.maptilersdk.map.style.MTMapReferenceStyle
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch

// Your GeoJSON Polygon
val polygonGeoJson = """
{
    "type": "Polygon",
    "coordinates": [[
        [8.5417, 47.3769],
        [8.5457, 47.3769],
        [8.5457, 47.3799],
        [8.5417, 47.3799],
        [8.5417, 47.3769]
    ]]
}
"""

MainScope().launch {
    try {
        // Parse the polygon geometry from GeoJSON
        val geometry = MTOfflineRegionGeometry.Polygon.fromGeoJson(polygonGeoJson)

        // Create the polygon definition
        val polyDefinition = MTOfflineRegionDefinition(
            geometry = geometry,
            minZoom = 0,
            maxZoom = 14,
            referenceStyle = MTMapReferenceStyle.STREETS
        )

        // Create and download the pack
        val pack = MTOfflineManager.createPack(context, polyDefinition)
        pack.download()
        println("Polygon download started")
    } catch (e: Exception) {
        e.printStackTrace()
    }
}
```

## Learn more

For more information browse our [API Reference](https://docs.maptiler.com/mobile-sdk/android/api/)

Check out our [SDK Kotlin Examples](https://docs.maptiler.com/mobile-sdk/android/examples/).
