How To Add Static Text to point

Topics: General Topics
Mar 17, 2007 at 12:22 PM
Edited Mar 17, 2007 at 12:23 PM
i searched all forum here
and couldnt find way of adding static text to a specified point of a map
i want to write something to 43,43 point..

my code below

SharpMap.Data.FeatureDataTable kaynak = new SharpMap.Data.FeatureDataTable();
SharpMap.Data.FeatureDataRow roww = kaynak.NewRow();
roww"bilgi" = "example text";
roww.Geometry = new SharpMap.Geometries.Point(43,43);

SharpMap.Layers.LabelLayer VLayer = new SharpMap.Layers.LabelLayer("bayiler");
VLayer.DataSource = new SharpMap.Data.Providers.GeometryProvider(roww);
VLayer.LabelColumn = "bilgi";
VLayer.Style = new SharpMap.Styles.LabelStyle();
VLayer.Style.ForeColor = Color.Tomato;
VLayer.Style.Font = new Font(FontFamily.GenericSerif, 12);
VLayer.Style.BackColor = new System.Drawing.SolidBrush(Color.FromArgb(128, 255, 0, 0));
VLayer.MaxVisible = 60;
VLayer.MinVisible = 20;
VLayer.Style.HorizontalAlignment = SharpMap.Styles.LabelStyle.HorizontalAlignmentEnum.Center;
VLayer.SRID = 4326;
VLayer.MultipartGeometryBehaviour = SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest;

it says Attribute data is not supported by the GeometryProvider.
if i am completely wrong could anybody tell me how to do this??
Mar 27, 2007 at 12:27 PM
Latest release version of Sharpmap (0.9) does not support attaching labels to geometric objects. However, you can implement a similar effect by getting the image of the map and drawing text on that image. Like this:

System.Drawing.Bitmap img = (System.Drawing.Bitmap)map.GetMap();
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(img);
g.DrawString("kolay gelsin", new Font("Arial", 9), new System.Drawing.SolidBrush(Color.Black), new PointF(43,43));