1 |
2671
|
harris
|
/*
|
2 |
|
|
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
|
3 |
|
|
Dependancies: Context
|
4 |
|
|
$Id$
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
// Ensure this object's dependancies are loaded.
|
8 |
|
|
mapbuilder.loadScript(baseDir+"/tool/ButtonBase.js");
|
9 |
|
|
|
10 |
|
|
/**
|
11 |
|
|
* Implements WMS GetFeatureInfo functionality, popping up a query result
|
12 |
|
|
* window when user clicks on map.
|
13 |
|
|
* @constructor
|
14 |
|
|
* @base ButtonBase
|
15 |
|
|
* @author Nedjo
|
16 |
|
|
* @constructor
|
17 |
|
|
* @param toolNode The XML node in the Config file referencing this object.
|
18 |
|
|
* @param model The widget object which this tool is associated with.
|
19 |
|
|
*/
|
20 |
|
|
function GetFeatureInfo(toolNode, model) {
|
21 |
|
|
// Extend ButtonBase
|
22 |
|
|
var base = new ButtonBase(this, toolNode, model);
|
23 |
|
|
|
24 |
|
|
/** Xsl to build a GetFeatureInfo URL */
|
25 |
|
|
this.xsl=new XslProcessor(baseDir+"/tool/GetFeatureInfo.xsl");
|
26 |
|
|
|
27 |
|
|
/** Determine whether Query result is returned as HTML or GML */
|
28 |
|
|
// TBD This should be stored in the Config file.
|
29 |
|
|
//this.infoFormat="application/vnd.ogc.gml";
|
30 |
|
|
this.infoFormat="text/html";
|
31 |
|
|
|
32 |
|
|
/**
|
33 |
|
|
* Open window with query info.
|
34 |
|
|
* This function is called when user clicks map with Query tool.
|
35 |
|
|
* @param objRef Pointer to this GetFeatureInfo object.
|
36 |
|
|
* @param targetNode The node for the enclosing HTML tag for this widget.
|
37 |
|
|
*/
|
38 |
|
|
|
39 |
|
|
this.doAction = function(objRef,targetNode) {
|
40 |
|
|
if (objRef.enabled) {
|
41 |
|
|
var selectedLayer=objRef.context.getParam("selectedLayer");
|
42 |
2676
|
harris
|
if (selectedLayer==null) { // assume the metacat layer
|
43 |
|
|
//alert("Query layer not selected, select a queryable layer in the Legend.");
|
44 |
|
|
// objRef.xsl.setParameter("FORMAT", "text/html");
|
45 |
|
|
objRef.xsl.setParameter("queryLayer", "topp:metacat_testdata");
|
46 |
|
|
objRef.xsl.setParameter("xCoord", targetNode.evpl[0]);
|
47 |
|
|
objRef.xsl.setParameter("yCoord", targetNode.evpl[1]);
|
48 |
|
|
objRef.xsl.setParameter("infoFormat", objRef.infoFormat);
|
49 |
|
|
objRef.xsl.setParameter("featureCount", "1");
|
50 |
|
|
|
51 |
|
|
urlNode=objRef.xsl.transformNodeToObject(objRef.context.doc);
|
52 |
|
|
//alert(selectedLayer);
|
53 |
|
|
url=urlNode.documentElement.firstChild.nodeValue;
|
54 |
|
|
//alert("GetFeatureInfo .. : \n url="+url);
|
55 |
|
|
|
56 |
|
|
if (objRef.infoFormat=="text/html"){
|
57 |
2678
|
harris
|
window.open(url,'queryWin','height=600,width=800,scrollbars=yes,toolbars=yes');
|
58 |
2676
|
harris
|
}
|
59 |
|
|
|
60 |
2671
|
harris
|
}
|
61 |
|
|
else {
|
62 |
|
|
// objRef.xsl.setParameter("FORMAT", "text/html");
|
63 |
|
|
objRef.xsl.setParameter("queryLayer", selectedLayer);
|
64 |
|
|
objRef.xsl.setParameter("xCoord", targetNode.evpl[0]);
|
65 |
|
|
objRef.xsl.setParameter("yCoord", targetNode.evpl[1]);
|
66 |
|
|
objRef.xsl.setParameter("infoFormat", objRef.infoFormat);
|
67 |
|
|
objRef.xsl.setParameter("featureCount", "1");
|
68 |
|
|
|
69 |
|
|
urlNode=objRef.xsl.transformNodeToObject(objRef.context.doc);
|
70 |
2676
|
harris
|
//alert(selectedLayer);
|
71 |
2671
|
harris
|
url=urlNode.documentElement.firstChild.nodeValue;
|
72 |
2699
|
harris
|
//alert("selected GetFeatureInfo .. : \n url="+url);
|
73 |
2700
|
harris
|
//alert("selected GetFeatureInfo .. : \n queryLayer="+selectedLayer);
|
74 |
2671
|
harris
|
|
75 |
|
|
if (objRef.infoFormat=="text/html"){
|
76 |
2699
|
harris
|
window.open(url,'queryWin','height=600,width=800,scrollbars=yes');
|
77 |
2671
|
harris
|
}
|
78 |
|
|
}
|
79 |
|
|
}
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
/**
|
83 |
|
|
* Register for mouseUp events.
|
84 |
|
|
* @param objRef Pointer to this object.
|
85 |
|
|
*/
|
86 |
|
|
this.setMouseListener = function(objRef) {
|
87 |
|
|
if (objRef.mouseHandler) {
|
88 |
|
|
objRef.mouseHandler.model.addListener('mouseup',objRef.doAction,objRef);
|
89 |
|
|
}
|
90 |
|
|
objRef.context=objRef.widgetNode.selectSingleNode("mb:context");
|
91 |
|
|
if (objRef.context){
|
92 |
|
|
objRef.context=eval("config.objects."+objRef.context.firstChild.nodeValue);
|
93 |
|
|
}
|
94 |
|
|
}
|
95 |
|
|
config.addListener( "loadModel", this.setMouseListener, this );
|
96 |
|
|
}
|