كوتلن
Kotlin 2.x / JVM 11+ (depends on bardiya-map-java)
A Kotlin-idiomatic wrapper over the Java client: a DSL builder, default and named arguments, and use blocks instead of try-with-resources. The Java artifact comes as a transitive dependency.
Install
Gradle
implementation("com.bardiyamap:bardiya-map-kotlin:0.1.0")What it supports
- The full Maps and Tracking surface of the Java client
- Bardiya.create { } DSL configuration
- use { } lifecycle blocks
Initialise the client
kotlin
val bardiya = Bardiya.create {
mapsApiKey = System.getenv("BARDIYA_MAPS_KEY")
trackingApiKey = System.getenv("BARDIYA_TRACKING_KEY")
}
bardiya.use {
val places = it.maps.searchPlaces("coffee", latitude = 30.0444, longitude = 31.2357, limit = 5)
println(places.count)
}Typical operation
Suspend-friendly wrapping
kotlin
suspend fun search(query: String) = withContext(Dispatchers.IO) {
bardiya.maps.searchPlaces(query, limit = 5)
}Things that catch people out
- The API is blocking. Wrap calls in withContext(Dispatchers.IO) rather than calling from a coroutine on the main dispatcher.
- Your project must resolve bardiya-map-java from Maven Central; a private repository does not exist.
