public class AlphaGoogleMapsLayer : Layer { private GoogleMapsLayer googleLayer; public float Alpha { get; set; } public AlphaGoogleMapsLayer() : this(255) { } public AlphaGoogleMapsLayer(float alpha) : base() { googleLayer = new GoogleMapsLayer(); Alpha = alpha; } public AlphaGoogleMapsLayer(float alpha, string licenseKey, string cacheDirectory) : this(alpha) { googleLayer.LicenseKey = licenseKey; googleLayer.CacheDirectory = cacheDirectory; } protected override void DrawCore(GeoCanvas canvas, System.Collections.ObjectModel.Collection labelsInAllLayers) { int canvasWidth = (int)canvas.Width; int canvasHeight = (int)canvas.Height; using (Bitmap bitmap = new Bitmap(canvasWidth, canvasHeight)) { GdiPlusGeoCanvas gdiCanvas = new GdiPlusGeoCanvas(); gdiCanvas.BeginDrawing(bitmap, canvas.CurrentWorldExtent, canvas.MapUnit); googleLayer.Open(); googleLayer.Draw(gdiCanvas, new Collection()); googleLayer.Close(); gdiCanvas.EndDrawing(); using (Bitmap newBitmap = new Bitmap(canvasWidth, canvasHeight)) { Graphics graphics = Graphics.FromImage(newBitmap); Rectangle rectangle = new Rectangle(0, 0, bitmap.Width, bitmap.Height); ImageAttributes imageAttributes = TranslateImage(); graphics.DrawImage(bitmap, rectangle, 0, 0, bitmap.Width, bitmap.Height, GraphicsUnit.Pixel, imageAttributes); MemoryStream stream = new MemoryStream(); newBitmap.Save(stream, ImageFormat.Png); GeoImage geoImage = new GeoImage(stream); canvas.DrawScreenImageWithoutScaling(geoImage, canvasWidth * 0.5f, canvasHeight * 0.5f, DrawingLevel.LevelOne, 0, 0, 0); stream.Close(); } } } private ImageAttributes TranslateImage() { // noramlize the color components to 1 float r = 0 / 255; float g = 0 / 255; float b = 0 / 255; float a = Alpha / 255.0f; float[][] floats = new float[5][]; floats[0] = new float[] { 1, 0, 0, 0, 0 }; floats[1] = new float[] { 0, 1, 0, 0, 0 }; floats[2] = new float[] { 0, 0, 1, 0, 0 }; floats[3] = new float[] { 0, 0, 0, a, 0 }; floats[4] = new float[] { r, g, b, 0, 1 }; ColorMatrix ColorMatrix = new ColorMatrix(floats); ImageAttributes imgAttributes = new ImageAttributes(); imgAttributes.SetColorMatrix(ColorMatrix); return imgAttributes; } }