title: Android Google Maps: Paint the entire map except for selected polygons
body: <h1>My design</h1>
  
  <p>I am writing an Android app with a Google Map component. In this app, any user can perform specific map actions in certain regions. Therefore, I want to paint the entire map in grey - except for some permitted areas defined by Polygons.</p>
  
  <p><img src="https://i.stack.imgur.com/9AuHC.png" alt="enter image description here">
  <strong>A Polygon - I would like to paint anything outside them.</strong></p>
  
  <h1>Current code</h1>
  
  <p>The problem is that painting specific polygons is pretty straightforward with <code>.fillColor(Color.SOME-COLOR))</code>, so I can easily fill the polygons with color:</p>
  
  <pre class="lang-java prettyprint-override"><code>FeatureCollection featureCollection = (FeatureCollection)geoJSON;
  List&lt;Feature&gt; features = featureCollection.getFeatures();
  for (Feature f : features)
  {
      Polygon poly = (Polygon) f.getGeometry();
      &lt;...&gt;
      int c = Color.RED;
      com.google.android.gms.maps.model.Polygon toAdd = 
          map.addPolygon(polygonOptions.strokeColor(c)
          .fillColor(Color.RED));
      toAdd.setGeodesic(true);
  }
  </code></pre>
  
  <h1>How do I paint everything else?</h1>
  
  <p>How can I do the opposite - use <code>fillColor(Color.TRANSPARENT)</code> and paint all the parts of the map that are not covered by a Polygon with a given color?</p>