ThinkGeo.com    |     Documentation    |     Premium Support

Printing Map

When printing the map using Marker Overlays in IE 7 (haven't tried other browsers), the print out does not show any Static overlays in the background behind the markers on my map.  Is there a way to get this to print out correctly using the Map.PrintMap() client method as in your simplified "Print Map" sample?


Also the Map controls (MiniMap, Pan, Zoom, etc.) are showing up on the printed map.  Is there a way to turn these off?


Thanks for all of the help!


Jeremy



Jeremy,  


You can customize the print template yourself; here is one sample for you.
 
Thanks,
 
Ben

368-Post5241.zip (95.5 KB)

Thanks for the reply and the sample code. 


After implementing the code, the navigation controls were gone, which is great, but I still have the problem of the map not printing correctly.  The backround Static Overlay shows up only if there is not a marker or a line drawn on a layer covering the Static Overlay.  Print Preview looks fine, it is just once we actually print that we see the problem.  Also if I try to right click on the map and save it as an image, the image only shows the lines that I've drawn in a InMemoryFeatureLayer.


 


 


Let me know what I can do to correct the issue.


Thanks for the excellent support so far!


Jeremy



The following code below should demonstrate the problem I am having:


 



protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#B3C6D4"));
            Map1.CurrentExtent = new RectangleShape(-131.22, 55.05, -54.03, 16.91);
            Map1.MapUnit = GeographyUnit.DecimalDegree;

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(MapPath("~/SampleData/world/cntry02.shp"));
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(255, 243, 239, 228), GeoColor.FromArgb(255, 218, 193, 163), 1);
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureLayer citiesLayer = new ShapeFileFeatureLayer(MapPath("~/SampleData/USA/cities_a.shp"));
            citiesLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City3;
            citiesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            citiesLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new TextStyle("AREANAME", new GeoFont("Verdana", 9), new GeoSolidBrush(GeoColor.StandardColors.Black));
            citiesLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen = new GeoPen(GeoColor.StandardColors.White, 2);
            citiesLayer.DrawingMarginPercentage = 50;

            InMemoryFeatureLayer shapeLayer = new InMemoryFeatureLayer();
            shapeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimplePointStyle(PointSymbolType.Star, GeoColor.StandardColors.Red, 5);
            shapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
            shapeLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.Highway2;
            shapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            Map1.StaticOverlay.Layers.Add(worldLayer);
            Map1.StaticOverlay.Layers.Add(citiesLayer);

Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.ContentHtml = "Kansas City</Div>";
Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.HasCloseButton = true;
Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.Width = 100;
Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.Height = 30;
Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.BackgroundColor = GeoColor.StandardColors.LightBlue;
Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.BorderColor = GeoColor.StandardColors.Black;
Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.Popup.BorderWidth = 1;
Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageOffsetX = -10.5f;
Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageOffsetY = -25f;
Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageWidth = 21;
Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.DefaultMarkerStyle.WebImage.ImageHeight = 25;
Map1.MarkerOverlay.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

double Longitude1 = -94.558;
double Longitude2 = -96.14608;
double Latitude1 = 39.078;
double Latitude2 = 41.54137;

Map1.MarkerOverlay.Features.Add("Kansas", new Feature(Longitude1, Latitude1));
Map1.MarkerOverlay.Features.Add("Blair, Nebraska", new Feature(Longitude2, Latitude2));

Collection<Vertex> historicalPoints = new Collection<Vertex>();
InMemoryFeatureLayer lineLayer = new InMemoryFeatureLayer();

lineLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.City3;
lineLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.Railway1;
lineLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

Map1.DynamicOverlay.Layers.Add("LineLayer", lineLayer);
historicalPoints.Add(new Vertex(Longitude1, Latitude1));
historicalPoints.Add(new Vertex(Longitude2, Latitude2));

lineLayer.InternalFeatures.Add("Line1", new Feature(new LineShape(historicalPoints)));

            Map1.MapTools.MouseCoordinate.Enabled = true;
            Map1.MapTools.OverlaySwitcher.Enabled = true;
            Map1.MapTools.MiniMap.Enabled = true;
            Map1.MapTools.PanZoomBar.Enabled = true;
            Map1.MapTools.ScaleLine.Enabled = true;
Map1.DynamicOverlay.Redraw();
        }
    }


Jeremy, 


I see your problem.
 
The map is composed of a couple overlays and each overlay on client is an image. So when you right click and save to image, you can only save the top one.  If you print, in fact that will print all the images one by one from bottom to top, so that’s important the printing device support transparent otherwise the top image will overwrite the bottom one.  I tried print it as an XPS Document and it is fine, but when I print it as a pdf it only shows the top image, even the preview if fine (I think that’s because the IE7 preview also supports transparent). 


I also tried to print it on a real printer (HP Laser Jet) and seem it support transparent, but the color is not accurate as if I set the sea color to lightblue, it is white on paper and if I changed it to black, it’s fine. I used a black-white printer so I don’t know what it will be like using a full color one. I am wondering what your case is? 
There is a possible enhancement that whenever we print, we merge the overlays to one image and then print, I don’t know if that work and we will test.
 
Thanks,
 
Ben

Ben, 
  
 Great reply!  I am printing to an HP Laser Jet black and white printer, and I only see the topmost layer, so I guess it does not support transparency.  I tried several different HP printers that we have for testing purposes, and got the same result each time.  I think flattening the image layers would be a solution as you suggested as this would solve the transparency issue.  Please let me know what your testing reveals and what a possible time frame might be. 
  
 Thanks, 
 Jeremy

Jeremy, 
  
 We are working on this, I think if everything goes well, we can add it to the coming version. I’m not sure about the release date, I guess it might be around the end of Q1. :) 
  
 Ben.

Ben, 
  
 I read a forum post on outputting the map to a PDF file.  This seems like it would actually work for us as a workaround, but I was having trouble implementing the example using Web Edition.  The example is using winforms code and Static Layers to draw the PDF version of the maps.  I would like to be able to use Web Edition with the YahooOverlay, if possible.  Let me know if there might be a way to do this as a workaround to printing. 
  
 Thanks again, 
 Jeremy

Jeremy, 
  
   At the moment this is not possible.  The reason is that the Yahoo Map images are fetched on the client and are not persisted or moved to the server in any way.  We use their java script control and it gives us few options.  If you used the GoogleMap, or Virtual Earth then it may be possible.  These system offer other static APIs for us to request the images on the server side.  In this way you could create a GoogleMapsLayer and use that.  I think the coordinate system between Yahoo and Google is the same but not sure.  If you could check, and I will check if Yahoo Maps has a static API to get maps based on a web request or a URL of some sort.  If so then we could make this work. 
  
 David

Jeremy, 
  
 In about one second of searching I found that Yahoo Maps does have a static API.  I will get this scheduled with the core team and see if we can get that in quickly. 
  
 David

Did this ever make it into the current version?  I do not see a YahooMapLayer object in version 3.1.273.  Printing the YahooOverlay is still a requirement we have.


Thanks!



Jeremy, 
  
   No, it didn’t make it in however let me see if someone is free to check it out again. 
  
 David