summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Guerra <fabian.guerra@mapbox.com>2018-09-25 14:35:28 -0700
committerFabian Guerra <fabian.guerra@mapbox.com>2018-09-26 10:28:51 -0700
commite54596081ffa472987a3676f1785e38a01b824d9 (patch)
tree6b234c1a902e061bf952e4bfc41dd639f4b17ebf
parente218fbc53c9782f9c18c9cc612c1f85cf7114397 (diff)
downloadqtlocation-mapboxgl-upstream/fabian-cross-source-12847.tar.gz
[ios, macos] Add perSourceCollisions property.upstream/fabian-cross-source-12847
-rw-r--r--platform/darwin/src/MGLRendererConfiguration.h14
-rw-r--r--platform/darwin/src/MGLRendererConfiguration.mm6
-rw-r--r--platform/ios/docs/guides/Info.plist Keys.md6
-rw-r--r--platform/ios/src/MGLMapView.mm3
-rw-r--r--platform/macos/docs/guides/Info.plist Keys.md8
-rw-r--r--platform/macos/src/MGLMapView.mm3
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<std::string> 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<std::string>();
}
-- (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<mbgl::Renderer>(*_mbglView, config.scaleFactor, *config.fileSource, *_mbglThreadPool, config.contextMode, config.cacheDir, config.localFontFamilyName);
+ BOOL enableCrossSourceCollisions = !config.perSourceCollisions;
_rendererFrontend = std::make_unique<MGLRenderFrontend>(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<mbgl::Renderer>(*_mbglView, config.scaleFactor, *config.fileSource, *_mbglThreadPool, config.contextMode, config.cacheDir, config.localFontFamilyName);
+ BOOL enableCrossSourceCollisions = !config.perSourceCollisions;
_rendererFrontend = std::make_unique<MGLRenderFrontend>(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.