I am following your printing example to try and print to pdf etc. The problem is that I am not able to see anything when I add my shape file to the printer layer. What am I doing wrong? I want to add a google layer, then add my shape file then preview and print it. Do you have any examples for this? I have copied the code from your example as shown below:
void AddMapLayer(WpfMap wpfPrint, string ShapeFileLocation)// Create the MapPrinterLayer and set the positionMapPrinterLayer mapPrinterLayer = new MapPrinterLayer();//Map Printer Layer is in feet (State Plane Texas North Central Feet NAD83) GeographyUnit.DecimalDegree;//Set the extent of the MapPrinterLayer with world coordinates. RectangleShape currentExtent = new RectangleShape(2276456, 6897886, 2280391, 6895437);new AreaStyle(new GeoPen(GeoColor.StandardColors.Black, 1));// Set the maps position slightly above the page center and 8 inches wide and 7 inches tall RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch,wpfPrint);PrintingUnit.Inch);//Setup the styles for the parcels layer. ShapeFileFeatureLayer parcelsLayer = new ShapeFileFeatureLayer(@ShapeFileLocation, ShapeFileReadWriteMode.ReadWrite);//Creates a value style for the parcel type (residential 1, commercial 2, industrial 3).
// Add the new parcels layer to the MapPrinterLayer // Add the MapPrinterLayer to the PrinterInteractiveOverlay PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)wpfPrint.InteractiveOverlays["PrintPreviewOverlay"];"MapLayer", mapPrinterLayer);{ public void SetupMapWithBlankPage(WpfMap Map1)try{// Setup the map unit, you want to always use feet or meters for the printer layout map. GeographyUnit.DecimalDegree;// Map1.CurrentExtent = new RectangleShape(17897271, -1367305, 19514067, -2411741); // That pre-defines commonly used zoom levels based on percentages of zoom
Map1.ZoomLevelSet =
Map1.BackgroundOverlay.BackgroundBrush =
Map1.InteractiveOverlays.Add(
Map1.InteractiveOverlays.MoveToBottom(
pagePrinterLayer.Open();
printerOverlay.PrinterLayers.Add(
Map1.CurrentExtent =
Map1.MinimumScale = Map1.ZoomLevelSet.ZoomLevel20.Scale;
}
}
new PrinterZoomLevelSet(Map1.MapUnit, PrinterHelper.GetPointsPerGeographyUnit(Map1.MapUnit));// Here we set the background color to gray so there is contrast with the white page new GeoSolidBrush(GeoColor.StandardColors.LightGray);// Create the PrinterInteractiveOverlay to contain all of the PrinterLayers. // The interactive overlay allows the layers to be interacted with PrinterInteractiveOverlay printerOverlay = new PrinterInteractiveOverlay();"PrintPreviewOverlay", printerOverlay);"PrintPreviewOverlay");// Create the PagePrinterLayer which shows the page boundary and is the area the user will // arrange all of the other layer on top of. PagePrinterLayer pagePrinterLayer = new PagePrinterLayer(PrinterPageSize.AnsiA, PrinterOrientation.Portrait);"PageLayer", pagePrinterLayer);// Get the pages extent, slightly scale it up, and then set that as the default current extent RectangleShape.ScaleUp(pagePrinterLayer.GetPosition(), 10).GetBoundingBox();// Set the minimum sscale of the map to the last zoom level catch{}
{
mapPrinterLayer.Layers.Add(parcelsLayer);
printerInteractiveOverlay.PrinterLayers.Add(
}
public
Map1.MapUnit =
mapPrinterLayer.MapUnit =
mapPrinterLayer.MapExtent = currentExtent;
mapPrinterLayer.BackgroundMask =
mapPrinterLayer.Open();
mapPrinterLayer.SetPosition(8, 7, pageBoundingbox.GetCenterPoint().X, pageBoundingbox.GetCenterPoint().Y + 1,
typeValueStyle.ColumnName = "PARCELTYPE";
typeValueStyle.ValueItems.Add(new ValueItem("1", new AreaStyle(new GeoPen(GeoColor.StandardColors.Black), new GeoSolidBrush(GeoColor.StandardColors.LightGreen))));
typeValueStyle.ValueItems.Add(new ValueItem("2", new AreaStyle(new GeoPen(GeoColor.StandardColors.Black), new GeoSolidBrush(GeoColor.StandardColors.LightPink))));
typeValueStyle.ValueItems.Add(new ValueItem("3", new AreaStyle(new GeoPen(GeoColor.StandardColors.Black), new GeoSolidBrush(GeoColor.StandardColors.LightBlue))));
parcelsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(typeValueStyle);