[OpenLayers-Users] printing...

Stephen Woodbridge woodbri at swoodbridge.com
Mon Mar 26 11:57:25 EDT 2007


Ed Dowding wrote:
> Stephen 
> 
> I saw your response about printing - I've a similar issue and was planning
> on using mapserver to render the flattened output. However, I'd like to use
> google's map data as my base layer.
> 
> Do you have any ideas about how this might be achieved?

No trivial ideas.

If the browser does not support printing overlaid images correctly then 
you have to look at doing it server-side.

If you have to do it server-side then you will have to pull the google 
tiles needed, and georeference them so you can feed them into mapserver 
to make a composite image. I'm not sure of the technical issues of how 
you would go about doing this or the legal issues of doing it. But the 
idea would be to have a print button on the map that might generate a 
new page layout for printing that requests a map image from say a 
php/mapscript application where the parameters are the information on 
the map extents, layers, etc that you want rendered, then the script 
would pull the google tiles georeference them and ask mapscript to 
render the image which gets send back to the print layout page.

Others have debated making a WMS wrapper Google and I'm sure you can 
find the threads in the mapserver and/or openlayers list archive. If 
there was a WMS wrapper that would make things easier and it might be 
acceptable to use it in this manner, but I'm not a lawyer and I haven't 
read the google EULA.

There may be an easier way, but this is one idea that might work.

-Steve W

> Thanks for your time,
> 
> Ed
> 
> 
> On 24/3/07 19:20, "Stephen Woodbridge" <woodbri at swoodbridge.com> wrote:
> 
>> John,
>>
>> Another approach is to render a new page the does the print layout on it
>> and to use mapserver to render a single image equivalent of what is
>> being displayed in open layers. You also might want to take a look at
>> what ka-map is doing for the printing.
>>
>> -Steve W
>>
>> John Cole wrote:
>>> Printing to a pdf via mapserver is ideal when you only need the map output,
>>> but when dealing with the contents of a web based application, the map is
>>> rarely the sole contents of the page.
>>>
>>> In my case, I have additional information associated with the map that needs
>>> to be included in the report, which rules out using mapserver's pdf output.
>>> I'll also have to create a legend which isn't supported with a mapserver
>>> pdf.
>>>
>>> I tried my idea of having two maps and div tags, turning one off with the
>>> screen stylesheet and vice versa with the print sytlesheet, but apparently
>>> the OL map object overrides the display value of the div tag, turning both
>>> on at the same time.
>>>
>>> As another approach, I was thinking of just having a div tag and setting
>>> it's background image property to the value of a WMS request pulled from one
>>> of the layers.  I believe that I will have to have a print button in order
>>> to have JS turn off the map visibility so that it will be replaced by the
>>> div with the wms background when using the print stylesheet.  I'd love to
>>> get this working just through the stylesheets, since then users could simply
>>> use the browsers file->print rather than rely on a page element (I know I'll
>>> get calls about file-print not working :-) )
>>>
>>> Still open to suggestions though!
>>>
>>> John 
>>>
>>> -----Original Message-----
>>> From: Christopher Schmidt [mailto:crschmidt at metacarta.com]
>>> Sent: Saturday, March 24, 2007 11:46 AM
>>> To: John Cole
>>> Cc: openlayers
>>> Subject: Re: [OpenLayers-Users] printing...
>>>
>>> On Sat, Mar 24, 2007 at 10:14:58AM -0600, John Cole wrote:
>>>> What is the easiest way of getting OL to configure itself for printing?
>>> The
>>>> issue I have is that when printing with overlays and controls, the base
>>> map
>>>> gets covered and doesn't show (try a print preview on one of the example
>>>> pages with multiple layers).
>>>> So far, my only idea is to have two maps defined, one with a single layer
>>>> that is only enabled in the print stylesheet while the other is disabled,
>>>> and have some JS to keep the two in sync.  Any other suggestions?
>>> I highly recommend not depending on browsers for printing.
>>>
>>> Instead, I recommend using some other tool to render a PDF out of your
>>> backend: MapServer, for example, has a PDF output. Using PDF output
>>> (instead of browser-based printing) means that your renderer is in
>>> control of styling of the map, and you don't have the issues with
>>> overlays or anything else.
>>>
>>> http://mumbai.freemap.in/ uses this technique.
>>>
>>> That's always been my recommendation, and I'm sticking to it :)
>>>
>>> Regards,
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
> 
> 
> 
> 
> 
> Ed
> 
>  
>  
> Ed Dowding
> ed at citysafe.org
> +44 (0)7775 79 18 14
> Skype: eddowding
> 
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> 
> Please consider your environmental responsibility before printing 
> 
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> Privileged or confidential information may be contained in this email
> and is intended for the addressee. If you are not the addressee, or
> the person responsible for delivering it to the person addressed, you
> may not copy or deliver this to anyone else. If you receive this
> email by mistake, please notify us immediately.
> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
> 
> 
> 




More information about the Users mailing list