Project

General

Profile

1
/*
2
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
3
Dependancies: Context
4
$Id: GetFeatureInfo.js 2673 2005-10-13 03:47:16Z harris $
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
      if (selectedLayer==null) {
43
        alert("Query layer not selected, select a queryable layer in the Legend.");
44
      }
45
      else {
46
 //       objRef.xsl.setParameter("FORMAT", "text/html");
47
        objRef.xsl.setParameter("queryLayer", selectedLayer);
48
        objRef.xsl.setParameter("xCoord", targetNode.evpl[0]);
49
        objRef.xsl.setParameter("yCoord", targetNode.evpl[1]);
50
        objRef.xsl.setParameter("infoFormat", objRef.infoFormat);
51
        objRef.xsl.setParameter("featureCount", "1");
52

    
53
        urlNode=objRef.xsl.transformNodeToObject(objRef.context.doc);
54
        //alert(urlNode);
55
        url=urlNode.documentElement.firstChild.nodeValue;
56
        //alert("GetFeatureInfo .. : \n url="+url);
57

    
58
        if (objRef.infoFormat=="text/html"){
59
          window.open(url,'queryWin','height=200,width=300,scrollbars=yes');
60
        }
61
      }
62
    }
63
  }
64

    
65
  /**
66
   * Register for mouseUp events.
67
   * @param objRef  Pointer to this object.
68
   */
69
  this.setMouseListener = function(objRef) {
70
    if (objRef.mouseHandler) {
71
      objRef.mouseHandler.model.addListener('mouseup',objRef.doAction,objRef);
72
    }
73
    objRef.context=objRef.widgetNode.selectSingleNode("mb:context");
74
    if (objRef.context){
75
      objRef.context=eval("config.objects."+objRef.context.firstChild.nodeValue);
76
    }
77
  }
78
  config.addListener( "loadModel", this.setMouseListener, this );
79
}
    (1-1/1)