Created
November 19, 2013 21:54
-
-
Save joeldrotleff/7553256 to your computer and use it in GitHub Desktop.
Objective-C category to get the radius of an MKMapView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment