|
void drawNewFeature(
const CString &csLayerName,
double dblLng,
double dblLat,
const CString &csName,
const CString &csLevel,
const CString &csTime
)
{
CMapX *m_mapx;
CMapXStyle pStyle;
pStyle.CreateDispatch(pStyle.GetClsid());
pStyle.SetSymbolType(miSymbolTypeVector);
pStyle.SetSymbolCharacter(34);
pStyle.SetSymbolVectorSize(16);
pStyle.SetSymbolVectorColor(miColorRed);
CMapXLayer pLayer;
pLayer = m_mapx->GetLayers().Item(csLayerName);
pLayer.BeginAccess(miAccessReadWrite);
{
m_mapx->SetAutoRedraw(FALSE);
pLayer.SetEditable(TRUE);
CMapXFeature pFeature;
CMapXPoint pPoint;
CMapXFeatureFactory pFeatureFactory;
pFeatureFactory = m_mapx->GetFeatureFactory();
pFeature.CreateDispatch(pFeature.GetClsid());
pPoint.CreateDispatch(pPoint.GetClsid());
pPoint.Set(dblLng,dblLat);
VARIANT vtPoint;
VARIANT vtStyle;
vtPoint.vt = VT_DISPATCH;
vtPoint.pdispVal = pPoint.m_lpDispatch;
vtStyle.vt = VT_DISPATCH;
vtStyle.pdispVal = pStyle.m_lpDispatch;
pFeature = pFeatureFactory.CreateSymbol(vtPoint, vtStyle);
pLayer.AddFeature(pFeature.m_lpDispatch);
pLayer.Refresh();
pLayer.SetKeyField("name");
pFeature.SetKeyValue(csName);
//在这里出错了
pFeature.Update();
pLayer.SetKeyField("level");
pFeature.SetKeyValue(csLevel);
pFeature.Update();
pLayer.SetKeyField("time");
pFeature.SetKeyValue(csTime);
pFeature.Update();
m_mapx->ZoomTo(1000,pFeature.GetCenterX(),pFeature.GetCenterY());
m_mapx->SetAutoRedraw(TRUE);
pLayer.SetEditable(FALSE);
m_mapx->Refresh();
}
pLayer.EndAccess();
} |
|