'Google map Polygon: Set transparent for circles intersecting

I follow the post Change map opacity outside circle of Google Maps JavaScript API v3, but I have multi circles and sometimes they are intersecting. In the intersecting, they are not transparent. How I can set them transparent?

Map have multi circles

Code On jsfiddle.net

Thank you.

// This example uses the Google Maps JavaScript API's Data layer
// to create a rectangular polygon with 2 holes in it.
const places = [
  {
    center: { "lat": 1.3512492664554796, "lng": 103.85072488875811 },
    radius: 2000
  },
  {
    center: { "lat": 1.3225896205754812, "lng": 103.86600275130694 },
    radius: 2000
  },
  {
    center:{ "lat": 1.3136655910729036, "lng": 103.88866205306475 },
    radius: 2000
  },
  {
    center: { "lat": 1.305427997082587, "lng": 103.83613367171709 },
    radius: 2000
  }
];

let map;

const mapDefault = {
    
};

function initMap() {
    map = new google.maps.Map(document.getElementById('map'), mapDefault);
  const bounds = new google.maps.LatLngBounds();
  
  let pathsCircle = [];
  
  places.forEach(place => {
    bounds.extend(place.center);
    pathsCircle.push(drawCircle(place.center, place.radius, 1));
  });

  map.fitBounds(bounds);
  
  const worldCoords = [
    new google.maps.LatLng(-85.1054596961173, -180),
    new google.maps.LatLng(85.1054596961173, -180),
    new google.maps.LatLng(85.1054596961173, 180),
    new google.maps.LatLng(-85.1054596961173, 180),
    new google.maps.LatLng(-85.1054596961173, 0)
  ];
  
  new google.maps.Polygon({
    paths: [worldCoords, ...pathsCircle],
    strokeColor: '#fff',
    strokeOpacity: 0,
    strokeWeight: 0,
    fillColor: '#000',
    fillOpacity: 0.3,
    map,
  });
}

function drawCircle(point, radius, dir) {
}

That is my code.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source