Hi,
I need to use bingMap or googleMap in print (PrinterInteractiveOverlay).
Is there any sample for this ?
thanks
Using BingMap with printing
Hi Maryam,
I think the below codes should be fit for you:
privatevoidDisplayMap_Load(objectsender, EventArgs e){winformsMap1.MapUnit = GeographyUnit.Meter;winformsMap1.BackgroundOverlay.BackgroundBrush =newGeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
PrinterInteractiveOverLay printerOverlay =newPrinterInteractiveOverLay();winformsMap1.InteractiveOverlays.Add(“PrintPreviewOverlay”, printerOverlay);winformsMap1.InteractiveOverlays.MoveToBottom(“PrintPreviewOverlay”);
PagePrinterLayer pagePrinterLayer =newPagePrinterLayer(PrinterPageSize.AnsiA, PrinterOrientation.Portrait);pagePrinterLayer.Open();printerOverlay.PrinterLayers.Add(“PageLayer”, pagePrinterLayer);
AddMapLayer();
winformsMap1.CurrentExtent = RectangleShape.ScaleUp(pagePrinterLayer.GetPosition(), 10).GetBoundingBox();winformsMap1.Refresh();}
privatevoidAddMapLayer(){// Create the MapPrinterLayer and set the positionMapPrinterLayer mapPrinterLayer =newMapPrinterLayer();mapPrinterLayer.MapUnit = GeographyUnit.Meter;mapPrinterLayer.MapExtent =newRectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);mapPrinterLayer.BackgroundMask =newAreaStyle(newGeoPen(GeoColor.StandardColors.Black, 1));mapPrinterLayer.Open();
RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch);mapPrinterLayer.SetPosition(8, 7, pageBoundingbox.GetCenterPoint().X, pageBoundingbox.GetCenterPoint().Y + 1, PrintingUnit.Inch);
mapPrinterLayer.Layers.Add(newGoogleMapsLayer());
// Add the MapPrinterLayer to the PrinterInteractiveOverlayPrinterInteractiveOverLay printerInteractiveOverLay = (PrinterInteractiveOverLay)winformsMap1.InteractiveOverlays[“PrintPreviewOverlay”];printerInteractiveOverLay.PrinterLayers.Add(“MapLayer”, mapPrinterLayer);}
privateRectangleShape GetPageBoundingBox(PrintingUnit unit){// This helper method gets the pages bounding box in the unit requestedPrinterInteractiveOverLay printerInteractiveOverLay = (PrinterInteractiveOverLay)winformsMap1.InteractiveOverlays[“PrintPreviewOverlay”];PagePrinterLayer pagePrinterLayer = (PagePrinterLayer)printerInteractiveOverLay.PrinterLayers[“PageLayer”];returnpagePrinterLayer.GetPosition(unit); ;}
The result should be look like this if everything goes well.

Hope it helps.
Regards,
Troy
Hi,
Your answer really helped me .
thanks a lot .
Hi Maryam,
Good to hear it works for you.
If any other queries, don’t hesitate to let us know.
Regards,
Troy