Hi:
I want to add my own label on the map such as google map, can Sharpmap support to add own label?
I want to know it. If anyone knows,please tell me.Thank you!
I am looking forward to it.
Here is a work around. I had to do this as posts like
Adding a labelLayer on the fly with fix TEXT values. could not create a label and throwing this exception:
"Attribute data is not supported by the GeometryProvider."
What I am doing is, creating a Bitmap with the string that I want, using DrawString and adding this to the layer as a symbol.
Here is the code:
SharpMap.Layers.VectorLayer SymbolsLayer = new SharpMap.Layers.VectorLayer("Symbol");
List<SharpMap.Geometries.Geometry> geometries = new List<SharpMap.Geometries.Geometry>();
geometries.Add(new SharpMap.Geometries.Point(p.X, p.Y));
SymbolsLayer.DataSource = new SharpMap.Data.Providers.GeometryProvider(geometries);
Bitmap labelbmp = new Bitmap(80, 20);
Graphics g = Graphics.FromImage(labelbmp);
g.DrawString("Some Text", new Font("Arial", 10, FontStyle.Bold), new SolidBrush(Color.Red), 1, 1);
SymbolsLayer.Style.Symbol = labelbmp;
mapBox1.Map.Layers.Add(SymbolsLayer);
I am sure this is not a good method and there are limitations but atleast I am not getting any exceptions.