[mapguide-commits] r9037 - in branches/2.6/MgDev: . Web/src/viewerfiles

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Sep 19 06:06:25 PDT 2016


Author: jng
Date: 2016-09-19 06:06:25 -0700 (Mon, 19 Sep 2016)
New Revision: 9037

Modified:
   branches/2.6/MgDev/
   branches/2.6/MgDev/Web/src/viewerfiles/
   branches/2.6/MgDev/Web/src/viewerfiles/ajaxmappane.templ
Log:
Merged revision(s) 9034 from trunk/MgDev:
#2737: Fix selected features being added in append mode (SHIFT key pressed) when selecting a selected features. Previously (circa pre-2.6), this would de-select that particular feature, but with the introduction of the improved QUERYMAPFEATURES, this action would add the feature to the selection regardless. 

To fix this, we add a selKey property to each selected feature and when we're selecting with append mode, we check if an existing feature with that selection key (matching the selection key we're about to include) exists, if so we remove the feature from the current selection set instead of including the feature 
........



Property changes on: branches/2.6/MgDev
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev:6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/branches/3.0/MgDev:8658,8958-8959
/branches/3.1/MgDev:9026
/sandbox/adsk/2.6l:8727
/sandbox/adsk/3.0m:8563,8584,8607,8625
/sandbox/adsk/3.1n:8871,8912,8921-8922,8942,9019-9020
/sandbox/jng/createruntimemap:7486-7555
/sandbox/jng/php56x:8975-8985
/sandbox/jng/rfc155:8874-8884
/sandbox/rfc94:5099-5163
/trunk/MgDev:8209-8210,8230,8313,8333,8359,8388,8392,8423,8433,8439,8443-8444,8518-8519,8567-8568,8571,8588-8589,8595,8616-8618,8626,8682,8728,8844,8956,8980,8996,9000,9004-9006,9021,9028
   + /branches/2.4/MgDev:6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/branches/3.0/MgDev:8658,8958-8959
/branches/3.1/MgDev:9026
/sandbox/adsk/2.6l:8727
/sandbox/adsk/3.0m:8563,8584,8607,8625
/sandbox/adsk/3.1n:8871,8912,8921-8922,8942,9019-9020
/sandbox/jng/createruntimemap:7486-7555
/sandbox/jng/php56x:8975-8985
/sandbox/jng/rfc155:8874-8884
/sandbox/rfc94:5099-5163
/trunk/MgDev:8209-8210,8230,8313,8333,8359,8388,8392,8423,8433,8439,8443-8444,8518-8519,8567-8568,8571,8588-8589,8595,8616-8618,8626,8682,8728,8844,8956,8980,8996,9000,9004-9006,9021,9028,9034


Property changes on: branches/2.6/MgDev/Web/src/viewerfiles
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/2.4/MgDev/Web/src/viewerfiles:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/sandbox/adsk/2.2gp/Web/src/viewerfiles:5392
/sandbox/adsk/3.0m/Web/src/viewerfiles:8607
/sandbox/jng/createruntimemap/Web/src/viewerfiles:7486-7555
/trunk/MgDev/Web/src/viewerfiles:8313,8616-8618
   + /branches/2.4/MgDev/Web/src/viewerfiles:6738-6741,6749-6756,6777-6783,6785-6787,6789,6791-6794,6796-6801,6954-6962,6986-7006
/sandbox/adsk/2.2gp/Web/src/viewerfiles:5392
/sandbox/adsk/3.0m/Web/src/viewerfiles:8607
/sandbox/jng/createruntimemap/Web/src/viewerfiles:7486-7555
/trunk/MgDev/Web/src/viewerfiles:8313,8616-8618,9034

Modified: branches/2.6/MgDev/Web/src/viewerfiles/ajaxmappane.templ
===================================================================
--- branches/2.6/MgDev/Web/src/viewerfiles/ajaxmappane.templ	2016-09-19 13:05:41 UTC (rev 9036)
+++ branches/2.6/MgDev/Web/src/viewerfiles/ajaxmappane.templ	2016-09-19 13:06:25 UTC (rev 9037)
@@ -3182,7 +3182,7 @@
             {
                 //Check if we have attributes inline
                 var props = xmlIn.getElementsByTagName("SelectedLayer");
-                var resp = ConvertToSelectedFeatureSet(props);
+                var resp = ConvertToSelectedFeatureSet(props, xmlIn, append);
                 ProcessSelectedFeatureSet(resp, append);
             }
             else
@@ -4197,20 +4197,42 @@
 var selFeatures = {};
 var selBounds = null;
 
-function ConvertToSelectedFeatureSet(layerEls)
+function GetSelectedLayerElement(selLayerEls, layerId)
 {
+    for (var i = 0; i < selLayerEls.length; i++) {
+        var selLayerEl = selLayerEls[i];
+        if (selLayerEl.getAttribute("id") == layerId) {
+            return selLayerEl;
+        }
+    }
+    return null;
+}
+
+function ConvertToSelectedFeatureSet(layerEls, xmlIn, append)
+{
     var featuresByLayer = {};
+    //Unfortunately, Selection does not model the selection set
+    //in a way that we can attach selection keys without breaking
+    //the API, so we have no choice but to re-parse the XML selection
+    //again
+    var selLayerEls = xmlIn.getElementsByTagName("Layer");
+    //assert: selLayerEls.length == layerEls.length
     for (var i = 0; i < layerEls.length; i++)
     {
         var layerEl = layerEls[i];
+        var layerId = layerEl.getAttribute("id");
+        var selLayerEl = GetSelectedLayerElement(selLayerEls, layerId);
+        var selFeatEls = selLayerEl.getElementsByTagName("ID");
         var layerName = layerEl.getAttribute("name");
         if (!featuresByLayer[layerName])
             featuresByLayer[layerName] = [];
             
         var featEls = layerEl.getElementsByTagName("Feature");
+        var selLayer = selection.layers.getItem(layerId);
+        //assert: selFeatEls.length == featEls.legnth
         for (var j = 0; j < featEls.length; j++)
         {
-            var feat = { values: [] };
+            var feat = { /* INTERNAL_API */ selKey: ((msie && !msie10plus) ? selFeatEls[j].text : selFeatEls[j].textContent), values: [] };
             var featEl = featEls[j];
             var bounds = featEl.getElementsByTagName("Bounds")[0];
             var bbox = ((msie && !msie10plus) ? bounds.text : bounds.textContent).split(" ");
@@ -4275,7 +4297,21 @@
                 selFeatures[layerName] = [];
             for (var i = 0; i < resp[layerName].length; i++) {
                 var feat = resp[layerName][i];
-                selFeatures[layerName].push(feat);
+                var selIndex = -1;
+                for (var j = 0; j < selFeatures[layerName].length; j++) {
+                    var selFeat = selFeatures[layerName][j];
+                    if (selFeat.selKey == feat.selKey) {
+                        selIndex = j;
+                        break;
+                    }
+                }
+                //In append mode, if we find an existing selected feature with
+                //the same selection key, remove it instead of adding on.
+                if (selIndex >= 0) {
+                    selFeatures[layerName].splice(selIndex, 1);
+                } else {
+                    selFeatures[layerName].push(feat);
+                }
             }
         } else {
             selFeatures[layerName] = resp[layerName];



More information about the mapguide-commits mailing list