I have a customized Text Style for my layers. It used to be called before I applied the recent 2 or 3 updates.
What are the requirements to use custom styles?
I applied it to all zoom levels, and added all required column names, override drawcore, and GetRequiredColumnNamesCore functions.
I also tried to set my custom style to both Layer…ZoomLevel.DefaultTextStyle and Layer…ZoomLevel.CustomStyles.
Am I missing anything?
Custom Text Style never got called?
Guangming,
I am a bit confusion on which custom style you means? Defining a new text style class or how the CustomStyles property usage in zoomlevelset?
If you means defining a new text style, would you please attach the codes on this class and don’t forget to specify the TextColumn in the instance?
If you means the CustomStyles property, then it means the default style can’t fit for our requirement and we want to add more styles in the current zoomlevel. For instance, there are two columns we want to label them, if we use the defaultTextStyle, we only can display one column label. In this case, we can create two textstyles for each columns and then add them in the ZoomLevel.CustomStyles.
If the problem still persists, please let us know.
Thanks,
Troy
both actually.
my question is: can i assign my newly inherited TextStyle class to ZoomLevel.DefaultTextStyle?
It seems not. I figured it out add my custom TextStyle to ZoomLevel.CustomStyles to make it work.
So to be curios, i am wondering why the defaulttextstyle does not take my custom class, still inherited from TextStyle?
Thanks,
guangming,
Could you attach your custom text style codes? I created a text style class, but the drawcore method is always called.
internal class CustomTextStyle : TextStyle
{
public CustomTextStyle(string textColumnName, GeoFont textFont, GeoSolidBrush textSolidBrush)
: base(textColumnName, textFont, textSolidBrush)
{
}
protected override void DrawCore(System.Collections.Generic.IEnumerable<
Feature
> features, GeoCanvas canvas, Collection<
SimpleCandidate
> labelsInThisLayer, Collection<
SimpleCandidate
> labelsInAllLayers)
{
base.DrawCore(features, canvas, labelsInThisLayer, labelsInAllLayers);
}
}
and use it
ShapeFileFeatureLayer worldCapitalsLabelsLayer = new ShapeFileFeatureLayer(MapPath("~/SampleData/world/capital.shp"));
worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new CustomTextStyle("city_name", new GeoFont("Arial", 12), new GeoSolidBrush(GeoColor.SimpleColors.Black));//TextStyles.Capital1("city_name");
BTW, in a same zoomlevel, using both a default style and custom styles collection is not allowed, we should always use one of it.
Let me know if you have any question.
Thanks,
Troy