A Kotlin Library for Drawing Routes on Google Maps for Android

A Kotlin Library for Drawing Routes on Google Maps for Android

Introducing DrawRoute: A Kotlin Library for Drawing Routes on Google Maps for Android. A compact way to draw routes in your Android app

I am happy to share DrawRoute, an open source route-drawing library to be used with the Google Maps API for Android.

Tech stack: Kotlin, OkHttp, RxJava, and AndroidX.

Before Diving In

The library uses the Google Directions API to fetch route information when drawing on the map. It is not free and requires you to have a project with this API enabled as well as a billing account.

See how to get started.

A New Kotlin Library

This library is completely written in Kotlin and wraps on the boilerplate code involved in consuming the Google Directions API using reactive programming for more control and precision. It also exposes an extension function that can be used on the Google Maps object itself once the map is ready.

Integration steps

In your build.gradle file (project level), add the following in the allProjects block:

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

Then in your build.gradle (app level), add the following in the dependencies block:

dependencies {
    implementation 'com.github.malikdawar:drawroute:1.1-rx'
}

Once you’ve successfully integrated the Google Maps API and followed the integration steps above, you can call the drawRouteOnMap method that will draw the route on the map and return as an Rx-Disposable, which should be used to dispose of the executed subscription.

A helper moveCameraOnMapmethodis also added in the library used here to focus and zoom on the source location before drawing the route.

kotlin mobile

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Sync Mobile Development Teams with Kotlin Multiplatform

In mobile app development, the main challenge for developers is whether the app should be built for native or cross-platform frameworks. The best way to solve this dilemma is to actually test both of them using the Kotlin Multiplatform approach. Teams can easily synchronize and deliver apps for different platforms simultaneously with this method.

How to Develop an Android App with Kotlin?

AppClues Infotech is a top Mobile App Development Company in USA building high-quality Android, iOS, and Native apps for Startups, SMBs, & Enterprises. Contact us now!

Kotlin 1.4 Online Event: Kotlin everywhere: Android, Mobile Multiplatform, Kotlin/JS

Kotlin 1.4 Online Event: Kotlin everywhere: Android, Mobile Multiplatform, Kotlin/JS. State of Kotlin in Android. It's time for Kotlin Multiplatform Mobile. Kotlin/JS in 1.4 and Beyond. Diving into Kotlin Multiplatform

Top Kotlin Android App Development Company in USA

AppClues Infotech is a top Mobile App Development Company in USA building high-quality Android, iOS, and Native apps for Startups, SMBs, & Enterprises. Contact us now!

Top-notch Kotlin App Development Company in USA

AppClues Infotech is a top Mobile App Development Company in USA building high-quality Android, iOS, and Native apps for Startups, SMBs, & Enterprises. Contact us now!