1
|
/*
|
2
|
Author: Mike Adair
|
3
|
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
|
4
|
|
5
|
$Id$
|
6
|
*/
|
7
|
|
8
|
// Ensure this object's dependancies are loaded.
|
9
|
mapbuilder.loadScript(baseDir+"/widget/MapContainerBase.js");
|
10
|
|
11
|
/**
|
12
|
* Widget to render a single map layer from an OGC context document.
|
13
|
* TBD: not yet completed.
|
14
|
* @constructor
|
15
|
* @base MapContainerBase
|
16
|
* @param widgetNode The widget's XML object node from the configuration document.
|
17
|
* @param model The model object that this widget belongs to.
|
18
|
*/
|
19
|
function MapImage(widgetNode, model) {
|
20
|
WidgetBase.apply(this,new Array(widgetNode, model));
|
21
|
|
22
|
this.paint = function(objRef) {
|
23
|
if (objRef.model.doc && objRef.node) {
|
24
|
|
25
|
objRef.prePaint(objRef);
|
26
|
|
27
|
//confirm inputs
|
28
|
|
29
|
//set to output to a temporary node
|
30
|
//hack to get by doc parsing problem in IE
|
31
|
//the firstChild of tempNode will be the root element output by the stylesheet
|
32
|
var outputNode = document.getElementById( objRef.outputNodeId );
|
33
|
var tempNode = document.createElement("DIV");
|
34
|
|
35
|
//here the model document is an image
|
36
|
tempNode.style.position="absolute";
|
37
|
tempNode.style.top=0;
|
38
|
tempNode.style.left=0;
|
39
|
tempNode.appendChild(objRef.model.doc); //!!doc is an IMG object
|
40
|
tempNode.setAttribute("id", objRef.outputNodeId);
|
41
|
|
42
|
//look for this widgets output and replace if found,
|
43
|
//otherwise append it
|
44
|
if (outputNode) {
|
45
|
objRef.node.replaceChild(tempNode,outputNode);
|
46
|
} else {
|
47
|
objRef.node.appendChild(tempNode);
|
48
|
}
|
49
|
|
50
|
objRef.postPaint(objRef);
|
51
|
}
|
52
|
}
|
53
|
this.model.addListener("refresh",this.paint, this);
|
54
|
|
55
|
MapContainerBase.apply(this,new Array(widgetNode, model));
|
56
|
|
57
|
/**
|
58
|
* Override of widget prepaint to set the width and height of the Map layer
|
59
|
* document.
|
60
|
* @param objRef Pointer to this object.
|
61
|
*/
|
62
|
this.prePaint = function(objRef) {
|
63
|
objRef.model.doc.width = objRef.containerModel.getWindowWidth();
|
64
|
objRef.model.doc.height = objRef.containerModel.getWindowHeight();
|
65
|
}
|
66
|
|
67
|
}
|