Skip to main content

Polyline

You can animating the polyline with easier code. There is a feature to determine the draw of the animation.

Download#

implementation 'com.utsman.geolib:polyline:{last_version}'

Create Instance#

val animatorBuilder: PolylineAnimatorBuilder = googleMap.createPolylineAnimatorBuilder()
val polylineAnimator: PolylineAnimtor = animatorBuilder.createPolylineAnimator()

Configuration builder#

Paramtypedesc
withPrimaryPolyline(PolylineOptions.() -> Unit)PolylineAnimatorBuilderDSL param for add primary polyline
withAccentPolyline(PolylineOptions.() -> Unit)PolylineAnimatorBuilderDSL param for add accent polyline
withCameraAutoFocus(Boolean)PolylineAnimatorBuilderSet for auto zoom camera
withStackAnimationMode(StackAnimationMode)PolylineAnimatorBuilderSet for animate type polyline
createAnimatePolyline()PolylineAnimatorto create PolylineAnimator

Animating polyline#

Start animate polyline#

To start animate use startAnimate(geometries: List<LatLng>, duration: Long) and result is PointPolyline

val point = polylineAnimator.startAnimate(geometries, 2000)

Start with existing Polyline#

With PolylineOptions

val polyline = googleMap.addPolyline(polylineOptions)
polyline.withAnimate(googleMap, polylineOptions) {
stackAnimationMode = StackAnimationMode.BlockStackAnimation
}

Or with PolylineAnimator

val polyline = googleMap.addPolyline(options)
polyline.withAnimate(polylineAnimator) {
polylineDrawMode = PolylineDrawMode.Normal
}

Add points in polyline#

You can added polyline in existing polyline

val nextPoint = point.addPoints(nextGeometries)

Remove polyline#

Remove polyline on PointPolyline

val isRemoveSuccess = nextPoint.remove()

Or by geometries

val isRemoveSuccess = point.remove(nextGeometries)

Configuration with DSL#

Paramreturndesc
withPrimaryPolyline(PolylineOptions.() -> Unit)UnitDSL param for add primary polyline
withAccentPolyline(PolylineOptions.() -> Unit)UnitDSL param for add accent polyline
durationLongDuration of animation
cameraAutoUpdateBooleanSet for auto zoom camera
stackAnimationModeStackAnimationModeSet for animate type polyline
polylineDrawModePolylineDrawModeSet for draw type polyline
enableBorder(isEnable: Boolean, color: Int, width: Int)UnitSet for border of polyline
doOnStartAnimation(action: (LatLng) -> Unit)UnitDo action when animation is start
doOnEndAnimation(action: (LatLng) -> Unit)UnitDo action when animation is finish
doOnUpdateAnimation(action: (latLng: LatLng, mapCameraDuration: Int) -> Unit)UnitDo action when animation is update with duration for camera movement

Stack Animation Mode#

This is animation type of polyline

  • Button 1: StackAnimationMode.BlockStackAnimation (this default configuration)
  • Button 2: StackAnimationMode.WaitStackEndAnimation
  • Button 2: StackAnimationMode.OffStackAnimation

Polyline draw mode#

This library able to customize polyline draw mode

  • Button 1: PolylineDrawMode.Normal (this default configuration)
  • Button 2: PolylineDrawMode.Curved
  • Button 2: PolylineDrawMode.Lank