title: Add a label in the center of a polygon in MapKit
body: <p>There are similarly named questions, like <a href="https://stackoverflow.com/questions/33505355/add-a-text-label-to-a-polygon-in-google-maps-for-ios-swift">this one</a>, but that is not what I'm looking for.</p>
  
  <p>Basically I'm drawing a bunch of <code>MKPolygon</code>s on a standard map giving them a stroke, a random colour etc.. I'd like to be able to "name" them, adding a label or perhaps a UIView with a label so it looks nice. Is this possible?</p>
  
  <p>Here's how my map looks like</p>
  
  <p><a href="https://i.stack.imgur.com/Njic3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Njic3.jpg" alt="enter image description here"></a></p>
  
  <p>And here's the implementation</p>
  
  <pre><code>func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -&gt; MKOverlayRenderer {
  
      if overlay is MacaronMKPolygon {
  
          let macaronOverlay = overlay as! MacaronMKPolygon
  
          let polygonView = MKPolygonRenderer(overlay: macaronOverlay)
          polygonView.strokeColor = UIColor.gray
          polygonView.lineWidth = 1
          polygonView.alpha = shouldShowMacaron ? 1.0 : 0.0
          polygonView.fillColor = macaronOverlay.color
          return polygonView
  
      }
  
      return MKOverlayRenderer()
  }
  </code></pre>