Skip to content

tintinscorpion/Dual-color-Polyline-Animation

Repository files navigation

Dual-color-Polyline-Animation

Android Arsenal Platform
This library will help to show the polyline in dual color similar as Uber with animation in the demo.

Demo



Dependency

App Level:
implementation 'com.github.tintinscorpion:Dual-color-Polyline-Animation:{latest_version}'
Project Level:
maven { url 'https://jitpack.io' }

Steps:

Pass the googlemap context and Latlng points stored in arraylist.

   In Kotlin:

   MapAnimator.animateRoute(googleMap, polyLineList)

   In Java:

   MapAnimator.INSTANCE.animateRoute(googleMap, polyLineList);

polyLineList refers to the List of LatLng, the coordinates which is to be decoded from the directions api of google.

Additional:

You can change the color and animation time and the width of the polyline by passing :

MapAnimator.setPrimaryLineColor(color)
MapAnimator.setSecondaryLineColor(color) 
MapAnimator.setPercentCompletion(@IntegerRes time: Int) default is 2500 //amount of time to draw the initial polyline 
MapAnimator.setColorFillCompletion(@IntegerRes time: Int) default is 1800 //amount of time to refill the primary color
MapAnimator.setDelayTime(@IntegerRes time: Int) default is 200 //amount of time for delaying to run the sequenceof animation
MapAnimator.setPrimaryLineCompletion(@IntegerRes time: Int) default is 2000 //amount of time required for the animation to reach from point A to B
MapAnimator.setPolylineWidth(width: Float) default is 8f 

If you are calling these methods, call it before animateRoute() method call else it won't reflect.

Note:

If you are using proguard then, write this in proguard-rules.pro

//For android studio 4.0 and above- 
-keepclassmembers class com.logicbeanzs.uberpolylineanimation.* {
  <fields>;
  <init>();
  <methods>;
}


//For android studio below 4.0-
-keep class com.logicbeanzs.uberpolylineanimation.**



Developers

Pritam Dasgupta

License

MIT License Copyright (c) 2018 Pritam Dasgupta

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.