Place label in center of visible part of feature #209
-
|
Hi, I need to place a layer's label in the visible part of the feature, each time the bounding box changes. I am aware of layer.LabelPositionDelegate(); I am not sure how I should use it with a multi-polygon layer, in order to display a label in the visible part of each feature... Thanks, |
Beta Was this translation helpful? Give feedback.
Answered by
FObermaier
Mar 8, 2021
Replies: 1 comment 1 reply
-
|
I have not tried it exactly but sth along these lines should work: public class ClipLabelPosition
{
private readonly SharpMap.Map _map;
private GeoAPI.Geometries.IGeometry _clip;
public ClipLabelPosition(SharpMap.Map map)
{
_map = map;
map.MapViewOnChange += () => _clip = _map.Factory.ToGeometry(_map.Envelope);
}
public GeoAPI.Geometries.Coordinate GetClippedPosition(SharpMap.Data.FeatureDataRow row)
{
var g = _clip.Intersection(row.Geometry);
return g.PointOnSurface.Coordinate;
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
gcapnias
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have not tried it exactly but sth along these lines should work: