Reputation: 534
Is there a way how I can automatic increase and decrease the width of a polyline when I zoom in and out on Google Maps V2?
It looks horrible especially on newer devices when it stays so extremely thin. But you need it that thin when zoomed out.
Upvotes: 1
Views: 2341
Reputation: 5651
Save the polyline when it is added to the map. Then perform actions on the polyline.
Example for saving the polyline to an arraylist when added to the map.
polylines = new ArrayList<Polyline>();
protected void onProgressUpdate(PolylineOptions... progress) {
if (isCancelled()) {
return;
}
if (progress[0] != null) {
// add the poly line to the map
// save the polyline for later user
if (mMap != null) {
polylines.add(mMap.addPolyline(progress[0]));
}
}
}
meanwhile back in the code act on the polyline
polylines.get(0).setWidth(width)
or
for (Polyline po: polylines){
po.setWidth(newWidth);
}
Upvotes: 4