3

Following OpenLayers map printing demo here, I'm able to get my map in image format. But I'm facing two issues with the export:

  1. Google Street base map is not included in the image output;
  2. Whenever I activate any WMS layer, the export fails with the error TypeMismatchError: The type of an object is incompatible with the expected type of the parameter associated to the object

To get an image output of the map, I'm using Canvas.toDataURL(), which opens another window with the image of my WFS layers. According to the demo, when using Canvas.toDataURL(), images should be requested through a proxy, a point I don't understand as far as Google base layer is concerned. Any clarification will be appreciated.

I'm not sure what I may be doing wrong. Below shows how I retrieve Google base map and WMS layers:

Google base map:

var gStreet = new OpenLayers.Layer.Google(
            'Google Street',
            {numZoomLevels: 19},
            {visibility: true},
            {isBaseLayer: true},
            {useCanvas: OpenLayers.Layer.Grid.ONECANVASPERLAYER}
    );

WMS Layer:

var wmsLayer = new OpenLayers.Layer.WMS("My WMS Layer",
        GEOSERVER_HOST + "/wms", 
        {layers: "wms_layer", format: 'image/png'},
        {
            useCanvas: OpenLayers.Layer.Grid.ONECANVASPERLAYER,
            isBaseLayer: false
        }
    );

GEOSERVER_HOST is proxied via Apache web server. I've configured Apache to channel all GeoServer requests as necessary. As such, I'm not making direct request to GeoServer in my client.

Any idea on what I may be doing wrong will be appreciated.

  • 1
    You may need to use static maps api: developers.google.com/maps/documentation/staticmaps – U2ros Sep 25 '12 at 9:05
  • Following the example of google staticmaps at openlayers.org/dev/examples/google-static.html, I've been trying in vain to get it working. If you know of a working OL google static map example, plz post a link. – okello Sep 27 '12 at 7:12
  • erm, i think the examples pretty much start from scratch. The whole map generation is controleed via parameters passed by the URL, the api then returns an image. My suggestion is, copy a working example URL from there, and play with parameters to get comfortable. – U2ros Sep 27 '12 at 8:56
  • I got the static map working. I'll now test it with the printing. – okello Sep 27 '12 at 9:30
  • Hi, printing maps are not a simple problem. Next post don't show a real solution but can help in some situations: acuriousanimal.com/blog/2012/09/17/… – EricSonaron Sep 28 '12 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.