From defbfa5e002b92d183293d8a48fd97b31f4375cf Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Wed, 16 Aug 2017 18:13:28 -0400 Subject: [ios, macos] Fix querying features returning nil when features available. --- platform/darwin/src/MGLSource.mm | 5 +++-- platform/darwin/src/MGLSource_Private.h | 2 +- platform/darwin/src/MGLStyle.mm | 9 +++++---- platform/ios/CHANGELOG.md | 1 + platform/macos/CHANGELOG.md | 4 ++++ 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/platform/darwin/src/MGLSource.mm b/platform/darwin/src/MGLSource.mm index eb859ba2c0..7bab90e9de 100644 --- a/platform/darwin/src/MGLSource.mm +++ b/platform/darwin/src/MGLSource.mm @@ -27,17 +27,18 @@ return self; } -- (instancetype)initWithRawSource:(mbgl::style::Source *)rawSource { +- (instancetype)initWithRawSource:(mbgl::style::Source *)rawSource mapView:(MGLMapView *)mapView { NSString *identifier = @(rawSource->getID().c_str()); if (self = [self initWithIdentifier:identifier]) { _rawSource = rawSource; _rawSource->peer = SourceWrapper { self }; + _mapView = mapView; } return self; } - (instancetype)initWithPendingSource:(std::unique_ptr)pendingSource { - if (self = [self initWithRawSource:pendingSource.get()]) { + if (self = [self initWithRawSource:pendingSource.get() mapView:nil]) { _pendingSource = std::move(pendingSource); } return self; diff --git a/platform/darwin/src/MGLSource_Private.h b/platform/darwin/src/MGLSource_Private.h index 91bfac6390..13a3dd5a30 100644 --- a/platform/darwin/src/MGLSource_Private.h +++ b/platform/darwin/src/MGLSource_Private.h @@ -26,7 +26,7 @@ struct SourceWrapper { Initializes and returns a source with a raw pointer to the backing store, associated with a style. */ -- (instancetype)initWithRawSource:(mbgl::style::Source *)rawSource; +- (instancetype)initWithRawSource:(mbgl::style::Source *)rawSource mapView:(nullable MGLMapView *)mapView; /** Initializes and returns a source with an owning pointer to the backing store, diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index 1e0a2e02b7..d8aa014341 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -187,6 +187,7 @@ static NSURL *MGLStyleURL_emerald; - (MGLSource *)sourceWithIdentifier:(NSString *)identifier { auto rawSource = self.mapView.mbglMap->getSource(identifier.UTF8String); + return rawSource ? [self sourceFromMBGLSource:rawSource] : nil; } @@ -198,13 +199,13 @@ static NSURL *MGLStyleURL_emerald; // TODO: Fill in options specific to the respective source classes // https://github.com/mapbox/mapbox-gl-native/issues/6584 if (auto vectorSource = rawSource->as()) { - return [[MGLVectorSource alloc] initWithRawSource:vectorSource]; + return [[MGLVectorSource alloc] initWithRawSource:vectorSource mapView:self.mapView]; } else if (auto geoJSONSource = rawSource->as()) { - return [[MGLShapeSource alloc] initWithRawSource:geoJSONSource]; + return [[MGLShapeSource alloc] initWithRawSource:geoJSONSource mapView:self.mapView]; } else if (auto rasterSource = rawSource->as()) { - return [[MGLRasterSource alloc] initWithRawSource:rasterSource]; + return [[MGLRasterSource alloc] initWithRawSource:rasterSource mapView:self.mapView]; } else { - return [[MGLSource alloc] initWithRawSource:rawSource]; + return [[MGLSource alloc] initWithRawSource:rawSource mapView:self.mapView]; } } diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 8535073cd0..2b50eefbba 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -7,6 +7,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Added an MGLStyle.localizesLabels property, off by default, that localizes any Mapbox Streets–sourced symbol layer into the user’s preferred language. ([#9582](https://github.com/mapbox/mapbox-gl-native/pull/9582)) * Added an additional camera method to MGLMapView that accepts an edge padding parameter. ([#9651](https://github.com/mapbox/mapbox-gl-native/pull/9651)) * Fixed an issue with the scaling of the user location annotation’s horizontal accuracy indicator. ([#9721](https://github.com/mapbox/mapbox-gl-native/pull/9721)) +* Fixed an issue that caused querying features in a source return nil. ([#9784](https://github.com/mapbox/mapbox-gl-native/pull/9784)) ## 3.6.1 - July 28, 2017 diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 1af3c03d68..0c41064954 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog for Mapbox macOS SDK +## 0.5.2 + +* Fixed an issue that caused querying features in a source return nil. ([#9784](https://github.com/mapbox/mapbox-gl-native/pull/9784)) + ## 0.5.1 * Added an MGLStyle.localizesLabels property, off by default, that localizes any Mapbox Streets–sourced symbol layer into the user’s preferred language. ([#9582](https://github.com/mapbox/mapbox-gl-native/pull/9582)) -- cgit v1.2.1