[GIS] Can Bing base layers be used with the Mapfish / Geoserver print plugin

bing-mapsmapfishpdfprinting

After being able to solve most of my problems just be lurking, I find I now need to come into the light for this one. The headline is pretty explicit. I have been unable to use the mapfish print utility to generate my PDF's including the Bing base layers. For a live example, please visit http://gis.lhtac.org/safety_print . Steps to reproduce follow:

 1.  Select a region.  Click on one of the colored areas.  I suggest district 2.
 2.  Select a Jurisdiction.  A panel will pop with a list of road jurisdictions.  I suggest 'Grangeville'. 
 3.  Please observe the layers, including the Bing base layers, and our in-house WMS layers.  Also, observe the 'Print Map' button is now live in the Crash Statistics panel.
 4.  If desired, drag a bounding box to select some of the indicated crashes. This will select some datapoints for a WFS layer derived from the Crash Location WMS layer data. 
 5.  Click on the 'Print Map' button. 
 6.  Observe the GeoExt print panel, and that the Bing Layers are shown, but possibly only around the edges.
 7.  Zoom in once or twice and observe the Bing layer is now fully represented. 
 8.  Click the 'Create PDF' anchor in the tbox of the print panel.  Wait for a bit while the server thinks about it.  Presuming nothing has broken, a generated pdf will be offered for download.
 9.  Open the pdf, and please observe the following: 

 A: the Bing base layer is missing. 
 B: our in-house WMS layers are shown, although at poor resolution.
 C: If WFS selections had been made, they are shown, with the known filled polygon rendering bug. 
 D: Other artifacts are shown, pretty much as might be expected. 

My best guess as to the cause of no base layer is that there is some unspecified problem using Bing with the Mapfish utility. I have been unable to find any reference to this, however, either as a bug, or as a terms of service issue. The second most likely problem is my config.yaml is incorrectly referencing the Bing servers. That section of the config.yaml follows: (The SE editor has mangled it slightly)

hosts:
– !ipMatch
ip: 127.0.0.1
port: 8080
– !ipMatch
ip: gis.lhtac.org
– !ipMatch
ip: www.camptocamp.org
– !dnsMatch
host: maps.live.com
port: 80
– !dnsMatch
host: virtualearth.com
port: 80

Thanks for looking.

Best Answer

Sure, here they go:

  1. https://groups.google.com/forum/#!topic/geoext-users-archive/CuRNR0Bunao
  2. http://lists.mapfish.org/pipermail/users/2009-June/001358.html
  3. http://web.archiveorange.com/archive/v/0qLmXZEGywMbGnqRlv67

However, you can use GMaps v2 API through OpenLayers, and perhaps print it as basemap with MapFish, here it is the source code:

var options = {
    singleTile: true,
    ratio: 1,
    isBaseLayer: true,
    wrapDateLine: true,
    getURL: function() {
        var center = this.map.getCenter().transform("EPSG:3857", "EPSG:4326"),
            size = this.map.getSize();
        return [
            this.url, "&center=", center.lat, ",", center.lon,
            "&zoom=", this.map.getZoom(), "&size=", size.w, "x", size.h
        ].join("");
    }
};

var map = new OpenLayers.Map({
    div: "map",
    projection: "EPSG:3857",
    numZoomLevels: 22,
    layers: [
        new OpenLayers.Layer.Grid(
            "Google Physical",
            "http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=terrain", 
            null, options
        ),
        new OpenLayers.Layer.Grid(
            "Google Streets",
            "http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=roadmap", 
            null, options
        ),
        new OpenLayers.Layer.Grid(
            "Google Hybrid",
            "http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=hybrid", 
            null, options
        ),
        new OpenLayers.Layer.Grid(
            "Google Satellite",
            "http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=satellite", 
            null, options
        ),
        // the same layer again, but scaled to allow map sizes up to 1280x1280 pixels
        new OpenLayers.Layer.Grid(
            "Google Satellite (scale=2)",
            "http://maps.googleapis.com/maps/api/staticmap?sensor=false&maptype=satellite&scale=2", 
            null, OpenLayers.Util.applyDefaults({
                getURL: function() {
                    var center = this.map.getCenter().transform("EPSG:3857", "EPSG:4326"),
                        size = this.map.getSize();
                    return [
                        this.url, "&center=", center.lat, ",", center.lon,
                        "&zoom=", (this.map.getZoom() - 1),
                        "&size=", Math.floor(size.w / 2), "x", Math.floor(size.h / 2)
                    ].join("");
                }
            }, options)
        )
    ],
    center: new OpenLayers.LonLat(10.2, 48.9).transform("EPSG:4326", "EPSG:3857"),
    zoom: 5
});
map.addControl(new OpenLayers.Control.LayerSwitcher());

and the OpenLayers example:

http://openlayers.org/dev/examples/google-static.html

Additionally, this nice post may help you if you want to include GMaps + MapServer + TileCache:

http://crschmidt.net/blog/archives/311/using-tilecache-with-google-maps-and-virtual-earth/

Related Question