Hi Al,
The map suite line's labeling is based on LineBaseShape. In other words, one label per one LineShape or MultiLineShape. To render multiple labels for MultiLineShape, we need to make a custom TextStyle and overwrite GetLabelingCandidateCore method. It returns a collection of LabelingCandiate which contains position information where a road label should display. Generally, all the labels are drawn at the center of the lineshape, and you can change the postion using XOffsetInPixel and YOffsetInPixel. Here as following are the sample code about the question 1 and 2. Please pay attention to the “ToDo” comments:
protected override Collection<LabelingCandidate> GetLabelingCandidateCore(Feature feature, GeoCanvas canvas)
{
Collection<LabelingCandidate> labelingCandidates = new Collection<LabelingCandidate>();
WellKnownType shapeType = feature.GetWellKnownType();
switch (shapeType)
{
default:
labelingCandidates = base.GetLabelingCandidateCore(feature, canvas);
break;
case WellKnownType.Multiline:
// split it into individual lines, solve them independently and then join results.
MultilineShape multiLineShape = (MultilineShape)feature.GetShape();
foreach (LineShape lineShape in multiLineShape.Lines)
{
Feature lineFeauture = new Feature(lineShape, feature.ColumnValues);
Collection<LabelingCandidate> lineCandidates = GetLabelingCandidateCore(lineFeauture, canvas);
foreach (LabelingCandidate candidate in lineCandidates)
labelingCandidates.Add(candidate);
}
break;
case WellKnownType.Line:
LineShape lineShapeOverall = (LineShape)feature.GetShape();
labelingCandidates = base.GetLabelingCandidateCore(feature, canvas);
// ToDo: you can change the label position here based on custom senario
foreach (LabelingCandidate candidate in labelingCandidates)
{
foreach (LabelInformation information in candidate.LabelInformation)
{
PointShape labelPostion = information.PositionInScreenCoordinates;
// Todo: custom setting........
}
}
break;
}
return labelingCandidates;
}
Note: Both the WebEdition and DesktopEdition are based on MapSuiteCore.dll, so some of the desktop code community sample also can take effet in WebEdition.
The webEdition also can work on the pre-generated tiles. Here as following is about how to setting the cache for the Overlay:
Map1.StaticOverlay.ServerCache.CacheDirectory = MapPath("~/ImageCache/" + Request.Path);
Thanks,
Johnny