Код: Выделить всё
if (mapState.lineSteps.isNotEmpty()) {
val polylinePoints = remember { mapState.lineSteps.map { LatLng(it.lat, it.lon) } }
Polyline(
points = polylinePoints
)
}
Код: Выделить всё
val arrowBitmapDescriptor: BitmapDescriptor by remember { mutableStateOf(BitmapDescriptorFactory.fromResource(R.drawable.arrow)) }
var numberOfArrows: Int = mapState.busStops.size / 3
if (numberOfArrows > 15) numberOfArrows = 15
val stepsBetweenArrows: Int = mapState.lineSteps.size / numberOfArrows
var stepsToNextArrow = 0
var currentPos: LatLng
var previousPos: LatLng = LatLng(mapState.lineSteps[0].lat, mapState.lineSteps[0].lon)
for (step in mapState.lineSteps) {
currentPos = LatLng(step.lat, step.lon)
if (stepsToNextArrow >= stepsBetweenArrows) {
Polyline(
points = listOf(previousPos, currentPos),
startCap = RoundCap(),
endCap = CustomCap(arrowBitmapDescriptor, 30f),
color = Color(0xff0e71b8),
width = 7f,
jointType = JointType.ROUND,
geodesic = true
)
stepsToNextArrow = 0
} else {
Polyline(
points = listOf(previousPos, currentPos),
color = Color(0xff0e71b8),
width = 7f,
jointType = JointType.ROUND,
geodesic = true
)
}
stepsToNextArrow++
previousPos = currentPos
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... mpose-maps