length as a label ?

May 9, 2015 at 8:43 AM

Would it be possible to add shape length as a label without storing it in an attribute before ?


May 9, 2015 at 10:05 AM
Certainly. With something like this:

    for (int i = 0; i < sf.NumShapes; i++)
        var shape = sf.Shape[i];
        var pnt = shape.Centroid;
        sf.Labels.AddLabel(shape.Length.ToString(), pnt.x, pnt.y);

Use AxMap.GeodesicLength for precise calculations.

Hope it helps,
May 9, 2015 at 10:46 AM
Thanks for this idea Sergei, I was think of another way of using "Generate."

Bythe way, is it possible to create an event to call this procedure when sf or axmap redraws (at the beginning) ? My problem is that I want to label lines that are created and modified inside different parts of the code and would avoid to write the call to this procedure each time ?
May 11, 2015 at 8:18 AM
There is no event to do it I believe. Map.OnDrawBackBuffer / BeforeDrawing / AfterDrawing are fired only when the data layers are already drawn. In fact would be good to add such an event. You can create a feature request in the Issues section if you like.