Image Overlay

Feb 9, 2011 at 5:50 PM

Use Case: display an image on a map.

The code below overlays an image on top of an existing map

         private void add_image()
        {
            Image image = Image.FromFile("C:\\MapData\\Unknown.bmp");
            Graphics g = Graphics.FromImage(image);
            Point point = new Point();

            ImageData idata = new InRamImageData("C:\\work\\2525b\\2525B\\A_Warfighting\\ground_track\\Unknown.png");

            Extent inExtent = new Extent();
            inExtent.MinX = 127.3;
            inExtent.MaxX = 127.35;
            inExtent.MinY = 37.2;
            inExtent.MaxY = 37.25;
            idata.Projection = map1.Projection;  //make the image projection the same as the maps
            idata.Extent = inExtent; //put the image in a position on the map
            IMapImageLayer imageLayer = map1.Layers.Add(idata) as IMapImageLayer;
            imageLayer.DataSet = idata;           
            imageLayer.Symbolizer = new ImageSymbolizer();
            map1.MapFrame.Invalidate();
            map1.Invalidate();
        }

The image is placed within extents of the lower image layer. the extents of the new image layer lies within small bounderies so it appears as a small image in a  location on the map.

I suppose if I wanted the image to increase/decrease based on resolution I could add/subtract values to the extents based on zoom-in/zoom-out requests.

Not sure if this is the best way to display a symbol on top of a map but its what I came up with.

I'd be interested in alternate solutions.

Thanks,

Alan