refs #59: fixups to location tracking when invalid
Showing
1 changed file
with
12 additions
and
3 deletions
@@ -76,6 +76,7 @@ | @@ -76,6 +76,7 @@ | ||
76 | - (void)correctMinZoomScaleForBoundingMask; | 76 | - (void)correctMinZoomScaleForBoundingMask; |
77 | 77 | ||
78 | - (void)updateHeadingForDeviceOrientation; | 78 | - (void)updateHeadingForDeviceOrientation; |
79 | +- (BOOL)locationCoordinateIsValid:(CLLocationCoordinate2D)coordinate; | ||
79 | 80 | ||
80 | @end | 81 | @end |
81 | 82 | ||
@@ -2581,6 +2582,9 @@ | @@ -2581,6 +2582,9 @@ | ||
2581 | if (mode == userTrackingMode) | 2582 | if (mode == userTrackingMode) |
2582 | return; | 2583 | return; |
2583 | 2584 | ||
2585 | + if (mode == RMUserTrackingModeFollowWithHeading && ! [self locationCoordinateIsValid:userLocation.coordinate]) | ||
2586 | + mode = RMUserTrackingModeNone; | ||
2587 | + | ||
2584 | userTrackingMode = mode; | 2588 | userTrackingMode = mode; |
2585 | 2589 | ||
2586 | switch (userTrackingMode) | 2590 | switch (userTrackingMode) |
@@ -2721,7 +2725,7 @@ | @@ -2721,7 +2725,7 @@ | ||
2721 | 2725 | ||
2722 | - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation | 2726 | - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation |
2723 | { | 2727 | { |
2724 | - if ( ! showsUserLocation || _mapScrollView.isDragging) | 2728 | + if ( ! showsUserLocation || _mapScrollView.isDragging || ! [self locationCoordinateIsValid:newLocation.coordinate]) |
2725 | return; | 2729 | return; |
2726 | 2730 | ||
2727 | if ([newLocation distanceFromLocation:oldLocation]) | 2731 | if ([newLocation distanceFromLocation:oldLocation]) |
@@ -2860,11 +2864,11 @@ | @@ -2860,11 +2864,11 @@ | ||
2860 | if ([newLocation distanceFromLocation:oldLocation]) | 2864 | if ([newLocation distanceFromLocation:oldLocation]) |
2861 | trackingHaloAnnotation.coordinate = newLocation.coordinate; | 2865 | trackingHaloAnnotation.coordinate = newLocation.coordinate; |
2862 | 2866 | ||
2863 | - userLocation.layer.hidden = ((trackingHaloAnnotation.coordinate.latitude == 0 && trackingHaloAnnotation.coordinate.longitude == 0) || self.userTrackingMode == RMUserTrackingModeFollowWithHeading); | 2867 | + userLocation.layer.hidden = ( ! [self locationCoordinateIsValid:trackingHaloAnnotation.coordinate] || self.userTrackingMode == RMUserTrackingModeFollowWithHeading); |
2864 | 2868 | ||
2865 | accuracyCircleAnnotation.layer.hidden = newLocation.horizontalAccuracy <= 10; | 2869 | accuracyCircleAnnotation.layer.hidden = newLocation.horizontalAccuracy <= 10; |
2866 | 2870 | ||
2867 | - trackingHaloAnnotation.layer.hidden = ((trackingHaloAnnotation.coordinate.latitude == 0 && trackingHaloAnnotation.coordinate.longitude == 0) || newLocation.horizontalAccuracy > 10); | 2871 | + trackingHaloAnnotation.layer.hidden = ( ! [self locationCoordinateIsValid:trackingHaloAnnotation.coordinate] || newLocation.horizontalAccuracy > 10); |
2868 | 2872 | ||
2869 | if ( ! [_annotations containsObject:userLocation]) | 2873 | if ( ! [_annotations containsObject:userLocation]) |
2870 | [self addAnnotation:userLocation]; | 2874 | [self addAnnotation:userLocation]; |
@@ -2960,6 +2964,11 @@ | @@ -2960,6 +2964,11 @@ | ||
2960 | } | 2964 | } |
2961 | } | 2965 | } |
2962 | 2966 | ||
2967 | +- (BOOL)locationCoordinateIsValid:(CLLocationCoordinate2D)coordinate | ||
2968 | +{ | ||
2969 | + return (CLLocationCoordinate2DIsValid(coordinate) && ! (coordinate.latitude == 0.0 && coordinate.longitude == 0.0)); | ||
2970 | +} | ||
2971 | + | ||
2963 | #pragma mark - | 2972 | #pragma mark - |
2964 | #pragma mark Attribution | 2973 | #pragma mark Attribution |
2965 | 2974 |
-
Please register or login to post a comment