I am currently creating an application which uses Google Maps with a lot of polygons rendered on it. My problem is, when two polygons overlap (which may happen quite often in my data set) the lower one will become a little darker. What I want to do is to clear what is beneath the polygon before rendering it.
In iOS I did it like this:
class MyMKRenderer : MKPolygonRenderer {
override func draw(_ mapRect: MKMapRect, zoomScale: MKZoomScale, in context: CGContext) {
context.saveGState()
context.setBlendMode(.clear)
context.setFillColor(self.fillColor!.cgColor)
context.setStrokeColor(UIColor.white.cgColor)
context.setLineWidth(1.0)
if polygon.pointCount > 1 {
context.beginPath()
let firstPoint = point(for: polygon.points()[0])
context.move(to: CGPoint(x: CGFloat(firstPoint.x), y: CGFloat(firstPoint.y)))
for i in 1 ..< polygon.pointCount {
let secondPoint = point(for: polygon.points()[i])
context.addLine(to: CGPoint(x: CGFloat(secondPoint.x), y: CGFloat(secondPoint.y)))
}
context.closePath()
context.drawPath(using: .fillStroke)
}
context.restoreGState()
super.draw(mapRect, zoomScale: zoomScale, in: context)
}
}
But I can't seem to find a similar way to do it in Android.
Picture of the issue:
Does anybody know a way?