[fusion-commits] r1566 - in trunk: lib widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Mon Sep 29 14:26:44 EDT 2008
Author: pagameba
Date: 2008-09-29 14:26:44 -0400 (Mon, 29 Sep 2008)
New Revision: 1566
Modified:
trunk/lib/fusion.js
trunk/widgets/ViewOptions.js
Log:
Add concept of unit system to Fusion and support setting the right unit system in View Options widget when the map changes unit systems.
Modified: trunk/lib/fusion.js
===================================================================
--- trunk/lib/fusion.js 2008-09-29 18:11:27 UTC (rev 1565)
+++ trunk/lib/fusion.js 2008-09-29 18:26:44 UTC (rev 1566)
@@ -876,6 +876,31 @@
Fusion.UNKNOWN;
}
},
+
+ unitSystem: function(unit) {
+ switch(unit) {
+
+ case Fusion.INCHES:
+ case Fusion.FEET:
+ case Fusion.YARDS:
+ case Fusion.MILES:
+ case Fusion.NAUTICALMILES:
+ return 'imperial';
+ case Fusion.MILLIMETERS:
+ case Fusion.CENTIMETERS:
+ case Fusion.METERS:
+ case Fusion.KILOMETERS:
+ return 'metric';
+ case Fusion.DEGREES:
+ case Fusion.DECIMALDEGREES:
+ case Fusion.DMS:
+ return 'deg';
+ case Fusion.UNKNOWN:
+ case Fusion.PIXELS:
+ default:
+ return 'device';
+ }
+ },
unitName: function(unit) {
if (unit >= Fusion.UNKNOWN && unit <= Fusion.PIXELS) {
Modified: trunk/widgets/ViewOptions.js
===================================================================
--- trunk/widgets/ViewOptions.js 2008-09-29 18:11:27 UTC (rev 1565)
+++ trunk/widgets/ViewOptions.js 2008-09-29 18:26:44 UTC (rev 1566)
@@ -37,12 +37,15 @@
'metric': 'Meters',
'deg': 'Degrees'
},
+
+ menuItems: null,
initializeWidget: function(widgetTag) {
var json = widgetTag.extension;
this.displayUnits = json.DisplayUnits ? json.DisplayUnits[0] : false;
this.getMap().registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.setMapUnits, this));
+ this.menuItems = {};
},
setUiObject: function(uiObj) {
@@ -57,20 +60,20 @@
});
buttonSet.add(menuItem);
this.uiObj.add(menuItem);
+ this.menuItems[key] = menuItem;
}
},
- //action to perform when the button is clicked
- activate: function(e) {
- //this.oMenu.show(e);
- },
-
setViewOptions: function(units) {
- this.getMap().setViewOptions(units);
+ this.getMap().setViewOptions(units);
},
setMapUnits: function() {
- var units = this.displayUnits ? this.displayUnits : this.getMap().getUnits();
- this.setViewOptions(units);
+ var units = this.displayUnits ? this.displayUnits : this.getMap().getUnits();
+ this.setViewOptions(units);
+ var system = Fusion.unitSystem(Fusion.unitFromName(units));
+ if (this.menuItems[system]) {
+ this.menuItems[system].setActive(true);
+ }
}
});
More information about the fusion-commits
mailing list