[OpenLayers-Users] Printing overlay

Julien-Samuel Lacroix jlacroix at mapgears.com
Tue Sep 4 11:05:53 EDT 2007


Hi list,

I finally found a way to print a very small dataset with a Google Maps 
layer. My application simply needs to print a map at street level with 
few streets highlighted so I extracted the geometry of few streets and 
draw the street lines on the map using the jsGraphics library using a 
custom GoogleMaps overlay. The drawback of what I've done is that I'm 
now using Google API directly and I would prefer to use OpenLayers since 
I could switch to another datasource if I want.

I wondered if it is possible to reuse the same method with openlayers 
vector overlays. Including jsGraphics directly in OpenLayers is probably 
not feasible since it's a LGPL library, but I'm not sure.

jsGraphics have a mode the is 10% to 25% slower but allow you to print 
the shapes you draw. This is enabled by calling the setPrintable(true) 
function. From there, the shapes drawn on the map use a div colors 
instead of div background-colors, it use the _mkDivPrt instead of _mkDiv 
function. From the code:

function _mkDiv(x, y, w, h)
{
	this.htm += '<div style="position:absolute;'+
		'left:' + x + 'px;'+
		'top:' + y + 'px;'+
		'width:' + w + 'px;'+
		'height:' + h + 'px;'+
		'clip:rect(0,'+w+'px,'+h+'px,0);'+
		'background-color:' + this.color +
		(!jg_moz? ';overflow:hidden' : '')+
		';"><\/div>';
}


function _mkDivPrt(x, y, w, h)
{
	this.htm += '<div style="position:absolute;'+
		'border-left:' + w + 'px solid ' + this.color + ';'+
		'left:' + x + 'px;'+
		'top:' + y + 'px;'+
		'width:0px;'+
		'height:' + h + 'px;'+
		'clip:rect(0,'+w+'px,'+h+'px,0);'+
		'background-color:' + this.color +
		(!jg_moz? ';overflow:hidden' : '')+
		';"><\/div>';
}

Idea?

Julien

Christopher Schmidt wrote:
> On Tue, Aug 14, 2007 at 09:09:56AM +0100, Duarte Carreira wrote:
> 
>>Julien,
>>
>>Can you merge/mosaic your map images on the server? Then you could send
>>a single image to the browser ready to print.
> 
> 
> One can't merge/mosaic with Google Maps. (I suggest that this might be a
> case where the only real answer is "Get your own data instead of using Google
> Maps" -- though I understand it isn't practical.)
> 
> Regards,

-- 
Julien-Samuel Lacroix
Mapgears
http://www.mapgears.com/



More information about the Users mailing list