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 add a marker symbol to an ArcGIS Engine MapControl at a specific coordinate?

share|improve this question
add comment

1 Answer

    /// <summary>
    /// Places a marker on a map at an X and Y position.
    /// </summary>
    /// <param name="map">The map to place the dot on.</param>
    /// <param name="mapX">The X coordinate for the dot.</param>
    /// <param name="mapY">The Y coordinate for the dot.</param>
    /// <param name="markerSymbol">An IMarkerSymbol object describing the highlight symbol.</param>
    public static void DropMarkerOnMap(IMap map, double mapX, double mapY,
        IMarkerSymbol markerSymbol)
    {
        IActiveView av = (IActiveView) map;
        IGraphicsContainer gc = av.GraphicsContainer;
        IPoint pt = new PointClass();
        pt.X = mapX;
        pt.Y = mapY;
        IMarkerElement ptElem = new MarkerElementClass();
        ptElem.Symbol = markerSymbol;
        IElement elem = (IElement) ptElem;
        elem.Geometry = pt;
        gc.AddElement(elem, 0);
        av.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, av.Extent);
    }
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.