I got Response between two points from Directions API and parsed it and draw Polyline on the map but the problem is the line being draw over building
The code to draw the polyline:
JSONArray steps = response.getJSONObject(0).getJSONArray("legs").getJSONObject(0).getJSONArray("steps");
PolylineOptions rectOptions = new PolylineOptions();
for (int i = 0; i < steps.length(); i++) {
//add start_location
JSONObject stepS = steps.getJSONObject(i).getJSONObject("start_location");
rectOptions.add(new LatLng(stepS.getDouble("lat"), stepS.getDouble("lng")));
//add end location
JSONObject stepE = steps.getJSONObject(i).getJSONObject("end_location");
rectOptions.add(new LatLng(stepE.getDouble("lat"), stepE.getDouble("lng")));
EDIT : I found the solution
rectOptions.addAll(PolyUtil.decode(steps.getJSONObject(i).getJSONObject("polyline").getString("points")));
Solution : adding this line solved the problem
rectOptions.addAll(PolyUtil.decode(steps.getJSONObject(i).getJSONObject("polyline").getString("points")));