-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[core] fix collisions with icon-text-fit and variable placement #15828
Conversation
src/mbgl/text/placement.cpp
Outdated
const auto placeFeatureForVariableAnchors = [&] (const CollisionFeature& collisionFeature, style::TextWritingModeType orientation) { | ||
const bool doVariableIconPlacement = hasIconTextFit && !iconAllowOverlap && symbolInstance.placedIconIndex; | ||
|
||
const auto placeFeatureForVariableAnchors = [&] (const CollisionFeature& collisionFeature, style::TextWritingModeType orientation, const CollisionFeature& iconCollisionFeature) { |
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: s/collisionFeature/textCollisionFeature ?
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.
yep, changed!
src/mbgl/text/placement.cpp
Outdated
@@ -329,6 +331,15 @@ void Placement::placeBucket( | |||
allowOverlap, | |||
pitchWithMap, | |||
params.showCollisionBoxes, avoidEdges, collisionGroup.second, textBoxes); | |||
|
|||
if (doVariableIconPlacement) { | |||
auto placedIconFeature = collisionIndex.placeFeature(iconCollisionFeature, shift, |
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.
do we still need to call placedFeature = collisionIndex.placeFeature(..
above? wouldn't just one placeFeature()
call suffice?
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.
In the case there is negative icon padding (or an icon offset?) the text box might be larger than the icon box. Placing both is the clearest way to handle the possible differences
70c3e0e
to
a85187a
Compare
port 61a61a1982cb8c637d467f91da5b0817a61a9de6
a85187a
to
0fe6136
Compare
port https://github.com/mapbox/mapbox-gl-js/pull/8803/files
When deciding the placement position it was only checking whether there were text collisions. If there was an icon collision then it would hide the icon (and by default, the text with it) instead of trying a different position.
If icon-text-fit is used it now checks whether the icon fits before accepting a placement position.