Ignore invalid location updates
Avoid passing invalid locations along to the map view delegate or user location annotation. Also, If the user wants to visit the Prime Meridian or Equator, that’s their prerogative. Mapbox GL should show them where they’re at. Null Island is a different story. Fixes #1912.
This commit is contained in:
@@ -2309,7 +2309,7 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
|
||||
{
|
||||
if ( ! _showsUserLocation || ! newLocation || ! CLLocationCoordinate2DIsValid(newLocation.coordinate)) return;
|
||||
|
||||
if ([newLocation distanceFromLocation:oldLocation] || ! oldLocation)
|
||||
if (! oldLocation || ! CLLocationCoordinate2DIsValid(oldLocation.coordinate) || [newLocation distanceFromLocation:oldLocation])
|
||||
{
|
||||
self.userLocation.location = newLocation;
|
||||
|
||||
|
||||
@@ -37,13 +37,13 @@ NS_ASSUME_NONNULL_END
|
||||
|
||||
- (void)setLocation:(CLLocation *)newLocation
|
||||
{
|
||||
if ([newLocation distanceFromLocation:_location] && newLocation.coordinate.latitude != 0 &&
|
||||
newLocation.coordinate.longitude != 0)
|
||||
{
|
||||
[self willChangeValueForKey:@"location"];
|
||||
_location = newLocation;
|
||||
[self didChangeValueForKey:@"location"];
|
||||
}
|
||||
if ( ! newLocation || ! CLLocationCoordinate2DIsValid(newLocation.coordinate)) return;
|
||||
if ( _location && CLLocationCoordinate2DIsValid(_location.coordinate) && [newLocation distanceFromLocation:_location] == 0) return;
|
||||
if (newLocation.coordinate.latitude == 0 && newLocation.coordinate.longitude == 0) return;
|
||||
|
||||
[self willChangeValueForKey:@"location"];
|
||||
_location = newLocation;
|
||||
[self didChangeValueForKey:@"location"];
|
||||
}
|
||||
|
||||
- (BOOL)isUpdating
|
||||
|
||||
Reference in New Issue
Block a user