Skip to content

Instantly share code, notes, and snippets.

@joeldrotleff
Created November 19, 2013 21:54

Revisions

  1. joeldrotleff created this gist Nov 19, 2013.
    27 changes: 27 additions & 0 deletions MKMapView+Utilities.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    //
    // Created by Joel Drotleff on 11/19/13.
    // Copyright (c) 2013 Joel Drotleff. All rights reserved.
    //


    #import <MapKit/MapKit.h>
    #import <CoreLocation/CoreLocation.h>
    #import "MKMapView+Utilities.h"


    @implementation MKMapView (Utilities)

    - (CLLocationDistance)getRadius
    {
    // init center location from center coordinate
    CLLocation *centerLocation = [[CLLocation alloc] initWithLatitude:self.centerCoordinate.latitude
    longitude:self.centerCoordinate.longitude];
    double topCenterLat = centerLocation.coordinate.latitude-self.region.span.latitudeDelta/2.;
    CLLocation *topCenterLocation = [[CLLocation alloc] initWithLatitude:topCenterLat
    longitude:centerLocation.coordinate.longitude];

    CLLocationDistance distance = [centerLocation distanceFromLocation:topCenterLocation];
    return distance;
    }

    @end