相比于添加点要素,线要素就有点复杂了,话不多说
我要贴图了:
这是一个线路的空间数据类,绿框框中的一定要加上,就是返回线的节点集合的一个方法;
type=6 是代表画线,也就是告诉mapcontrol 我要画线啊,不是点
接下来读你自己的数据,接下来一些属性的设置,贴图楼
恩,就是这样:接下来,重中之重
///
/// 线路地图展示渲染设置
///
public class LSMapFactory : DefaultMapItemFactory
{
protected override void InitializeItem(MapItem item, object obj)
{
base.InitializeItem(item, obj);
MapPolyline polyLine = item as MapPolyline;
LineGeoInfo line = obj as LineGeoInfo;
if (polyLine != null)
{
polyLine.IsGeodesic = true;
polyLine.Fill = Color.Empty;
//polyLine.Stroke = Color.FromArgb(12, 113, 250);
polyLine.Points = line.GetLineGeo();
//polyLine.StrokeWidth = 3;
polyLine.ToolTipPattern = line.LineNum;
}
MapCustomElement customElement = item as MapCustomElement;
if (customElement != null)
{
customElement.UseAnimation = false;
customElement.BackgroundDrawingMode = ElementState.None;
}
item.Visible = true;
}
}
添加一个这样的方法:可以根据需要设置每条线的style,程序中调用:
mapControl1.SetMapItemFactory(new LSMapFactory());
就是这样,具体为什么这样写,我也不太明白,我看的源码是这样写的,如果有大神了解请告知一下,恩,小仙女不在意这些细节!
好像是没了
整理的有点乱,就先这样吧 如果还有问题可以加q:574028237,没啥事就不要随便加了