[fusion-commits] r1393 - in trunk: MapGuide common/php lib templates/mapguide/standard widgets

svn_fusion at osgeo.org svn_fusion at osgeo.org
Wed May 7 13:20:49 EDT 2008


Author: madair
Date: 2008-05-07 13:20:48 -0400 (Wed, 07 May 2008)
New Revision: 1393

Modified:
   trunk/MapGuide/MapGuide.js
   trunk/common/php/Xml2JSON.php
   trunk/lib/MGBroker.js
   trunk/templates/mapguide/standard/ApplicationDefinition.xml
   trunk/templates/mapguide/standard/index.html
   trunk/widgets/Maptip.js
Log:
closes #56: adding layerAttributeFilter param to maptip requests;
remove DomNode class from maptip widget;
add Maptips to standard template;



Modified: trunk/MapGuide/MapGuide.js
===================================================================
--- trunk/MapGuide/MapGuide.js	2008-05-06 19:21:00 UTC (rev 1392)
+++ trunk/MapGuide/MapGuide.js	2008-05-07 17:20:48 UTC (rev 1393)
@@ -943,6 +943,7 @@
         var persist = 0;
         var selection = 'INTERSECTS';
         var layerNames = '';
+        var layerAttributeFilter = 3;
         var sep = '';
         for (var i=0; i<this.aLayers.length; ++i) {
           layerNames += sep + this.aLayers[i].layerName;
@@ -951,7 +952,8 @@
         var r = new Fusion.Lib.MGRequest.MGQueryMapFeatures(this.mapWidget.getSessionID(),
                                                             this._sMapname,
                                                             sGeometry,
-                                                            maxFeatures, persist, selection, layerNames);
+                                                            maxFeatures, persist, selection, layerNames, 
+                                                            layerAttributeFilter);
         var callback = OpenLayers.Function.bind(this.crtlClickDisplay, this);
         Fusion.oBroker.dispatchRequest(r, OpenLayers.Function.bind(Fusion.xml2json, this, callback));
       }

Modified: trunk/common/php/Xml2JSON.php
===================================================================
--- trunk/common/php/Xml2JSON.php	2008-05-06 19:21:00 UTC (rev 1392)
+++ trunk/common/php/Xml2JSON.php	2008-05-07 17:20:48 UTC (rev 1393)
@@ -35,10 +35,11 @@
     if (!isset($REQUEST_VARS['xml'])) {
         die('xml not set');
     }
+    header('Content-type: text/plain');
+    header('X-JSON: true');
     $xml = rawurldecode ($REQUEST_VARS['xml']);
     $xml = str_replace('\"', '"', $xml);
-    header('Content-type: text/plain');
-    header('X-JSON: true');
+    $xml = str_replace('&quot;', "'", $xml);
 } elseif (isset($argv)) {
     $cliArgs = arguments($argv);
     if (isset($cliArgs['obj'])) {

Modified: trunk/lib/MGBroker.js
===================================================================
--- trunk/lib/MGBroker.js	2008-05-06 19:21:00 UTC (rev 1392)
+++ trunk/lib/MGBroker.js	2008-05-07 17:20:48 UTC (rev 1393)
@@ -567,11 +567,13 @@
      * @param maxFeatures {integer} number of maximum results (-1 to indicate no maximum)
      * @param selectionPersist {boolean} save the selection (valid values are 0 and 1) 
      * @param selectionVariant {String} indicates the spatial operation. Valid values are 'INTERSECTS', ...
-     *@param layerNames {String} comma separated list of layer names to include in the query
+     * @param layerNames {String} comma separated list of layer names to include in the query
+     * @param layerAttributeFilter {integer} bitmask determining layer selection behaviour (1=visible layers,
+     *          2=selectable layers, 4=layers with tooltips)
      *
      * @return {Object} an instance of Fusion.Lib.MGRequest.MGQueryMapFeatures
      */
-    initialize : function( sessionId, mapName, geometry, maxFeatures, persist, selectionVariant, layerNames ) 
+    initialize : function( sessionId, mapName, geometry, maxFeatures, persist, selectionVariant, layerNames, layerAttributeFilter ) 
     {
         this.initializeRequest();
         this.setParams( {
@@ -582,7 +584,8 @@
             maxFeatures: maxFeatures,
             persist: persist,
             selectionVariant: selectionVariant,
-            layerNames: layerNames
+            layerNames: layerNames,
+            layerAttributeFilter: layerAttributeFilter
         } );
     }
 });

Modified: trunk/templates/mapguide/standard/ApplicationDefinition.xml
===================================================================
--- trunk/templates/mapguide/standard/ApplicationDefinition.xml	2008-05-06 19:21:00 UTC (rev 1392)
+++ trunk/templates/mapguide/standard/ApplicationDefinition.xml	2008-05-07 17:20:48 UTC (rev 1393)
@@ -299,6 +299,19 @@
       </Item>
     </Container>
 
+<!-- MAP -->
+
+    <MapWidget xsi:type="WidgetType">
+      <Name>Map</Name>
+      <Type>Map</Type>
+      <StatusItem>The map.</StatusItem>
+      <Extension xsi:type="CustomContentType">
+        <MenuContainer>MapContextMenu</MenuContainer>
+        <Scales>2000000 1000000 500000 250000 125000 50000</Scales>
+      </Extension>
+      <MapId>sheboygan</MapId>
+    </MapWidget>
+
 <!-- ****************************************** 
 * Context Menu - Widgets
 *
@@ -994,18 +1007,6 @@
       <Disabled/>
     </Widget>
 
-<!-- MAP -->
-
-    <MapWidget xsi:type="WidgetType">
-      <Name>Map</Name>
-      <Type>Map</Type>
-      <StatusItem>The map.</StatusItem>
-      <Extension xsi:type="CustomContentType">
-        <MenuContainer>MapContextMenu</MenuContainer>
-      </Extension>
-      <MapId>sheboygan</MapId>
-    </MapWidget>
-
 <!-- OVERVIEW MAP -->
 
     <Widget xsi:type="WidgetType">
@@ -1056,8 +1057,18 @@
       <Type>ScalebarDual</Type>
     </Widget>
     
-    </WidgetSet>
+    <Widget xsi:type="WidgetType">
+      <Name>MapTip</Name>
+      <Type>Maptip</Type>
+      <Extension>
+        <Label>Map Tips</Label>
+        <Delay>350</Delay>
+        <Layer>Parcels</Layer>
+      </Extension>
+    </Widget>
 
+  </WidgetSet>
+
   <Extension/>
 
 </ApplicationDefinition>

Modified: trunk/templates/mapguide/standard/index.html
===================================================================
--- trunk/templates/mapguide/standard/index.html	2008-05-06 19:21:00 UTC (rev 1392)
+++ trunk/templates/mapguide/standard/index.html	2008-05-07 17:20:48 UTC (rev 1393)
@@ -136,6 +136,7 @@
 
   <div id="TaskPane"></div>
   <div id="Statusbar"></div>
+  <div id="MapTip"></div>
   <div id="PoweredBy" class="statusBarItem">
     <a href="http://mapserver.gis.umn.edu.org/" target="_blank">
       <img src="images/PoweredBy_MapServer.gif" width="137" height="18" border="0">

Modified: trunk/widgets/Maptip.js
===================================================================
--- trunk/widgets/Maptip.js	2008-05-06 19:21:00 UTC (rev 1392)
+++ trunk/widgets/Maptip.js	2008-05-07 17:20:48 UTC (rev 1393)
@@ -158,19 +158,29 @@
         var maxFeatures = 1;
         var persist = 0;
         var selection = 'INTERSECTS';
+        // only select visible layers with maptips defined (1+4)
+        var layerAttributeFilter = 5;
         var maps = this.getMap().getAllMaps();
         //TODO: possibly make the layer names configurable?
         var layerNames = this.aLayers.toString();
         var r = new Fusion.Lib.MGRequest.MGQueryMapFeatures(maps[0].getSessionID(),
                                         maps[0]._sMapname,
                                         sGeometry,
-                                        maxFeatures, persist, selection, layerNames);
-        oBroker.dispatchRequest(r, OpenLayers.Function.bind(this._display, this));
-
+                                        maxFeatures, persist, selection, layerNames,
+                                        layerAttributeFilter);
+        oBroker.dispatchRequest(r, 
+            OpenLayers.Function.bind(Fusion.xml2json, this, 
+                  OpenLayers.Function.bind(this.requestCB, this)));
     },
-    _display: function(r) {
+    
+    requestCB: function(xhr) {
+        var o;
+        eval("o="+xhr.responseText);
+        this._display(o);
+    },
+    
+    _display: function(tooltip) {
       //console.log('maptip _display');
-        if (r.responseXML) {
             this.domObj.innerHTML = '&nbsp;';
             var contentDiv = document.createElement('div');
             contentDiv.className = 'maptipContent';
@@ -178,20 +188,18 @@
             
             var empty = true;
             this.bIsVisible = true;
-            var d = new DomNode(r.responseXML);
-            var t = d.getNodeText('Tooltip');
-            if (t != '') {
-              t = t.replace(/\\n/g, "<br>");
-              contentDiv.innerHTML = t;
+            var t = tooltip['FeatureInformation']['Tooltip'];
+            if (t) {
+              contentDiv.innerHTML = t[0].replace(/\\n/g, "<br>");
               empty = false;
             }
-            var h = d.getNodeText('Hyperlink');
-            if (h != '') {
+            var h = tooltip['FeatureInformation']['Hyperlink'];
+            if (h) {
               var linkDiv = document.createElement('div');
               var a = document.createElement('a');
-              a.innerHTML = h;
+              a.innerHTML = h[0];
               a.href = 'javascript:void(0)';
-              a.onclick = OpenLayers.Function.bindAsEventListener(this.openLink, this, h);
+              a.onclick = OpenLayers.Function.bindAsEventListener(this.openLink, this, h[0]);
               linkDiv.appendChild(a);
               contentDiv.appendChild(linkDiv);
               empty = false;
@@ -214,9 +222,6 @@
             } else {
                 this.hideMaptip();
             }
-        } else {
-            this.bIsVisible = false;
-        }
     },
     
     hideMaptip: function() {
@@ -229,7 +234,7 @@
       //console.log('maptip _hide');
         this.hideTimer = null;
         this.domObj.style.display = 'none';
-        this.oMapTipPosition = null;
+        //this.oMapTipPosition = null;
     },
     
     mouseOverTip: function() {



More information about the fusion-commits mailing list