Android : How to change a Google Map PolygonOption fill color after its drawn

on Friday, October 31, 2014


Is there a way to change a PolygonOption's fill color after it has been drawn and update a Google map without clearing and redrawing it?


What I'm currently doing is



polygonOptions.fillColor(context.getResources().getColor(R.color.polygonSolidFill));
polygonOptions.strokeWidth(2);
polygonOptions.strokeColor(Color.BLACK);
// Add some LatLngs
googleMap.addPolygon(polygonOptions);


When the user is at a certain location I want to change the fill color. What I'm doing to achieve the color update is



polygonOptions.fillColor(context.getResources().getColor(R.color.polygonSolidFill2));
googleMap.clear();
googleMap.addPolygon(polygonOptions);


However there is a small flicker in the map when its cleared and redrawn which I would like to avoid.


0 comments:

Post a Comment