[fusion-commits] r2050 - in sandbox/jxlib-3.0: layers/MapServer widgets

svn_fusion at osgeo.org svn_fusion at osgeo.org
Mon Feb 1 16:13:05 EST 2010


Author: madair
Date: 2010-02-01 16:13:04 -0500 (Mon, 01 Feb 2010)
New Revision: 2050

Modified:
   sandbox/jxlib-3.0/layers/MapServer/MapServer.js
   sandbox/jxlib-3.0/widgets/LayerManager.js
   sandbox/jxlib-3.0/widgets/Legend.js
Log:
update so that Legend and LayerManager both get updated when order/visibility changes

Modified: sandbox/jxlib-3.0/layers/MapServer/MapServer.js
===================================================================
--- sandbox/jxlib-3.0/layers/MapServer/MapServer.js	2010-02-01 19:56:37 UTC (rev 2049)
+++ sandbox/jxlib-3.0/layers/MapServer/MapServer.js	2010-02-01 21:13:04 UTC (rev 2050)
@@ -454,6 +454,20 @@
         }
     },
 
+    parseLayers: function() {
+        //this.layerRoot.clear();
+        for (var i=0; i<this.aLayers.length; i++) {
+            var layer = this.aLayers[i];
+            var parent;
+            if (layer.parentGroup != '') {
+                parent = this.layerRoot.findGroup(layer.parentGroup.name);
+            } else {
+                parent = this.layerRoot;
+            }
+            parent.addLayer(layer, this.bLayersReversed);
+        }
+    },
+
     getScale: function() {
         return this.mapWidget.getScale();
     },

Modified: sandbox/jxlib-3.0/widgets/LayerManager.js
===================================================================
--- sandbox/jxlib-3.0/widgets/LayerManager.js	2010-02-01 19:56:37 UTC (rev 2049)
+++ sandbox/jxlib-3.0/widgets/LayerManager.js	2010-02-01 21:13:04 UTC (rev 2050)
@@ -79,7 +79,8 @@
         //this.draw();
     },
     
-    layerChanged: function() {
+    layerChanged: function(eventId, layer) {
+        this.updateLayer(this.map.aMaps[0]);
         this.updateSessionMapFile();
     },
     
@@ -168,7 +169,7 @@
                 revert: true,
                 onComplete: OpenLayers.Function.bind(this.updateLayer, this, map)
             };
-    var mySortables = new Sortables(this.mapBlockList.id, sortableOptions);
+      var mySortables = new Sortables(this.mapBlockList.id, sortableOptions);
     },
    
   createItemHtml: function(parent, layer) {
@@ -260,7 +261,7 @@
       }
   },
   
-  updateLayer: function(map, ul) {
+  updateLayer: function(map) {
    //console.log("updateLayer");
     //reorder the layers in the client as well as the session
     var aLayerIndex = [];
@@ -278,7 +279,7 @@
       var node = this.mapBlockList.childNodes[i];
       aIds[i].push(i);
       node.id = aIds[i].join('_');
-      node.childNodes[1].checked = node.layer.isVisible()
+      node.childNodes[2].checked = node.layer.isVisible()
     }
     
     //check tos ee if the layer indexes have been modified
@@ -299,16 +300,15 @@
     }
   },
    
-  updateMapBlock: function(map, ul) {
+  updateMapBlock: function(map) {
     //reorder the OL layers
   },
   
   deleteLayer: function(layer, ev) {
    // console.log("deleteLayer");
     var targetLI = (new Event(ev)).target.parentNode;
-    var ul = targetLI.parentNode;
     $(targetLI).dispose();
-    this.updateLayer(layer.oMap, ul);
+    this.updateLayer(layer.oMap);
   },
   
   showLayerInfo: function(layer, ev) {

Modified: sandbox/jxlib-3.0/widgets/Legend.js
===================================================================
--- sandbox/jxlib-3.0/widgets/Legend.js	2010-02-01 19:56:37 UTC (rev 2049)
+++ sandbox/jxlib-3.0/widgets/Legend.js	2010-02-01 21:13:04 UTC (rev 2050)
@@ -173,6 +173,14 @@
      */
     mapReloaded: function() {},
 
+     /**
+     * Method: mapRefresh
+     * Abstract method that handle the event: Fusion.Event.MAP_LAYER_ORDER_CHANGED. This method
+     * should be implemented by all concrete class.
+     *
+     */
+    mapRefresh: function() {},
+
     /**
      * Method: getMap
      * Helper method to obtains the map.
@@ -366,22 +374,24 @@
    
     mapLoaded: function() {
         this.getMap().registerForEvent(Fusion.Event.MAP_EXTENTS_CHANGED, this.extentsChangedWatcher);
+        var baseLayer = this.getMap().aMaps[0]; 
+        baseLayer.registerForEvent(Fusion.Event.MAP_LAYER_ORDER_CHANGED, OpenLayers.Function.bind(this.mapRefresh, this));
+        this.layerRoot = this.getMap().layerRoot;
+        this.renderLegend();
     },
     
     mapReloaded: function() {
+        this.layerRoot = this.getMap().layerRoot;
+        this.renderLegend();
     },
     
-    /**
-     * the map state has become invalid in some way (layer added, removed,
-     * ect).  For now, we just re-request the map state from the server
-     * which calls draw which recreates the entire legend from scratch
-     *
-     * TODO: more fine grained updating of the legend would be nice
-     */
-    invalidate: function() {
-        this.draw();
+    mapRefresh: function() {
+        var baseLayer = this.getMap().aMaps[0];
+        baseLayer.parseLayers();
+        this.layerRoot = this.getMap().layerRoot;
+        this.renderLegend();
     },
-   
+    
     /**
      * Callback for legend XML response. Creates a list of layers and sets up event
      * handling. Create groups if applicable.
@@ -414,7 +424,7 @@
         this.bIsDrawn = true;
         this.update();
     },
-   
+
     processMapGroup: function(group, folder) {
         if (group.displayInLegend) {
             /* make a 'namespace' on the group object to store legend-related info */



More information about the fusion-commits mailing list