ThinkGeo.com    |     Documentation    |     Premium Support

Making labels scale

I’m trying to have my labels for features only show when you are zoomed into that feature, sort of like the “Draw and label water features” in the HowDoI example. But I want the label to get bigger as I zoom into the feature, just like my feature does.

Ex:

//I create a feature, in this case an ellipse with 1000 ft. radius
PolygonShape polygoneShape = new PolygonShape();

polygoneShape = (new EllipseShape(new PointShape(0, 0), 1000, GeographyUnit.DecimalDegree, DistanceUnit.Feet)).ToPolygon();

Feature feature = new Feature(polygoneShape);
feature.ColumnValues.Add("styleName", "EmptyYellow2"); //custom style, just a yellow circle
feature.ColumnValues.Add("fontStyleName", "Title3Yellow"); //custom style, just yellow text
feature.ColumnValues.Add("label", spriteModel.Label);

My custom textstyle being used is constructed with the following properties set:

return new TextStyle
{
    Font = new GeoFont(FontName, FontSize, FontStyle | FontStyle2),
    TextSolidBrush = new GeoSolidBrush(FontColor),
    TextColumnName = TextColumnName,
    PointPlacement = PointPlacement.Center
};

Finally, the layer that the features will be in:

InMemoryFeatureLayer spritesLayer = new InMemoryFeatureLayer();
spritesLayer.Name = "Sprites Layer";
spritesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle); //valueStyle contains the styles for the polygon
spritesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(fontValueStyle); //fontValueStyle contains the style for fonts
spritesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
spritesOverlay.Layers.Add(spritesLayer.Name, spritesLayer);

In the image below, you’ll see that the label is visible even when zoomed far out.

It stays the same size regardless of zoom level.

Instead, I want it to act like the feature, where the label gets bigger as you zoom in. How can I achieve this? Thanks!

Hi Dan,

I think you should want to make the text size follow the change of zoomlevels.

We have a sample about it:http://wiki.thinkgeo.com/wiki/source_code_serviceseditionsample_scalingtextstyleforpolygon_101001.zip

You can download it here: http://wiki.thinkgeo.com/wiki/map_suite_desktop_edition_all_samples

Please refer it, and add your custom logic if you want.

Regards,

Ethan