Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

How do I convert from an ESRI.ArcGIS.Geometry.IPoint to an ESRI.ArcGIS.Client.Graphic point object?

In other words, I'm wanting to convert from an IGeometry to a runtime geometry, I guess.

share|improve this question
    
Are you working in SilverLight? Have you looked at the sample given here: help.arcgis.com/en/webapi/silverlight/apiref/… –  Devdatta Tengshe Jan 15 '13 at 16:45
    
Yes, actually I've been looking at this link this morning, but couldn't really pin-point my answer. I'll take another look at it. Maybe I'm just missing something. Thanks! –  Renee Cammarere Jan 15 '13 at 18:47
    
If you are working in the Silverlight API, you won't have an IPoint. That exists only in the ArcObjects API. In silverlight, you will have a MapPoint. The linked page, shows how you can make a graphic from a MapPoint. –  Devdatta Tengshe Jan 16 '13 at 3:13
add comment

1 Answer

up vote 2 down vote accepted

I was able to do this with the following code snippit . . .

       //  *********************   Convert from IGeometry to runtime geometry    *********************
        // Create a new instance of one Graphic.
        ESRI.ArcGIS.Client.Graphic aGraphic = new ESRI.ArcGIS.Client.Graphic();

       // Create a SpatialReference for the Graphic. Point Graphics are known as MapPoint objects
       ESRI.ArcGIS.Client.Geometry.SpatialReference aSpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326);
        // Create a MapPoint object and set its SpatialReference and coordinate (X,Y,Z) information. 
        ESRI.ArcGIS.Client.Geometry.MapPoint aMapPoint = new ESRI.ArcGIS.Client.Geometry.MapPoint();
        aMapPoint.SpatialReference = aSpatialReference;
        aMapPoint.X = Point.X;// Point is an IPoint object
        aMapPoint.Y = Point.Y;
        aMapPoint.Z = Point.Z;

       // Create a new instance of a SimpleMarkerSymbol and set its Style, and Size Properties.
       ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol aSimpleMarkerSymbol = new ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol();
        aSimpleMarkerSymbol.Style = ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol.SimpleMarkerStyle.Circle;
        aSimpleMarkerSymbol.Size = 10;

         // Apply the Graphic's Geometry and Symbol Properties.
       aGraphic.Geometry = (ESRI.ArcGIS.Client.Geometry.Geometry)aMapPoint;
        aGraphic.Symbol = (ESRI.ArcGIS.Client.Symbols.Symbol)aSimpleMarkerSymbol;

       _graphicsLayer.Graphics.Add(aGraphic);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.