neaten up locate user

This commit is contained in:
Justin R. Miller
2014-06-01 13:56:27 -07:00
parent 5d588c5997
commit 6819b9dea5

View File

@@ -175,11 +175,7 @@ llmr::Settings_NSUserDefaults *settings = nullptr;
- (void)locateUser
{
[NSObject cancelPreviousPerformRequestsWithTarget:self.locationManager selector:@selector(stopUpdatingLocation) object:nil];
[self.locationManager startUpdatingLocation];
[self.locationManager performSelector:@selector(stopUpdatingLocation) withObject:nil afterDelay:5.0];
}
#pragma mark - Destruction
@@ -205,7 +201,12 @@ llmr::Settings_NSUserDefaults *settings = nullptr;
{
CLLocation *latestLocation = locations.lastObject;
[self.mapView setCenterCoordinate:CLLocationCoordinate2DMake(latestLocation.coordinate.latitude, latestLocation.coordinate.longitude) zoomLevel:17 animated:YES];
if ([latestLocation distanceFromLocation:[[CLLocation alloc] initWithLatitude:self.mapView.centerCoordinate.latitude longitude:self.mapView.centerCoordinate.longitude]] > 100)
{
[self.mapView setCenterCoordinate:CLLocationCoordinate2DMake(latestLocation.coordinate.latitude, latestLocation.coordinate.longitude) zoomLevel:17 animated:YES];
[self.locationManager stopUpdatingLocation];
}
}
#pragma clang diagnostic pop