How to add my own label?

How to add my own label? 
Tags: General Topics

May 31 2007 at 9:27 AM
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.

Jun 1 2007 at 8:15 PM
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.

Jun 4 2007 at 3:20 PM
List<SharpMap.Geometries.Geometry> geometries = new List<SharpMap.Geometries.Geometry>();


say List not define. what is the issue.

Jun 4 2007 at 5:34 PM
 
 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值