[fusion-commits] r3007 - sandbox/adsk/3.1n/layers/MapGuide

svn_fusion at osgeo.org svn_fusion at osgeo.org
Tue Sep 5 23:03:49 PDT 2017


Author: zhanga
Date: 2017-09-05 23:03:49 -0700 (Tue, 05 Sep 2017)
New Revision: 3007

Modified:
   sandbox/adsk/3.1n/layers/MapGuide/MapGuide.js
Log:
Fix issue that Selection Panel is wrong after de-select features.

Modified: sandbox/adsk/3.1n/layers/MapGuide/MapGuide.js
===================================================================
--- sandbox/adsk/3.1n/layers/MapGuide/MapGuide.js	2017-06-26 14:20:43 UTC (rev 3006)
+++ sandbox/adsk/3.1n/layers/MapGuide/MapGuide.js	2017-09-06 06:03:49 UTC (rev 3007)
@@ -1379,6 +1379,7 @@
       }
       if (this.previousSelection != null)
       {
+          this.previousAttributes = null;
           this.previousSelection.clear();
       }
     },
@@ -1992,6 +1993,9 @@
             //Nothing to merge, return original
             return attributes;
         }
+        if (!attributes.hasSelection) {
+            return prevAttributes;
+        }
         //Start off with prevAttributes as the base
         var merged = {};
         merged.hasSelection = prevAttributes.hasSelection;
@@ -2040,16 +2044,20 @@
         if (mergeSelection == true)
         {
             sel.merge(this.previousSelection);
-            attributes = this.mergeAttributes(attributes, this.previousAttributes);
+            if (sel.nLayers > 0)
+                attributes = this.mergeAttributes(attributes, this.previousAttributes);
         }
         var selText = sel.getSelectionXml();
-        this.previousSelection = sel;
         //Because the QUERYMAPFEATURES 2.6.0 response contains mostly everything we need, we cut down
         //on lots of async request ping-pong. So we can just update the selection image and notify any
         //interested parties of the new selection attributes
         if (selText != "" && selText != null) {
+            this.previousSelection = sel;
             this.previousAttributes = attributes;
-            this.updateMapSelection(selText, false, mergeSelection);
+            if (sel.isDeselect)
+                this.updateMapSelection(selText, false, false, true);
+            else
+                this.updateMapSelection(selText, false, mergeSelection);
         } else {
             //Only clear if we're not merging an empty selection
             if (mergeSelection == false) {
@@ -2088,6 +2096,7 @@
 Fusion.SimpleSelectionObject = OpenLayers.Class({
     aLayers : null,
     nLayers : 0,
+    isDeselect: false,
 
     initialize: function(featureInfoResponse)
     {
@@ -2185,6 +2194,7 @@
     {
         if (previousSelection != null && previousSelection.nLayers > 0)
         {
+            this.isDeselect = false;
             for (var prevSelIndex = 0; prevSelIndex < previousSelection.nLayers; prevSelIndex++)
             {
                 var prevSelLayer = previousSelection.aLayers[prevSelIndex];
@@ -2205,11 +2215,12 @@
                         {
                             // the feature was previously selected, so toggle it off when selected again
                             currentLayer.removeFeatures(prevSelFeatureIndexes);
+                            this.isDeselect = true;
                         }
                     }
                     if (currentLayer.featIds.length == 0)
                     {
-                        this.clear();
+                        this.removeLayer(currentLayer);
                     }
                 }
                 else
@@ -2228,6 +2239,30 @@
         }
     },
 
+    getLayerIndex : function(layer)
+    {
+        var index = -1;
+        for (var i=0; i<this.nLayers; i++)
+        {
+            if (this.aLayers[i] == layer)
+            {
+                index = i;
+                break;
+            }
+        }
+        return index;
+    },
+
+    removeLayer: function(layer)
+    {
+        var index = this.getLayerIndex(layer);
+        if (index >=0 && index < this.nLayers)
+        {
+            this.aLayers.remove(index);
+            this.nLayers--;
+        } 
+    },
+
     clear: function()
     {
         this.aLayers = [];



More information about the fusion-commits mailing list