[fusion-commits] r2365 - in branches/fusion-2.2: layers lib templates/mapguide/standard widgets widgets/BufferPanel widgets/SelectWithin

svn_fusion at osgeo.org svn_fusion at osgeo.org
Thu Apr 14 15:04:46 EDT 2011


Author: madair
Date: 2011-04-14 12:04:46 -0700 (Thu, 14 Apr 2011)
New Revision: 2365

Modified:
   branches/fusion-2.2/layers/Layers.js
   branches/fusion-2.2/lib/ApplicationDefinition.js
   branches/fusion-2.2/lib/Widget.js
   branches/fusion-2.2/templates/mapguide/standard/ApplicationDefinition.xml
   branches/fusion-2.2/widgets/Buffer.js
   branches/fusion-2.2/widgets/BufferPanel.js
   branches/fusion-2.2/widgets/BufferPanel/BufferPanel.templ
   branches/fusion-2.2/widgets/BufferPanel/BufferReport.templ
   branches/fusion-2.2/widgets/FeatureInfo.js
   branches/fusion-2.2/widgets/Help.js
   branches/fusion-2.2/widgets/InvokeURL.js
   branches/fusion-2.2/widgets/LayerManager.js
   branches/fusion-2.2/widgets/Maptip.js
   branches/fusion-2.2/widgets/Measure.js
   branches/fusion-2.2/widgets/Print.js
   branches/fusion-2.2/widgets/Query.js
   branches/fusion-2.2/widgets/QuickPlot.js
   branches/fusion-2.2/widgets/SaveMap.js
   branches/fusion-2.2/widgets/Search.js
   branches/fusion-2.2/widgets/SelectRadius.js
   branches/fusion-2.2/widgets/SelectRadiusValue.js
   branches/fusion-2.2/widgets/SelectWithin.js
   branches/fusion-2.2/widgets/SelectWithin/SelectWithinPanel.templ
   branches/fusion-2.2/widgets/SelectionPanel.js
   branches/fusion-2.2/widgets/TaskPane.js
   branches/fusion-2.2/widgets/Theme.js
   branches/fusion-2.2/widgets/ZoomToSelection.js
Log:
re #426: removing references to hard-coded aMaps[0] references to allow widgets to work with multiple <Map> objects in a <MapGroup>

Modified: branches/fusion-2.2/layers/Layers.js
===================================================================
--- branches/fusion-2.2/layers/Layers.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/layers/Layers.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -76,6 +76,7 @@
         this.sMapResourceId = mapTag.resourceId ? mapTag.resourceId : '';
         this.mapInfo = mapTag.mapInfo;
         this.layerType = mapTag.type;
+        this.id = mapTag.id;
     },
 
     /**

Modified: branches/fusion-2.2/lib/ApplicationDefinition.js
===================================================================
--- branches/fusion-2.2/lib/ApplicationDefinition.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/lib/ApplicationDefinition.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -489,6 +489,7 @@
     
     initialize: function(jsonNode) {
         /* TODO: type can be any supported OpenLayers type */
+        this.id = jsonNode['@id'] ? jsonNode['@id'][0] : null;
         this.type = jsonNode.Type[0];
         if (jsonNode.SingleTile) {
             var b = jsonNode.SingleTile[0].toLowerCase();
@@ -705,16 +706,20 @@
      *
      * The map name to check
      *
-     * Returns: {Object} a map object or null.
+     * Returns: {Object} a map Layer object or null.
      */
     getMapByName : function(name) {
         var map = null;
-        if (this.mapWidget.getMapName() == name) {
-            map = this.mapWidget;
+        for (var i=0; i<this.mapWidget.aMaps.length; ++i) {
+          var mapLayer = this.mapWidget.aMaps[i];
+          if (mapLayer.getMapName() == name) {
+              map = mapLayer;
+          }
         }
         return map;
     },
 
+
     /**
      * Function getWidgetsByType
      *

Modified: branches/fusion-2.2/lib/Widget.js
===================================================================
--- branches/fusion-2.2/lib/Widget.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/lib/Widget.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -38,6 +38,7 @@
     name: null,
     type: null,
     oMap: null,
+    widgetLayerId: null,   //the AppDef <Map> object associated with this widget 
     enabled: false,
     mapLoadedWatcher: null,
     paramRegister: null,
@@ -75,6 +76,10 @@
 
         this.paramRegister = [];
         
+        //check to see if this widget is associated with a specific Map
+        var json = widgetTag.extension;
+        this.widgetLayerId = json.WidgetLayerId ? json.WidgetLayerId[0] : null;
+        
         this.initializeWidget(widgetTag);
     },
 
@@ -181,6 +186,25 @@
     },
     
     /**
+     * accessor to get the Map object that this widget is associated with
+     * @return {object} the map
+     */
+    getMapLayer: function() {
+      if (this.widgetLayerId) {
+        var map = this.getMap();
+        for (var i=0; i<map.aMaps.length; ++i) {
+          if (map.aMaps[i].id && (map.aMaps[i].id == this.widgetLayerId) ) {
+            return map.aMaps[i];
+          }
+        }
+        Fusion.reportError("Requested widgetLayerId not found:"+this.widgetLayerId);
+        return null;
+      } else {
+        return this.getMap().aMaps[0];
+      }
+    },
+    
+    /**
      * utility method to add an OL control to the OL map object
      */
     addControl: function(control) {

Modified: branches/fusion-2.2/templates/mapguide/standard/ApplicationDefinition.xml
===================================================================
--- branches/fusion-2.2/templates/mapguide/standard/ApplicationDefinition.xml	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/templates/mapguide/standard/ApplicationDefinition.xml	2011-04-14 19:04:46 UTC (rev 2365)
@@ -10,7 +10,7 @@
 
   <MapSet>
     <MapGroup id="sheboygan">
-      <Map>
+      <Map id="mapguide">
         <Type>MapGuide</Type>
         <SingleTile>true</SingleTile>
         <Extension>
@@ -22,6 +22,32 @@
         </Extension>
       </Map>
     </MapGroup>
+    <MapGroup id="google-sheboygan">
+      <Map>
+        <Type>Google</Type>
+        <Extension>
+          <ResourceId>google</ResourceId>
+          <Options>
+            <name>GoogleLayer</name>
+            <type>G_PHYSICAL_MAP</type>
+          </Options>
+        </Extension>
+      </Map>
+      <Map id="mapguide2">
+        <Type>MapGuide</Type>
+        <SingleTile>true</SingleTile>
+        <Extension>
+          <ResourceId>Library://Samples/Sheboygan/Maps/SheboyganMercator.MapDefinition</ResourceId>
+          <ImageFormat>PNG8</ImageFormat>
+          <SelectionAsOverlay>true</SelectionAsOverlay>
+          <SelectionFormat>PNG</SelectionFormat>
+          <SelectionColor>0xFF0000FF</SelectionColor>
+          <Options>
+            <isBaseLayer>false</isBaseLayer>
+          </Options>
+        </Extension>
+      </Map>
+    </MapGroup>
     <MapGroup id="mixed">
       <Map>
         <Type>WMS</Type>
@@ -621,6 +647,9 @@
     <Widget>
       <Name>menuSelectWithin</Name>
       <Type>SelectWithin</Type>
+      <Extension>
+        <WidgetLayerId>mapguide</WidgetLayerId>
+      </Extension>
       <StatusText>Select all features that fall within the currently selected area.</StatusText>
       <ImageUrl>images/icons.png</ImageUrl>
       <ImageClass>select-within</ImageClass>
@@ -634,6 +663,9 @@
     <Widget>
       <Name>menuBuffer</Name>
       <Type>BufferPanel</Type>
+      <Extension>
+        <WidgetLayerId>mapguide</WidgetLayerId>
+      </Extension>
       <StatusText>Create buffers around the selected features</StatusText>
       <ImageUrl>images/icons.png</ImageUrl>
       <ImageClass>buffer</ImageClass>
@@ -724,6 +756,7 @@
       <Label>Buffer</Label>
       <Extension>
         <Target>TaskPane</Target>
+        <WidgetLayerId>mapguide</WidgetLayerId>
       </Extension>
       <Disabled/>
     </Widget>
@@ -936,6 +969,7 @@
       <ImageUrl>images/icons/select-features.png</ImageUrl>
       <Extension>
         <Target>TaskPane</Target>
+        <WidgetLayerId>mapguide</WidgetLayerId>
       </Extension>
       <ImageClass/>
       <Tooltip>Select Within</Tooltip>
@@ -1025,6 +1059,9 @@
     <Widget>
       <Name>TaskPane</Name>
       <Type>TaskPane</Type>
+      <Extension>
+        <WidgetLayerId>mapguide</WidgetLayerId>
+      </Extension>
       <StatusText/>
       <Extension>
         <MenuContainer>TaskContextMenu</MenuContainer>
@@ -1149,6 +1186,7 @@
         <ShowLegend>true</ShowLegend>
         <ShowNorthArrow>true</ShowNorthArrow>
         <ImageBaseUrl>images/</ImageBaseUrl>
+        <WidgetLayerId>mapguide</WidgetLayerId>
       </Extension>
       <ImageUrl>images/icons.png</ImageUrl>
       <ImageClass>file-print</ImageClass>
@@ -1182,6 +1220,7 @@
         <Label>Map Tips</Label>
         <Delay>350</Delay>
         <Layer>Parcels</Layer>
+        <WidgetLayerId>mapguide</WidgetLayerId>
       </Extension>
     </Widget>
 

Modified: branches/fusion-2.2/widgets/Buffer.js
===================================================================
--- branches/fusion-2.2/widgets/Buffer.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/Buffer.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -202,25 +202,25 @@
         }
         
         var mapWidget = this.getMap();
-        var aMaps = mapWidget.getAllMaps();        
-        var s = aMaps[0].arch + '/' + Fusion.getScriptLanguage() + "/Buffer." + Fusion.getScriptLanguage();
+        var widgetLayer = this.getMapLayer();        
+        var s = widgetLayer.arch + '/' + Fusion.getScriptLanguage() + "/Buffer." + Fusion.getScriptLanguage();
         var params = {};
         params.parameters = 'locale='+Fusion.locale +
                             '&merge=1' +
-                            '&session='+aMaps[0].getSessionID() +
-                            '&mapname='+ aMaps[0].getMapName()+
+                            '&session='+widgetLayer.getSessionID() +
+                            '&mapname='+ widgetLayer.getMapName()+
                             layer+distance+borderColor+fillColor; 
         params.onComplete = OpenLayers.Function.bind(this.bufferCreated, this);
         Fusion.ajaxRequest(s, params);
     },
     
     bufferCreated: function() {
-        var aMaps = this.getMap().getAllMaps();
-        var layer = aMaps[0].getLayerByName(this.layerName);
+        var widgetLayer = this.getMapLayer();        
+        var layer = widgetLayer.getLayerByName(this.layerName);
         if (layer) {
           layer.noCache = true;
         }
-        aMaps[0].reloadMap();
-        aMaps[0].drawMap();
+        widgetLayer.reloadMap();
+        widgetLayer.drawMap();
     }
 });

Modified: branches/fusion-2.2/widgets/BufferPanel/BufferPanel.templ
===================================================================
--- branches/fusion-2.2/widgets/BufferPanel/BufferPanel.templ	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/BufferPanel/BufferPanel.templ	2011-04-14 19:04:46 UTC (rev 2365)
@@ -74,7 +74,7 @@
     mapName = document.getElementById('Frm').mapname.value;
     list.options.length = 0;
     var map = GetParent().Fusion.getMapByName(mapName);
-    var layers = map.aMaps[0].getSelectedLayers();  
+    var layers = map.getSelectedLayers();  
     if(layers.length > 0) {
       for(var i = 0; i < layers.length; i++) {
         var layer = layers[i];

Modified: branches/fusion-2.2/widgets/BufferPanel/BufferReport.templ
===================================================================
--- branches/fusion-2.2/widgets/BufferPanel/BufferReport.templ	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/BufferPanel/BufferReport.templ	2011-04-14 19:04:46 UTC (rev 2365)
@@ -47,7 +47,7 @@
 }
 
 function GetParent()
-{debugger;
+{
 	if(popup)
 		return opener;
 	else

Modified: branches/fusion-2.2/widgets/BufferPanel.js
===================================================================
--- branches/fusion-2.2/widgets/BufferPanel.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/BufferPanel.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -95,14 +95,14 @@
         //add in other parameters to the url here
         
         var map = this.getMap();
-        var mapLayers = map.getAllMaps();
+        var widgetLayer = this.getMapLayer();        
         var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
         var pageElement = $(this.sTarget);
 
         var params = [];
         params.push('locale='+Fusion.locale);
-        params.push('session='+mapLayers[0].getSessionID());
-        params.push('mapname='+mapLayers[0].getMapName());
+        params.push('session='+widgetLayer.getSessionID());
+        params.push('mapname='+widgetLayer.getMapName());
         if (taskPaneTarget || pageElement) {
           params.push('popup=false');
         } else {

Modified: branches/fusion-2.2/widgets/FeatureInfo.js
===================================================================
--- branches/fusion-2.2/widgets/FeatureInfo.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/FeatureInfo.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -38,7 +38,7 @@
 Fusion.Widget.FeatureInfo = OpenLayers.Class(Fusion.Widget, {
     isExclusive: true,
     uiClass: Jx.Button,
-    sFeatures : 'menubar=no,location=no,resizable=no,status=no',
+    sFeatures: 'menubar=no,location=no,resizable=no,status=no',
 
     initializeWidget: function(widgetTag) {
         var json = widgetTag.extension;
@@ -51,14 +51,14 @@
         //add in other parameters to the url here
 
         var map = this.getMap();
-        var mapLayers = map.getAllMaps();
+        var widgetLayer = this.getMapLayer();
         var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
         var pageElement = $(this.sTarget);
 
         var params = [];
         params.push('LOCALE='+Fusion.locale);
-        params.push('SESSION='+mapLayers[0].getSessionID());
-        params.push('MAPNAME='+mapLayers[0].getMapName());
+        params.push('SESSION='+widgetLayer.getSessionID());
+        params.push('MAPNAME='+widgetLayer.getMapName());
         if (taskPaneTarget || pageElement) {
           params.push('POPUP=false');
         } else {

Modified: branches/fusion-2.2/widgets/Help.js
===================================================================
--- branches/fusion-2.2/widgets/Help.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/Help.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -69,7 +69,7 @@
     activate: function() {
         var url = this.baseUrl;
         
-        var map = this.getMap();
+        var map = this.getMapLayer();
         var params = [];
         params.push('LOCALE='+Fusion.locale);
         params.push('SESSION='+map.getSessionID());

Modified: branches/fusion-2.2/widgets/InvokeURL.js
===================================================================
--- branches/fusion-2.2/widgets/InvokeURL.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/InvokeURL.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -93,7 +93,7 @@
         var url = this.sBaseUrl;
         //add in other parameters to the url here
         
-        var map = this.getMap();
+        var map = this.getMapLayer();
         var params = [];
         params.push('LOCALE='+Fusion.locale);
         params.push('SESSION='+map.getSessionID());

Modified: branches/fusion-2.2/widgets/LayerManager.js
===================================================================
--- branches/fusion-2.2/widgets/LayerManager.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/LayerManager.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -66,7 +66,7 @@
         this.map.registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.mapLoaded, this));
         this.map.registerForEvent(Fusion.Event.MAP_RELOADED, OpenLayers.Function.bind(this.mapReLoaded, this));
         // update changes to the legend in this widget
-        this.map.aMaps[0].registerForEvent(Fusion.Event.LAYER_PROPERTY_CHANGED, OpenLayers.Function.bind(this.layerChanged,this));
+        this.getMapLayer().registerForEvent(Fusion.Event.LAYER_PROPERTY_CHANGED, OpenLayers.Function.bind(this.layerChanged,this));
     },
     
     mapLoaded: function() {
@@ -210,7 +210,7 @@
     this.setCursor('auto', ev.currentTarget.parentNode);
   },
   
-  setCursor : function(cursor, domObj) {
+  setCursor: function(cursor, domObj) {
       this.cursor = cursor;
       if (cursor && cursor.length && typeof cursor == 'object') {
           for (var i = 0; i < cursor.length; i++) {
@@ -273,14 +273,11 @@
   },
   updateSessionMapFile: function(){
    // console.log("updateSessionMapFile");
-    // get map
-    var map = this.getMap();
-    var aMaps = map.getAllMaps();
-    var currentMap = aMaps[0];
-    var sessionId = aMaps[0].getSessionID();
+    var widgetLayer = this.getMapLayer();
+    var sessionId = widgetLayer.getSessionID();
 
     // get all layers
-    var oLayers = currentMap.aLayers;
+    var oLayers = widgetLayer.aLayers;
     var aLayerNames = [];
     var visibleLayers = [];
     for(var i=0;i<oLayers.length;i++){
@@ -291,13 +288,12 @@
     }
 
     // prepare ajax req
-    var params =  '&session='+sessionId+'&mapname='+ this.getMap().getMapName()+'&visLayers='+visibleLayers+'&layers='+aLayerNames;
+    var params =  '&session='+sessionId+'&mapname='+ widgetLayer.getMapName()+'&visLayers='+visibleLayers+'&layers='+aLayerNames;
     var options = {parameters: params};
 
     // fire the request no need to return
-    var m = this.getMap().aMaps[0];
-    var url = 'layers/' + m.arch + '/' + Fusion.getScriptLanguage() + "/updateSessionMapFile." + Fusion.getScriptLanguage()
-    Fusion.ajaxRequest(  url, options);
+    var url = 'layers/' + widgetLayer.arch + '/' + Fusion.getScriptLanguage() + "/updateSessionMapFile." + Fusion.getScriptLanguage()
+    Fusion.ajaxRequest(url, options);
   }
 
 });

Modified: branches/fusion-2.2/widgets/Maptip.js
===================================================================
--- branches/fusion-2.2/widgets/Maptip.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/Maptip.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -180,7 +180,7 @@
     },
     
     showMaptip: function() {
-        this.getMap().getMapTip(this);
+        this.getMapLayer().getMapTip(this);
         this.mapTipFired = true;
     },
     

Modified: branches/fusion-2.2/widgets/Measure.js
===================================================================
--- branches/fusion-2.2/widgets/Measure.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/Measure.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -482,13 +482,13 @@
 
     remoteMeasureSegment: function(marker, from, to, geom) {
         var mapWidget = this.getMap();
-        var aMaps = mapWidget.getAllMaps();
-        var s = 'layers/' + aMaps[0].arch + '/' + Fusion.getScriptLanguage() + "/Measure." + Fusion.getScriptLanguage();
+        var widgetLayer = this.getMapLayer();
+        var s = 'layers/' + widgetLayer.arch + '/' + Fusion.getScriptLanguage() + "/Measure." + Fusion.getScriptLanguage();
         var fromGeo = mapWidget.pixToGeo(from.x, from.y);
         var toGeo = mapWidget.pixToGeo(to.x, to.y);
         var options = {
             parameters: {
-                'session': aMaps[0].getSessionID(),
+                'session': widgetLayer.getSessionID(),
                 'locale': Fusion.locale,
                 'mapname': mapWidget.getMapName(),
                 'x1': fromGeo.x,

Modified: branches/fusion-2.2/widgets/Print.js
===================================================================
--- branches/fusion-2.2/widgets/Print.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/Print.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -168,9 +168,9 @@
         var centerY = (extents.top + extents.bottom)/ 2;
         var dpi = mainMap._nDpi;
         var scale = mainMap.getScale();
-        var maps = mainMap.getAllMaps();
-        url = url + 'MAPNAME=' + mainMap.getMapName();
-        url = url + '&SESSION=' + maps[0].getSessionID();
+        var widgetLayer = this.getMapLayer();
+        url = url + 'MAPNAME=' + widgetLayer.getMapName();
+        url = url + '&SESSION=' + widgetLayer.getSessionID();
         url = url + '&CENTERX='+centerX;
         url = url + '&CENTERY='+centerY;
         url = url + '&DPI='+dpi;

Modified: branches/fusion-2.2/widgets/Query.js
===================================================================
--- branches/fusion-2.2/widgets/Query.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/Query.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -51,15 +51,14 @@
         var url = this.sBaseUrl;
         //add in other parameters to the url here
 
-        var map = this.getMap();
-        var mapLayers = map.getAllMaps();
+        var widgetLayer = this.getMapLayer();
         var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
         var pageElement = $(this.sTarget);
 
         var params = [];
         params.push('LOCALE='+Fusion.locale);
-        params.push('SESSION='+mapLayers[0].getSessionID());
-        params.push('MAPNAME='+mapLayers[0].getMapName());
+        params.push('SESSION='+widgetLayer.getSessionID());
+        params.push('MAPNAME='+widgetLayer.getMapName());
         if (taskPaneTarget || pageElement) {
           params.push('POPUP=false');
         } else {

Modified: branches/fusion-2.2/widgets/QuickPlot.js
===================================================================
--- branches/fusion-2.2/widgets/QuickPlot.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/QuickPlot.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -44,15 +44,14 @@
     activate: function() 
     {
         var url = this.sBaseUrl;
-        var map = this.getMap();
-        var mapLayers      = map.getAllMaps();
+        var widgetLayer    = this.getMapLayer();
         var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
         var pageElement    = $(this.sTarget);
 
         var params = [];
         params.push('locale='+Fusion.locale);
-        params.push('session='+mapLayers[0].getSessionID());
-        params.push('mapname='+mapLayers[0].getMapName());
+        params.push('session='+widgetLayer.getSessionID());
+        params.push('mapname='+widgetLayer.getMapName());
         
         if (taskPaneTarget || pageElement) 
         {
@@ -113,7 +112,7 @@
      ***************************************************************************************/
     preview: function(dialogConentLoadedCallback, printDpi)
     {
-        var map = this.getMap();
+        var map = this.getMapLayer();
         var capture  = this.mapCapturer.getCaptureBox();
         var normalizedCapture = this.mapCapturer.getNormalizedCapture();
         var vertices = capture.geometry.getVertices();

Modified: branches/fusion-2.2/widgets/SaveMap.js
===================================================================
--- branches/fusion-2.2/widgets/SaveMap.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/SaveMap.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -197,7 +197,7 @@
         if (this.imageWidth) {
             szWidth = '&width=' + this.imageWidth;
         }
-        var m = this.getMap().aMaps[0];
+        var m = this.getMapLayer();
         if(navigator.appVersion.match(/\bMSIE\b/)) {
             var url = Fusion.fusionURL + 'layers/' + m.arch + '/' + Fusion.getScriptLanguage() + "/SaveMapFrame." + Fusion.getScriptLanguage() + '?session='+m.getSessionID() + '&mapname=' + m.getMapName() + '&format=' + this.format.toUpperCase() + szLayout + szScale + szWidth + szHeight + szPageHeight + szPageWidth + szPageMargins;
             w = open(url, "Save", 'menubar=no,height=200,width=300');

Modified: branches/fusion-2.2/widgets/Search.js
===================================================================
--- branches/fusion-2.2/widgets/Search.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/Search.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -53,15 +53,14 @@
         var url = this.sBaseUrl;
         //add in other parameters to the url here
 
-        var map = this.getMap();
-        var mapLayers = map.getAllMaps();
+        var widgetLayer = this.getMapLayer();
         var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
         var pageElement = $(this.sTarget);
 
         var params = [];
         params.push('locale='+Fusion.locale);
-        params.push('session='+mapLayers[0].getSessionID());
-        params.push('mapname='+mapLayers[0].getMapName());
+        params.push('session='+widgetLayer.getSessionID());
+        params.push('mapname='+widgetLayer.getMapName());
         if (taskPaneTarget || pageElement) {
           params.push('popup=false');
         } else {

Modified: branches/fusion-2.2/widgets/SelectRadius.js
===================================================================
--- branches/fusion-2.2/widgets/SelectRadius.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/SelectRadius.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -110,10 +110,11 @@
         var radius = this.getMap().pixToGeoMeasure(this.defaultRadius);
         this.handler.setOptions({radius: radius});
         this.handler.activate();
-        this.getMap().setCursor(this.asCursor);
-        /*map units for tool tip*/
-        this.units = this.getMap().getAllMaps()[0].units;
-        this.getMap().supressContextMenu(true);
+        var map = this.getMap();
+        map.setCursor(this.asCursor);
+         /*map units for tool tip*/
+        this.units = map.units;
+        map.supressContextMenu(true);
         this.triggerEvent(Fusion.Event.RADIUS_WIDGET_ACTIVATED, true);
     },
 

Modified: branches/fusion-2.2/widgets/SelectRadiusValue.js
===================================================================
--- branches/fusion-2.2/widgets/SelectRadiusValue.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/SelectRadiusValue.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -50,7 +50,7 @@
     
     draw: function() {
         /* put in the label */
-        var units = this.getMap().getAllMaps()[0].units;
+        var units = this.getMap().units;
         this.domLabel = document.createElement('span');
         this.domLabel.className = this.className;
         this.domLabel.innerHTML = this.label + '(' + units + ')';

Modified: branches/fusion-2.2/widgets/SelectWithin/SelectWithinPanel.templ
===================================================================
--- branches/fusion-2.2/widgets/SelectWithin/SelectWithinPanel.templ	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/SelectWithin/SelectWithinPanel.templ	2011-04-14 19:04:46 UTC (rev 2365)
@@ -83,7 +83,6 @@
     }
 
     var mapWidget = GetParent().Fusion.getMapByName(mapName);
-    var map = mapWidget.aMaps[0];
     var params = {
       "mapname": mapName,
       "session": sessionId,
@@ -98,8 +97,7 @@
 }
 
 function selectedSuccess(r) {
-    var mapWidget = GetParent().Fusion.getMapByName(mapName);
-    var map = mapWidget.aMaps[0];
+    var map = GetParent().Fusion.getMapByName(mapName);
     map.processQueryResults(zoomTo, r);
 }
 
@@ -126,7 +124,7 @@
     var listNames = document.getElementById("layerNames");
     list.options.length = 0;
     var map = GetParent().Fusion.getMapByName(mapName);
-    var layers = map.aMaps[0].getSelectableLayers();
+    var layers = map.getSelectableLayers();
     if(layers.length > 0) {
       for(var i = 0; i < layers.length; i++) {
         var layer = layers[i];
@@ -146,7 +144,7 @@
 }
 
 function GetParent()
-{debugger;
+{
 	if(popup)
 		return opener;
 	else

Modified: branches/fusion-2.2/widgets/SelectWithin.js
===================================================================
--- branches/fusion-2.2/widgets/SelectWithin.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/SelectWithin.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -89,15 +89,14 @@
         var url = this.sBaseUrl;
         //add in other parameters to the url here
         
-        var map = this.getMap();
-        var mapLayers = map.getAllMaps();
+        var widgetLayer = this.getMapLayer();
         var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
         var pageElement = $(this.sTarget);
 
         var params = [];
         params.push('locale='+Fusion.locale);
-        params.push('session='+mapLayers[0].getSessionID());
-        params.push('mapname='+mapLayers[0].getMapName());
+        params.push('session='+widgetLayer.getSessionID());
+        params.push('mapname='+widgetLayer.getMapName());
         if (taskPaneTarget || pageElement) {
           params.push('popup=false');
         } else {

Modified: branches/fusion-2.2/widgets/SelectionPanel.js
===================================================================
--- branches/fusion-2.2/widgets/SelectionPanel.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/SelectionPanel.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -337,7 +337,17 @@
         for (var i=0; i<nLayers; i++) {
             var layerObj = this.oSelection.getLayer(i);
             //find the legend label from the Map layer objects
-            var mapLayers = this.getMap().aMaps[0].aLayers; //TODO: allow multiple maps
+            //join up all layers from all maps into an array
+            var mapLayers = [];
+            var map = this.getMap();
+            for (j=0; j<map.aMaps.length; ++j) {
+              if (map.aMaps[j].aLayers) {
+                for (k=0; k<map.aMaps[j].aLayers.length; ++k) {
+                  mapLayers.push(map.aMaps[j].aLayers[k]);
+                }
+              }
+            }
+            
             var labelName = layerObj.getName();
             for (var j=0; j<mapLayers.length; ++j) {
               if (mapLayers[j].layerName == labelName) {
@@ -492,7 +502,7 @@
             var layerObj = this.oSelection.getLayer(i);
             var aNames = layerObj.getPropertyNames();
             //find the legend label from the Map layer objects
-            var mapLayers = this.getMap().aMaps[0].aLayers; //TODO: allow multiple maps
+            var mapLayers = this.getMapLayer().aLayers;
             var labelName = layerObj.getName();
             for (var j=0; j<mapLayers.length; ++j) {
                 if (mapLayers[j].layerName == labelName) {

Modified: branches/fusion-2.2/widgets/TaskPane.js
===================================================================
--- branches/fusion-2.2/widgets/TaskPane.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/TaskPane.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -171,15 +171,15 @@
         //add in some common parameters if they aren't supplied already
         var baseUrl = url.split("?");
         var params = OpenLayers.Util.getParameters(url);
-        var mapLayers = this.getMap().getAllMaps();
+        var widgetLayer = this.getMapLayer();
         if (!params["LOCALE"] && !params["locale"]) {
           params["locale"] = Fusion.locale;
         }
         if (!params["SESSION"] && !params["session"]) {
-          params["session"] = mapLayers[0].getSessionID();
+          params["session"] = widgetLayer.getSessionID();
         }
         if (!params["MAPNAME"] && !params["mapname"]) {
-          params["mapname"] = mapLayers[0].getMapName();
+          params["mapname"] = widgetLayer.getMapName();
         }
         var newUrl = baseUrl[0] + "?" + OpenLayers.Util.getParameterString(params);
         

Modified: branches/fusion-2.2/widgets/Theme.js
===================================================================
--- branches/fusion-2.2/widgets/Theme.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/Theme.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -50,15 +50,14 @@
         var url = this.sBaseUrl;
         //add in other parameters to the url here
 
-        var map = this.getMap();
-        var mapLayers = map.getAllMaps();
+        var widgetLayer = this.getMapLayer();
         var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
         var pageElement = $(this.sTarget);
 
         var params = [];
         params.push('LOCALE='+Fusion.locale);
-        params.push('SESSION='+mapLayers[0].getSessionID());
-        params.push('MAPNAME='+mapLayers[0].getMapName());
+        params.push('SESSION='+widgetLayer.getSessionID());
+        params.push('MAPNAME='+widgetLayer.getMapName());
         if (taskPaneTarget || pageElement) {
           params.push('POPUP=false');
         } else {

Modified: branches/fusion-2.2/widgets/ZoomToSelection.js
===================================================================
--- branches/fusion-2.2/widgets/ZoomToSelection.js	2011-04-14 13:19:20 UTC (rev 2364)
+++ branches/fusion-2.2/widgets/ZoomToSelection.js	2011-04-14 19:04:46 UTC (rev 2365)
@@ -59,18 +59,25 @@
      * 
      * @param selection the active selection, or null if there is none
      */
-    zoomToSelection : function(selection) {
-        var map = this.oMap.aMaps[0]; //TODO: allow selection on multple maps
-        var ll = selection[map.getMapName()].getLowerLeftCoord();
-        var ur = selection[map.getMapName()].getUpperRightCoord();
-        var zoom_size = this.zoomFactor * Math.max( Math.abs(ur.x - ll.x), Math.abs(ur.y - ll.y)) / 2;
-        var cX = (ur.x + ll.x)/2;
-        var cY = (ur.y + ll.y)/2;
-        ll.x = cX - zoom_size;
-        ur.x = cX + zoom_size;
-        ll.y = cY - zoom_size;
-        ur.y = cY + zoom_size;
-        this.getMap().setExtents(new OpenLayers.Bounds(ll.x,ll.y,ur.x,ur.y));
+    zoomToSelection: function(selection) {
+        var aMaps = this.getMap().getAllMaps();
+        var bounds = new OpenLayers.Bounds();
+        for (var i=0; i<aMaps.length; ++i) {
+          var mapName = aMaps[i].getMapName()
+          if (selection[mapName]) {
+            var ll = selection[mapName].getLowerLeftCoord();//make this an OL Pixel
+            bounds.extend(new OpenLayers.LonLat(ll.x,ll.y));
+            var ur = selection[mapName].getUpperRightCoord();
+            bounds.extend(new OpenLayers.LonLat(ur.x,ur.y));
+          }
+        }
+        var zoom_size = this.zoomFactor * Math.max( Math.abs(bounds.getWidth()), Math.abs(bounds.getHeight())) / 2;
+        var center = bounds.getCenterLonLat();
+        llx = center.lon - zoom_size;
+        urx = center.lon + zoom_size;
+        lly = center.lat - zoom_size;
+        ury = center.lat + zoom_size;
+        this.getMap().setExtents(new OpenLayers.Bounds(llx,lly,urx,ury));
     },
     
     enable: function() {



More information about the fusion-commits mailing list