[fusion-commits] r2339 - trunk/lib

svn_fusion at osgeo.org svn_fusion at osgeo.org
Mon Feb 14 13:59:54 EST 2011


Author: madair
Date: 2011-02-14 10:59:54 -0800 (Mon, 14 Feb 2011)
New Revision: 2339

Modified:
   trunk/lib/Map.js
Log:
allow the Mapmenu to leave the base layer as is and load overlays on top from the menu

Modified: trunk/lib/Map.js
===================================================================
--- trunk/lib/Map.js	2011-02-14 18:56:53 UTC (rev 2338)
+++ trunk/lib/Map.js	2011-02-14 18:59:54 UTC (rev 2339)
@@ -270,40 +270,49 @@
      * Controls the creation of Layers based on the MapGroup object passed in
      *
      * Parameter: {Object} mapGroup - a representation of the MapGroup object
+     * {Boolean} loadOverlays - if true, this will leave the first layer (usually
+     * a commercial baselayer) on the map and just replace all the overlays
      *
      * Return: none
      */
-    loadMapGroup: function(mapGroup) {
+    loadMapGroup: function(mapGroup, loadOverlays) {
         //clear any existing selection
         this.mapsLoaded = false;
         this.clearSelection();
         //this._addWorker();
 
         this.mapGroup = mapGroup;
-        for (var i=0; i<this.aMaps.length; i++) {
+        var startIndex = loadOverlays?1:0;
+        for (var i=startIndex; i<this.aMaps.length; i++) {
           if (this.aMaps[i].oLayerOL) {
             this.aMaps[i].oLayerOL.destroy();
+            this.aMaps.splice(i,1);
           }
         }
  
         this._fMetersperunit = -1;
         this.oMapOL.center = null;
         this.maxExtent = new OpenLayers.Bounds();
-        this.aMaps = [];
+        var storedBase;
+        if (loadOverlays) {
+          storedBase = this.layerRoot.layers[0];
+        }
         this.layerRoot.clear();
+        if (loadOverlays) {
+          this.layerRoot.addLayer(storedBase);
+        }
 
         for (var i=0; i<mapGroup.maps.length; ++i) {
           var mapTag = mapGroup.maps[i];
 
           if (Fusion.Layers[mapTag.type]) {
-              this.aMaps[i] = new Fusion.Layers[mapTag.type](this, mapTag, true);
-              this.layerRoot.addGroup(this.aMaps[i].layerRoot);
+              this.aMaps.push(new Fusion.Layers[mapTag.type](this, mapTag, true));
+              this.layerRoot.addGroup(this.aMaps[this.aMaps.length-1].layerRoot);
           } else {
-              this.aMaps[i] = new Fusion.Layers.Generic(this, mapTag, true);
-              this.layerRoot.addLayer(this.aMaps[i].layerRoot);
-              this.layerLoaded();   //Generic layers are loaded synchronously
+              this.aMaps.push(new Fusion.Layers.Generic(this, mapTag, true));
+              this.layerRoot.addLayer(this.aMaps[this.aMaps.length-1].layerRoot);
           }
-          this.aMaps[i].registerForEvent(Fusion.Event.LAYER_LOADED, OpenLayers.Function.bind(this.layerLoaded,this));
+          this.aMaps[this.aMaps.length-1].registerForEvent(Fusion.Event.LAYER_LOADED, OpenLayers.Function.bind(this.layerLoaded,this,mapTag));
         }
         this.triggerEvent(Fusion.Event.MAP_MAP_GROUP_LOADED);
     },
@@ -319,7 +328,7 @@
      *
      * Return: none
      */
-    layerLoaded: function() {
+    layerLoaded: function(mapTag) {
       for (var i=0; i<this.aMaps.length; ++i) {
         if (!this.aMaps[i].isMapLoaded()) {
           return;
@@ -346,7 +355,7 @@
       this.setExtents(initialExtent);
       }
 
-      this.triggerEvent(Fusion.Event.MAP_LOADED);
+      this.triggerEvent(Fusion.Event.MAP_LOADED, mapTag);
     },
 
     /**
@@ -441,57 +450,6 @@
 
 
     /**
-     * Function: getMapName
-     *
-     * returns the name of the baselayer map
-     *
-     * Parameters: none
-     *
-     * Return: {String} the name of the baselayer map
-     */
-    getMapName: function() {
-        //TODO: what is the mapname in the case of multiple map layer objects?
-        //just return baselayer mapname for now
-        return this.aMaps[0].getMapName();
-    },
-
-    /**
-     * Function: getMapTitle
-     *
-     * returns the Title of the baselayer map.  This is a human-readable title
-     *
-     * Parameters: none
-     *
-     * Return: {String} the Title of the baselayer map
-     */
-    getMapTitle: function() {
-        //TODO: what is the map title in the case of multiple map layer objects?
-        //just return baselayer mapTitle for now
-        return this.aMaps[0]._sMapTitle;
-    },
-
-    getMetadata: function(key) {
-        //TODO: what is the map title in the case of multiple map layer objects?
-        //just return baselayer mapTitle for now
-        return this.aMaps[0].getMetadata(key);
-    },
-
-    /**
-     * Function: getSessionID
-     *
-     * returns the server session ID
-     *
-     * Parameters: none
-     *
-     * Return: {String} the session ID
-     */
-    getSessionID: function() {
-        //TODO: what is the mapname in the case of multiple map layer objects?
-        //just return baselayer session ID for now
-        return this.aMaps[0].getSessionID();
-    },
-
-    /**
      * Function: getDomId
      *
      * returns the ID of dom element for this widget
@@ -526,39 +484,36 @@
      *
      * Return: none
      */
-    addMap: function(currentmap) {
+    addMap: function(map) {
 
-        if (currentmap.mapTag.layerOptions.maxExtent) {
-          this.maxExtent.extend(currentmap.mapTag.layerOptions.maxExtent);
+        if (map.mapTag.layerOptions.maxExtent) {
+          this.maxExtent.extend(map.mapTag.layerOptions.maxExtent);
           this.oMapOL.setOptions({maxExtent: this.maxExtent});
         }
-        if (currentmap.mapTag.layerOptions.restrictedExtent) {
-          this.oMapOL.setOptions({restrictedExtent: currentmap.mapTag.layerOptions.restrictedExtent});
-        }
 
         //if bRestrictExtent is null, use the default OL behaviour with somewhat restricted map navigation
         //if bRestrictExtent is set to true, map navigation is limited to the map extent
         //if bRestrictExtent is set to false, map navigation is not restricted at all
         if (this.bRestrictExtent != null) {
           if (this.bRestrictExtent) {
-            this.oMapOL.restrictedExtent = currentmap.mapTag.layerOptions.maxExtent;
+            this.oMapOL.restrictedExtent = map.mapTag.layerOptions.maxExtent;
           } else {
             this.oMapOL.restrictedExtent = false;
           }
         }
-        this.oMapOL.addLayer(currentmap.oLayerOL);
-        if (currentmap.oLayerOL.isBaseLayer) {
-          this.projection = currentmap.projection;
-          this.units = currentmap.units;
+        this.oMapOL.addLayer(map.oLayerOL);
+        if (map.oLayerOL.isBaseLayer) {
+          this.projection = map.oLayerOL.projection;
+          this.units = map.oLayerOL.units;
           this.oMapOL.setOptions({
-                  units: currentmap.units,
+                  units: this.units,
                   projection: this.projection
           });
         }
         
-        currentmap.registerForEvent(Fusion.Event.MAP_SELECTION_OFF,
+        map.registerForEvent(Fusion.Event.MAP_SELECTION_OFF,
                 OpenLayers.Function.bind(this.selectionHandler, this));
-        currentmap.registerForEvent(Fusion.Event.MAP_SELECTION_ON,
+        map.registerForEvent(Fusion.Event.MAP_SELECTION_ON,
                 OpenLayers.Function.bind(this.selectionHandler, this));
     },
 
@@ -1427,16 +1382,11 @@
         return OpenLayers.Util.getParameterString(queryParams);
      },
      
-     getMapTip: function(oMapTips) {
-        //TODO send this to the correct aMap object
-        this.aMaps[0].getMapTip(oMapTips);
-     },
-     
      supressContextMenu: function( bSupress ) {
          this.bSupressContextMenu = bSupress;
      },
 
-     setContextMenu: function(menu) {
+     setContextMenu: function(menu) {                         
          //console.log('setcontextmenu');
          this.oContextMenu = menu;
      },



More information about the fusion-commits mailing list