Hello,
In my application, the user can export his map. For that, I have to use a GoogleMapsLayer in the StaticOverlay to have a background map but the loading is longer than a GoogleOverlay in the BackgroundOverlay.
To make it easier, I want to show to the user the GoogleOverlay but when he exports his map, I want to switch to the StaticOverlay to put a background in his bitmap.
I use this code to do it but it doesn't work:
Map1.BackgroundOverlay.IsVisible = false;
Map1.StaticOverlay.Layers["GoogleMapsLayer"].IsVisible = true;
ScreenPointF ul = Map1.ToScreenCoordinate(Map1.CurrentExtent.UpperLeftPoint);
ScreenPointF lr = Map1.ToScreenCoordinate(Map1.CurrentExtent.LowerRightPoint);
int width = Convert.ToInt32(lr.X - ul.X);
int height = Convert.ToInt32(lr.Y - ul.Y);
Bitmap bmp = Map1.GetBitmap(width, height);
MemoryStream ms = new MemoryStream();
bmp.Save(ms, ImageFormat.Bmp);
byte[] myByte = ms.ToArray();
Map1.BackgroundOverlay.IsVisible = true;
Map1.StaticOverlay.Layers["GoogleMapsLayer"].IsVisible = false;
If I use the OverlaySwitcher, it works very well.
How can I switch between my 2 layers without the OverlaySwitcher.
The declaration of my 2 layers:
string sOverlayMapURL = "Google Key;
GoogleOverlay gOverlay = new GoogleOverlay();
gOverlay.Name = "Google Overlay";
gOverlay.GoogleMapType = GoogleMapType.Hybrid;
gOverlay.JavaScriptLibraryUri = new Uri(sOverlayMapURL);
Map1.BackgroundOverlay = gOverlay;
GoogleMapsLayer gLayer = new GoogleMapsLayer(sOverlayMapURL);
gLayer.Name = "GoogleMapsLayer";
gLayer.MapType = GoogleMapsMapType.Hybrid;
gLayer.PictureFormat = GoogleMapsPictureFormat.Jpeg;
Map1.StaticOverlay.Layers.Add("GoogleMapsLayer", gLayer);