CMapXFeatureFactory FeaFac;
CMapXLayer Layer;
CMapXFeature Feature;
CMapXStyle Style;
double centerX,centerY;
centerX=m_ctrlMapX.GetCenterX();
centerY=m_ctrlMapX.GetCenterY();
Pnts.CreateDispatch(Pnts.GetClsid());
CMapXLayers layers=m_ctrlMapX.GetLayers();
BOOL Flag=false;
for(int i=0;i<layers.GetCount();i++)
{
Layer=layers.Item(i+1);
if(Layer.GetName()=="tempLayer")
{
Flag=true;
break;
}
}
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);
Layer.Refresh();