Programmatically setting spatial reference/coordinate system of marker symbol

Discussion created by uci.gis on Nov 6, 2010
Dear All,

In one of our DLL application, we are creating a marker symbol and this symbol is updated by the application time to time. It's not a GPS tracking application. But the marker symbol is updated according to some coordinates we read from a GPS device log file.

The DLL does not require certain layer structure. Therefore, we are not sure about the spatial reference. So while we are creating the point, we simply set IPoint's X and Y coordinates and as expected in some cases the point does not appear at the correct location on the map.

Here is the code how we create the symbol and set coordinates:

ESRI.ArcGIS.Geometry.IPoint pPoint = new ESRI.ArcGIS.Geometry.PointClass();
pPoint.X = gpsData.longitude;
pPoint.Y = gpsData.latitude;
ESRI.ArcGIS.Geometry.IZAware zAware = (ESRI.ArcGIS.Geometry.IZAware)pPoint;
zAware.ZAware = true;
pPoint.Z = gpsData.altitude;
// Here, we are trying to set pPoint.SpatialReference to current map's spatial reference.
// pPoint.SpatialReference = m_Map.SpatialReference;
// It doesn't work
// But sometimes we realize that the current map's spatial reference is unknown.

IMarkerElement me = mCameraIconElement as IMarkerElement;
IPictureMarkerSymbol pms = me.Symbol as IPictureMarkerSymbol;
pms.Angle = -(double)(mCurrentAzimuth + pan) / TO_RADIAN;
me.Symbol = pms;
mCameraIconElement = (IElement)me;
mCameraIconElement.Geometry = pPoint;
IGraphicsContainer graphicsContainer = (IGraphicsContainer)m_Map;

Thanks for your help in advance.