title: Draw Custom shapes (Geofences) zones on MKMapView
body: <p>I'm creating an <code>Universal app</code> and I have to create custom safe zones on the <code>map view</code>.</p>
  
  <p>What I do is: </p>
  
  <ol>
  <li>Add a new <code>UIView</code> as superview of <code>map view</code> called <code>squareZone</code>. </li>
  <li>To the <code>squareZone</code> view I add <code>UIPanGestureRecognizer</code>, <code>UIPinchGestureRecognizer</code> and <code>UIRotationGestureRecognizer</code> so I can move, rotate and zoom (in and out).</li>
  </ol>
  
  <p>Here is the code of SquareZone</p>
  
  <pre><code>- (id)initWithFrame:(CGRect)frame{
      self = [super initWithFrame:frame];
      if (self) {
          self.opaque = NO;
          self.layer.cornerRadius = 5.0f;
      }
      return self;
  }
  
  - (void)drawRect:(CGRect)rect {
      [super drawRect:rect];
  
      UIColor *color = [UIColor colorWithRed: 0.765 green: 0.439 blue: 0.443 alpha: 0.658];
  
      UIBezierPath *rectanglePath = [UIBezierPath bezierPathWithRect: rect];
      [color setFill];
      [rectanglePath fill];
      [UIColor.whiteColor setStroke];
      rectanglePath.lineWidth = 5;
      CGFloat rectanglePattern[] = {2, 3};
      [rectanglePath setLineDash: rectanglePattern count: 2 phase: 0];
      [rectanglePath stroke];
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/DMggh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DMggh.png" alt="squareZone"></a></p>
  
  <p>Now, when the user adjust the <code>squareZone</code> I have to show on a <code>UILabel</code> the distance between each point in meters. For that task I'm using </p>
  
  <pre><code>- (CLLocationDistance)distanceFromLocation:(const CLLocation *)location
  </code></pre>
  
  <p>How can I add/show the four <code>UILabels</code> when the user interacts with the <code>squareZone</code>.</p>
  
  <p>I need some light here. I had seen many tutorials but I cannot imagine how can this is posible. For reference, there is an app called</p>
  
  <p>Trax: <a href="https://itunes.apple.com/us/app/trax-gps-tracker/id647170688?mt=8" rel="nofollow noreferrer">https://itunes.apple.com/us/app/trax-gps-tracker/id647170688?mt=8</a></p>
  
  <p>I have to do the same Drawing Geofence Zone.</p>
  
  <p>Thanks in advance.</p>