- void CLmtestView::DrawLine(CMapXLayer* layer, Position startPoint, Position endPoint)//画轨迹线
- {
- CMapXStyle lineSty; //线图元
- COleVariant vt;
- vt.vt=VT_DISPATCH;
- CMapXFeature newFeature; //新建图元
- CMapXPoint pt; //点图元
- CMapXPoints pts; //点集合
- pt.CreateDispatch(pt.GetClsid());
- pts.CreateDispatch(pts.GetClsid());
- pts.RemoveAll();
- pt.Set(startPoint.m_longtidude, startPoint.m_latitude); //线的起点
- pts.Add(pt);
- pt.Set(endPoint.m_longtidude,endPoint.m_latitude); //线的终点
- pts.Add(pt);
- vt.pdispVal=pts.m_lpDispatch;
- vt.pdispVal->AddRef();//此句不可缺
- CMapXFeature sidefeature=m_map.GetFeatureFactory().CreateLine(vt); //创建线图元
- lineSty=sidefeature.GetStyle(); //设置线图元的风格
- lineSty.SetLineColor(miColorBlue);
- lineSty.SetLineStyle(36);
- sidefeature.SetStyle(lineSty.m_lpDispatch);
- sidefeature=(*layer).AddFeature(sidefeature); //将创建的图元加入到图层中
- sidefeature.Update();
- long sid=sidefeature.GetFeatureID();//过去图元的ID号,此ID号只能读,不能写
- m_sidearray.Add(sid); //该数组保存着线图元的ID号
- m_map.Refresh();
- }