[fusion-commits] r3022 - in trunk: . layers/MapGuide lib lib/jxLib widgets widgets/Measure

svn_fusion at osgeo.org svn_fusion at osgeo.org
Thu Mar 8 05:18:34 PST 2018


Author: jng
Date: 2018-03-08 05:18:34 -0800 (Thu, 08 Mar 2018)
New Revision: 3022

Modified:
   trunk/
   trunk/layers/MapGuide/MapGuide.js
   trunk/lib/Map.js
   trunk/lib/jxLib/jxlib.uncompressed.js
   trunk/widgets/Legend.js
   trunk/widgets/MapMenu.js
   trunk/widgets/Maptip.js
   trunk/widgets/Measure.js
   trunk/widgets/Measure/Measure.php
Log:
Merged revision(s) 3008-3012 from sandbox/adsk/3.1n:
This submission solved 3 issues:
1. Hide group in legend tree if it is empty.
2. Set map initial active state in "Maps" menu.
3. If there are more than one base layer groups and one of them is invisible initially, the features of the layer in the group cannot be selected after show the group. It is because we don't save the map object when clicking the check box of base layer group. I added a call of GETVISIBLEMAPEXTENT to workaround this issue.
........
This submission made 3 changes:
1.	Suppress Fusion error in client when query features/get map tip
2.	Turn off map tip by default
3.	Fix a typo

........
Fix bug: Features are selected when using measure tool.
........
Fix 2 measure issues.
1. fusion error if zoom after click 'Measure' button. It is because the line string is not valid yet. Now add a check for the vertex count before update marker.
2. If there are 2 'Measure' defined (one for distance, the other for area), when switch between the 2 buttons, the 'Unload' of previous page is always after the new page's 'activate', which results in values of some global variables e.g. isDigitizing are not correct. Now we change the event to 'onbeforeunload' to solve the issue.
........


Index: trunk
===================================================================
--- trunk	2018-03-08 13:16:53 UTC (rev 3021)
+++ trunk	2018-03-08 13:18:34 UTC (rev 3022)

Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
## -1,7 +1,7 ##
 /branches/fusion-mg24:2560
 /branches/fusion-mg26:2855,2869
 /sandbox/adsk/2.6l:2911
-/sandbox/adsk/3.1n:2925-2927,2935,2987,2989,3007
+/sandbox/adsk/3.1n:2925-2927,2935,2987,2989,3007-3012
 /sandbox/adsk/3.2o:2969-2972,2974,2978-2984
 /sandbox/createruntimemap:2699-2708
 /sandbox/jxlib-3.0:1957-2248
Modified: trunk/layers/MapGuide/MapGuide.js
===================================================================
--- trunk/layers/MapGuide/MapGuide.js	2018-03-08 13:16:53 UTC (rev 3021)
+++ trunk/layers/MapGuide/MapGuide.js	2018-03-08 13:18:34 UTC (rev 3022)
@@ -1798,6 +1798,11 @@
                     this.oLayersOLTile[i].setVisibility(true);
                 }
             }
+            this.aShowGroups.push(group.uniqueId);
+            if (this.drawDelay > 0) {
+                this.aHideGroups.erase(group.uniqueId);
+            }
+            this.mapExtentsChanged();
         } else {
             this.aShowGroups.push(group.uniqueId);
             //A group cannot be both hidden and shown, which can be the case if there is a draw
@@ -1822,6 +1827,11 @@
                     this.oLayersOLTile[i].setVisibility(false);
                 }
             }
+            this.aHideGroups.push(group.uniqueId);
+            if (this.drawDelay > 0) {
+                this.aShowGroups.erase(group.uniqueId);
+            }
+            this.mapExtentsChanged();
         } else {
             this.aHideGroups.push(group.uniqueId);
             //A group cannot be both hidden and shown, which can be the case if there is a draw
@@ -1894,7 +1904,16 @@
       if (!this.singleTile) {
           var center = this.mapWidget.oMapOL.getCenter();
           var display = this.mapWidget.oMapOL.getSize();
+<<<<<<< .working
 
+||||||| .merge-left.r3007
+          
+=======
+          var showGroups = this.aShowGroups.length > 0 ? this.aShowGroups.toString() : null;
+          var hideGroups = this.aHideGroups.length > 0 ? this.aHideGroups.toString() : null;
+          this.aShowGroups = [];
+          this.aHideGroups = [];
+>>>>>>> .merge-right.r3012
           var r = new Fusion.Lib.MGRequest.MGGetVisibleMapExtent(this.getSessionID(),
                                                               this._sMapname,
                                                               center.lon, center.lat,
@@ -1901,7 +1920,11 @@
                                                               this.mapWidget.oMapOL.getScale(),
                                                               null,
                                                               this._nDpi,
-                                                              display.w, display.h);
+                                                              display.w, display.h,
+                                                              null,
+                                                              null,
+                                                              showGroups,
+                                                              hideGroups);
           Fusion.oBroker.dispatchRequest(r);
       }
     },
@@ -2012,8 +2035,14 @@
     },
 
     parseMapTip: function(xhr) {
-        var o;
-        var tooltip = Fusion.parseJSON(xhr.responseText);
+        var tooltip;
+        // Don't show error window, just return if the response is invalid.
+        try {
+            tooltip = Fusion.parseJSON(xhr.responseText);
+        }
+        catch (err) {
+            return;
+        }
         this.oMaptip = {t:"",h:""};
         var t = tooltip['FeatureInformation']['Tooltip'];
         if (t) {
@@ -2310,7 +2339,15 @@
     },
 
     processSelectedExtendedFeatureInfo: function(r, mergeSelection) {
-        var o = Fusion.parseJSON(r.responseText);
+        var o;
+        // Don't show error window, just return if the response is invalid.
+        try {
+            o = Fusion.parseJSON(r.responseText);
+        }
+        catch (err) {
+            this.mapWidget._removeWorker();
+            return;
+        }
         var sel = new Fusion.SimpleSelectionObject(o, this.bHasCleanJsonSupport);
         var attributes = this.convertExtendedFeatureInfo(o);
         if (mergeSelection == true)
@@ -2349,7 +2386,15 @@
     },
 
     processSelectedFeatureInfo: function (r, mergeSelection) {
-        var o = Fusion.parseJSON(r.responseText);
+        var o;
+        // Don't show error window, just return if the response is invalid.
+        try {
+            o = Fusion.parseJSON(r.responseText);
+        }
+        catch (err) {
+            this.mapWidget._removeWorker();
+            return;
+        }
 
         var newSelection = new Fusion.SimpleSelectionObject(o, this.bHasCleanJsonSupport);
         if(mergeSelection == true)

Modified: trunk/lib/Map.js
===================================================================
--- trunk/lib/Map.js	2018-03-08 13:16:53 UTC (rev 3021)
+++ trunk/lib/Map.js	2018-03-08 13:18:34 UTC (rev 3022)
@@ -415,6 +415,14 @@
         var startIndex = loadOverlays?1:0;
         for (var i = this.aMaps.length-1; i >= startIndex; i--) {
           if (this.aMaps[i].oLayerOL) {
+            if (this.aMaps[i].oLayerOL2) {
+                this.aMaps[i].oLayerOL2.destroy();
+            }
+            if (this.aMaps[i].oLayersOLTile) {
+                for (var j = 0; j < this.aMaps[i].oLayersOLTile.length; j++) {
+                    this.aMaps[i].oLayersOLTile[j].destroy();
+                }
+            }
             this.aMaps[i].oLayerOL.destroy();
             this.aMaps.splice(i,1);
           }
@@ -422,6 +430,9 @@
  
         this._fMetersperunit = -1;
         this.oMapOL.center = null;
+        this.oMapOL.minPx = null;
+        this.oMapOL.maxPx = null;
+        this.oMapOL.zoom = null;
         this.maxExtent = new OpenLayers.Bounds();
         var storedBase;
         if (loadOverlays) {

Modified: trunk/lib/jxLib/jxlib.uncompressed.js
===================================================================
--- trunk/lib/jxLib/jxlib.uncompressed.js	2018-03-08 13:16:53 UTC (rev 3021)
+++ trunk/lib/jxLib/jxlib.uncompressed.js	2018-03-08 13:18:34 UTC (rev 3022)
@@ -16972,7 +16972,7 @@
             scroll,
             size,
             left,
-            rigbht,
+            right,
             top,
             bottom,
             n,

Modified: trunk/widgets/Legend.js
===================================================================
--- trunk/widgets/Legend.js	2018-03-08 13:16:53 UTC (rev 3021)
+++ trunk/widgets/Legend.js	2018-03-08 13:18:34 UTC (rev 3022)
@@ -249,7 +249,13 @@
      */
     bIncludeVisToggle: true,
     offsetsCalculated: false,
-   
+
+    /**
+     * Property: bHideEmptyGroups
+     * {Boolean} Determine if a group which has non-visible layer must be draw in the legend.
+     */
+    bHideEmptyGroups: true,
+
     initialize: function(legend, widgetTag) {   
         Fusion.Widget.Legend.LegendRenderer.prototype.initialize.apply(this, [legend]);
 
@@ -287,7 +293,8 @@
         this.showRootFolder = (json.ShowRootFolder && json.ShowRootFolder[0] == 'true') ? true:false;
         //do show the map folder by default
         this.showMapFolder = (json.ShowMapFolder && json.ShowMapFolder[0] == 'false') ? false:true;
-        
+        this.bHideEmptyGroups = true;
+
         if (!this.showRootFolder) {
             //console.log('supressing root folder');
             this.oRoot = this.oTree;
@@ -543,9 +550,27 @@
         for (var i=map.layerRoot.layers.length-1; i>=0; i--) {
             this.updateLayer(map.layerRoot.layers[i], currentScale);
         }
+        if (this.bHideEmptyGroups) {
+            for (var i=0; i<map.layerRoot.groups.length; i++) {
+                this.hideEmptyGroup(map.layerRoot.groups[i]);
+            }
+        }
         this.oTree.thaw();
     },
    
+    hideEmptyGroup: function(group) {
+        if (group.hasVisibleLayers) {
+            if (group.legend.treeItem) {
+                group.legend.treeItem.domObj.style.display = 'block';
+            }
+            for (var i=0; i<group.groups.length; i++) {
+                this.hideEmptyGroup(group.groups[i])
+            }
+        } else {
+            group.legend.treeItem.domObj.style.display = 'none';
+        }
+    },
+   
     /**
      * remove the dom objects representing the legend layers and groups
      */
@@ -576,6 +601,7 @@
         }
       }
     },
+
     addLayerStyleTreeItems: function(treeItem, items) {
         treeItem.tree.freeze();
         treeItem.add(items);
@@ -601,7 +627,9 @@
         //above are still valid.
         treeItem.add(layerTreeItem, 0);
     },
+
     updateGroupLayers: function(group, fScale) {
+        group.hasVisibleLayers = false;
         for (var i=0; i<group.groups.length; i++) {
             this.updateGroupLayers(group.groups[i], fScale);
         }
@@ -609,10 +637,30 @@
         for (var i=group.layers.length-1 ; i >= 0; i--) {
             this.updateLayer(group.layers[i], fScale);
         }
+
+        // Hide empty groups if necessary.
+        if (!this.bHideEmptyGroups)
+            return;
+        // Check if the group has visible layers
+        for (var i=0; i<group.layers.length; i++) {
+            if (group.layers[i].visibleInGroupLegend) {
+                group.hasVisibleLayers = true;
+                break;
+            }
+        }
+        if (group.hasVisibleLayers)
+            return;
+        for (var i=0; i<group.groups.length; i++) {
+            if (group.groups[i].hasVisibleLayers) {
+                group.hasVisibleLayers = true;
+                break;
+            }
+        }
     },
     updateLayer: function(layer, fScale) {
         /* no need to do anything if we are hiding the layer */
         if (!layer.displayInLegend || !layer.legend) {
+            layer.visibleInGroupLegend = false;
             return;
         }
         /* check the layer's current scale range against the previous one
@@ -721,9 +769,12 @@
             }
         }
         if (layer.legend.treeItem) {
+            layer.visibleInGroupLegend = true;
             layer.legend.treeItem.options.data = layer;
             if (!layer.isBaseMapLayer) //Tiled layers don't have a checkbox so there's nothing to check
                 layer.legend.treeItem.check(layer.visible);
+        } else {
+            layer.visibleInGroupLegend = false;
         }
     },
     getThemeExpandContextMenu: function(node) {

Modified: trunk/widgets/MapMenu.js
===================================================================
--- trunk/widgets/MapMenu.js	2018-03-08 13:16:53 UTC (rev 3021)
+++ trunk/widgets/MapMenu.js	2018-03-08 13:18:34 UTC (rev 3022)
@@ -80,6 +80,7 @@
         
         var mapGroups = Fusion.applicationDefinition.mapGroups;
         this.mapGroupData = {};
+        var oMap = this.getMap();
         var buttonSet = new Jx.ButtonSet();
         for (var key in mapGroups) {
             if (mapGroups[key].mapId) {
@@ -95,6 +96,8 @@
                     });
                     buttonSet.add(menuItem);
                     this.uiObj.add(menuItem);
+                    if (oMap && oMap.mapGroup.mapId == mapGroup.mapId)
+                        menuItem.setActive(true);
                 }
             }
         }

Modified: trunk/widgets/Maptip.js
===================================================================
--- trunk/widgets/Maptip.js	2018-03-08 13:16:53 UTC (rev 3021)
+++ trunk/widgets/Maptip.js	2018-03-08 13:18:34 UTC (rev 3022)
@@ -180,11 +180,10 @@
         if (this.widgetTag.tooltip) {
             this.mapTipBtn.setTooltip(this.widgetTag.tooltip);
         }
-        if (uiObj.options.active) {
-            this.mapTipBtn.setActive(true);
-        }
+        // turn off map tip by default
+        this.mapTipBtn.setActive(false);
 
-        this.uiObj = uiObj;	
+        this.uiObj = uiObj;
     },
     
     activate : function() {

Modified: trunk/widgets/Measure/Measure.php
===================================================================
--- trunk/widgets/Measure/Measure.php	2018-03-08 13:16:53 UTC (rev 3021)
+++ trunk/widgets/Measure/Measure.php	2018-03-08 13:18:34 UTC (rev 3022)
@@ -83,11 +83,13 @@
         }
         
         function OnUnload() {
-            _widget.deactivate();
+            if (_widget)
+                _widget.deactivate();
         }
         
         function SetWidget(widget) {
             _widget = widget;
+            _widget.getMap().isDigitizing = true;
             _widget.setButtons(document.getElementById("measureStopBtn"), document.getElementById("measureStartBtn"));
         }
         
@@ -101,7 +103,7 @@
     
     </script>
 </head>
-<body id="MeasurementWidgetResults" onload="OnLoad()" onunload="OnUnload()">
+<body id="MeasurementWidgetResults" onload="OnLoad()" onbeforeunload="OnUnload()">
     <h1><?php echo $title ?></h1>
     <hr />
     <p><?php echo $hint ?></p>

Modified: trunk/widgets/Measure.js
===================================================================
--- trunk/widgets/Measure.js	2018-03-08 13:16:53 UTC (rev 3021)
+++ trunk/widgets/Measure.js	2018-03-08 13:18:34 UTC (rev 3022)
@@ -357,6 +357,8 @@
         var at = null;
         var pixQuantity = 0;
         if (geom.CLASS_NAME.indexOf('LineString') != -1) {
+            if(v.length < 2)
+                return;
             from = this.getMap().geoToPix(v[0].x,v[0].y);
             to = this.getMap().geoToPix(v[1].x,v[1].y);
             at = {x: (from.x + to.x) / 2, y: (from.y + to.y) / 2};
@@ -467,6 +469,7 @@
         this.getMap().supressContextMenu(true);
         this.updateButtonStates();
         //This is digitization, so trigger the necessary event
+        this.getMap().isDigitizing = true;
         this.getMap().triggerEvent(Fusion.Event.MAP_DIGITIZER_ACTIVATED);
     },
     
@@ -478,6 +481,7 @@
         this.getMap().supressContextMenu(false);
         this.updateButtonStates();
         //This is digitization, so trigger the necessary event
+        this.getMap().isDigitizing = false;
         this.getMap().triggerEvent(Fusion.Event.MAP_DIGITIZER_DEACTIVATED);
     },
     



More information about the fusion-commits mailing list