Getting the response from the Google map server and parse response string to JSON format. How to get response see the Link-
Get the distance & duration between two locations in android?
Then parse & store all the Lat and Long values into ArrayList.
1 2 3 |
ArrayList <Double>lat; ArrayList <Double> lng; |
full code method-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
public void drawLine(ArrayList<Double> lat, ArrayList<Double> lng, GoogleMap map){ ArrayList<LatLng> points = new ArrayList<LatLng>(); PolylineOptions lineOptions = new PolylineOptions(); for(int i = 0; i< lat.size(); i++ ){ LatLng position = new LatLng(lat.get(i), lng.get(i)); points.add(position); } lineOptions.addAll(points); lineOptions.width(3); lineOptions.color(Color.RED); map.addPolyline(lineOptions); } |