[fusion-commits] r1951 - trunk/widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Mon Oct 26 01:21:44 EDT 2009
Author: liuar
Date: 2009-10-26 01:21:43 -0400 (Mon, 26 Oct 2009)
New Revision: 1951
Modified:
trunk/widgets/BasemapSwitcher.js
Log:
Fixed ticket #299 List of External Provider widget is not updated per Map.
[http://trac.osgeo.org/fusion/ticket/299]
Modified: trunk/widgets/BasemapSwitcher.js
===================================================================
--- trunk/widgets/BasemapSwitcher.js 2009-10-22 14:57:19 UTC (rev 1950)
+++ trunk/widgets/BasemapSwitcher.js 2009-10-26 05:21:43 UTC (rev 1951)
@@ -38,10 +38,20 @@
defaultBasemap: null,
- menuItems: null,
+ menuItems: {},
initializeWidget: function(widgetTag) {
- var maps = this.getMap().aMaps;
+ this.getMap().registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.setDefaultBasemap, this));
+ },
+
+ generateOptions: function(){
+ // Clear previous settings
+ this.options = {};
+ this.baseMaps = {};
+ this.defaultBasemap = null;
+ this.menuItems = {};
+
+ var maps = this.getMap().aMaps;
for (var i = 0, len = maps.length; i < len; i++) {
var map = maps[i];
switch (map.layerType) {
@@ -189,32 +199,11 @@
default:
break;
}
-
}
-
- this.getMap().registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.setDefaultBasemap, this));
-
- this.menuItems = {};
- },
-
+ },
+
setUiObject: function(uiObj) {
Fusion.Widget.prototype.setUiObject.apply(this, [uiObj]);
- var buttonSet = new Jx.ButtonSet();
- //set up the root menu
- for (var key in this.options) {
- if (this.options[key]) {
- var menuItem = new Jx.Menu.Item({
- label: OpenLayers.i18n(this.options[key]),
- toggle: true,
- onDown: OpenLayers.Function.bind(this.setBasemap, this, key)
- });
- buttonSet.add(menuItem);
- this.uiObj.add(menuItem);
-
- this.menuItems[key] = menuItem;
- }
- }
-
},
setBasemap: function(baseMap) {
@@ -232,7 +221,27 @@
},
setDefaultBasemap: function() {
+ this.generateOptions();
+ //re-generate the menu
+ this.uiObj.initialize();
+
+ //set up the root menu
+ var buttonSet = new Jx.ButtonSet();
+ for (var key in this.options) {
+ if (this.options[key]) {
+ var menuItem = new Jx.Menu.Item({
+ label: OpenLayers.i18n(this.options[key]),
+ toggle: true,
+ onDown: OpenLayers.Function.bind(this.setBasemap, this, key)
+ });
+ buttonSet.add(menuItem);
+ this.uiObj.add(menuItem);
+ this.menuItems[key] = menuItem;
+ }
+ }
this.menuItems[this.defaultBasemap].setActive(true);
this.setBasemap(this.defaultBasemap);
+
+
}
});
More information about the fusion-commits
mailing list