Place individual labels inside polygon

Dear all,

I need to use MapWindow/MapWinGIS for a simple structure with polygons and labels inside of them. However, by using the regular Labels module, it seems like the labels adapt to the map zooming state and do not stay in the polygons.

How can I make the labels static (in terms of size and positioning) in the polygon? Perhaps the usual Labels module does not suffice, in which case I’m open to other options.

Kind regards

Hello @deangelisalex, and welcome.

It would be best, I think, to use the labeling that is built into the layer itself. See Shapefile.Labels. There is inherently one label per shape, and their positioning is always relative to the associated Shape (so you never have to specify their x, y position - they will always, for example, be centered). See these label positioning methods.

If you need more specifics, perhaps you could post the code where you set up they labeling, and we could give more specific guidance.


Another way is
i replace all the text in a shape by something that I call a GeometryFont
Step One
Convert a text to geometry with the specific font
FormattedText text = new FormattedText(NomduNavire,
new Typeface(new FontFamily(“Seaport”),
FontStyles.Normal, FontWeights.Bold, FontStretches.Normal),
text.TextAlignment = TextAlignment.Left;
Geometry geometry = text.BuildGeometry(new Point(0, 0));
//// Create a set of polygons by flattening the Geometry object.
PathGeometry pathGeometry = geometry.GetFlattenedPathGeometry(0.001, ToleranceType.Relative);
//var mesure = MeasureString(".");

                Pen pen = new Pen
                    Brush = Brushes.Gray,
                    Thickness = 2
                var bound = pathGeometry.GetRenderBounds(pen);

Step 2 Find the good scale and placement
Encapsulates the specific text in the shape at the good scale
var rect2 = Rectborder(bound.Height * ech, bound.Width * ech, (k * 10) * ech);
var ok = geoModeleNavire.FillContainsWithDetail(rect2);
var t = Largeur * 0.33;
var s = bound.Height * ech;
if (ok == IntersectionDetail.FullyContains && t >= s)

Step 3 Save in shape file and use it

For me good showing at any scale and circumstance