[fusion-commits] r2041 - in trunk: layers layers/MapGuide layers/MapGuide/php widgets

svn_fusion at osgeo.org svn_fusion at osgeo.org
Fri Jan 22 12:15:00 EST 2010


Author: chrisclaydon
Date: 2010-01-22 12:14:59 -0500 (Fri, 22 Jan 2010)
New Revision: 2041

Modified:
   trunk/layers/Layers.js
   trunk/layers/MapGuide/MapGuide.js
   trunk/layers/MapGuide/php/LoadMap.php
   trunk/widgets/Legend.js
   trunk/widgets/Navigator.js
Log:
Fix MG ticket 469 (http://trac.osgeo.org/mapguide/ticket/469) Problems with tiled MG maps

Modified: trunk/layers/Layers.js
===================================================================
--- trunk/layers/Layers.js	2010-01-20 19:13:08 UTC (rev 2040)
+++ trunk/layers/Layers.js	2010-01-22 17:14:59 UTC (rev 2041)
@@ -329,6 +329,7 @@
         this.visible = o.visible;
         this.initiallyVisible = o.visible;
         this.actuallyVisible = o.actuallyVisible;
+        this.isBaseMapGroup = o.isBaseMapGroup;
         this.registerEventID(Fusion.Event.GROUP_PROPERTY_CHANGED);
     },
 
@@ -459,6 +460,7 @@
         this.visible = o.visible;
         this.initiallyVisible = o.visible;
         this.selectable = o.selectable;
+        this.isBaseMapLayer = o.isBaseMapLayer;
 
 
         //determine the layer type so that the correct icon can be displayed in the legend

Modified: trunk/layers/MapGuide/MapGuide.js
===================================================================
--- trunk/layers/MapGuide/MapGuide.js	2010-01-20 19:13:08 UTC (rev 2040)
+++ trunk/layers/MapGuide/MapGuide.js	2010-01-22 17:14:59 UTC (rev 2041)
@@ -322,15 +322,29 @@
                 this.oLayerOL.destroy();
             }
 
-            this.oLayerOL = this.createOLLayer(this._sMapname, this.bSingleTile,2);
+            this.oLayerOL = this.createOLLayer(this._sMapname, this.bSingleTile,2,false);
             this.oLayerOL.events.register("loadstart", this, this.loadStart);
             this.oLayerOL.events.register("loadend", this, this.loadEnd);
             this.oLayerOL.events.register("loadcancel", this, this.loadEnd);
 
+            
+            //remove the dynamic overlay layer if it was already created
+            if (this.oLayerOL2) {
+                this.oLayerOL2.destroy();
+            }
+
             //this is to distinguish between a regular map and an overview map
             this.bMapLoaded = true;
             if (this.bIsMapWidgetLayer) {
-              this.mapWidget.addMap(this);
+                this.mapWidget.addMap(this);
+                
+                //if we have a tiled map that also contains dynamic layers, we need to create
+                //an additional overlay layer to render them on top of the tiles
+                if(!this.bSingleTile && o.hasDynamicLayers) {
+                    this.oLayerOL2 = this.createOLLayer(this._sMapname + "_DynamicOverlay",true,2,true);
+                    this.mapWidget.oMapOL.addLayer(this.oLayerOL2);
+                    this.oLayerOL2.setVisibility(true);
+                }
             }
         }
         this.mapWidget._removeWorker();
@@ -530,7 +544,12 @@
         this.aHideGroups = [];
         this.aRefreshLayers = [];
 
-        this.oLayerOL.mergeNewParams(params);
+        if(this.oLayerOL2) {
+            this.oLayerOL2.mergeNewParams(params);
+        } else {
+            this.oLayerOL.mergeNewParams(params);
+        }
+        
     },
 
     drawSelection: function() {
@@ -546,7 +565,7 @@
      *
      * Returns an OpenLayers MapGuide layer object
      */
-    createOLLayer: function(layerName, bSingleTile, behavior) {
+    createOLLayer: function(layerName, bSingleTile, behavior, forceAsOverlay) {
       /* prevent the useOverlay flag based on MapGuide config element */
       this.useAsyncOverlay = Fusion.getConfigurationItem('mapguide', 'useAsyncOverlay');
       if (!this.useAsyncOverlay) {          //v2.0.1 or earlier
@@ -601,8 +620,12 @@
         if (behavior == 5) {
           params.selectioncolor = this.selectionColor;
           params.format = this.selectionFormat;
-          layerOptions.isBaseLayer = false;
         }
+        
+        if(forceAsOverlay)
+        {
+            layerOptions.isBaseLayer = false;
+        }
 
       } else {
         params = {      //tiled version
@@ -624,8 +647,8 @@
       } else {
         url = Fusion.getConfigurationItem('mapguide', 'mapAgentUrl');
       }
-      var oLayerOL = new OpenLayers.Layer.MapGuide( layerName, url, params, layerOptions );
-      return oLayerOL;
+      var oNewLayerOL = new OpenLayers.Layer.MapGuide( layerName, url, params, layerOptions );
+      return oNewLayerOL;
     },
 
     /**
@@ -910,7 +933,7 @@
             if (oNode.hasSelection) {
               if (this.selectionAsOverlay) {
                 if (!this.queryLayer) {
-                  this.queryLayer = this.createOLLayer("query layer", true, 5);
+                  this.queryLayer = this.createOLLayer("query layer", true, 5, true);
                   this.mapWidget.oMapOL.addLayer(this.queryLayer);
                   this.mapWidget.registerForEvent(Fusion.Event.MAP_LOADING,
                         OpenLayers.Function.bind(this.removeQueryLayer, this));
@@ -999,6 +1022,9 @@
         this.processGroupEvents(group, true);
         if (group.groupName == 'layerRoot') {
             this.oLayerOL.setVisibility(true);
+            this.oLayerOL2.setVisibility(true);
+        } else if (group.isBaseMapGroup) {
+            this.oLayerOL.setVisibility(true);
         } else {
             this.aShowGroups.push(group.uniqueId);
             if (!noDraw) {
@@ -1010,6 +1036,9 @@
         this.processGroupEvents(group, false);
         if (group.groupName == 'layerRoot') {
             this.oLayerOL.setVisibility(false);
+            this.oLayerOL2.setVisibility(false);
+        } else if (group.isBaseMapGroup) {
+            this.oLayerOL.setVisibility(false);
         } else {
             this.aHideGroups.push(group.uniqueId);
             if (!noDraw) {

Modified: trunk/layers/MapGuide/php/LoadMap.php
===================================================================
--- trunk/layers/MapGuide/php/LoadMap.php	2010-01-20 19:13:08 UTC (rev 2040)
+++ trunk/layers/MapGuide/php/LoadMap.php	2010-01-22 17:14:59 UTC (rev 2041)
@@ -148,6 +148,16 @@
         $layerObj->actuallyVisible = $layer->isVisible();
         $layerObj->editable = IsLayerEditable($resourceService, $layer);
 
+        $isBaseMapLayer = ($layer->GetLayerType() == MgLayerType::BaseMap);
+        $layerObj->isBaseMapLayer = $isBaseMapLayer;
+        if($isBaseMapLayer)
+        {
+        	$mapObj->hasBaseMapLayers = true;
+        }
+        else
+        {
+        	$mapObj->hasDynamicLayers = true;
+        }
 
         $layerObj->legendLabel = addslashes($layer->GetLegendLabel());
         $layerObj->displayInLegend = $layer->GetDisplayInLegend();
@@ -375,6 +385,8 @@
     $groupObj->parentUniqueId = $parent != null ? $parent->GetObjectId() : '';
     $groupObj->visible = $group->GetVisible();
     $groupObj->actuallyVisible = $group->isVisible();
+    $isBaseMapGroup = ($group->GetLayerGroupType() == MgLayerGroupType::BaseMap);
+    $groupObj->isBaseMapGroup =  $isBaseMapGroup;
 
     return $groupObj;
 }

Modified: trunk/widgets/Legend.js
===================================================================
--- trunk/widgets/Legend.js	2010-01-20 19:13:08 UTC (rev 2040)
+++ trunk/widgets/Legend.js	2010-01-22 17:14:59 UTC (rev 2041)
@@ -255,7 +255,7 @@
             var opt = {
                 label: OpenLayers.i18n('defaultMapTitle'),
                 open: true,
-                draw: this.renderFolder,
+                draw: this.renderFolderCheckbox,
                 contextMenu: this.getContextMenu(),
                 'class':'fusionLegendFolder'
             };
@@ -376,7 +376,7 @@
      *
      * @param r Object the reponse xhr object
      */
-    /*renderLegend: function(r) {
+    /*renderLegend: function(r) {
         this.bIsDrawn = false;
         this.clear();
 
@@ -400,43 +400,43 @@
         }
         this.bIsDrawn = true;
         this.update();
-    },*/
-    renderLegend: function(r) {
-        this.bIsDrawn = false;
-        this.clear();
-
-        if (this.showRootFolder) {
-            this.oRoot.itemLabelobj.innerHTML = this.getMap().getMapTitle();
-        }
-
-        if (this.showMapFolder) {
-		this.renderGroup(this.layerRoot);
-        } else {
-		if (this.layerRoot.groups.length > 0) {
-			for (var i = 0; i < this.layerRoot.groups.length; i++)
-				this.renderGroup(this.layerRoot.groups[i]);
-		} else {
-			for (var i = 0; i < group.layers.length; i++)
-				this.processMapLayer(group.layers[i], this.oRoot);
-		}
-        }
-
-        this.bIsDrawn = true;
-        this.update();
-    },
-    
-    renderGroup: function(group) {
-        if (!group.legend) {
-            group.legend = {};
-            group.legend.treeItem = this.oRoot;
-        }
-        for (var i = 0; i < group.groups.length; i++) {
-            this.processMapGroup(group.groups[i], this.oRoot);
-        }
-        for (var i = 0; i < group.layers.length; i++) {
-            this.processMapLayer(group.layers[i], this.oRoot);
-        }
+    },*/
+    renderLegend: function(r) {
+        this.bIsDrawn = false;
+        this.clear();
+
+        if (this.showRootFolder) {
+            this.oRoot.itemLabelobj.innerHTML = this.getMap().getMapTitle();
+        }
+
+        if (this.showMapFolder) {
+        this.renderGroup(this.layerRoot);
+        } else {
+        if (this.layerRoot.groups.length > 0) {
+            for (var i = 0; i < this.layerRoot.groups.length; i++)
+                this.renderGroup(this.layerRoot.groups[i]);
+        } else {
+            for (var i = 0; i < group.layers.length; i++)
+                this.processMapLayer(group.layers[i], this.oRoot);
+        }
+        }
+
+        this.bIsDrawn = true;
+        this.update();
     },
+    
+    renderGroup: function(group) {
+        if (!group.legend) {
+            group.legend = {};
+            group.legend.treeItem = this.oRoot;
+        }
+        for (var i = 0; i < group.groups.length; i++) {
+            this.processMapGroup(group.groups[i], this.oRoot);
+        }
+        for (var i = 0; i < group.layers.length; i++) {
+            this.processMapLayer(group.layers[i], this.oRoot);
+        }
+    },
    
     processMapGroup: function(group, folder) {
         if (group.displayInLegend) {
@@ -445,7 +445,7 @@
             var opt = {
                 label: group.legendLabel,
                 open: group.expandInLegend,
-                draw: this.renderFolder,
+                draw: this.renderFolderCheckbox,
                 contextMenu: this.getContextMenu(),
                 'class':'fusionLegendFolder'
             };
@@ -463,8 +463,11 @@
             );
 
             folder.append(group.legend.treeItem);
-            group.legend.treeItem.checkBox.checked = group.visible?true:false;
-            OpenLayers.Event.observe(group.legend.treeItem.checkBox, 'click', OpenLayers.Function.bind(this.stateChanged, this, group));
+            if(group.legend.treeItem.checkBox)
+            {
+                group.legend.treeItem.checkBox.checked = group.visible?true:false;
+                OpenLayers.Event.observe(group.legend.treeItem.checkBox, 'click', OpenLayers.Function.bind(this.stateChanged, this, group));
+            }
 
             var groupInfo = group.oMap.getGroupInfoUrl(group.groupName);
             if (groupInfo) {
@@ -500,7 +503,10 @@
     },
    
     layerPropertyChanged: function(eventID, layer) {
-        layer.legend.treeItem.checkBox.checked = layer.isVisible();
+        if(layer.legend.treeItem.checkBox)
+        {
+            layer.legend.treeItem.checkBox.checked = layer.isVisible();
+        }
     },
 
     update: function() {
@@ -557,7 +563,7 @@
     },
     updateLayer: function(layer, fScale) {
 
-        var checkbox = layer.oMap.bSingleTile ? this.bIncludeVisToggle : false;
+        var checkbox = layer.isBaseMapLayer ? false : this.bIncludeVisToggle;
         if (!layer.displayInLegend || !layer.legend) {
             return;
         }
@@ -571,13 +577,19 @@
             if (range.styles.length > 1) {
                 //tree item needs to be a folder
                 if (!layer.legend.treeItem) {
-                    layer.legend.treeItem = this.createFolderItem(layer);
-                    OpenLayers.Event.observe(layer.legend.treeItem.checkBox, 'click', OpenLayers.Function.bind(this.stateChanged, this, layer));
+                    layer.legend.treeItem = this.createFolderItem(layer, checkbox);
+                    if(layer.legend.treeItem.checkBox)
+                    {
+                        OpenLayers.Event.observe(layer.legend.treeItem.checkBox, 'click', OpenLayers.Function.bind(this.stateChanged, this, layer));
+                    }
                     layer.parentGroup.legend.treeItem.append(layer.legend.treeItem);
                 } else if (layer.legend.treeItem instanceof Jx.TreeItem) {
                     this.clearTreeItem(layer);
-                    layer.legend.treeItem = this.createFolderItem(layer);
-                    OpenLayers.Event.observe(layer.legend.treeItem.checkBox, 'click', OpenLayers.Function.bind(this.stateChanged, this, layer));
+                    layer.legend.treeItem = this.createFolderItem(layer, checkbox);
+                    if(layer.legend.treeItem.checkBox)
+                    {
+                        OpenLayers.Event.observe(layer.legend.treeItem.checkBox, 'click', OpenLayers.Function.bind(this.stateChanged, this, layer));
+                    }
                     layer.parentGroup.legend.treeItem.append(layer.legend.treeItem);
                 } else {
                     while(layer.legend.treeItem.nodes.length > 0) {
@@ -612,8 +624,8 @@
                     layer.parentGroup.legend.treeItem.append(layer.legend.treeItem);
                 } else {
                     if (range.styles.length > 0) {
-                        layer.legend.treeItem.domImg.style.backgroundImage = 'url('+layer.oMap.getLegendImageURL(fScale, layer, range.styles[0])+')';
-                        layer.legend.treeItem.domImg.style.backgroundPosition = '0px 0px';
+                        layer.legend.treeItem.domImg.style.backgroundImage = 'url('+layer.oMap.getLegendImageURL(fScale, layer, range.styles[0])+')';
+                        layer.legend.treeItem.domImg.style.backgroundPosition = '0px 0px';
                         $(layer.legend.treeItem.domObj).removeClass('jxDisabled');
                     } else {
                         $(layer.legend.treeItem.domObj).addClass('jxDisabled');
@@ -654,11 +666,11 @@
         }
     },
     
-    createFolderItem: function(layer) {
+    createFolderItem: function(layer, hasCheckbox) {
         var opt = {
             label: layer.legendLabel == '' ? '&nbsp;' : layer.legendLabel,
             isOpen: layer.expandInLegend,
-            draw: this.renderFolder,
+            draw: hasCheckbox ? this.renderFolderCheckbox : this.renderFolder,
             'class':'fusionLegendItemCheckbox',
             contextMenu: this.getContextMenu(),
             // image overrides
@@ -791,8 +803,6 @@
             }
         });
         
-        this.checkBox = document.createElement('input');
-        this.checkBox.type = 'checkbox';
         
         this.domImg = document.createElement('img');
         this.domImg.className = 'jxTreeIcon ' + (this.options.imageClass ? this.options.imageClass : '');
@@ -807,7 +817,6 @@
             html: this.options.label
         });
         
-        domA.appendChild(this.checkBox);
         domA.appendChild(this.domImg);
         domA.appendChild(domLabel);
 
@@ -817,6 +826,43 @@
         
     },
     
+    renderFolderCheckbox: function() {
+        var domA = new Element('a',{
+            'class':this.options['class'],
+            href:'javascript:void(0)',
+            events: {
+                click: this.selected.bindWithEvent(this),
+                dblclick: this.selected.bindWithEvent(this),
+                contextmenu: this.options.contextMenu.show.bindWithEvent(this.options.contextMenu)
+            }
+        });
+
+        this.checkBox = document.createElement('input');
+        this.checkBox.type = 'checkbox';
+
+        this.domImg = document.createElement('img');
+        this.domImg.className = 'jxTreeIcon ' + (this.options.imageClass ? this.options.imageClass : '');
+        this.domImg.src = Jx.aPixel.src;
+
+        if (this.options.image) {
+            this.domImg.style.backgroundImage = 'url('+this.options.image+')';
+        }
+
+        var domLabel = new Element('span',{
+            'class': 'fusionLegendLabel',
+            html: this.options.label
+        });
+
+        domA.appendChild(this.checkBox);
+        domA.appendChild(this.domImg);
+        domA.appendChild(domLabel);
+
+        this.itemLabelobj = domA;
+
+        return domA;
+
+    },
+    
     renderItem: function() {
 
         var domA = new Element('a', {

Modified: trunk/widgets/Navigator.js
===================================================================
--- trunk/widgets/Navigator.js	2010-01-20 19:13:08 UTC (rev 2040)
+++ trunk/widgets/Navigator.js	2010-01-22 17:14:59 UTC (rev 2041)
@@ -196,7 +196,7 @@
                 olMap.zoomTo(olMap.getZoomForResolution(resolution));
                 this.bInternalChange = false;
             } else {
-                var zoom = olMap.baseLayer.resolutions.length - value;
+                var zoom = olMap.baseLayer.resolutions.length - value - 1;
                 this.bInternalChange = true;
                 olMap.zoomTo(zoom);
                 this.bInternalChange = false;
@@ -243,8 +243,8 @@
             this.slider.set(position);
             this.bInternalChange = false;
         } else {
-            this.slider.steps = map.baseLayer.resolutions.length;
-            var position = map.baseLayer.resolutions.length - map.getZoom();
+            this.slider.steps = map.baseLayer.resolutions.length - 1;
+            var position = map.baseLayer.resolutions.length -1 - map.getZoom();
             this.bInternalChange = true;
             this.slider.set(position);
             this.bInternalChange = false;



More information about the fusion-commits mailing list