When applications state changed to "applicationEnterBackground", -mapView didUpdateUserLocation method doesn't refresh so receiving device's location is being impossible. So I can't draw user's traveled roads to the map. It only draws just one line starting from the point user started walking to the end point that user stopped walking.
Is there any method that I can draw users traveled roads in applicationEnterBackground state.
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
NSLog(@"%@ ----- %@", self, NSStringFromSelector(_cmd));
CLLocation *location = [[CLLocation alloc] initWithLatitude:userLocation.coordinate.latitude
longitude:userLocation.coordinate.longitude];
NSLog(@"latitude %+.6f, longitude %+.6f\n", userLocation.coordinate.latitude, userLocation.coordinate.longitude);
[_latitudeArray addObject:[NSString stringWithFormat:@"%f",userLocation.coordinate.latitude]];
[_longitudeArray addObject:[NSString stringWithFormat:@"%f",userLocation.coordinate.longitude]];
// check the zero point
if (userLocation.coordinate.latitude == 0.00f ||
userLocation.coordinate.longitude == 0.00f)
return;
// check the move distance
if (_points.count > 0) {
CLLocationDistance distance = [location distanceFromLocation:_currentLocation];
if (distance < 5)
return;
}
if (nil == _points) {
_points = [[NSMutableArray alloc] init];
}
[_points addObject:location];
_currentLocation = location;
[self configureRoutes];
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(userLocation.coordinate.latitude, userLocation.coordinate.longitude);
[self.mapView setCenterCoordinate:coordinate animated:YES];
}