Ext.namespace("GeoExt.ux")
GeoExt.ux.Measure=Ext.extend(GeoExt.Action,{tip:null,template:null,decimals:2,constructor:function(config){config=config||{};config.control=this.createControl(config.handlerClass,config.styleMap||this.createStyleMap(),config.controlOptions);delete config.handlerClass;delete config.styleMap;delete config.controlOptions;if(typeof(config.template)=="string"){this.template=new Ext.XTemplate(config.template,{decimals:config.decimals===undefined?this.decimals:config.decimals,compiled:true});}else if(config.template instanceof Ext.XTemplate){this.template=config.template;}
delete config.template;delete config.decimals;arguments.callee.superclass.constructor.call(this,config);},createControl:function(handlerClass,styleMap,controlOptions){controlOptions=Ext.apply({persist:true,eventListeners:{"measure":this.display,"deactivate":this.cleanup,"measurepartial":this.cleanup,scope:this},handlerOptions:{layerOptions:{styleMap:styleMap}}},controlOptions);return new OpenLayers.Control.Measure(handlerClass,controlOptions);},cleanup:function(){if(this.tip){this.tip.destroy();this.tip=null;}},makeString:function(event){return this.template.apply(event);},display:function(event){this.cleanup();this.tip=new Ext.Tip({html:this.makeString(event),closable:true,draggable:false,listeners:{hide:function(){this.control.cancel();this.cleanup();},scope:this}});Ext.getBody().on("mousemove",function(e){this.tip.showAt(e.getXY());},this,{single:true});},createStyleMap:function(){var sketchSymbolizers={"Point":{pointRadius:4,graphicName:"square",fillColor:"white",fillOpacity:1,strokeWidth:1,strokeOpacity:1,strokeColor:"#333333"},"Line":{strokeWidth:2,strokeOpacity:1,strokeColor:"#666666",strokeDashstyle:"dash"},"Polygon":{strokeWidth:2,strokeOpacity:1,strokeColor:"#666666",fillColor:"white",fillOpacity:0.3}};return new OpenLayers.StyleMap({"default":new OpenLayers.Style(null,{rules:[new OpenLayers.Rule({symbolizer:sketchSymbolizers})]})});}});;Ext.namespace("GeoExt.ux")
GeoExt.ux.MeasureArea=Ext.extend(GeoExt.ux.Measure,{constructor:function(config){config=Ext.apply({handlerClass:OpenLayers.Handler.Polygon,iconCls:'gx-map-measurearea',tooltip:"Fläche messen:Ende mit Doppelklick",template:'<p>{[values.measure.toFixed(this.decimals)]}&nbsp;'+'{units}<sup>2</sup></p>'},config);arguments.callee.superclass.constructor.call(this,config);}});;Ext.namespace("GeoExt.ux")
GeoExt.ux.MeasureLength=Ext.extend(GeoExt.ux.Measure,{constructor:function(config){config=Ext.apply({handlerClass:OpenLayers.Handler.Path,iconCls:'gx-map-measurelength',tooltip:"Länge messen:Ende mit Doppelklick",template:'<p>{[values.measure.toFixed(this.decimals)]}&nbsp;'+'{units}</p>'},config);arguments.callee.superclass.constructor.call(this,config);}});
