[fusion-commits] r2704 - sandbox/createruntimemap/layers/MapGuide

svn_fusion at osgeo.org svn_fusion at osgeo.org
Fri May 17 06:55:23 PDT 2013


Author: jng
Date: 2013-05-17 06:55:23 -0700 (Fri, 17 May 2013)
New Revision: 2704

Modified:
   sandbox/createruntimemap/layers/MapGuide/MapGuide.js
Log:
Update to handle the latest CREATERUNTIMEMAP response format. Also default to use GIF as that icon format as my tests have shown that GIF produces the smallest 16x16 icons as base64 strings.

Modified: sandbox/createruntimemap/layers/MapGuide/MapGuide.js
===================================================================
--- sandbox/createruntimemap/layers/MapGuide/MapGuide.js	2013-05-17 04:23:20 UTC (rev 2703)
+++ sandbox/createruntimemap/layers/MapGuide/MapGuide.js	2013-05-17 13:55:23 UTC (rev 2704)
@@ -123,8 +123,8 @@
         this.noCache = true;
         this.oLayersOLTile = [];
         
-        //NOTE: This can only be true in conjunction with support for QUERYMAPFEATURES 2.6.0 because the current LoadMap.php
-        //and LoadScaleRanges.php stash cached state server-side (yuck!) that would be missing if we go this route >:(
+        //NOTE: This may cause a slight (but not too much) delay in any requests to PHP scripts that use layer property mappings as they will be
+        //lazy loaded due to us not calling LoadMap.php, which would've pre-cached such information.
         this.bUseNativeServices = true;
         var sid = Fusion.sessionId;
         if (sid) {
@@ -240,9 +240,12 @@
         
         if (this.bUseNativeServices) {
             var features = (1 | 2 | 4); //We want the whole lot
-            var r = new Fusion.Lib.MGRequest.MGCreateRuntimeMap(resourceId, features, 25);
+            var r = new Fusion.Lib.MGRequest.MGCreateRuntimeMap(resourceId, features, 3);
             var mapName = this.calcMapName(resourceId, true);
-            r.setParams({ targetMapName: mapName });
+            r.setParams({ 
+                targetMapName: mapName,
+                iconFormat: "GIF"
+            });
             if (this.session.length == 1)
                 r.setParams({ session: this.session[0] });
             Fusion.oBroker.dispatchRequest(r, OpenLayers.Function.bind(this.onRuntimeMapCreated, this));
@@ -318,7 +321,6 @@
         var lsr = {
             layers: []
         };
-        
         for (var i = 0; i < rt.Layer.length; i++) {
             var lyr = rt.Layer[i];
             var cl = {
@@ -362,24 +364,27 @@
                     minScale = Math.min(minScale, sr.MinScale[0]);
                     maxScale = Math.max(maxScale, sr.MaxScale[0]);
                     
-                    if (sr.Rule) {
-                        for (var k = 0; k < sr.Rule.length; k++) {
-                            var rule = sr.Rule[k];
-                            var cr = {
-                                categoryIndex: parseInt(rule.ThemeCategory[0]),
-                                filter: rule.Filter ? rule.Filter[0] : "",
-                                geometryType: parseInt(rule.GeometryType[0]),
-                                legendLabel: rule.LegendLabel ? rule.LegendLabel[0] : ""
-                            };
-                            if (typeof(ltypes[cr.geometryType]) == 'undefined')
-                                ltypes[cr.geometryType] = cr.geometryType;
-                            //One single absence of an icon is enough to hint that it's compressed
-                            if (!rule.Icon) {
-                                csr.isCompressed = false;
-                            } else {
-                                cr.imageData = "data:" + rule.Icon[0].MimeType[0] + ";base64," + rule.Icon[0].Content[0];
+                    if (sr.FeatureStyle) {
+                        for (var f = 0; f < sr.FeatureStyle.length; f++) {
+                            var fts = sr.FeatureStyle[f];
+                            for (var k = 0; k < fts.Rule.length; k++) {
+                                var rule = fts.Rule[k];
+                                var cr = {
+                                    categoryIndex: k,
+                                    filter: rule.Filter ? rule.Filter[0] : "",
+                                    geometryType: parseInt(fts.Type[0]),
+                                    legendLabel: rule.LegendLabel ? rule.LegendLabel[0] : ""
+                                };
+                                if (typeof(ltypes[cr.geometryType]) == 'undefined')
+                                    ltypes[cr.geometryType] = cr.geometryType;
+                                //One single absence of an icon is enough to hint that it's compressed
+                                if (!rule.Icon) {
+                                    csr.isCompressed = true;
+                                } else {
+                                    cr.imageData = "data:" + rt.IconMimeType[0] + ";base64," + rule.Icon[0];
+                                }
+                                csr.styles.push(cr);
                             }
-                            csr.styles.push(cr);
                         }
                     }
                     clsr.scaleRanges.push(csr);



More information about the fusion-commits mailing list