Thanks Ben,
I try your example. Was able to save a VirtualEarthLayer image with content or shape. However, encounter some problems.
First, I can't add a custom ImageUri on VirtualEarthLayer. Second , whenever I add the add shapes to VirtualEarthLayer layer, I am getting "The given key was not present in the dictionary." on Bitmap bmpMap = Map1.GetBitmap(iWidth, iHeight).
private void SaveImage(){
Overlay objAactiveOverlay = Map1.ActiveBaseOverlay;
SetTicketLogoImage();
Map1.CustomOverlays["VirtualEarth Overlay"].IsVisible = true;
Map1.ActiveBaseOverlay = (LayerOverlay)Map1.CustomOverlays["VirtualEarth Overlay"];
ScreenPointF ULPoint = Map1.ToScreenCoordinate(Map1.CurrentExtent.UpperLeftPoint);
ScreenPointF LRCoord = Map1.ToScreenCoordinate(Map1.CurrentExtent.LowerRightPoint);
int iWidth = Convert.ToInt32(LRCoord.X - ULPoint.X);
int iHeight = Convert.ToInt32(LRCoord.Y - ULPoint.Y);
Bitmap bmpMap = Map1.GetBitmap(iWidth, iHeight);
bmpMap.Save((@"c:\TEST\A-" + DateTime.Now.ToString("MM-dd-yyyy hhmm tt") + ".jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
//Reset existing
//Map1.ActiveBaseOverlay = objAactiveOverlay;
}
This is how I structure my application-- Three CustomOverlays (VirtualEarthOverlay, custom shapes and text overlay, and hidden VirtualEarthLayer). All shapes and drawing is done on client-side; On Save, the client-side shapes are added to the Customlayers before calling the GetBitMap function. Below is my two sample functions. Please advise. Thanks
private void testAddEdit2Overlay()
{
LayerOverlay lOlay = (LayerOverlay)Map1.CustomOverlays["shapeOverlay"];
LayerOverlay veOlay = (LayerOverlay)Map1.CustomOverlays["VirtualEarth Overlay"];
InMemoryFeatureLayer shapeLayer = (InMemoryFeatureLayer)lOlay.Layers[0];
InMemoryFeatureLayer textLayer = (InMemoryFeatureLayer)lOlay.Layers[1];
InMemoryFeatureLayer veLayer = (InMemoryFeatureLayer)lOlay.Layers[0];
shapeLayer.InternalFeatures.Clear();
veLayer.InternalFeatures.Clear();
foreach (string EditShapeKey in Map1.EditOverlay.Features.GetKeys())
{
Feature featureEdit = Map1.EditOverlay.Features[EditShapeKey];
// shapeLayer.InternalFeatures.Add(featureEdit.Id, featureEdit);
veLayer.InternalFeatures.Add(featureEdit.Id, featureEdit);
textLayer.InternalFeatures.Add(featureEdit.Id, featureEdit);
}
lOlay.Redraw();
veOlay.Redraw();
}