}
//没有tempLayer图层,就新建
if (Flag==false)
{
CMapXLayer lyr=m_ctrlMapX.GetLayers().CreateLayer("tempLayer");
m_ctrlMapX.GetLayers().SetAnimationLayer(lyr); //设为动态图层
}
Layer=m_ctrlMapX.GetLayers().Item("tempLayer");
FeaFac=m_ctrlMapX.GetFeatureFactory();
//加点
Pnts.AddXY(centerX,centerY);
Pnts.AddXY(centerX+20,centerY+20);
//
COleVariant vtPoints;
vtPoints.vt=VT_DISPATCH;
vtPoints.pdispVal=Pnts.m_lpDispatch;
vtPoints.pdispVal->AddRef();
Feature=FeaFac.CreateLine(vtPoints); //按照点集画线
Style=Feature.GetStyle();
Style.SetLineColor(miColorRed); //线条颜色
Style.SetLineWidth(2); //线条宽度
Feature.SetStyle(Style.m_lpDispatch);
Layer.AddFeature(Feature); //加入Feature
Layer.Refresh(); //更新图层
------------------------------
简单说明,tempLayer是画线的图层,首先判断是否存在。如果不存在就新建,并且使它为动态图层。
点的加入顺序不同,画出来的线条也是不一样的,大家可以测试一下,就明白了。