[fusion-commits] r1379 - in sandbox/olcore: . layers lib widgets

svn_fusion at osgeo.org svn_fusion at osgeo.org
Fri Apr 18 10:27:20 EDT 2008


Author: madair
Date: 2008-04-18 10:27:20 -0400 (Fri, 18 Apr 2008)
New Revision: 1379

Added:
   sandbox/olcore/layers/
   sandbox/olcore/layers/Layers.js
Modified:
   sandbox/olcore/lib/ApplicationDefinition.js
   sandbox/olcore/lib/Map.js
   sandbox/olcore/lib/fusion.js
   sandbox/olcore/widgets/CursorPosition.js
   sandbox/olcore/widgets/Legend.js
   sandbox/olcore/widgets/MapMenu.js
   sandbox/olcore/widgets/OverviewMap.js
Log:
initial cut  at refactoring Map classes

Added: sandbox/olcore/layers/Layers.js
===================================================================
--- sandbox/olcore/layers/Layers.js	                        (rev 0)
+++ sandbox/olcore/layers/Layers.js	2008-04-18 14:27:20 UTC (rev 1379)
@@ -0,0 +1,1101 @@
+/**
+ * Fusion.Layers.MapGuide
+ *
+ * $Id: MapGuide.js 1355 2008-03-31 18:56:52Z madair $
+ *
+ * Copyright (c) 2007, DM Solutions Group Inc.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/***************************************************************************
+* Class: Fusion.Layers.MapGuide
+*
+* Implements the map widget for MapGuide Open Source services.
+*/
+
+Fusion.Event.MAP_LAYER_TOGGLED = Fusion.Event.lastEventId++;
+ 
+Fusion.Layers = OpenLayers.Class(Fusion.Lib.EventMgr, {
+    session: null,
+    bSingleTile: null,  
+    bIsBaseLayer: true,     //TODO: set this in AppDef?
+    sActiveLayer: null,
+    selectionType: 'INTERSECTS',
+    bSelectionOn: false,
+    oSelection: null,
+    bDisplayInLegend: true,  //TODO: set this in AppDef?
+    bExpandInLegend: true,   //TODO: set this in AppDef?
+    bMapLoaded: false,
+    bIsMapWidgetLayer: true, //Set this to false for overview map layers
+    bLayersReversed: false,  //MGOS returns layers top-most layer first
+    sMapResourceId: null,    //pointer to the resource that defines the map (URL, MapFile, MGOS, etc)
+    sImageType : 'png',      //TODO: set this in AppDef?
+    _sResourceId: null,      //the resource id of the current Map as stored in the session
+    
+    initialize : function(map, mapTag, isMapWidgetLayer) {
+        // console.log('MapGuide.initialize');
+                
+        this.registerEventID(Fusion.Event.MAP_SESSION_CREATED);
+        this.registerEventID(Fusion.Event.MAP_SELECTION_ON);
+        this.registerEventID(Fusion.Event.MAP_SELECTION_OFF);
+        this.registerEventID(Fusion.Event.MAP_LOADED);
+        this.registerEventID(Fusion.Event.MAP_LOADING);
+        this.registerEventID(Fusion.Event.MAP_LAYER_ORDER_CHANGED);
+
+        this.mapWidget = map;
+        this.oSelection = null;
+        if (isMapWidgetLayer != null) {
+            this.bIsMapWidgetLayer = isMapWidgetLayer;
+        }
+        
+        this.bSingleTile = mapTag.singleTile; //this is set in thhe AppDef.Map class
+
+        this.extension = mapTag.extension; 
+        this.selectionType = this.extension.SelectionType ? this.extension.SelectionType[0] : 'INTERSECTS';
+        this.ratio = this.extension.MapRatio ? this.extension.MapRatio[0] : 1.0;
+        this.keepAliveInterval = parseInt(this.extension.KeepAliveInterval ? this.extension.KeepAliveInterval[0] : 300);
+        
+        rootOpts = {
+          displayInLegend: this.bDisplayInLegend,
+          expandInLegend: this.bExpandInLegend,
+          legendLabel: 'layerRoot',
+          uniqueId: 'layerRoot',
+          groupName: 'layerRoot',
+          visible: true,
+          actuallyVisible: true
+          //TODO: set other opts for group initialization as required
+        };
+        this.layerRoot = new Fusion.Layers.Group(rootOpts,this);
+
+        var sid = Fusion.sessionId;
+        if (sid) {
+            this.session = sid;
+            this.mapSessionCreated();
+        } else {
+            this.createSession();
+        }
+    },
+
+    createSession: function() {
+        if (!this.session) {                     
+            this.registerForEvent(Fusion.Event.MAP_SESSION_CREATED, 
+                OpenLayers.Function.bind(this.mapSessionCreated, this));
+            var sl = Fusion.getScriptLanguage();
+            var scriptURL = 'layers/' + this.arch + '/' + sl + '/CreateSession.' + sl;
+            var options = {onSuccess: OpenLayers.Function.bind(this.createSessionCB, this)};
+            Fusion.ajaxRequest(scriptURL,options);  
+        } else {
+            this.mapSessionCreated();
+        }
+    },
+    
+    createSessionCB : function(xhr) {
+        if (xhr.status == 200) {
+            var o;
+            eval('o='+xhr.responseText);
+            this.session = o.sessionId;
+            this.triggerEvent(Fusion.Event.MAP_SESSION_CREATED);
+        }
+    },
+
+    mapSessionCreated: function() {
+        if (this.sMapResourceId != '') {
+            this.loadMap(this.sMapResourceId);
+        }
+        window.setInterval(OpenLayers.Function.bind(this.pingServer, this), this.keepAliveInterval * 1000);
+    },
+
+    sessionReady: function() {
+        return (typeof this.session == 'string');
+    },
+
+    getSessionID: function() {
+        return this.session;
+    },
+    
+    getMapName: function() {
+        return this._sMapname;
+    },
+    
+    getMapTitle: function() {
+        return this._sMapTitle;
+    },
+    
+    loadMap: function(resourceId) {
+        this.bMapLoaded = false;
+
+        /* don't do anything if the map is already loaded? */
+        if (this._sResourceId == resourceId) {
+            return;
+        }
+
+        if (!this.sessionReady()) {
+            this.sMapResourceId = resourceId;
+            return;
+        }
+        
+        if (this.bIsMapWidgetLayer) {
+            this.mapWidget.triggerEvent(Fusion.Event.MAP_LOADING);
+        } else {
+          this.triggerEvent(Fusion.Event.MAP_LOADING);
+        }
+        this.mapWidget._addWorker();
+        
+        this._fScale = -1;
+        this._nDpi = 96;
+        
+        this.aLayers = [];
+
+        this.oSelection = null;
+        this.aSelectionCallbacks = [];
+        this._bSelectionIsLoading = false;
+
+        var sl = Fusion.getScriptLanguage();
+        var loadmapScript = 'layers/' + this.arch + '/' + sl  + '/LoadMap.' +sl;
+        
+        var params = this.getMapParams();
+        var options = {
+              onSuccess: OpenLayers.Function.bind(this.mapLoaded,this), 
+              onException: OpenLayers.Function.bind(this.mapLoadFailed, this),
+              parameters:params
+        };
+        Fusion.ajaxRequest(loadmapScript, options);
+    },
+    
+    mapLoaded: function(r) {
+        if (r.status == 200) {
+            var o;
+            eval('o='+r.responseText);
+            this.bMapLoaded = true;
+            this._sResourceId = o.mapId;
+            this._sMapname = o.mapName;
+            this._sMapTitle = o.mapTitle;
+            this._fMetersperunit = o.metersPerUnit;
+            this.mapWidget._fMetersperunit = this._fMetersperunit;
+
+            this._oMaxExtent = OpenLayers.Bounds.fromArray(o.extent); 
+
+            this.layerRoot.clear();
+            this.layerRoot.legendLabel = this._sMapTitle;
+            
+            this.parseMapLayersAndGroups(o);
+            
+            this.minScale = 1.0e10;
+            this.maxScale = 0;
+            for (var i=0; i<this.aLayers.length; i++) {
+              this.minScale = Math.min(this.minScale, this.aLayers[i].minScale);
+              this.maxScale = Math.max(this.maxScale, this.aLayers[i].maxScale);
+            }
+            //a scale value of 0 is undefined
+            if (this.minScale <= 0) {
+              this.minScale = 1.0;
+            }
+            
+            if (!this.bSingleTile) {
+              if (o.groups.length >0) {
+                this.groupName = o.groups[0].groupName  //assumes only one group for now
+              } else {
+                this.bSingleTile = true;
+              }
+            }
+
+            //set projection units and code if supplied
+            //TODO: consider passing the metersPerUnit value into the framework
+            //to allow for scaling that doesn't match any of the pre-canned units
+            //this.units = 'degrees';
+            //this.projection = this.WKT[o.projectionWKT];
+            this.units = 'm';
+            this.projection = 'EPSG:42304';
+            
+            //add in scales array if supplied
+            if (o.FiniteDisplayScales && o.FiniteDisplayScales.length>0) {
+              this.scales = o.FiniteDisplayScales;
+            }
+            
+            var layerOptions = {
+              units : this.units,
+              projection: this.projection,
+              isBaseLayer : this.bIsBaseLayer,
+              singleTile : this.bSingleTile,
+              maxExtent : this._oMaxExtent,
+              maxResolution : 'auto',
+              ratio : this.ratio,
+              transitionEffect : 'resize'
+            };
+
+            //add in scales array if supplied
+            if (this.scales && this.scales.length>0) {
+              layerOptions.scales = this.scales;
+            }
+            if (this.maxScale != Infinity) {
+              layerOptions.minScale = this.maxScale;    //OL interpretation of min/max scale is reversed from Fusion
+            }
+            layerOptions.maxScale = this.minScale;
+
+            //remove this layer if it was already created
+            if (this.oLayerOL) {
+                this.oLayerOL.events.unregister("loadstart", this, this.loadStart);
+                this.oLayerOL.events.unregister("loadend", this, this.loadEnd);
+                this.oLayerOL.events.unregister("loadcancel", this, this.loadEnd);
+                this.oLayerOL.destroy();
+            }
+
+            this.oLayerOL = this.createOLLayer(this._sMapname, layerOptions);
+            this.oLayerOL.events.register("loadstart", this, this.loadStart);
+            this.oLayerOL.events.register("loadend", this, this.loadEnd);
+            this.oLayerOL.events.register("loadcancel", this, this.loadEnd);
+            
+            //this is to distinguish between a regular map and an overview map
+            if (this.bIsMapWidgetLayer) {
+              this.mapWidget.addMap(this);
+              this.mapWidget.oMapOL.setBaseLayer(this.oLayerOL);
+              this.mapWidget._oInitialExtents = null;
+              this.mapWidget.fullExtents();
+            }
+            this.triggerEvent(Fusion.Event.MAP_LOADED);
+        } else {
+            Fusion.reportError( new Fusion.Error(Fusion.Error.FATAL,
+                        'Failed to load requested map:\n'+r.responseText));
+        }
+        this.mapWidget._removeWorker();
+    },
+    
+//TBD: this function not yet converted for OL    
+    reloadMap: function() {
+        
+        this.mapWidget._addWorker();
+        //console.log('loadMap: ' + resourceId);
+        this.layerRoot.clear();
+        this.oldLayers = this.aLayers.clone();
+        this.aLayers = [];
+        
+        var sl = Fusion.getScriptLanguage();
+        var loadmapScript = 'layers/' + this.arch + '/' + sl  + '/LoadMap.' +sl;
+        
+        var options = {
+              onSuccess: OpenLayers.Function.bind(this.mapReloaded,this), 
+              onException: OpenLayers.Function.bind(this.mapLoadFailed, this),
+              parameters: this.getMapParams()};
+        Fusion.ajaxRequest(loadmapScript, options);
+    },
+
+    mapLoadFailed: function(r) {
+      Fusion.reportError( new Fusion.Error(Fusion.Error.FATAL, 
+        OpenLayers.i18n('mapLoadError', {'error':r.transport.responseText})));
+      this.mapWidget._removeWorker();
+    },
+
+//TBD: this function not yet converted for OL    
+    mapReloaded: function(r) {
+        if (r.status == 200) {
+            var o;
+            eval('o='+r.responseText);
+            this.parseMapLayersAndGroups(o);
+            for (var i=0; i<this.aLayers.length; ++i) {
+              var newLayer = this.aLayers[i];
+              for (var j=0; j<this.oldLayers.length; ++j) {
+                if (this.oldLayers[j].uniqueId == newLayer.uniqueId) {
+                  newLayer.selectedFeatureCount = this.oldLayers[j].selectedFeatureCount;
+                  break;
+                }
+              }
+            }
+            this.oldLayers = null;
+            this.mapWidget.triggerEvent(Fusion.Event.MAP_RELOADED);
+            this.drawMap();
+        }
+        this.mapWidget._removeWorker();
+    },
+    
+    reorderLayers: function(aLayerIndex) {
+        var sl = Fusion.getScriptLanguage();
+        var reorderScript = 'layers/' + this.arch + '/' + sl  +'/SetLayers.'+sl;
+        
+        var params = {
+            'mapname': this._sMapname, 
+            'session': this.getSessionID(),
+            'layerindex': aLayerIndex.join()
+        };
+        
+        var options = {
+            onSuccess: OpenLayers.Function.bind(this.mapLayersReset, this, aLayerIndex), 
+            parameters: params};
+        Fusion.ajaxRequest(loadmapScript, options);
+    },
+    
+    mapLayersReset: function(aLayerIndex,r) {  
+      if (r.status == 200) {
+        var o;
+        eval('o='+r.responseText);
+        if (o.success) {
+            var layerCopy = this.aLayers.clone();
+            this.aLayers = [];
+            for (var i=0; i<aLayerIndex.length; ++i) {
+              this.aLayers.push( layerCopy[ aLayerIndex[i] ] );
+            } 
+            
+            this.drawMap();
+            this.triggerEvent(Fusion.Event.MAP_LAYER_ORDER_CHANGED);
+        } else {
+            alert(OpenLayers.i18n('setLayersError', {'error':o.layerindex}));
+        }
+      }
+    },
+            
+    parseMapLayersAndGroups: function(o) {
+        var groupToggle = OpenLayers.Function.bind(this.groupToggle, this);
+        for (var i=0; i<o.groups.length; i++) {
+            var group = new Fusion.Layers.Group(o.groups[i], this);
+            group.registerForEvent(Fusion.Event.GROUP_PROPERTY_CHANGED,groupToggle);
+            var parent;
+            if (group.parentUniqueId && group.parentUniqueId != '') {
+                parent = this.layerRoot.findGroupByAttribute('uniqueId', group.parentUniqueId);
+            } else {
+                parent = this.layerRoot;
+            }
+            parent.addGroup(group, this.bLayersReversed);
+        }
+
+        var layerToggle = OpenLayers.Function.bind(this.layerToggle, this);
+        for (var i=0; i<o.layers.length; i++) {
+            var layer = new Fusion.Layers.Layer(o.layers[i], this);
+            layer.registerForEvent(Fusion.Event.LAYER_PROPERTY_CHANGED,layerToggle);
+            var parent;
+            if (layer.parentGroup != '') {
+                parent = this.layerRoot.findGroupByAttribute('uniqueId', layer.parentGroup);
+            } else {
+                parent = this.layerRoot;
+            }
+            parent.addLayer(layer, this.bLayersReversed);
+            this.aLayers.push(layer);
+        }
+    },
+    
+    groupToggle: function(eventId, layer, visible) {
+        this.processLayerEvents(layer, visible);
+        this.drawMap();
+    },
+    
+    layerToggle: function(eventId, layer, visible) {
+        this.processGroupEvents(layer, visible);
+        this.drawMap();
+    },
+    
+    /**
+     * Function: getLayerByName
+     * 
+     * Returns the MapGuide layer object as identified by the layer name
+     */
+    getLayerByName : function(name)
+    {
+        var oLayer = null;
+        for (var i=0; i<this.aLayers.length; i++)
+        {
+            if (this.aLayers[i].layerName == name)
+            {
+                oLayer = this.aLayers[i];
+                break;
+            }
+        }
+        return oLayer;
+    },
+
+    /**
+     * Function: isMapLoaded
+     * 
+     * Returns true if the Map has been laoded succesfully form the server
+     */
+    isMapLoaded: function() {
+        return this.bMapLoaded;
+    },
+
+    hasSelection: function() { return this.bSelectionOn; },
+    
+    getSelectionCB : function(userFunc, layers, startend, r) {
+      if (r.status == 200) 
+      {
+          var o;
+          eval("o="+r.responseText);
+
+          var oSelection = new GxSelectionObject(o);
+          userFunc(oSelection);
+      }
+      
+    },
+    
+    /**
+     * advertise a new selection is available and redraw the map
+     */
+    newSelection: function() {
+        if (this.oSelection) {
+            this.oSelection = null;
+        }
+        this.bSelectionOn = true;
+        this.drawMap();
+        this.triggerEvent(Fusion.Event.MAP_SELECTION_ON);
+    },
+
+    /**
+     * Returns the number of features selected for this map layer
+     */
+    getSelectedFeatureCount : function() {
+      var total = 0;
+      for (var j=0; j<this.aLayers.length; ++j) {
+        total += this.aLayers[j].selectedFeatureCount;
+      }
+      return total;
+    },
+
+    /**
+     * Returns the number of features selected for this map layer
+     */
+    getSelectedLayers : function() {
+      var layers = [];
+      for (var j=0; j<this.aLayers.length; ++j) {
+        if (this.aLayers[j].selectedFeatureCount>0) {
+          layers.push(this.aLayers[j]);
+        }
+      }
+      return layers;
+    },
+
+    /**
+     * Returns the number of features selected for this map layer
+     */
+    getSelectableLayers : function() {
+      var layers = [];
+      for (var j=0; j<this.aLayers.length; ++j) {
+        if (this.aLayers[j].selectable) {
+          layers.push(this.aLayers[j]);
+        }
+      }
+      return layers;
+    },
+
+     /**
+      * Function: zoomToSelection
+      *
+      * sets a Selection XML back to the server
+      */
+    zoomToSelection: function(extent) {
+      var center = extent.getCenterPixel();
+      var size = extent.getSize();
+      extent.left = center.x - 2*size.w;
+      extent.right = center.x + 2*size.w;
+      extent.bottom = center.y - 2*size.h;
+      extent.top = center.y + 2*size.h;
+      this.mapWidget.setExtents(extent);
+    },  
+
+    setSelection: function (selText, zoomTo) {
+      this.mapWidget._addWorker();
+      var sl = Fusion.getScriptLanguage();
+      var setSelectionScript = 'layers/' + this.arch + '/' + sl  + '/SetSelection.' + sl;
+      var params = {
+          'mapname': this.getMapName(),
+          'session': this.getSessionID(),
+          'selection': encodeURIComponent(selText),
+          'seq': Math.random()
+      };
+      var options = {onSuccess: OpenLayers.Function.bind(this.processQueryResults, this, zoomTo), 
+                     parameters:params, asynchronous:false};
+      Fusion.ajaxRequest(setSelectionScript, options);
+    },
+
+
+     /**
+     * asynchronously load the current selection.  When the current
+     * selection changes, the selection is not loaded because it
+     * could be a lengthy process.  The user-supplied function will
+     * be called when the selection is available.
+     *
+     * @param userFunc {Function} a function to call when the
+     *        selection has loaded
+     *
+     * @param layers {string} Optional parameter.  A comma separated
+     *        list of layer names (Roads,Parcels). If it is not
+     *        given, all the layers that have a selection will be used  
+     *
+     * @param startcount {string} Optional parameter.  A comma separated
+     *        list of a statinh index and the number of features to be retured for
+     *        each layer given in the layers parameter. Index starts at 0
+     *        (eg: 0:4,2:6 : return 4 elements for the first layers starting at index 0 and
+     *         six elements for layer 2 starting at index 6). If it is not
+     *        given, all the elemsnts will be returned.  
+     */
+    getSelection : function(userFunc, layers, startcount) {
+
+      /*for now always go back to server to fetch selection */
+      if (userFunc) 
+      {
+          //this.aSelectionCallbacks.push(userFunc);
+      
+      
+          //this.mapWidget._addWorker();
+          // this._bSelectionIsLoading = true;
+          var s = 'layers/' + this.arch + '/' + Fusion.getScriptLanguage() + "/Selection." + Fusion.getScriptLanguage() ;
+          var options = {
+              parameters: {'session': this.getSessionID(),
+                          'mapname': this._sMapname,
+                          'layers': layers,
+                          'startcount': startcount},
+              onSuccess: OpenLayers.Function.bind(this.getSelectionCB, this, userFunc, layers, startcount)
+          };
+          Fusion.ajaxRequest(s, options);
+      }
+    },
+
+    /**
+       Call back function when selection is cleared
+    */
+    selectionCleared : function()
+    {
+        //clear the selection count for the layers
+        for (var j=0; j<this.aLayers.length; ++j) {
+          this.aLayers[j].selectedFeatureCount = 0;
+        }
+
+        this.bSelectionOn = false;
+        if (this.queryLayer) {
+          this.queryLayer.setVisibility(false);
+        }
+        this.triggerEvent(Fusion.Event.MAP_SELECTION_OFF);
+        this.drawMap();
+        this.oSelection = null;
+    },
+
+    /**
+       Utility function to clear current selection
+    */
+    clearSelection : function() {
+      if (this.hasSelection()) {
+          var sl = Fusion.getScriptLanguage();
+          var s = 'layers/' + this.arch + '/' + sl + "/ClearSelection." + sl;
+          var options = {
+              parameters: {'session': this.getSessionID(),
+                          'mapname': this._sMapname},
+              onSuccess: OpenLayers.Function.bind(this.selectionCleared, this)
+          };
+          Fusion.ajaxRequest(s, options);
+      }
+    },
+
+    /**
+       removes the queryLayer from the map
+    */
+    removeQueryLayer : function() {
+      if (this.queryLayer) {
+        this.queryLayer.destroy();
+        this.queryLayer = null;
+      }
+    },
+
+
+    /**
+       Call back function when slect functions are called (eg queryRect)
+    */
+    processQueryResults : function(zoomTo, r) {
+        this.mapWidget._removeWorker();
+        if (r.status == 200 && r.responseText) {   
+            var oNode;
+            eval('oNode='+r.responseText);
+            
+            if (oNode.hasSelection) {
+              if (!this.bSingleTile) {
+                if (!this.queryLayer) {
+                  this.queryLayer = this.createOLLayer("query layer", this.projectionCode, false, true);
+                  this.mapWidget.oMapOL.addLayer(this.queryLayer);
+                  this.mapWidget.registerForEvent(Fusion.Event.MAP_LOADING, 
+                        OpenLayers.Function.bind(this.removeQueryLayer, this));
+                } else {
+                  this.queryLayer.setVisibility(true);
+                }
+              }
+
+              this._sQueryfile = oNode.queryFile;
+              
+              // set the feature count on each layer making up this map
+              for (var i=0; i<oNode.layers.length; ++i) {
+                var layerName = oNode.layers[i];
+                for (var j=0; j<this.aLayers.length; ++j) {
+                  if (layerName == this.aLayers[j].layerName) {
+                    this.aLayers[j].selectedFeatureCount = oNode[layerName].featureCount;
+                  }
+                }
+              }
+              
+              if (zoomTo) {
+                var ext = oNode.extents
+                var extents = new OpenLayers.Bounds(ext.minx, ext.miny, ext.maxx, ext.maxy);
+                this.zoomToSelection(extents);
+              }
+              this.newSelection();
+            } else {
+              this.clearSelection();
+              return;
+            }
+        }
+    },
+
+    /**
+       Do a query on the map
+    */
+    query : function(options) {
+        this.mapWidget._addWorker();
+        
+        //clear the selection count for the layers
+        for (var j=0; j<this.aLayers.length; ++j) {
+          this.aLayers[j].selectedFeatureCount = 0;
+        }
+
+        var bPersistant = options.persistent || true;
+        var zoomTo = options.zoomTo ?  true : false;
+        var layers = options.layers || '';
+        /* if no layers are given, query only visible layers. This is ususally the most common case*/
+        if (layers == '') {
+            var aLayers = [];
+            for (var i=0; i<this.aLayers.length; i++) {
+                var l = this.aLayers[i];
+                if (l.isVisible()) {
+                    aLayers.push(l.layerName);
+                }
+            }
+            layers = aLayers.join(',');
+        }
+
+        var params = {
+            'mapname': this._sMapname,
+            'session': this.getSessionID(),
+            'spatialfilter': options.geometry || '',
+            'maxfeatures': options.maxFeatures || 0, //zero means select all features
+            'layers': layers,
+            'variant': options.selectionType || this.selectionType
+        }
+        if (options.filter) {
+            params.filter= options.filter;
+        }
+        if (options.extendSelection) {
+            params.extendselection = true;
+        }
+        if (options.computedProperties) {
+            params.computed = true;
+        }
+        var ajaxOptions = {
+            onSuccess: OpenLayers.Function.bind(this.processQueryResults, this, zoomTo), 
+            parameters: params
+        };
+            
+        var sl = Fusion.getScriptLanguage();
+        var queryScript = 'layers/' + this.arch + '/' + sl  + '/Query.' + sl;
+        Fusion.ajaxRequest(queryScript, ajaxOptions);
+    },
+    
+    processLayerEvents: function(layer, isEnabling) {
+        if (this.mapInfo && this.mapInfo.mapEvents.layerEvents[layer.layerName]) {
+            var layerEvent = this.mapInfo.mapEvents.layerEvents[layer.layerName];
+            var events = isEnabling ? layerEvent.onEnable : layerEvent.onDisable;
+            for (var i=0; i<events.length; i++) {
+                var o = events[i];
+                if (o.type == 'layer') {
+                    var l = this.layerRoot.findLayer(o.name);
+                    if (l) {
+                        if (o.enable) {
+                            l.show(true);
+                        } else {
+                            l.hide(true);
+                        }
+                    }
+                    
+                } else if (o.type == 'group') {
+                    var g = this.layerRoot.findGroupByAttribute('groupName', o.name);
+                    if (g) {
+                        if (o.enable) {
+                            g.show(true);
+                        } else {
+                            g.hide(true);
+                        }
+                    }
+                }
+            }
+        }
+    },
+    
+    processGroupEvents: function(group, isEnabling) {
+        if (this.mapInfo && this.mapInfo.mapEvents.groupEvents[group.groupName]) {
+            var groupEvent = this.mapInfo.mapEvents.groupEvents[group.groupName];
+            var events = isEnabling ? groupEvent.onEnable : groupEvent.onDisable;
+            for (var i=0; i<events.length; i++) {
+                var o = events[i];
+                if (o.type == 'layer') {
+                    var l = this.layerRoot.findLayer(o.name);
+                    if (l) {
+                        if (o.enable) {
+                            l.show(true);
+                        } else {
+                            l.hide(true);
+                        }
+                    }
+                    
+                } else if (o.type == 'group') {
+                    var g = this.layerRoot.findGroupByAttribute('groupName', o.name);
+                    if (g) {
+                        if (o.enable) {
+                            g.show(true);
+                        } else {
+                            g.hide(true);
+                        }
+                    }
+                }
+            }
+        }
+    },
+        
+    //TODO:  is this needed?
+    refreshLayer: function( layer ) {
+        this.drawMap();
+    },
+    setParameter : function(param, value) {
+        if (param == 'SelectionType') {
+            this.selectionType = value;
+        }
+    },
+
+    loadStart: function() {
+        this.mapWidget._addWorker();
+    },
+
+    loadEnd: function() {
+        this.mapWidget._removeWorker();
+    },
+    
+    pingServer: function() {
+        var s = 'layers/' + this.arch + '/' + Fusion.getScriptLanguage() + "/Common." + Fusion.getScriptLanguage() ;
+        var params = {};
+        params.parameters = {'session': this.getSessionID()};
+        Fusion.ajaxRequest(s, params);
+    },
+    
+    getGroupInfoUrl: function(groupName) {
+        if (this.mapInfo) {
+            var groups = this.mapInfo.links.groups;
+            for (var i=0; i<groups.length; i++) {
+                if (groups[i].name == groupName) {
+                    return groups[i].url;
+                }
+            }
+        }
+        return null;
+    },
+    
+    getLayerInfoUrl: function(layerName) {
+        if (this.mapInfo) {
+            var layers = this.mapInfo.links.layers;
+            for (var i=0; i<layers.length; i++) {
+                if (layers[i].name == layerName) {
+                    return layers[i].url;
+                }
+            }
+        }
+        return null;
+    }
+});
+    
+/***************************************************************************
+* Class: Fusion.Layers.MapGuide.Group
+*
+ * generic class for map layer groups.  This class is primarily for legends.
+ * **********************************************************************/
+Fusion.Event.GROUP_PROPERTY_CHANGED = Fusion.Event.lastEventId++;
+
+Fusion.Layers.Group = OpenLayers.Class(Fusion.Lib.EventMgr, {
+    name: null,
+    groups: null,
+    layers: null,
+    oMap: null,
+    initialize: function(o, oMap) {
+        this.uniqueId = o.uniqueId;
+        this.name = o.groupName;
+        this.groups = [];
+        this.layers = [];
+        this.oMap = oMap;
+        this.groupName = o.groupName;
+        this.legendLabel = o.legendLabel;
+        this.parentUniqueId = o.parentUniqueId;
+        this.groupType = o.groupType;
+        this.displayInLegend = o.displayInLegend;
+        this.expandInLegend = o.expandInLegend;
+        this.visible = o.visible;
+        this.actuallyVisible = o.actuallyVisible;
+        this.registerEventID(Fusion.Event.GROUP_PROPERTY_CHANGED);
+    },
+    
+    show: function(noDraw) {
+        if (this.visible) {
+            return;
+        }
+        this.set('visible', true);
+        if (this.legend && this.legend.checkBox) {
+            this.legend.checkBox.checked = true;
+        }
+    },
+    
+    hide: function(noDraw) {
+        if (!this.visible) {
+            return;
+        }
+        this.set('visible', false);
+        if (this.legend && this.legend.checkBox) {
+            this.legend.checkBox.checked = false;
+        }
+    },
+    
+    isVisible: function() {
+        var bParentVisible = (this.parentGroup && this.parentGroup.isVisible) ? this.parentGroup.isVisible() : true;
+        return this.visible && bParentVisible;
+    },
+    
+    clear: function() {
+        for (var i=0; i<this.groups.length; i++) {
+            this.groups[i].clear();
+        }
+        for (var i=0; i<this.layers.length; i++) {
+            this.layers[i].clear();
+        }
+        this.groups = [];
+        this.layers = [];
+    },
+    set: function(property, value) {
+        this[property] = value;
+        this.triggerEvent(Fusion.Event.GROUP_PROPERTY_CHANGED, this, value);
+    },
+    addGroup: function(group,reverse) {
+        group.parentGroup = this;
+        if (reverse) {
+          this.groups.unshift(group);
+        } else {
+          this.groups.push(group);
+        }
+    },
+    addLayer: function(layer,reverse) {
+        layer.parentGroup = this;
+        if (reverse) {
+          this.layers.unshift(layer);
+        } else {
+          this.layers.push(layer);
+        }
+    },
+    findGroup: function(name) {
+        return this.findGroupByAttribute('name', name);
+    },
+    findGroupByAttribute: function(attribute, value) {
+        if (this[attribute] == value) {
+            return this;
+        }
+        for (var i=0; i<this.groups.length; i++) {
+            var group = this.groups[i].findGroupByAttribute(attribute, value);
+            if (group) {
+                return group;
+            }
+        }
+        return null;
+    },
+    findLayer: function(name) {
+        return this.findLayerByAttribute('name', name);
+    },
+    findLayerByAttribute: function(attribute, value) {
+        for (var i=0; i<this.layers.length; i++) {
+            if (this.layers[i][attribute] == value) {
+                return this.layers[i];
+            }
+        }
+        for (var i=0; i<this.groups.length; i++) {
+            var layer = this.groups[i].findLayerByAttribute(attribute,value);
+            if (layer) {
+                return layer;
+            }
+        }
+        return null;
+    }
+});
+
+/***************************************************************************
+* Class: Fusion.Layers.Layer
+*
+ * generic class for map layers.  This class is primarily for legends.
+ * **********************************************************************/
+Fusion.Event.LAYER_PROPERTY_CHANGED = Fusion.Event.lastEventId++;
+
+Fusion.Layers.Layer = OpenLayers.Class(Fusion.Lib.EventMgr, {
+    scaleRanges: null,
+    oMap: null,
+    
+    initialize: function(o, oMap) {
+        this.uniqueId = o.uniqueId;
+        this.name = o.layerName;
+        this.oMap = oMap;
+        this.layerName = o.layerName;
+        this.uniqueId = o.uniqueId;
+        this.resourceId = o.resourceId;
+        this.legendLabel = o.legendLabel;
+        this.selectable = o.selectable;
+        this.selectedFeatureCount = 0;
+        this.layerTypes = [].concat(o.layerTypes);
+        this.displayInLegend = o.displayInLegend;
+        this.expandInLegend = o.expandInLegend;
+        this.visible = o.visible;
+        this.actuallyVisible = o.actuallyVisible;
+        this.editable = o.editable;
+        this.parentGroup = o.parentGroup;
+        this.metadata = o.metadata;
+        this.scaleRanges = [];
+        this.minScale = 1.0e10;
+        this.maxScale = 0;
+        for (var i=0; i<o.scaleRanges.length; i++) {
+          var scaleRange = new Fusion.Layers.ScaleRange(o.scaleRanges[i], this.layerType);
+          this.scaleRanges.push(scaleRange);
+          this.minScale = Math.min(this.minScale, scaleRange.minScale);
+          this.maxScale = Math.max(this.maxScale, scaleRange.maxScale);
+        }
+        
+        //determine the layer type so that the correct icon can be displayed in the legend
+        this.layerType = null;
+        if (this.supportsType(Fusion.Constant.LAYER_RASTER_TYPE)) {   //raster layers
+          this.layerType = Fusion.Constant.LAYER_RASTER_TYPE;
+        } else if (this.supportsType(Fusion.Constant.LAYER_DWF_TYPE)) {  //DWF layers
+          this.layerType = Fusion.Constant.LAYER_DWF_TYPE;
+        }
+        
+        this.registerEventID(Fusion.Event.LAYER_PROPERTY_CHANGED);
+    },
+    
+    clear: function() {
+        this.oMap = null;
+        this.legend = null;
+    },
+    
+    set: function(property, value) {
+        this[property] = value;
+        this.triggerEvent(Fusion.Event.LAYER_PROPERTY_CHANGED, this, value);
+    },
+    
+    supportsType: function(type) {
+        for (var i=0; i<this.layerTypes.length; i++) {
+            if (this.layerTypes[i] == type) {
+                return true;
+            }
+        }
+        return false;
+    },
+    
+    getScaleRange: function(fScale) {
+        for (var i=0; i<this.scaleRanges.length; i++) {
+            if (this.scaleRanges[i].contains(fScale)) {
+                return this.scaleRanges[i];
+            }
+        }
+        return null;
+    },
+
+    show: function(noDraw) {
+        if (this.visible) {
+            return;
+        }
+        this.set('visible', true);
+        if (this.legend && this.legend.checkBox) {
+            this.legend.checkBox.checked = true;
+        }
+    },
+
+    hide: function(noDraw) {
+        if (!this.visible) {
+            return;
+        }
+        this.set('visible',false);
+        if (this.legend && this.legend.checkBox) {
+            this.legend.checkBox.checked = false;
+        }
+    },
+
+    isVisible: function() {
+        var bParentVisible = this.parentGroup ? this.parentGroup.isVisible() : true;
+        return this.visible && bParentVisible;
+    },
+
+    getMetadata: function(key) {
+        if (typeof this.metadata[key] != 'undefined') {
+            return this.metadata[key];
+        } else {
+            return '';
+        }
+    }
+});
+
+/***************************************************************************
+* Class: Fusion.Layers.MapGuide
+*
+* Implements a scale range object for MapGuide services
+*/
+
+Fusion.Layers.ScaleRange = OpenLayers.Class({
+    styles: null,
+    initialize: function(o, layerType) {
+        this.minScale = o.minScale;
+        this.maxScale = o.maxScale;
+        if (this.maxScale == 'infinity') {
+          this.maxScale = Infinity;
+        }
+        this.styles = [];
+        if (!o.styles) {
+          var styleItem = new Fusion.Layers.StyleItem({legendLabel:'DWF'}, layerType);
+          this.styles.push(styleItem);
+          return;
+        }
+        var staticIcon = o.styles.length>1 ? false : layerType;
+        for (var i=0; i<o.styles.length; i++) {
+            var styleItem = new Fusion.Layers.StyleItem(o.styles[i], staticIcon);
+            this.styles.push(styleItem);
+        }
+    },
+    contains: function(fScale) {
+        return fScale >= this.minScale && fScale <= this.maxScale;
+    }
+});
+
+/***************************************************************************
+* Class: Fusion.Layers.MapGuide
+*
+* Implements the legend style items to get a legend icon from the server
+*/
+
+Fusion.Layers.StyleItem = OpenLayers.Class({
+    initialize: function(o, staticIcon) {
+        this.legendLabel = o.legendLabel;
+        this.filter = o.filter;
+        this.geometryType = o.geometryType;
+        if (this.geometryType == '') {
+            this.geometryType = -1;
+        }
+        this.index = o.index;   //TBD: should these be merged?
+        this.categoryIndex = o.categoryIndex;
+        if (this.categoryindex == '') {
+            this.categoryindex = -1;
+        }
+        this.staticIcon = staticIcon;
+    }
+});

Modified: sandbox/olcore/lib/ApplicationDefinition.js
===================================================================
--- sandbox/olcore/lib/ApplicationDefinition.js	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/lib/ApplicationDefinition.js	2008-04-18 14:27:20 UTC (rev 1379)
@@ -491,7 +491,7 @@
         }
         this.resourceId = this.extension.ResourceId ? this.extension.ResourceId[0] : '';
         if ( !Fusion.Maps[this.type] ) {
-          Fusion.require(this.type + '/' + this.type + '.js');
+          Fusion.require('layers/' + this.type + '/' + this.type + '.js');
         }
     }
 });

Modified: sandbox/olcore/lib/Map.js
===================================================================
--- sandbox/olcore/lib/Map.js	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/lib/Map.js	2008-04-18 14:27:20 UTC (rev 1379)
@@ -40,6 +40,7 @@
 Fusion.Event.MAP_LOADING = Fusion.Event.lastEventId++;
 Fusion.Event.MAP_RELOADED = Fusion.Event.lastEventId++;
 Fusion.Event.MAP_SESSION_CREATED = Fusion.Event.lastEventId++;
+Fusion.Event.MAP_LAYER_ORDER_CHANGED = Fusion.Event.lastEventId++;
 
 
 Fusion.Constant.LAYER_POINT_TYPE = 0;
@@ -80,7 +81,12 @@
         this._nCellSize = -1;
         this._sDomObj = name;
         this._oDomObj = $(this._sDomObj);
-        this.layerRoot = new Fusion.Widget.Map.Group();
+        this.layerRoot = new Fusion.Layers.Group({
+            legendLabel: 'mapRoot',
+            uniqueId: 'mapRoot',
+            groupName: 'mapRoot',
+            visible: true
+        });
         
         if (this._oDomObj.jxLayout) {
             this._oDomObj.jxLayout.addSizeChangeListener(this);
@@ -102,6 +108,9 @@
             }
             this.oMapOL = new OpenLayers.Map(this._sDomObj, options );
         }
+        if (this.bIsBaseLayer) {
+          this.mapWidget.oMapOL.setOptions({});
+        }
         
         this.oMapOL.viewPortDiv.style.position = 'absolute';  //not the top level container so set it to absolute
         
@@ -122,10 +131,11 @@
         //create the 'Map' layer widgets defined in the MapGroup
         this.aMaps = [];
         this.mapGroup = mapGroup;
+        this.mapLoadCounter = 0;
         for (var i=0; i<mapGroup.maps.length; ++i) {
           var mapTag = mapGroup.maps[i];
-          if (Fusion.Maps[mapTag.type]) {
-              this.aMaps[i] = eval("new Fusion.Maps."+mapTag.type+"(this,mapTag)");
+          if (Fusion.Layers[mapTag.type]) {
+              this.aMaps[i] = eval("new Fusion.Layers."+mapTag.type+"(this,mapTag)");
               this.layerRoot.addGroup(this.aMaps[i].layerRoot);
               
           } else {
@@ -180,15 +190,17 @@
         
         this.mapGroup = mapGroup;
         for (var i=0; i<this.aMaps.length; i++) {
-            this.aMaps[i].oLayerOL.destroy();
+            if (this.aMaps[i].oLayerOL) {
+              this.aMaps[i].oLayerOL.destroy();
+            }
         }
         
         this.aMaps = [];
         this.layerRoot = new Fusion.Widget.Map.Group();
         for (var i=0; i<mapGroup.maps.length; ++i) {
           var mapTag = mapGroup.maps[i];
-          if (Fusion.Maps[mapTag.type]) {
-              this.aMaps[i] = eval("new Fusion.Maps."+mapTag.type+"(this,mapTag)");
+          if (Fusion.Layers[mapTag.type]) {
+              this.aMaps[i] = eval("new Fusion.Layers."+mapTag.type+"(this,mapTag)");
               this.layerRoot.addGroup(this.aMaps[i].layerRoot);
               
           } else {
@@ -295,6 +307,8 @@
           }
         }
         this.oMapOL.addLayer(map.oLayerOL);
+        map.registerForEvent(Fusion.Event.MAP_LOADED, 
+                OpenLayers.Function.bind(this.mapLoadHandler, this));
         map.registerForEvent(Fusion.Event.MAP_SELECTION_OFF, 
                 OpenLayers.Function.bind(this.selectionHandler, this));
         map.registerForEvent(Fusion.Event.MAP_SELECTION_ON, 
@@ -331,6 +345,19 @@
      * handle selection events from maps and republish for
      * widgets as appropriate
      */
+    mapLoadHandler: function() {
+        ++this.mapLoadCounter;
+        if (this.mapLoadCounter == this.aMaps.length) {
+            this.triggerEvent(Fusion.Event.MAP_LOADED);
+        }
+    },
+    
+  /**
+     * Function: selectionHandler
+     *
+     * handle selection events from maps and republish for
+     * widgets as appropriate
+     */
     selectionHandler: function() {
         if (this.hasSelection()) {
             this.triggerEvent(Fusion.Event.MAP_SELECTION_ON);
@@ -834,106 +861,7 @@
      }
 });
 
- /****************************************************************************
- * Class: Fusion.Widget.Map.Layer
- *
- * generic class for map layers.  This class is primarily for legends.
- * **********************************************************************/
-Fusion.Event.LAYER_PROPERTY_CHANGED = Fusion.Event.lastEventId++;
-Fusion.Widget.Map.Layer = OpenLayers.Class(Fusion.Lib.EventMgr, {
-    name: null,
-    initialize: function(name) {
-        this.name = name;
-        this.registerEventID(Fusion.Event.LAYER_PROPERTY_CHANGED);
-    },
-    clear: function() {},
-    set: function(property, value) {
-        this[property] = value;
-        this.triggerEvent(Fusion.Event.LAYER_PROPERTY_CHANGED, this);
-    }
-});
 
- /****************************************************************************
- * Class: Fusion.Widget.Map.Group
- *
- * generic class for map layer groups.  This class is primarily for legends.
- * **********************************************************************/
-Fusion.Event.GROUP_PROPERTY_CHANGED = Fusion.Event.lastEventId++;
-Fusion.Widget.Map.Group = OpenLayers.Class(Fusion.Lib.EventMgr, {
-    name: null,
-    groups: null,
-    layers: null,
-    initialize: function(name) {
-        this.name = name;
-        this.groups = [];
-        this.layers = [];
-        this.registerEventID(Fusion.Event.GROUP_PROPERTY_CHANGED);
-    },
-    clear: function() {
-        for (var i=0; i<this.groups.length; i++) {
-            this.groups[i].clear();
-        }
-        for (var i=0; i<this.layers.length; i++) {
-            this.layers[i].clear();
-        }
-        this.groups = [];
-        this.layers = [];
-    },
-    set: function(property, value) {
-        this[property] = value;
-        this.triggerEvent(Fusion.Event.GROUP_PROPERTY_CHANGED, this);
-    },
-    addGroup: function(group,reverse) {
-        group.parentGroup = this;
-        if (reverse) {
-          this.groups.unshift(group);
-        } else {
-          this.groups.push(group);
-        }
-    },
-    addLayer: function(layer,reverse) {
-        layer.parentGroup = this;
-        if (reverse) {
-          this.layers.unshift(layer);
-        } else {
-          this.layers.push(layer);
-        }
-    },
-    findGroup: function(name) {
-        return this.findGroupByAttribute('name', name);
-    },
-    findGroupByAttribute: function(attribute, value) {
-        if (this[attribute] == value) {
-            return this;
-        }
-        for (var i=0; i<this.groups.length; i++) {
-            var group = this.groups[i].findGroupByAttribute(attribute, value);
-            if (group) {
-                return group;
-            }
-        }
-        return null;
-    },
-    findLayer: function(name) {
-        return this.findLayerByAttribute('name', name);
-    },
-    findLayerByAttribute: function(attribute, value) {
-        for (var i=0; i<this.layers.length; i++) {
-            if (this.layers[i][attribute] == value) {
-                return this.layers[i];
-            }
-        }
-        for (var i=0; i<this.groups.length; i++) {
-            var layer = this.groups[i].findLayerByAttribute(attribute,value);
-            if (layer) {
-                return layer;
-            }
-        }
-        return null;
-    }
-});
-
-
 /**
  * SelectionObject
  *

Modified: sandbox/olcore/lib/fusion.js
===================================================================
--- sandbox/olcore/lib/fusion.js	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/lib/fusion.js	2008-04-18 14:27:20 UTC (rev 1379)
@@ -59,6 +59,7 @@
                         'lib/ClickTool.js',
                         'lib/RectTool.js',
                         'lib/Map.js',
+                        'layers/Layers.js',
                         'lib/Search.js',
                         'text/en/strings.json'];
 }
@@ -332,6 +333,8 @@
                 options.onSuccess = OpenLayers.Function.bind(this.serverSet, this);
                 options.onFailure = OpenLayers.Function.bind(this.serverFailed, this);
                 var test = window.location.protocol+'//'+window.location.host;
+                //test += window.location.port != '' ? ':'+window.location.port : '';
+                //test += '/';
                 //if (this.fusionURL.indexOf(test,0) == 0) {
                 if ( ((this.fusionURL.indexOf("http://") < 0) || (this.fusionURL.indexOf(test,0) == 0)) && !(this.bForceRedirect)) {
                     this.sRedirectScript = '';
@@ -627,6 +630,9 @@
             r = r + '?s=';
         }
         var url = r + this.getFusionURL() + scriptURL;
+        if (!options.method) {
+            options.method = 'get';
+        }
         if (!options.onException) {
             options.onException = OpenLayers.Function.bind(this.ajaxException, this);
         }

Modified: sandbox/olcore/widgets/CursorPosition.js
===================================================================
--- sandbox/olcore/widgets/CursorPosition.js	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/widgets/CursorPosition.js	2008-04-18 14:27:20 UTC (rev 1379)
@@ -65,12 +65,11 @@
         //console.log('CursorPosition.initialize');
         Fusion.Widget.prototype.initialize.apply(this, [widgetTag, true]);
                 
-        
         var json = widgetTag.extension;
         
         this.emptyText = json.EmptyText ? json.EmptyText[0] : this.domObj.innerHTML;
         this.template = json.Template ? json.Template[0] : this.defaultTemplate;
-        this.precision = json.Precision ? parseInt(json.Precision[0]) : -1;
+        this.precision = json.Precision ? parseInt(json.Precision[0]) : 4;
         this.units = json.Units ? Fusion.unitFromName(json.Units[0]) : Fusion.UNKOWN;
 
         this.domSpan = document.createElement('span');
@@ -78,14 +77,26 @@
         this.domSpan.innerHTML = this.emptyText;
         this.domObj.innerHTML = '';
         this.domObj.appendChild(this.domSpan);
-
+        
+        var options = {
+          displayClass: 'spanCursorPosition',
+          div: this.domSpan,
+          template: this.template,
+          numdigits: this.precision,
+          units: this.units
+        };
+        this.control = new OpenLayers.Control.MousePosition(options)
+        this.addControl(this.control);
+/*
         this.enable = Fusion.Widget.CursorPosition.prototype.enable;
         this.disable = Fusion.Widget.CursorPosition.prototype.enable;
-        
+        */
+       
         this.getMap().registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.setUnits, this));
         this.registerParameter('Units');
-    },
-    
+     },
+
+/*    
     enable: function() {
         this.mouseMoveWatcher = OpenLayers.Function.bind(this.mouseMove, this);
         this.mouseOutWatcher = OpenLayers.Function.bind(this.mouseOut, this);
@@ -126,6 +137,7 @@
             this.domSpan.innerHTML = this.template.replace('{x}',p.x).replace('{y}',p.y).replace('{units}', unitAbbr).replace('{units}', unitAbbr);
         }
     },
+    */
 
     setUnits: function() {
       if (this.units == Fusion.UNKNOWN) {
@@ -136,6 +148,22 @@
     setParameter: function(param, value) {
         if (param == 'Units') {
             this.units = Fusion.unitFromName(value);
+            this.control.units = Fusion.unitFromName(value);
+            if (this.units == 'degrees' || this.units == 'dd') {
+              this.control.displayProjection = Proj4js.WGS84;
+            } else {
+              this.control.displayProjection = null;
+            }
         }
     }
 });
+
+OpenLayers.Control.MousePosition.prototype.formatOutput = function(lonLat) {
+    var unitAbbr = Fusion.unitAbbr(this.units);
+    var str = this.template;
+    str = str.replace('{x}',lonLat.lon.toFixed(this.numdigits));
+    str = str.replace('{units}', unitAbbr);
+    str = str.replace('{y}',lonLat.lon.toFixed(this.numdigits));
+    str = str.replace('{units}', unitAbbr);
+    return str;
+}

Modified: sandbox/olcore/widgets/Legend.js
===================================================================
--- sandbox/olcore/widgets/Legend.js	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/widgets/Legend.js	2008-04-18 14:27:20 UTC (rev 1379)
@@ -381,7 +381,7 @@
                     if (range.styles.length > 0) {
                         Jx.addToImgQueue({
                             domElement:layer.legend.treeItem.domObj.childNodes[2], 
-                            src: range.styles[0].getLegendImageURL(fScale, layer, this.getMap())
+                            src: layer.oMap.getLegendImageURL(fScale, layer, range.styles[0])
                         });
                         Element.removeClassName(layer.legend.treeItem.domObj, 'jxDisabled');
                     } else {
@@ -458,7 +458,7 @@
               opt.imgIcon = this.imgLayerRasterIcon;
             }
           } else {
-            opt.imgIcon = style.getLegendImageURL(scale, layer);
+            opt.imgIcon = layer.oMap.getLegendImageURL(scale, layer, style);
           }
         }
        

Modified: sandbox/olcore/widgets/MapMenu.js
===================================================================
--- sandbox/olcore/widgets/MapMenu.js	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/widgets/MapMenu.js	2008-04-18 14:27:20 UTC (rev 1379)
@@ -61,7 +61,7 @@
         //in the widget tag. All subfolders will be enumerated.
         //FIXME: this should be platform agnostic, Library:// isn't!
         //FIXME: use JSON rather than XML        
-        this.arch = this.getMap().getAllMaps()[0].arch;
+        this.arch = 'MapGuide';//this.getMap().getAllMaps()[0].arch;
         if (this.arch == 'MapGuide' && json.Folder) {
             this.sRootFolder = json.Folder ? json.Folder[0] : 'Library://';
             var s =       this.arch + '/' + Fusion.getScriptLanguage() +

Modified: sandbox/olcore/widgets/OverviewMap.js
===================================================================
--- sandbox/olcore/widgets/OverviewMap.js	2008-04-16 19:49:10 UTC (rev 1378)
+++ sandbox/olcore/widgets/OverviewMap.js	2008-04-18 14:27:20 UTC (rev 1379)
@@ -59,7 +59,7 @@
           var mainMap = this.getMap();
           mapTag = mainMap.mapGroup.maps[0];    //TODO: always use the baselayer Map in the group?
         }
-        this.mapObject = eval("new Fusion.Maps."+mapTag.type+"(this.getMap(),mapTag,false)");
+        this.mapObject = eval("new Fusion.Layers."+mapTag.type+"(this.getMap(),mapTag,false)");
         this.mapObject.registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.loadOverview, this));
 
         //first set the size to the size of the DOM element if available



More information about the fusion-commits mailing list