-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[ios, macos] Add crossSourceCollissions property. #12941
Conversation
A Boolean value indicating whether symbol layers may enable cross-source symbol | ||
collision detection. | ||
|
||
Set `MGLCrossSourceCollisions` in your containing app's Info.plist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure this is a setting that should be uniform application-wide? Or is there a use case for enabling this setting for one map view but not another in the same application? If the latter, then there needs to be a method on MGLStyle that controls this setting. That means it needs to be possible to pass the setting into mbgl::Map
at an arbitrary point after the mbgl::Map
is constructed. (The developer can’t be expected to provide this setting as part of an MGLMapView initializer, because views are typically initialized with nothing but a frame.)
/cc @ChrisLoer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, in the long back-and-forth on the JS side that led to us making this flag, we ended up conceptualizing this flag as much as possible as a "backwards compatibility switch", just in order to constrain the scope of what can quickly become a confusing design space. In my mind, making the setting application-wide is consistent with the "backwards compatibility" approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we consider this to be legacy behavior, then perhaps we should name the option somewhat more disparagingly and document it as a legacy behavior.
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`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s a bit awkward that leaving the Info.plist option unset is equivalent to YES
. Normally leaving an option unset would be equivalent to NO
. Could we rename the option to make it more naturally have NO
as a default value? Perhaps MGLPerSourceCollisions
or MGLV3CollisionBehavior
.
A Boolean value indicating whether symbol layers may enable cross-source symbol | ||
collision detection. | ||
|
||
Set `MGLCrossSourceCollisions` in your containing app's Info.plist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the header is internal, this documentation isn’t visible to developers. Add an entry about the Info.plist key to the “Info.plist Keys” guide.
29e96ef
to
f24e913
Compare
@@ -23,3 +23,7 @@ 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. | |||
|
|||
## MGLPerSourceCollisions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per #12941 (comment), I think we should name this more discouragingly — this should be a key that shouts “legacy! only enable if you know what you’re doing.”
/cc @1ec5 @ChrisLoer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or at least the practical consequences of enabling it should be made more clear: that symbols in different sources, such as Streets versus a shape source, may overlap unexpectedly.
|
||
## MGLPerSourceCollisions | ||
|
||
Use this key to enable per-source symbol collision detection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is legacy functionality, let’s also say so here.
f24e913
to
25b4a13
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here’s some revised wording that explains in more detail how the behavior differs.
|
||
## MGLCollisionBehaviorPre4_0 | ||
|
||
If enabled symbol layers will only run legacy collision detection against other symbol layers that are part of the same source. Symbols in different sources, such as Streets versus a shape source, may overlap unexpectedly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pretty convoluted behavior to explain in lay terms, but I think this more or less covers it:
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 anMGLSymbolStyleLayer
based on one source (for example, anMGLShapeSource
) 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 theMGLSymbolStyleLayer.iconAllowsOverlap
,MGLSymbolStyleLayer.iconIgnoresPlacement
,MGLSymbolStyleLayer.textAllowsOverlap
, andMGLSymbolStyleLayer.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
).
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, I just realized it isn’t “4.0” for macOS. Not a big deal I suppose.
## MGLCollisionBehaviorPre4_0 | ||
|
||
If enabled symbol layers will only run legacy collision detection against other symbol layers that are part of the same source. Symbols in different sources, such as Streets versus a shape source, may overlap unexpectedly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 anMGLSymbolStyleLayer
based on one source (for example, anMGLShapeSource
) 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 theMGLSymbolStyleLayer.iconAllowsOverlap
,MGLSymbolStyleLayer.iconIgnoresPlacement
,MGLSymbolStyleLayer.textAllowsOverlap
, andMGLSymbolStyleLayer.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.
A Boolean value indicating whether symbol layers may enable per-source symbol | ||
collision detection. | ||
|
||
Set `MGLCollisionBehaviorPre4_0` in your containing app's Info.plist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: add a period at the end of this sentence.
|
||
Set `MGLCollisionBehaviorPre4_0` in your containing app's Info.plist | ||
|
||
Setting this property to `YES`, symbol layers will only run collision detection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting this property to
YES
,
This could be confusing, as the property defined in this header is readonly
. Here’s my suggestion:
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.
25b4a13
to
e545960
Compare
@@ -16,6 +16,7 @@ | |||
* Fixed an issue where `-[MGLMapSnapshotter startWithQueue:completionHandler:]` failed to call its completion handler in some cases. ([#12355](https://github.com/mapbox/mapbox-gl-native/pull/12355)) | |||
* Fixed an issue where `MGLMapView` produced a designable error in Interface Builder storyboards in Xcode 10. ([#12883](https://github.com/mapbox/mapbox-gl-native/pull/12883)) | |||
* Fixed bugs in coercion expression operators ("to-array" applied to empty arrays, "to-color" applied to colors, and "to-number" applied to null) [#12864](https://github.com/mapbox/mapbox-gl-native/pull/12864) | |||
* Added the `MGLCollisionBehaviorPre4_0` Info.plist key for applications that require the collision detection behavior in version v3.7 of the SDK. ([#12941](https://github.com/mapbox/mapbox-gl-native/pull/12941)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On macOS, it was version v0.6, not v3.7.
/cc @fabian-guerra
Fixes #12847