[fusion-commits] r2881 - in branches/fusion-mg26: . lib widgets

svn_fusion at osgeo.org svn_fusion at osgeo.org
Sat Sep 27 00:07:46 PDT 2014


Author: jng
Date: 2014-09-27 00:07:46 -0700 (Sat, 27 Sep 2014)
New Revision: 2881

Modified:
   branches/fusion-mg26/
   branches/fusion-mg26/lib/Map.js
   branches/fusion-mg26/widgets/BasemapSwitcher.js
   branches/fusion-mg26/widgets/OverviewMap.js
Log:
Merged revision(s) 2880 from trunk:
#628: Fix OverviewMap widget not showing external base layers. A new event (Fusion.Event.MAP_BASE_LAYER_CHANGED) is triggered when the map's external base layer changes. The OverviewMap widget now includes any external layers when creating the OverviewMap control, and will keep the active external base layer in sync with the main map by listening to this event.
........



Property changes on: branches/fusion-mg26
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/fusion-mg24:2560
/sandbox/createruntimemap:2699-2708
/sandbox/jxlib-3.0:1957-2248
/sandbox/ol213:2801-2803
/sandbox/robust_error_handling:2818-2825
/trunk:2847,2850,2857,2859,2862-2863,2872,2877
   + /branches/fusion-mg24:2560
/sandbox/createruntimemap:2699-2708
/sandbox/jxlib-3.0:1957-2248
/sandbox/ol213:2801-2803
/sandbox/robust_error_handling:2818-2825
/trunk:2847,2850,2857,2859,2862-2863,2872,2877,2880

Modified: branches/fusion-mg26/lib/Map.js
===================================================================
--- branches/fusion-mg26/lib/Map.js	2014-09-27 07:06:31 UTC (rev 2880)
+++ branches/fusion-mg26/lib/Map.js	2014-09-27 07:07:46 UTC (rev 2881)
@@ -92,6 +92,10 @@
  */
 Fusion.Event.MAP_DIGITIZER_DEACTIVATED = Fusion.Event.lastEventId++;
 /**
+ * Constant: Fusion.Event.MAP_BASE_LAYER_CHANGED
+ */
+Fusion.Event.MAP_BASE_LAYER_CHANGED = Fusion.Event.lastEventId++;
+/**
  * Constant: Fusion.Constant.LAYER_POINT_TYPE
  */
 Fusion.Constant.LAYER_POINT_TYPE = 0;
@@ -309,6 +313,7 @@
         this.registerEventID(Fusion.Event.MAP_MAP_GROUP_LOADED);
         this.registerEventID(Fusion.Event.MAP_DIGITIZER_ACTIVATED);
         this.registerEventID(Fusion.Event.MAP_DIGITIZER_DEACTIVATED);
+        this.registerEventID(Fusion.Event.MAP_BASE_LAYER_CHANGED);
 
         this.registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.mapLoaded,this));
         this.registerForEvent(Fusion.Event.MAP_RELOADED, OpenLayers.Function.bind(this.mapLoaded,this));
@@ -340,6 +345,20 @@
         //create the 'Map' layer widgets defined in the MapGroup
         this.loadMapGroup(mapGroup);
     },
+    
+    /**
+     * Function: setExternalBaseLayer
+     *
+     * Sets the given external layer as the new base layer
+     *
+     * Parameter: {Fusion.Layers} baseLayer - a Fusion.Layers instance to set as the new base map
+     *
+     * Return: none
+     */
+    setExternalBaseLayer: function(baseLayer) {
+        this.oMapOL.setBaseLayer(baseLayer.oLayerOL, false);
+        this.triggerEvent(Fusion.Event.MAP_BASE_LAYER_CHANGED, baseLayer);
+    },
 
     /**
      * Function: mapLoaded

Modified: branches/fusion-mg26/widgets/BasemapSwitcher.js
===================================================================
--- branches/fusion-mg26/widgets/BasemapSwitcher.js	2014-09-27 07:06:31 UTC (rev 2880)
+++ branches/fusion-mg26/widgets/BasemapSwitcher.js	2014-09-27 07:07:46 UTC (rev 2881)
@@ -333,14 +333,14 @@
     setBasemap: function(baseMap) {
         if ("None" != baseMap && this.getMap().oMapOL.baseLayer.CLASS_NAME == "OpenLayers.Layer.MapGuide") {
             var visibility = this.baseMaps["None"].oLayerOL.visibility;
-            this.getMap().oMapOL.setBaseLayer(this.baseMaps[baseMap].oLayerOL, false);
+            this.getMap().setExternalBaseLayer(this.baseMaps[baseMap], false);
             this.applyZoomOffset(baseMap);
             // Keep the MapGuide layers visibility
             this.baseMaps["None"].oLayerOL.visibility = visibility;
             this.baseMaps["None"].oLayerOL.redraw();
         }
         else {
-            this.getMap().oMapOL.setBaseLayer(this.baseMaps[baseMap].oLayerOL, false);
+            this.getMap().setExternalBaseLayer(this.baseMaps[baseMap], false);
             this.applyZoomOffset(baseMap);
         }
         this.activeBasemap = baseMap;


Property changes on: branches/fusion-mg26/widgets/BasemapSwitcher.js
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/fusion-mg24/widgets/BasemapSwitcher.js:2560
/sandbox/adsk/2.4j/widgets/BasemapSwitcher.js:2486-2526
/sandbox/createruntimemap/widgets/BasemapSwitcher.js:2699-2708
/sandbox/jxlib-3.0/widgets/BasemapSwitcher.js:1957-2248
/sandbox/ol213/widgets/BasemapSwitcher.js:2801-2803
/sandbox/robust_error_handling/widgets/BasemapSwitcher.js:2818-2825
/trunk/widgets/BasemapSwitcher.js:2469-2485
   + /branches/fusion-mg24/widgets/BasemapSwitcher.js:2560
/sandbox/adsk/2.4j/widgets/BasemapSwitcher.js:2486-2526
/sandbox/createruntimemap/widgets/BasemapSwitcher.js:2699-2708
/sandbox/jxlib-3.0/widgets/BasemapSwitcher.js:1957-2248
/sandbox/ol213/widgets/BasemapSwitcher.js:2801-2803
/sandbox/robust_error_handling/widgets/BasemapSwitcher.js:2818-2825
/trunk/widgets/BasemapSwitcher.js:2469-2485,2880

Modified: branches/fusion-mg26/widgets/OverviewMap.js
===================================================================
--- branches/fusion-mg26/widgets/OverviewMap.js	2014-09-27 07:06:31 UTC (rev 2880)
+++ branches/fusion-mg26/widgets/OverviewMap.js	2014-09-27 07:07:46 UTC (rev 2881)
@@ -65,6 +65,7 @@
         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_BASE_LAYER_CHANGED, OpenLayers.Function.bind(this.mapBaseLayerChanged, this));
     },
 
     mapWidgetLoaded: function()
@@ -128,6 +129,21 @@
                 }
             }
             
+            // Check if we have any external layers, if so add them too.
+            var bHasOtherLayers = false;
+            var otherLayers = this.getMap().getAllMaps();
+            for (var i = 0; i < otherLayers.length; i++) {
+                if (otherLayers[i].arch != "MapGuide") {
+                    var olLayer = otherLayers[i].oLayerOL.clone();
+                    ovLayers.push(olLayer);
+                    bHasOtherLayers = true;
+                }
+            }
+            // If we found external layers, the MapGuide one is no longer a base layer but an overlay
+            if (bHasOtherLayers) {
+                layer.isBaseLayer = false;
+            }
+            
             var options = {
               div: this.domObj,
               size: this.oSize,
@@ -150,6 +166,26 @@
             //console.log('OverviewMap mapLoaded');
         }
     },
+    
+    mapBaseLayerChanged: function(evtId, newBaseLayer) {
+        //OverviewMap control not created yet. Come back later
+        if (!this.control) {
+            return;
+        }
+        var newOLLayer = newBaseLayer.oLayerOL;
+        //Update ov map's base layer to match
+        var layers = this.control.ovmap.layers;
+        var newOvLayer = null;
+        for (var i = 0; i < layers.length; i++) {
+            layers[i].isBaseLayer = false;
+            if (layers[i].name == newOLLayer.name) {
+                newOvLayer = layers[i];
+            }
+        }
+        if (newOvLayer != null) {
+            this.control.ovmap.setBaseLayer(newOvLayer);
+        }
+    },
 
     sizeChanged: function() {
         var size = $(this.domObj).getContentBoxSize();



More information about the fusion-commits mailing list