/PolylineAnimator

Android google maps polyline animator library

Primary LanguageKotlinMIT LicenseMIT

PolylineAnimator

PolylineAnimator

Android google maps polyline animator

A library that will provide an animated polyline object.

Import

  1. Add it in your root build.gradle at the end of repositories:
    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }
  1. Add the dependency
    dependencies {
        implementation 'com.github.p72b:PolylineAnimator:0.1.0'
    }

Implementation

Basic example

     override fun onMapReady(googleMap: GoogleMap) {
         mMap = googleMap

         val animatedPolyline = AnimatedPolyline(
                 mMap,
                 wayPoints
         )
         animatedPolyline.start()
     }

Styled with dotted line and callback to listen on animation events.

    override fun onMapReady(googleMap: GoogleMap) {
        mMap = googleMap

        val animatedPolyline = AnimatedPolyline(
                mMap,
                wayPoints,
                polylineOptions = PolylineOptions()
                                      .color(ContextCompat.getColor(this, R.color.colorPrimary))
                                      .pattern(
                                          listOf(
                                              Dot(), Gap(20F)
                                          )
                                      ),
                duration = 1250,
                interpolator = DecelerateInterpolator(),
                animatorListenerAdapter = object : AnimatorListenerAdapter() {
                                              override fun onAnimationEnd(animation: Animator) {
                                                  animatedPolyline.start() // e.g. endless animation
                                              }
                                          }
        )
        animatedPolyline.startWithDelay(1000)
    }

Library Dependencies:

  • play-services-maps is consumed
  • android-maps-utils 1.0.0

Benefits:

  • lightweight small library
  • fast native Polyline animation
  • kotlin based code
  • google maps polyline will be used e.g. none pixel based custom rendering

Requirements

Library: No google API key is required. The library can be used starting at:

  • MinSdk 21 (Android 5.0)

Demo App: Android google maps key is required. Runs on:

  • MinSdk 21 (Android 5.0)

Download

Check out the lib version on JitPack

Library Sample App

To build the demo app there is an android google maps key needed. Place the key inside app/signing.properties file like this:

GOOGLE_MAPS_API_KEY=key_here

Example of demo app:

DemoApp[default] DemoApp[custom styled]

Animation in video format here