getPolylinePrefix

fun getPolylinePrefix(polyline: List<LatLng>, percentage: Double): List<LatLng>

Returns a new polyline that is a prefix of the original polyline, representing a given percentage of the original polyline's length.

Note: The returned polyline should be displayed on the map with geodesic set to true to ensure it follows the same spherical path as the calculation.

Return

a new polyline representing the prefix, or an empty list if the original polyline is empty or the percentage is outside the range 0, 1

Parameters

polyline

the original polyline

percentage

the percentage of the original polyline's length to include in the prefix