[fusion-commits] r2068 - trunk/widgets

svn_fusion at osgeo.org svn_fusion at osgeo.org
Wed Feb 10 16:16:58 EST 2010


Author: madair
Date: 2010-02-10 16:16:57 -0500 (Wed, 10 Feb 2010)
New Revision: 2068

Modified:
   trunk/widgets/MapMenu.js
   trunk/widgets/OverviewMap.js
Log:
closes 315: convert initial extents when switching maps

Modified: trunk/widgets/MapMenu.js
===================================================================
--- trunk/widgets/MapMenu.js	2010-02-10 21:12:27 UTC (rev 2067)
+++ trunk/widgets/MapMenu.js	2010-02-10 21:16:57 UTC (rev 2068)
@@ -157,6 +157,8 @@
     //change the map, preserving current extents
     switchMap: function(data) {
         var ce = this.getMap().getCurrentExtents();
+        var dest = new OpenLayers.Projection(data.maps[0].projCode);
+        ce = ce.transform(this.oMap.oMapOL.baseLayer.projection, dest);
         data.initialView = {minX:ce.left,
                             minY:ce.bottom,
                             maxX:ce.right,

Modified: trunk/widgets/OverviewMap.js
===================================================================
--- trunk/widgets/OverviewMap.js	2010-02-10 21:12:27 UTC (rev 2067)
+++ trunk/widgets/OverviewMap.js	2010-02-10 21:16:57 UTC (rev 2068)
@@ -59,7 +59,7 @@
         } else {
           this.mapObject = new Fusion.Layers.Generic(this, mapTag, false);
         }
-        this.mapObject.registerForEvent(Fusion.Event.LAYER_LOADED, OpenLayers.Function.bind(this.loadOverview, this));
+        //this.mapObject.registerForEvent(Fusion.Event.LAYER_LOADED, OpenLayers.Function.bind(this.loadOverview, this));
 
         //first set the size to the size of the DOM element if available
         if (this.domObj) {
@@ -73,28 +73,23 @@
         
         this.oMapOptions = {};  //TODO: allow setting some mapOptions in AppDef
 
-        //this.getMap().registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.mapWidgetLoaded, this));
+        this.getMap().registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.mapWidgetLoaded, this));
     },
     
     mapWidgetLoaded: function() 
     {
         var mapWidget = this.getMap();
-        if (this.sMapGroupId && (mapWidget.projection == this.mapObject.projection) ) {
-          this.loadOverview([this.mapObject.oLayerOL]);
+        if (this.sMapGroupId) {// && (mapWidget.projection == this.mapObject.projection) ) {
+          this.loadOverview(this.mapObject.oLayerOL);
         } else {
           //just use the base map layer
-          var extent = this.oMap._oCurrentExtents;
-          this.loadOverview([this.getMap().oMapOL.baseLayer.clone()]);
+          //setTimeout(OpenLayers.Function.bind(this.loadOverview, this), 5000);
+          this.loadOverview();
         }
     },
 
-    keymapLoaded: function() 
+    loadOverview: function(layer) 
     {
-        this.mapObject.oLayerOL.isBaseLayer = true;  
-    },
-
-    loadOverview: function() 
-    {
         if (this.control) {
           this.control.destroy();
         }
@@ -102,22 +97,25 @@
         var size = $(this.domObj).getContentBoxSize();
         this.oSize = new OpenLayers.Size(size.width, size.height);
         
-        this.mapObject.oLayerOL.isBaseLayer = true;  
-        if (this.mapObject.oLayerOL.singleTile) {
+        if (!layer) {
+            layer = this.getMap().oMapOL.baseLayer.clone();
+        }
+        layer.isBaseLayer = true; 
+        layer.ratio = 1.0;
+        if (layer.singleTile) {
           this.oMapOptions.numZoomLevels = 3;  //TODO: make this configurable?
         }
 
-        this.mapObject.oLayerOL.ratio = 1.0;
-        var mapOpts = {
+        var options = {
           div: this.domObj,
           size: this.oSize,
           minRatio: this.nMinRatio,
           maxRatio: this.nMaxRatio,
           mapOptions: this.oMapOptions,
-          layers: [this.mapObject.oLayerOL]
+          layers: [layer]
         };
 
-        this.control = new OpenLayers.Control.OverviewMap(mapOpts);
+        this.control = new OpenLayers.Control.OverviewMap(options);
         if (size.width == 0 || size.height == 0) {
           return;   //don't try to load if the container is not visible
         } else {



More information about the fusion-commits mailing list