Route Stroke Issue GMAP 路径样式问题

在GMapRoute.cs中,由于默认笔触(DefaultStroke)的属性更改会影响到所有路径,导致样式统一变化。通过将公共笔触(Stroke)设置为默认笔触的克隆对象,可以避免此问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I was trying to figure out why when I changed the color of one of my routes (using route.Stroke.Color = something) all of my routes would change color. When I dug into your code a bit I figured out what’s going on.

On line 188 of GMapRoute.cs you have

public Pen Stroke = DefaultStroke

The problem is even though DefaultStroke is readonly if I change any of the properties associated with the stroke of one route it will change the properties of DefaultStroke which will then affect all routes that are using the default.

Changing line 188 to the following prevents the issue:

public Pen Stroke = DefaultStroke.Clone() as Pen;

在引用GMAP源代码后出现了路径样式问题:
改变某个路径样式,所有路径的样式均会改变。参考以上方法可以解决。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值