<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Programmatically setting spatial reference/coordinate system of marker symbol in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/programmatically-setting-spatial-reference/m-p/438619#M11871</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dear All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the code how we create the symbol and set coordinates:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
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;
graphicsContainer.UpdateElement(mCameraIconElement);
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help in advance.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 06 Nov 2010 07:50:43 GMT</pubDate>
    <dc:creator>BarisUz</dc:creator>
    <dc:date>2010-11-06T07:50:43Z</dc:date>
    <item>
      <title>Programmatically setting spatial reference/coordinate system of marker symbol</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/programmatically-setting-spatial-reference/m-p/438619#M11871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dear All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the code how we create the symbol and set coordinates:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
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;
graphicsContainer.UpdateElement(mCameraIconElement);
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help in advance.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Nov 2010 07:50:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/programmatically-setting-spatial-reference/m-p/438619#M11871</guid>
      <dc:creator>BarisUz</dc:creator>
      <dc:date>2010-11-06T07:50:43Z</dc:date>
    </item>
  </channel>
</rss>

