Text Labels: How do I add text labels that only appear when they fit inside a polygon? #1506

Open
shashashasha opened this Issue Sep 27, 2012 · 2 comments

Projects

None yet

2 participants

@shashashasha

I've been playing with text-placement, but "interior" seems to only be for when the center of the polygon is not within the polygon. Is there a text-placement method that accounts for the size of the label and doesn't place the label when the text is too big for the polygon?

@springmeyer
Member

Right interior only changes placement location with polygons (it is equivalent to postgis's "point on surface"). There is minimum-path-length (called text-min-path-length in CartoCSS) that will hold back labels for small features. So minimum-path-length="10" would skip labeling lines that are not more than 10 pixels long and polygon whose bbox width (in screen pixels) is not more than 10 pixels wide.

The behavior you describe of skipping labeling when the text does not fit within the feature is actually the default behavior for placement=line, but we'ver never consider making it so for placement=point|interior. That is a good idea.

@springmeyer
Member

just confirmed that minimum-path-length should kick in for polygons here: https://github.com/mapnik/mapnik/blob/master/src/symbolizer_helpers.cpp#L181-188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment