Reputation: 24012
I am adding a Polygon like this:
PolygonOptions options = new PolygonOptions();
for (int x = 0; x <= 360; x++) {
//get LatLng ll
options.add(ll);
}
options.strokeColor(Color.BLUE);
options.strokeWidth(2);
options.fillColor(Color.CYAN);
map.addPolygon(options);
What i get is a blue stroke polygon(circle). But I am not able to fill it with a color(it just empty). What am i missing?
Thank You
Upvotes: 2
Views: 1966
Reputation: 1
if duplicate points exits in list then also fill color will be not shown. actually I'm adding same point list two time into polygon's point list that the issue in my case
Upvotes: 0
Reputation: 131
According to the Docs, to fill the polygon with color, the vertices should be added in clockwise order. If you want to make holes, they should be added in counter-clockwise order
List<GeoPoint> geoPoints = new ArrayList<>();
//clockwise
geoPoints.add(new GeoPoint(-8.146242825034385, -29.267578125));
geoPoints.add(new GeoPoint(-12.8974891, -25.3125));
geoPoints.add(new GeoPoint(-23.40276490, -33.585937499999));
geoPoints.add(new GeoPoint(-17.895114303, -40.51757812));
Polygon polygon = new Polygon(); //see note below
geoPoints.add(geoPoints.get(0)); //forces the loop to close(connect last point to first point)
polygon.getFillPaint().setColor(Color.RED); //set fill color,
polygon.setPoints(geoPoints);
//polygons supports holes too, points should be in a counter-clockwise order
// List<List<GeoPoint>> holes = new ArrayList<>();
// holes.add(geoPoints); //HERE geopoints has to be a different list from above
// polygon.setHoles(holes);
Upvotes: 0