From c36e08b97658c07bb74cd950942ff6bcd98fdb06 Mon Sep 17 00:00:00 2001 From: Jason Wray Date: Mon, 31 Jul 2017 16:18:24 -0400 Subject: Return an invalid `coordinate` when `location` is nil With _location no longer initialized to an invalid coordinate, trying to access `_location.coordinate` when `_location == nil` will return `0, 0`, which is a valid coordinate. --- platform/ios/CHANGELOG.md | 4 ++++ platform/ios/src/MGLUserLocation.h | 3 +-- platform/ios/src/MGLUserLocation.m | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 43df49a9ac..2be8c56d06 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,6 +2,10 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. +## 3.6.2 + +* Fixed an issue where `MGLUserLocation.location` did not follow its documented initialization behavior. This property will now properly return `nil` until the user’s location has been determined. ([#9639](https://github.com/mapbox/mapbox-gl-native/pull/9639)) + ## 3.6.1 * Reduced the size of the dynamic framework by optimizing symbol visibility. ([#7604](https://github.com/mapbox/mapbox-gl-native/pull/7604)) diff --git a/platform/ios/src/MGLUserLocation.h b/platform/ios/src/MGLUserLocation.h index 8c6fe46136..91abadbcb7 100644 --- a/platform/ios/src/MGLUserLocation.h +++ b/platform/ios/src/MGLUserLocation.h @@ -20,8 +20,7 @@ MGL_EXPORT /** The current location of the device. (read-only) - This property contains `nil` if the map view is not currently showing the user - location or if the user’s location has not yet been determined. + This property returns `nil` if the user’s location has not yet been determined. */ @property (nonatomic, readonly, nullable) CLLocation *location; diff --git a/platform/ios/src/MGLUserLocation.m b/platform/ios/src/MGLUserLocation.m index 1e38689cb3..074d138a72 100644 --- a/platform/ios/src/MGLUserLocation.m +++ b/platform/ios/src/MGLUserLocation.m @@ -101,7 +101,7 @@ NS_ASSUME_NONNULL_END - (CLLocationCoordinate2D)coordinate { - return self.location.coordinate; + return _location ? _location.coordinate : kCLLocationCoordinate2DInvalid; } - (NSString *)title -- cgit v1.2.1