MapSuite Team,
I would like to implement a custom TextStyle. The reason I would like to do this is in regard to labeling parcels/buildings. In most cases a font size of 12 is fine, but in some cases that is too big and a font size of 7 or 8 is needed in order to ensure all building labels are displayed. Some cases a font size of 14 is good as there is enough space for that size of a label.
Do you have any sample custom TextStyle that can implement a font size based on size of polygon that is to be labeled?
Thanks for your assistance?
Regards,
Dennis
Custom TextStyle
Hi Dennis,
For simplest way, you should want to directly set text style for each zoomlevel, for example:
Map1.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.City1(“city”);
Map1.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level09;
Map1.ZoomLevelSet.ZoomLevel10.DefaultTextStyle = TextStyles.City2(“city”);
Map1.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level15;
Map1.ZoomLevelSet.ZoomLevel16.DefaultTextStyle = TextStyles.City3(“city”);
Map1.ZoomLevelSet.ZoomLevel16.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level18;
Map1.ZoomLevelSet.ZoomLevel19.DefaultTextStyle = TextStyles.City4(“city”);
Map1.ZoomLevelSet.ZoomLevel19.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
If you want to implement that by write custom text style, we have a sample named “Scaling TextStyle for Polygon” should be helpful.
You can find it here: wiki.thinkgeo.com/wiki/Map_Suite_Desktop_Edition_All_Samples
And its code: wiki.thinkgeo.com/wiki/Source_Code_ServicesEditionSample_ScalingTextStyleForPolygon_101001.zip
Wish that’s helpful.
Regards,
Don
Don,
Thanks for your response and sample ScalingTextStyleForPoloygon as this gets me toward my goal.
My end-goal is to size the text label according to the actual size of each polygon for a current map scale. So for any given scale I want to apply a minimum or maximum font size to the text label depending on whether the final text label will fit within the bounds of the polygon. This is on the order of applying the FittingPolygon Property to each individual polygon. The end result for any given map scale would be that some text labels might be font size 6 and some might be font size 12.
My reason for doing this is that I am labeling a building footprint layer and since it is within a metropolitan city many of the buildings are side by side and hence the need to make sure all buildings are labeled at a given scale.
Appreciate your assistance.
Regards,
Dennis
Hi Dennis,
Thanks for let us know your detail requirement, I think based on the sample you can know how to calculate a suitable font size by your code logic.
Any question please let us know.
Regards,
Don
Don,
Font size will depend on the size of the polygon. Would you give me a hint as to how I can get the size of the polygon and determine whether the minimum or maximum font size will fit within the polygon.
Thanks,
Dennis
Hi Dennis,
I think we have an API named polygonShape.GetArea should be helpful for that.
Regards,
Don