i am trying to draw polyline for googlemap, it is working fine upto android version 4.4(kitkat) but it is not working in android 5.0(lollipop). what to do for working in lol
Try the modified codes for your onPostExecute
:
@Override
protected void onPostExecute(List>> result) {
ArrayList points = null;
//PolylineOptions lineOptions = null;
//MarkerOptions markerOptions = new MarkerOptions();
points = new ArrayList();
// Traversing through all the routes
for(int i=0;i();
//lineOptions = new PolylineOptions();
// Fetching i-th route
List> path = result.get(i);
// Fetching all the points in i-th route
for(int j=0;j point = path.get(j);
double lat = Double.parseDouble(point.get("lat"));
double lng = Double.parseDouble(point.get("lng"));
LatLng position = new LatLng(lat, lng);
points.add(position);
}
// Adding all the points in the route to LineOptions
//lineOptions.addAll(points);
//lineOptions.width(4);
//lineOptions.color(Color.BLUE);
}
// Drawing polyline in the Google Map for the i-th route
//map.addPolyline(lineOptions);
lineOptions.addAll(points);
lineOptions.width(4);
lineOptions.color(Color.BLUE);
line = map.addPolyline(lineOptions);
}
I moved your list points
instance before for
loop, and also lineOptions
after for
loop.
Hope this help.