title: Adding custom overlay in map view
body: <p>i'm new to iOS and my goal is to add custom overlay in map view using Swift 3 and MapKit. I've followed this <a href="https://stackoverflow.com/questions/9049790/add-inverted-circle-overlay-to-map-view">Add inverted circle overlay to map view</a>.
  Here is the code:</p>
  
  <pre><code>import UIKit
  import MapKit
  
  class MyMapOverlayRenderer: MKOverlayRenderer {
  
  let diameter: Double
  let fillColor: UIColor
  
  init(overlay: MKOverlay, diameter: Double, fillColor: UIColor) {
  
      self.diameter = diameter
      self.fillColor = fillColor
      super.init(overlay: overlay)
  
  }
  
  override func draw(_ mapRect: MKMapRect, zoomScale: MKZoomScale, in context: CGContext) {
  
      let path = UIBezierPath(rect: CGRect(x: mapRect.origin.x, y: mapRect.origin.y, width: mapRect.size.width, height: mapRect.size.height))
      path.usesEvenOddFillRule = true
      let radiusInMapPoints = diameter * MKMapPointsPerMeterAtLatitude(self.overlay.coordinate.latitude)
      let radiusSquared = MKMapSize(width: radiusInMapPoints, height: radiusInMapPoints)
      let regionOrigin = MKMapPointForCoordinate(self.overlay.coordinate)
      var regionRect = MKMapRect(origin: regionOrigin, size: radiusSquared)
      regionRect = MKMapRectOffset(regionRect, -radiusInMapPoints / 2, -radiusInMapPoints / 2)
      regionRect = MKMapRectIntersection(regionRect, MKMapRectWorld)
  
      let cornerRadius = CGFloat(regionRect.size.width / Double(2))
  
      let excludePath = UIBezierPath(roundedRect: CGRect(x: regionRect.origin.x, y: regionRect.origin.y, width: regionRect.size.width, height: regionRect.size.height), cornerRadius: cornerRadius)
      path.append(excludePath)
  
  
      context.setFillColor(fillColor.cgColor)
      context.addPath(path.cgPath)
      context.fillPath()
  
  }
  }
  </code></pre>
  
  <p>Eventually the overlay is shown without exclude path (a circle), any suggestions?</p>