ThinkGeo.com    |     Documentation    |     Premium Support

Custom Label Draw Interval

Hi,

I have a series of point shapes that have a number that I display using TextStyle; however, the labels get pretty busy at larger scales because every point is labeled.

What I would like to do is label the first, last and every nth point. Is this possible? Is it possible for these to be customized on a per zoom level basis?

Thanks,
Damian

Hi Damian,

If you can distinguish those points you want to label, you can create a custom TextStyle like following:

class MyTextStyle : TextStyle
{
	protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)
	{
		foreach (var feature in features)
		{
			// if it's first/last or nth feature on the line, call base.DrawCore()
			// otherwise, skip drawing
		}
	}
}

Thanks,
Ben