title: MKPolygon area calculation
body: <p>I'm trying to make an area calculation category for MKPolygon.
  I found some JS code <a href="https://github.com/mapbox/geojson-area/blob/master/index.js#L1" rel="noreferrer">https://github.com/mapbox/geojson-area/blob/master/index.js#L1</a> with a link to the algorithm: <a href="http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409" rel="noreferrer">http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409</a>.
  It says:
  <img src="https://i.stack.imgur.com/vift6.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/M0K8n.png" alt="enter image description here"></p>
  
  <p>Here is my code, which gave a wrong result (thousands times more than actual):</p>
  
  <pre><code>#define kEarthRadius 6378137
  @implementation MKPolygon (AreaCalculation)
  - (double) area {
      double area = 0;
      NSArray *coords = [self coordinates];
      if (coords.count &gt; 2) {
          CLLocationCoordinate2D p1, p2;
          for (int i = 0; i &lt; coords.count - 1; i++) {
              p1 = [coords[i] MKCoordinateValue];
              p2 = [coords[i + 1] MKCoordinateValue];
              area += degreesToRadians(p2.longitude - p1.longitude) * (2 + sinf(degreesToRadians(p1.latitude)) + sinf(degreesToRadians(p2.latitude)));
          }
  
          area = area * kEarthRadius * kEarthRadius / 2;
      }
  
      return area;
  }
  - (NSArray *)coordinates {
      NSMutableArray *points = [NSMutableArray arrayWithCapacity:self.pointCount];
      for (int i = 0; i &lt; self.pointCount; i++) {
          MKMapPoint *point = &amp;self.points[i];
          [points addObject:[NSValue valueWithMKCoordinate:MKCoordinateForMapPoint(* point)]];
      }
      return points.copy;
  }
  
  double degreesToRadians(double radius) {
      return radius * M_PI / 180;
  }
  
  @end
  </code></pre>
  
  <p>What did I miss?</p>