[fusion-commits] r2373 - trunk/widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Mon Apr 25 13:45:44 EDT 2011
Author: madair
Date: 2011-04-25 10:45:44 -0700 (Mon, 25 Apr 2011)
New Revision: 2373
Modified:
trunk/widgets/Measure.js
Log:
re #443: adds an optional clear button to a toolbar or similar container
Modified: trunk/widgets/Measure.js
===================================================================
--- trunk/widgets/Measure.js 2011-04-15 18:49:32 UTC (rev 2372)
+++ trunk/widgets/Measure.js 2011-04-25 17:45:44 UTC (rev 2373)
@@ -185,13 +185,33 @@
measure: this.measure,
scope: this
});
+
+ //add in the clear button if required
+ if(json.ClearButtonContainer) {
+ var clearButtonText = json.ClearButtonText? json.ClearButtonText[0] : 'Clear';
+ this.clearButton = new Jx.Button({
+ label: clearButtonText,
+ onClick: OpenLayers.Function.bind(this.clearMeasure, this)
+ }).addTo(json.ClearButtonContainer[0]);
+ this.registerForEvent(Fusion.Event.MEASURE_CLEAR, OpenLayers.Function.bind(this.toggleClearButton, this, false));
+ this.registerForEvent(Fusion.Event.MEASURE_SEGMENT_UPDATE, OpenLayers.Function.bind(this.toggleClearButton, this, true));
+ this.clearButton.setEnabled(false);
+ }
this.getMap().registerForEvent(Fusion.Event.MAP_EXTENTS_CHANGED, OpenLayers.Function.bind(this.extentsChangedCB, this));
this.getMap().registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.extentsChangedCB, this));
},
+
+ clearMeasure: function() {
+ this.control.cancel();
+ },
- extentsChangedCB : function() {
+ toggleClearButton: function(enabled) {
+ this.clearButton.setEnabled(enabled);
+ },
+
+ extentsChangedCB: function() {
var olControl = this.control;
if(olControl && olControl.active)
{
@@ -204,7 +224,7 @@
}
},
- updateMarkers : function(geom) {
+ updateMarkers: function(geom) {
var v = geom.getVertices();
for(var i = 0; i < this.distanceMarkers.length; i++)
{
More information about the fusion-commits
mailing list