MapSuite Team,
Attached is a picture of polygons (building footprints). At the top & bottom of the picture you will notice that not all the polygons are labeled and this is due to the fact that there is not sufficient room for each label.
It would appear to me that the labels that are present are centered within their respective polygon.
Is there a property that can be set that will cause the labels, in this case, to be staggered so that all polygons are labeled?
Your assistance is appreciated.
Regards,
Dennis
BuildingPolygonLabels.png (38.8 KB)
Label Placement in Polygons
Hi Dennis,
It looks you solve that in the other topic right?
If this issue hadn’t been solved please let me know.
Regards,
Don
Don,
This issue is different than my other post and has not been resolved.
Attached are two pictures. The first picture shows an old map product that I am replacing and the second shows the MapSuite based new product.
In the old product notice the text labeling for the building polygons along the top and bottom of the picture. The text labels are staggered which allows each building footprint to be labeled.
In the new product notice the text labeling for the building polygons along the top and bottom of the picture. The text labels are along what is basically a straight line (center point of each building), which prevents all the building footprints from being labeled since the labels would overlap.
My goal is for the MapSuite product to stagger labels similarly to the old map product.
Your thoughts are appreciated.
Regards,
Dennis
OldMapProductLabelsStaggered.png (93.9 KB)
NewMapProductLabelsStraightLine.png (202 KB)
Hi Dennis,
Thanks for your screen capture and description.
In fact that a littler hard for our product to put label with different offset. But it looks you are trying to implement custom text style, I think maybe you can create an algorithm (for example a random offset value algorithm) to make the label don’t always shows in the center of polygon.
But I think it still be hard if you want to make each label shows without overlap. If I have any idea about that I will let you know.
Regards,
Don
Hi Don,
Any help your team can give on this would be greatly appreciated. My users are not very happy that there new product can do what the old product did in labeling building addresses.
Is there any ability to label polygons from top to bottom is labeling from left to right does not fit?
Thanks,
Dennis
Hi Dennis,
I tried to help you implement that but found it’s a little hard, and when I did that I found maybe we missed another property BestPlacement.
The description of it mentioned:
This property gets and sets whether the labeler will attempt to change the label position to avoid overlapping for point-based features.
The positioning of point labels is mainly determined by the PointPlacement property. This allows you place the text to the right, top, bottom, etc. of the point. In some cases, placing the text in a certain place will cause many labels to be suppressed
when the points are dense. This property allows you to override the PointPlacement property and allow the labeler to try other locations, if the default location would cause the label to be suppressed.
I think it should works for your scenario. Please try to use BestPlacementSymbolHeight and BestPlacementSymbolWidth.
Regards,
Don
Don,
My application makes use of the BestPlacement Property on Point Layers and it works great.
However, the layer that I’m concerned with now is a polygon layer and setting BestPlacement to either True or False has no affect.
Attached is a picture for reference, which shows the result with polygon TextStyle set to AllowOverlapping Labels. It’s apparent that the MapSuite Labeler knows that labels will or will not overlap. At the point where the Labeler knows overlapping will result would it not be possible to then stagger the label? Seems like half the job is already done knowing that labels will overlap. If the ‘next’ label will overlap the previous then alter the center point y-coordinate for labeling by the size of the label font. Then depending on whether prior label was placed on its’ original center alter the center of the current label in the opposite vertical direction, i.e. either add or subtract label font size from center point y-coordinate.
I would suggest extending the enumerations of PolygonLabelingLocationMode to include something like CentroidWithStagger, or something to that effect.
What do you think?
Thanks,
Dennis
PolygonLabelsAllowOverlappingLabels.png (14.6 KB)
Hi Dennis,
That’s possible, but there isn’t any built-in property for this, we need to create a customized TextStyle inherited from TextStyle,and overwrite the method
Collection<LabelingCandidate> GetLabelingCandidateCore(Feature feature, GeoCanvas canvas)
there we can change the position of each label. The possible implementation should look like as following:
public
class
CustomizedTextStyle : TextStyle
{
// A collection to save all the drawing areas of labels.
private
Collection<PolygonShape> labelScreenAreas =
new
Collection<PolygonShape>();
protected
override
Collection<LabelingCandidate> GetLabelingCandidateCore(Feature feature, GeoCanvas canvas)
{
Collection <LabelingCandidate> candidates=
base
.GetLabelingCandidateCore(feature, canvas);
foreach
(var labelingCandidate
in
candidates)
{
// Todo: check if current labelingCandidate is overlapping with others in global variable labelScreenAreas
// if yes, we need to do some changes to current. Otherwise, keep.
// …
if
(CheckOverlapped(labelingCandidate, LabelAllLineParts))
{
// Todo: Overlapped, do changes to the position of label.
}
else
{
labelScreenAreas.Add(labelingCandidate.ScreenArea);
}
}
return
candidates;
}
}
NOTE: please make sure the OverlappingRule as LabelOverlappingRule.AllowOverlapping.
Thanks,
Johnny