[fusion-commits] r2845 - sandbox/tiling/layers/MapGuide

svn_fusion at osgeo.org svn_fusion at osgeo.org
Sat Jun 14 08:46:06 PDT 2014


Author: jng
Date: 2014-06-14 08:46:06 -0700 (Sat, 14 Jun 2014)
New Revision: 2845

Modified:
   sandbox/tiling/layers/MapGuide/MapGuide.js
Log:
Add support for tile set definitions and the updated CREATERUNTIMEMAP/DESCRIBERUNTIMEMAP response format

Modified: sandbox/tiling/layers/MapGuide/MapGuide.js
===================================================================
--- sandbox/tiling/layers/MapGuide/MapGuide.js	2014-06-14 15:45:09 UTC (rev 2844)
+++ sandbox/tiling/layers/MapGuide/MapGuide.js	2014-06-14 15:46:06 UTC (rev 2845)
@@ -55,7 +55,9 @@
         1155581.153, 2311162.307, 4622324.614, 9244649.227, 18489298.45, 
         36978596.91, 73957193.82, 147914387.6, 295828775.3, 591657550.5
     ],
+    defaultTileSize: [300,300],
     bUseNativeServices: false,
+    bHasTileSetSupport: false,
     selectionAsOverlay: true,
     useAsyncOverlay: false,
     defaultFormat: 'PNG',
@@ -169,10 +171,12 @@
         //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. but we get much better map init performance
         this.bUseNativeServices = false;
+        this.bHasTileSetSupport = false;
         var vMajor = this.siteVersion[0];
         var vMinor = this.siteVersion[1];
         if (vMajor > 2) { // 3.0 or higher
             this.bUseNativeServices = true;
+            this.bHasTileSetSupport = true;
         } else {
             if (vMajor == 2) { // 2.x
                 if (vMinor >= 6) { // >= 2.6
@@ -180,6 +184,7 @@
                 }
             }
         }
+        this.bHasTileSetSupport = true;
     },
 
     createSessionCB: function(xhr) {
@@ -285,6 +290,9 @@
         if (this.bUseNativeServices) {
             var features = (1 | 2 | 4); //We want the whole lot
             var r = new Fusion.Lib.MGRequest.MGCreateRuntimeMap(resourceId, features, 25);
+            if (this.bHasTileSetSupport) {
+                r.setParams({ version: "3.0.0" });
+            }
             var mapName = this.calcMapName(resourceId, true);
             r.setParams({ 
                 targetMapName: mapName,
@@ -352,9 +360,9 @@
                     parentUniqueId: grp.ParentId ? grp.ParentId[0] : "",
                     visible: (grp.Visible[0] == "true"),
                     actuallyVisible: (grp.ActuallyVisible[0] == "true"),
-                    isBaseMapGroup: (grp.Type[0] == "2")
+                    isBaseMapGroup: (grp.Type[0] == "2" || grp.Type[0] == "3")
                 };
-                if (grp.Type[0] == "2")
+                if (cg.isBaseMapGroup)
                     lm.hasBaseMapLayers = true;
                 else
                     lm.hasDynamicLayers = true;
@@ -652,14 +660,28 @@
         this.triggerEvent(Fusion.Event.LAYER_LOADED);
 
     },
+    convertAndLoadMapResponse: function(o) {
+        var co = this.convertResponse(o);
+        if (this.bHasTileSetSupport && o.RuntimeMap.TileSetDefinition) {
+            //Override default tile size based on what's in the 
+            if (o.RuntimeMap.TileWidth && o.RuntimeMap.TileHeight) {
+                this.defaultTileSize = [
+                    parseInt(o.RuntimeMap.TileWidth[0]),
+                    parseInt(o.RuntimeMap.TileHeight[0])
+                ];
+            }
+            this._tileSetId = o.RuntimeMap.TileSetDefinition[0];
+        }
+        this.initLoadMapResponse(co.LoadMap);
+        return co;
+    },
     /**
      * Callback function from a CREATERUNTIMEMAP request
      */
     onRuntimeMapCreated: function(r) {
         if (r.status == 200) {
             var o = Fusion.parseJSON(r.responseText);
-            var co = this.convertResponse(o);
-            this.initLoadMapResponse(co.LoadMap);
+            var co = this.convertAndLoadMapResponse(o);
             //Need to wait for the right event to trigger loadScaleRanges, so stash our
             //prepared result for when it comes
             this._initScaleRanges = co.LoadScaleRanges;
@@ -995,7 +1017,7 @@
 
       } else {
         params = {      //tiled version
-          mapdefinition: this._sResourceId,
+          mapdefinition: this._tileSetId || this._sResourceId,
           basemaplayergroupname: baselayerGroupName, 
           session: this.getSessionID(),
           clientagent: this.clientAgent
@@ -1033,6 +1055,9 @@
         }
       }
       
+      if (!bSingleTile)
+        layerOptions.defaultSize = new OpenLayers.Size(this.defaultTileSize[0], this.defaultTileSize[1]);
+      
       var oNewLayerOL = new OpenLayers.Layer.MapGuide( layerName, url, params, layerOptions );
       if (!bSingleTile) {
         if (oNewLayerOL.scales.length == this.aCmsScales.length) { 



More information about the fusion-commits mailing list