[mapguide-users] Watermarking a Map

gingerbbm stuart.jones at jacobs.com
Tue Sep 23 08:43:07 EDT 2008




>> Here is Fridays problem - Watermarking a map.  Not in Fusion, just on a
>> basic layout.
> 

Here's what I came up with (for the Ajax viewer). The expected parameters to
this JavaScript method are:

doc: The document object, such as that returned by
"frames['mapFrame'].document"
imageUrl: The path to the watermark tile, e.g. "/images/watermark.gif"

So this method will insert a DIV that covers the entire map with the tiled
image. My image is transparent except for the required watermark string. In
the code I set the opacity, but this is probably not necessary if you get
your image looking the way you want it to beforehand. There are two
important things to note:

1. I'm using this in a WebLayout with no left or right pane, and the middle
pane comprises the status bar and zoom control only (plus the map of
course). In this configuration the map frame is resizeable despite no left
pane being present, which is undesirable. Fortunately, the watermarking
method below covers this up and prevents manual resizing.

2. The z-index of the inserted DIV must be configured to be less than that
of the zoom control ("scale slider") so that it appears underneath, but
still above the map image.


	ShowInAjaxViewer: function(doc, imageUrl) {

		if (!doc) 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.
		//
		watermark.style.position = 'absolute';
		watermark.style.width = '100%';
		watermark.style.height = '100%';
		watermark.style.opacity = 0.5;
		watermark.style.filter = 'alpha(opacity=50)';

		doc.body.insertBefore(watermark, doc.body.firstChild);
	}


Hope this helps somebody.

Cheers
Stuart
-- 
View this message in context: http://n2.nabble.com/Watermarking-a-Map-tp1085166p1112325.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list