LabelLayer label position delegate

Topics: SharpMap v0.9 / v1.x
Jun 29, 2012 at 9:29 AM

Hello,

I actually want to set a custom label position. I think usually this should be possible with LabelPositionDelegate. Unfortunately when I am doing that it doesn´t have any effect. Maybe I am missing something?

 

_selectedFeatureDataRow.SetField( columnX, _exportMap.ImageToWorld(new PointF(e.X, e.Y)).X);
_selectedFeatureDataRow.SetField(columnY, _exportMap.ImageToWorld(new PointF(e.X, e.Y)).Y);
          
 _selectedLayer.LabelPositionDelegate = delegate(FeatureDataRow fdr)
{
      return new SharpMap.Geometries.Point(Convert.ToDouble(fdr["X"]),
                                                     Convert.ToDouble(fdr["Y"]));
};

I am recalculating the position from a specific row and set the data in the attribute table. But - no effect...
ah and: I am using SharpMap 0.9!

Thanks in advance!

 

Developer
Jun 30, 2012 at 4:26 AM
Edited Jun 30, 2012 at 4:27 AM

 

I think you wrong some thing. The first time you create a function for delegate method. After that you set

LabelPositionDelegate equal this funtion

Ex:

private void DelegateForLabelPosition( FeatureDataRow fdr)

{

  return new SharpMap.Geometries.Point(Convert.ToDouble(fdr["X"]),
                                                     Convert.ToDouble(fdr["Y"]));
}

_selectedLayer.LabelPositionDelegate = this.DelefateForLabelPosition;


Jul 4, 2012 at 10:54 AM
Edited Jul 4, 2012 at 12:07 PM

Thank you! Solved the problem!