专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > GIS

关于MapX画简单图形解决办法

发布时间:2010-06-06 17:15:38 文章来源:www.iduyao.cn 采编人员:星星草
关于MapX画简单图形
RT,我在网上看到例子,是使用MapX在VC里画个简单的矩形,代码
  CMapXPoints Pnts;
CMapXFeatureFactory FeaFac;
CMapXLayer Layer;
CMapXFeature Feature;
CMapXStyle Style;
CMapXRectangle rect;
rect.CreateDispatch(rect.GetClsid());
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()=="SOUNDINGS") 
{
Flag=true;  
break;
}
}
//没有tempLayer图层,就新建
if (Flag==false)
{
CMapXLayer lyr=m_ctrlMapX.GetLayers().CreateLayer("SOUNDINGS");
m_ctrlMapX.GetLayers().SetAnimationLayer(lyr); //设为动态图层  
}
Layer=m_ctrlMapX.GetLayers().Item("SOUNDINGS");
FeaFac=m_ctrlMapX.GetFeatureFactory();
Pnts.AddXY(centerX,centerY); //第一个点
Pnts.AddXY(centerX+200,centerY); //第二个点
Pnts.AddXY(centerX+200,centerY+200); //第三个点
Pnts.AddXY(centerX,centerY+20); //第四个点
COleVariant vtPoints;
vtPoints.vt=VT_DISPATCH;
vtPoints.pdispVal=Pnts.m_lpDispatch;
vtPoints.pdispVal->AddRef();
Feature=FeaFac.CreateRegion(vtPoints);
Style=Feature.GetStyle();
Style.SetRegionPattern(miPatternNoFill); //填充颜色 无
Style.SetRegionBorderColor(miColorRed); //边框颜色 红
Style.SetRegionBorderWidth(2); //边框宽度
Feature.SetStyle(Style.m_lpDispatch);
Layer.AddFeature(Feature); //加入Feature
Layer.Refresh(); //更新图层

但是为什么在图层里什么也没有显示?

------解决方案--------------------
探讨
我换了一种还是不行,调试到坐标转换时跳出。
VARIANT scx,scy;
points.CreateDispatch(points.GetClsid());
CMapXLayer layer=m_ctrlMapX.GetLayers().Item("SOUNDINSS"); //获得已有图层
//进行坐标变换
m_ctrlMapX.ConvertCoordV(&amp……
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: