From e54596081ffa472987a3676f1785e38a01b824d9 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Tue, 25 Sep 2018 14:35:28 -0700 Subject: [ios, macos] Add perSourceCollisions property. --- platform/darwin/src/MGLRendererConfiguration.h | 14 ++++++-------- platform/darwin/src/MGLRendererConfiguration.mm | 6 +++--- platform/ios/docs/guides/Info.plist Keys.md | 6 ++++++ platform/ios/src/MGLMapView.mm | 3 ++- platform/macos/docs/guides/Info.plist Keys.md | 8 +++++++- platform/macos/src/MGLMapView.mm | 3 ++- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/platform/darwin/src/MGLRendererConfiguration.h b/platform/darwin/src/MGLRendererConfiguration.h index deaa922a9e..d5b6527d7e 100644 --- a/platform/darwin/src/MGLRendererConfiguration.h +++ b/platform/darwin/src/MGLRendererConfiguration.h @@ -36,17 +36,15 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) mbgl::optional localFontFamilyName; /** - A Boolean value indicating whether symbol layers may enable cross-source symbol + A Boolean value indicating whether symbol layers may enable per-source symbol collision detection. - Set `MGLCrossSourceCollisions` in your containing app's Info.plist + Set `MGLCollisionBehaviorPre4_0` in your containing app's Info.plist. - Setting this property to `NO`, symbol layers will only run collision detection - against other symbol layers that are part of the same source. - - The default value of this property is `YES`. -*/ -@property (nonatomic, readonly) BOOL crossSourceCollisions; + Setting this property to `YES` in the plist results in symbol layers only running + collision detection against other symbol layers that are part of the same source. + */ +@property (nonatomic, readonly) BOOL perSourceCollisions; @end diff --git a/platform/darwin/src/MGLRendererConfiguration.mm b/platform/darwin/src/MGLRendererConfiguration.mm index 5c951e3dbd..b31da674cf 100644 --- a/platform/darwin/src/MGLRendererConfiguration.mm +++ b/platform/darwin/src/MGLRendererConfiguration.mm @@ -40,10 +40,10 @@ return fontFamilyName ? std::string([fontFamilyName UTF8String]) : mbgl::optional(); } -- (BOOL)crossSourceCollisions { - NSNumber *boolWrapper = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"MGLCrossSourceCollisions"]; +- (BOOL)perSourceCollisions { + NSNumber *boolWrapper = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"MGLCollisionBehaviorPre4_0"]; - return boolWrapper ? boolWrapper.boolValue : YES; + return boolWrapper.boolValue; } @end diff --git a/platform/ios/docs/guides/Info.plist Keys.md b/platform/ios/docs/guides/Info.plist Keys.md index cf00ec5499..9e753b2d79 100644 --- a/platform/ios/docs/guides/Info.plist Keys.md +++ b/platform/ios/docs/guides/Info.plist Keys.md @@ -23,3 +23,9 @@ If you have implemented custom opt-out of Mapbox Telemetry within the user inter ## MGLIdeographicFontFamilyName The name of the font family to use for client-side text rendering of CJK ideographs. Set this to the name of a font family which will be available at run time, e.g. `PingFang TC` (iOS 9+), `Heiti TC` (iOS 8+), another appropriate built-in font, or a font provided by your application. Note that if a non-existent font is specified, iOS will fall back to using Helvetica which is likely not to include support for the glyphs needed to render maps in your application. + +## MGLCollisionBehaviorPre4_0 + + If this key is set to YES (`true`), collision detection is performed only between symbol style layers based on the same source, as in versions 2.0–3.7 of the Mapbox Maps SDK for iOS. In other words, symbols in an `MGLSymbolStyleLayer` based on one source (for example, an `MGLShapeSource`) may overlap with symbols in another layer that is based on a different source (such as the Mapbox Streets source). This is the case regardless of the `MGLSymbolStyleLayer.iconAllowsOverlap`, `MGLSymbolStyleLayer.iconIgnoresPlacement`, `MGLSymbolStyleLayer.textAllowsOverlap`, and `MGLSymbolStyleLayer.textIgnoresPlacement` properties. + +Beginning in version 4.0, the SDK also performs collision detection between style layers based on different sources by default. For the default behavior, omit the `MGLCollisionBehaviorPre4_0` key or set it to NO (`false`). \ No newline at end of file diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index bac1f70e3b..869a5ae55c 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -437,8 +437,9 @@ public: _mbglThreadPool = mbgl::sharedThreadPool(); auto renderer = std::make_unique(*_mbglView, config.scaleFactor, *config.fileSource, *_mbglThreadPool, config.contextMode, config.cacheDir, config.localFontFamilyName); + BOOL enableCrossSourceCollisions = !config.perSourceCollisions; _rendererFrontend = std::make_unique(std::move(renderer), self, *_mbglView); - _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *[config fileSource], *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default, config.crossSourceCollisions); + _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *[config fileSource], *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default, enableCrossSourceCollisions); // start paused if in IB if (_isTargetingInterfaceBuilder || background) { diff --git a/platform/macos/docs/guides/Info.plist Keys.md b/platform/macos/docs/guides/Info.plist Keys.md index dd401d1ad3..fe4c87b0c0 100644 --- a/platform/macos/docs/guides/Info.plist Keys.md +++ b/platform/macos/docs/guides/Info.plist Keys.md @@ -18,4 +18,10 @@ The default value is `https://api.mapbox.com`. ## MGLIdeographicFontFamilyName -The name of the font family to use for client-side text rendering of CJK ideographs. Set this to the name of a font family which will be available at run time, e.g. `PingFang TC` (iOS 9+), `Heiti TC` (iOS 8+), another appropriate built-in font, or a font provided by your application. Note that if a non-existent font is specified, iOS will fall back to using Helvetica which is likely not to include support for the glyphs needed to render maps in your application. \ No newline at end of file +The name of the font family to use for client-side text rendering of CJK ideographs. Set this to the name of a font family which will be available at run time, e.g. `PingFang TC` (iOS 9+), `Heiti TC` (iOS 8+), another appropriate built-in font, or a font provided by your application. Note that if a non-existent font is specified, iOS will fall back to using Helvetica which is likely not to include support for the glyphs needed to render maps in your application. + +## MGLCollisionBehaviorPre4_0 + +If this key is set to YES (`true`), collision detection is performed only between symbol style layers based on the same source, as in versions 0.1–0.7 of the Mapbox Maps SDK for iOS. In other words, symbols in an `MGLSymbolStyleLayer` based on one source (for example, an `MGLShapeSource`) may overlap with symbols in another layer that is based on a different source (such as the Mapbox Streets source). This is the case regardless of the `MGLSymbolStyleLayer.iconAllowsOverlap`, `MGLSymbolStyleLayer.iconIgnoresPlacement`, `MGLSymbolStyleLayer.textAllowsOverlap`, and `MGLSymbolStyleLayer.textIgnoresPlacement` properties. + +Beginning in version 0.7, the SDK also performs collision detection between style layers based on different sources by default. For the default behavior, omit the `MGLCollisionBehaviorPre4_0` key or set it to NO (`false`). This property is so named because version 0.7 of the Mapbox Maps SDK for macOS corresponds to version 4.0 of the Mapbox Maps SDK for iOS. \ No newline at end of file diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 5e4fd2f727..4309a12693 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -278,8 +278,9 @@ public: MGLRendererConfiguration *config = [MGLRendererConfiguration currentConfiguration]; auto renderer = std::make_unique(*_mbglView, config.scaleFactor, *config.fileSource, *_mbglThreadPool, config.contextMode, config.cacheDir, config.localFontFamilyName); + BOOL enableCrossSourceCollisions = !config.perSourceCollisions; _rendererFrontend = std::make_unique(std::move(renderer), self, *_mbglView, true); - _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *config.fileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default, config.crossSourceCollisions); + _mbglMap = new mbgl::Map(*_rendererFrontend, *_mbglView, self.size, config.scaleFactor, *config.fileSource, *_mbglThreadPool, mbgl::MapMode::Continuous, mbgl::ConstrainMode::None, mbgl::ViewportMode::Default, enableCrossSourceCollisions); // Install the OpenGL layer. Interface Builder’s synchronous drawing means // we can’t display a map, so don’t even bother to have a map layer. -- cgit v1.2.1