Skip to content

Instantly share code, notes, and snippets.

@mizutori
Created January 6, 2019 09:02
Show Gist options
  • Save mizutori/49696e75f9bb30bb3e1c0d846a65cb30 to your computer and use it in GitHub Desktop.
Save mizutori/49696e75f9bb30bb3e1c0d846a65cb30 to your computer and use it in GitHub Desktop.
private fun addPolyline() {
locationService?.locationList?.let{locationList ->
runningPathPolyline?.let{
val toLocation = locationList[locationList.size - 1]
val to = LatLng(
toLocation.latitude,
toLocation.longitude
)
val points = it.points
points.add(to)
it.points = points
} ?: run{
if (locationList.size > 1) {
val fromLocation = locationList[locationList.size - 2]
val toLocation = locationList[locationList.size - 1]
val from = LatLng(
fromLocation.latitude,
fromLocation.longitude
)
val to = LatLng(
toLocation.latitude,
toLocation.longitude
)
this.runningPathPolyline = map.addPolyline(
PolylineOptions()
.add(from, to)
.width(polylineWidth.toFloat()).color(Color.parseColor("#801B60FE")).geodesic(true)
)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment