This project is read-only.

length as a label ?

May 9, 2015 at 9:43 AM
Hi,

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

Thanks,

Olivier
May 9, 2015 at 11:05 AM
Certainly. With something like this:
    sf.Labels.Clear();

    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);
    }

    axMap1.Redraw();
Use AxMap.GeodesicLength for precise calculations.

Hope it helps,
Sergei
May 9, 2015 at 11: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 9: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.