CMapXPoints Pnts;
//
点集对象
CMapXFeatureFactory FeaFac;
CMapXLayer Layer;
CMapXFeature Feature;
CMapXStyle Style;
double centerX,centerY; // 得到地图的中心
centerX = m_ctrlMapX.GetCenterX();
centerY = m_ctrlMapX.GetCenterY();
Pnts.CreateDispatch(Pnts.GetClsid());
// 判断是否存在tempLayer图层
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 ;
}
}
// 没有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(); // 更新图层
CMapXFeatureFactory FeaFac;
CMapXLayer Layer;
CMapXFeature Feature;
CMapXStyle Style;
double centerX,centerY; // 得到地图的中心
centerX = m_ctrlMapX.GetCenterX();
centerY = m_ctrlMapX.GetCenterY();
Pnts.CreateDispatch(Pnts.GetClsid());
// 判断是否存在tempLayer图层
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 ;
}
}
// 没有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是画线的图层,首先判断是否存在。如果不存在就新建,并且使它为动态图层。
点的加入顺序不同,画出来的线条也是不一样的,大家可以测试一下,就明白了。
简单说明,tempLayer是画线的图层,首先判断是否存在。如果不存在就新建,并且使它为动态图层。
点的加入顺序不同,画出来的线条也是不一样的,大家可以测试一下,就明白了。