|
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);
Ranch
CMapXLayer pLayer;
pLayer = m_mapx-> GetLayers (). Item (csLayerName);
Ranch
pLayer.BeginAccess (miAccessReadWrite);
Ranch
{
m_mapx-> SetAutoRedraw (FALSE);
pLayer.SetEditable (TRUE);
Ranch
CMapXFeature pFeature;
CMapXPoint pPoint;
CMapXFeatureFactory pFeatureFactory;
pFeatureFactory = m_mapx-> GetFeatureFactory ();
pFeature.CreateDispatch (pFeature.GetClsid ());
pPoint.CreateDispatch (pPoint.GetClsid ());
Ranch
pPoint.Set (dblLng, dblLat);
Ranch
VARIANT vtPoint;
VARIANT vtStyle;
Ranch
vtPoint.vt = VT_DISPATCH;
vtPoint.pdispVal = pPoint.m_lpDispatch;
Ranch
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);
// wrong here
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 ());
Ranch
m_mapx-> SetAutoRedraw (TRUE);
pLayer.SetEditable (FALSE);
Ranch
m_mapx-> Refresh ();
}
pLayer.EndAccess ();
} |
|