Label display observation

Hi

Today I observed some display problem in annotation(label). We have given alignment as tkLabelAlignment.laCenterRight and Inboxalignment as tkLabelAlignment.laCenterLeft. I observed some of the labels display correctly after the point and some of the labels on top of point and some of the labels are display right side of the point. Could you please suggest me on this to avoid this problem by applying any property. Please find the below code snippet::


private void loadAnnoData()
{Anno_Test.zip (1.5 KB)
axMap1.Projection = tkMapProjection.PROJECTION_NONE;
axMap1.GrabProjectionFromData = true;
Shapefile annoShapefile = new Shapefile();
annoShapefile.Open(@“C:\Temp\Anno_Test\anno.shp”);

        annoShapefile.Labels.FrameVisible = false;
        annoShapefile.Labels.Alignment = tkLabelAlignment.laCenterRight;
        annoShapefile.Labels.InboxAlignment = tkLabelAlignment.laCenterLeft;
        
        int fldIdx = annoShapefile.Table.FieldIndexByName["main_text"];
        int rotfldIdx = annoShapefile.Table.FieldIndexByName["rotation"];
      

        annoShapefile.Labels.FrameVisible = false;

        annoShapefile.Labels.FontName = "Arial";
        annoShapefile.Labels.FontSize = 8;
        annoShapefile.Labels.AvoidCollisions = false;

        annoShapefile.Labels.ScaleLabels = false;
        annoShapefile.Labels.Synchronized = true;


        for (int eachCnt = 0; eachCnt < annoShapefile.NumShapes; eachCnt++)
        {
            double ang = (double)annoShapefile.get_CellValue(rotfldIdx, (int)eachCnt);
            annoShapefile.Labels.AddLabel(annoShapefile.CellValue[fldIdx, eachCnt].ToString(), annoShapefile.Shape[eachCnt].Point[0].x, annoShapefile.Shape[eachCnt].Point[0].y, (double)-ang);
        }
            axMap1.AddLayer(annoShapefile, true);
       
    }

Regards,
Ramki

Hello Ramki

Try adding

annoShapefile.Labels.AutoOffset = true;

and remove the InboxAlignment, and see what you get.

Then try adding back InboxAlignment, and see if that’s messing things up.

Thank you,
Jerry.

Thank you @jerryfaust for quick solution.

We have checked as per your suggestion and the result is correctly display. but we need to display the each line text (Multi line text) start from left(Present it showing center without using Inboxalignment). As per API we used InboxAlignment as left for text starts from left side. If the one of the line values are empty then the text display as right side or center (not display correctly). Please find the attached image for your reference.

Regards,
Ramki

Hello Ramki

I was able to reproduce the problem and discovered that it is a result of have multiple lines of short strings, specifically, if the effectively rectangle is taller than it is wide. There was a bug in the OCX code.

To recreate the problem, I started with 3 lines of text as shown below:
image

Then I shortened the strings, 3 lines with just one character each, and here’s what happened. This is what you are seeing:
image

After fixing the bug in the OCX, this is now what I see, which is the desired result:
image

I will have to create a ticket and submit a change. Are you able to work around this for a little while?

Regards,
Jerry.

Addendum: It looks like there are additional alignment problems as soon as the Frame is visible, and then other problems if you adjust the transparency of the Frame. So I will try to work through a few more things before submitting a fix.

Thanks for your quick support. We will wait for the release.

Regards,
Ramki

MWGIS-229 has been submitted with code changes to account for proper label alignment within specified bounding box.

Hi @jerryfaust

Thanks for the quick solution. I have taken the latest code and build for testing the functionality. I observed that the problem was fixed but we are unable to view the Openstreetmaps (tiles) on maps. Could you please guide me how to fix this problem.

Thank you

Regards,
Ramki