Changes between Initial Version and Version 1 of CodeSamples/JavaScript/WaterMark


Ignore:
Timestamp:
Oct 31, 2008, 2:03:32 AM (16 years ago)
Author:
ksgeograf
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CodeSamples/JavaScript/WaterMark

    v1 v1  
     1[[PageOutline]]
     2
     3This page is one of the !MapGuide Community CodeSamples.  Visit the CodeSamples page to view more!
     4
     5== Displaying a watermark over the map in the AJAX viewer ==
     6
     7This page contains code from the MapGuide-users mail list, showing how to place a watermark over the map in the AJAX viewer.
     8The code was submitted to the mailing list by Stuart Jones:
     9http://n2.nabble.com/Watermarking-a-Map-td1085166.html
     10
     11{{{
     12/**
     13 * Place a tiled image between the map and the scale slider
     14 * to represent a watermark on the map. The image is expected to have a
     15 * transparent background.
     16 *
     17 * @doc       The document object.
     18 * @elName    The name of the element before which the watermark will be put.
     19 * @imageUrl  The URL of the map image used for the watermark.
     20 *
     21 */
     22ShowWatermark: function(doc, elName, imageUrl) {
     23
     24        if (!doc) return;
     25        if ((!elName) || (!doc.getElementById(elName))) return;
     26        if (!imageUrl) return;
     27
     28        //
     29        // Create a DIV to hold the watermark.
     30        //
     31        var watermark = doc.createElement('div');
     32
     33        //
     34        // Assign the passed-in background image URL.
     35        //
     36        watermark.style.backgroundImage = 'url(' + imageUrl + ')';
     37
     38        //
     39        // This value is very important. It must be less than the lowest z-index
     40        // value used by the scale slider (which happens to be 4 at the time of
     41        // writing.
     42        //
     43        watermark.style.zIndex = '3';
     44
     45        //
     46        // The rest of the styles.
     47        // TODO: Make this more sustainable. External CSS?
     48        //
     49        watermark.style.position = 'absolute';
     50        watermark.style.width = '100%';
     51        watermark.style.height = '100%';
     52        watermark.style.opacity = 0.5;
     53        watermark.style.filter = 'alpha(opacity=50)';
     54
     55        watermark.setAttribute('id', this.WATERMARK_ID);
     56
     57        //
     58        // Insert it into the DOM.
     59        //
     60        var el = doc.getElementById(elName);
     61        el.parentNode.insertBefore(watermark, el);
     62}
     63
     64}}}