MapSuite Team,
Below is a screen capture that shows labels in a point layer that are at an angle. How is this accomplished in MapSuite?
Thanks,
Dennis
MapSuite Team,
Below is a screen capture that shows labels in a point layer that are at an angle. How is this accomplished in MapSuite?
Thanks,
Dennis
Hi Dennis,
In MapSuite we can set RotationAngle property of TextStyle to display the text with angle. In the screenshot, I guess the points with the different colors have the different rotation angle, right? If so, I think there some options for this:
Hope it’s helped.
Thanks,
Peter
hi Peter,
Thanks for your reply. I implemented the RotationAngle Property and now the labels appear at an angle.
Couple other issues now. First, those labels where RotationAngle=135 the text is ‘upside down’. Second, I would like the label to begin at the position of the point instead of the label being centered on the point. I attempted to make use of the PointPlacement Property, but to no avail. How can the label be made to begin at the location of the point feature?
Thanks,
Dennis
Hi Dennis,
Please check the answers below:
The property PointPlacement only has effect on text without RotationAngle. Please try to set the YOffsetInPixel property and XOffsetInPixel property of TextStyle.
For the text “upside down” please try the formula angle + 180 to make the angle jump to the fourth quadrant.
Thanks,
Peter
Peter,
We’re getting closer. I changed the RotationAngle from 135 to 315 and label text is now right-side-up.
Still an issue is having the label starting its position at the feature point. In other layers I make nice use of XOffsetInPixel/YOffsetInPixel and it works quite well, but when RotationAngle is used it does not work so well. As you can see in the screen capture below the labels do not all have their starting position at the same distance from the feature point. The configuration being used is XOffsetInPixel=100 and YOffsetInPixel=0. It appears that the length of the label is being taken into consideration. The shorter the label the farther away the label is from the feature point. The longer the label the closer the label is to the feature point. When XOffsetInPixel/YOffsetInPixel are both set to zero the labels are centered directly over the feature point.
It would be reasonable, I believe, for MapSuite to actually make use of the PointPlacement Property when RotationAngle is used.
Is there anyway to have these labels positioned to start at the feature point by overriding some draw method?
Thanks,
Dennis
Hi Dennis,
Please try set the XOffsetInPixel and YOffsetInPixel instead of zero when RotationAngle is used.
Also, we can override the TextStyle’s method: protected virtual Collection GetLabelingCandidateCore(Feature feature, GeoCanvas canvas) to change the position of the text.
Following is the documents for LabelingCandidate and LabelInformation:
http://wiki.thinkgeo.com/wiki/thinkgeo.mapsuite.core.labelingcandidate
http://wiki.thinkgeo.com/wiki/thinkgeo.mapsuite.core.labelinformation
Thanks,
Peter
Peter,
The screen capture from my prior post shows XOffsetInPixel=100 and YOffsetInPixel=0.
The below screen capture has XOffsetInPixel=50 and YOffsetInPixel=50.
Do you have some actual code samples and how to use LabelingCandidate and LabelingInformation?
Thanks,
Dennis
Hi Dennis,
As below is a simple sample, you still need adjust the XOffsetInPixel and YOffsetInPixel value to make it works well.
private class MyTextStyle : TextStyle
{
public MyTextStyle(string textColumnName, GeoFont textFont, GeoSolidBrush textSolidBrush) : base(textColumnName, textFont, textSolidBrush)
{
}
public MyTextStyle() : base()
{ }
protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)
{
base.DrawCore(features, canvas, labelsInThisLayer, labelsInAllLayers);
}
protected override Collection<LabelingCandidate> GetLabelingCandidateCore(Feature feature, GeoCanvas canvas)
{
string labelText = feature.ColumnValues[base.TextColumnName];
DrawingRectangleF size = canvas.MeasureText(labelText, base.Font);
double width = size.Width;
//double height = size.Height;
base.XOffsetInPixel = (float)(width / 3);
//base.YOffsetInPixel = (float)(width / 3);
return base.GetLabelingCandidateCore(feature, canvas);
}
}
ShapeFileFeatureLayer majorCitiesShapeLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\MajorCities.shp");
majorCitiesShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City1;
majorCitiesShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new MyTextStyle("AREANAME", new GeoFont("Arial", 10, DrawingFontStyles.Regular), new GeoSolidBrush(GeoColor.StandardColors.Black));
majorCitiesShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.RotationAngle = 45;
majorCitiesShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.BestPlacement = true;
majorCitiesShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Wish that’s helpful.
Regards,
Don
Thanks Don. The code snippet is very helpful, I’ll see what I can do with it.
Dennis
Hi Dennis,
I am glad to hear that’s helpful.
Regards,
Don