[mapguide-users] Watermarking a Map
gingerbbm
stuart.jones at jacobs.com
Tue Oct 28 08:30:52 EDT 2008
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
--
View this message in context: http://n2.nabble.com/Watermarking-a-Map-tp1085166p1386694.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list