I have an
places = ArrayList<ArrayList<LatLng>>
I am adding LatLng points into the inner ArrayList and then I have a for loop that loops and adds polylines to the map.. except it doesnt do that... How can I add polylines dynamically to the GoogleMap? I checked whether or not places was being populated and it is.
Thanks in advance.
ArrayList<Polyline> pl = new ArrayList<Polyline>();
for(int i =0; i<places.size(); i++){
pl.add(mMap.addPolyline(new PolylineOptions().addAll(places.get(i))));
Log.e("size of places", "size of places is " + places.size());
}
What is the
places
variable you have because places need to be all the locations in the line and not just 1 point.So assuming places is
ArrayList<LatLng>
then by doingplaces.get(i)
you are only giving one point and not the whole list of points;Adding multiple points in map using polyline and arraylist
Once you have list of latitude an longitudes in your List, you can use the below to draw lines.
the above worked for me in my application