[mapguide-users] Watermarking a Map

Kenneth Skovhede, GEOGRAF A/S ks at geograf.dk
Fri Oct 31 05:05:15 EDT 2008


Thank you for the sample.
I have taken the liberty to add this example to the CodeSamples:
http://trac.osgeo.org/mapguide/wiki/CodeSamples
http://trac.osgeo.org/mapguide/wiki/CodeSamples/JavaScript/WaterMark

Regards, Kenneth Skovhede, GEOGRAF A/S


gingerbbm skrev:
> Dear all
>
> Here's a revised JavaScript method for watermarking. This will only overlay
> the map. I've added a new parameter elName which is the DIV which contains
> the map image. In the Ajax viewer the required value is "mapSpace", so it
> could be hard-coded if desired.
>
> 	/**
> 	 * Place a tiled image between the map and the scale slider
> 	 * to represent a watermark on the map. The image is expected to have a 
> 	 * transparent background.
> 	 *
> 	 * @doc       The document object.
> 	 * @elName    The name of the element before which the watermark will be
> put.
> 	 * @imageUrl  The URL of the map image used for the watermark.
> 	 *
> 	 */
> 	ShowWatermark: function(doc, elName, imageUrl) {
>
> 		if (!doc) return;
> 		if ((!elName) || (!doc.getElementById(elName))) return;
> 		if (!imageUrl) return;
>
> 		//
> 		// Create a DIV to hold the watermark.
> 		//
> 		var watermark = doc.createElement('div');
>
> 		//
> 		// Assign the passed-in background image URL.
> 		//
> 		watermark.style.backgroundImage = 'url(' + imageUrl + ')';
>
> 		//
> 		// This value is very important. It must be less than the lowest z-index
> 		// value used by the scale slider (which happens to be 4 at the time of 
> 		// writing.
> 		//
> 		watermark.style.zIndex = '3';
>
> 		//
> 		// The rest of the styles.
> 		// TODO: Make this more sustainable. External CSS?
> 		//
> 		watermark.style.position = 'absolute';
> 		watermark.style.width = '100%';
> 		watermark.style.height = '100%';
> 		watermark.style.opacity = 0.5;
> 		watermark.style.filter = 'alpha(opacity=50)';
>
> 		watermark.setAttribute('id', this.WATERMARK_ID);
>
> 		//
> 		// Insert it into the DOM. 
> 		//
> 		var el = doc.getElementById(elName);
> 		el.parentNode.insertBefore(watermark, el);
> 	}
>
> Cheers
> Stuart
>   


More information about the mapguide-users mailing list