My question is from my location and when I reach the goal I finish the polylinea and launch another activity I share my code
private fun cargarURL(url:String){
val queue = Volley.newRequestQueue(this)
val solictud = StringRequest(Request.Method.GET, url, Response.Listener {
response ->
Log.d("HTTP", response)
val coordenadas = ObtenerCoordenadas(response)
if (rutaMarcada != null){
rutaMarcada?.remove()
}
rutaMarcada = mMap.addPolyline(coordenadas)
}, Response.ErrorListener { })
queue.add(solictud)
}
private fun ObtenerCoordenadas(json:String): PolylineOptions {
val gson = Gson()
val objeto = gson.fromJson(json, com.voxpop.juckevox.juckevox.Response::class.java)
val puntos = objeto.routes?.get(0)!!.legs?.get(0)!!.steps!!
var coordenadas = PolylineOptions()
for (punto in puntos){
coordenadas.add(punto.start_location?.toLatLng())
coordenadas.add(punto.end_location?.toLatLng())
}