root/sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.Position.js

Revision 1932, 1.8 kB (checked in by fvanderbiest, 6 months ago)

Measure ux: we do not include OpenLayers classes for now

Line 
1 /**
2  * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
3  *
4  * Published under the BSD license.
5  * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
6  * of the license.
7  */
8
9 Ext.namespace("GeoExt.ux")
10
11 /*
12  * @requires GeoExt.ux/Measure.js
13  */
14
15 /** api: (define)
16  *  module = GeoExt.ux.Measure
17  *  class = Position
18  */
19
20 /** api: constructor
21  *  .. class:: Position
22  *
23  *  A GeoExt.Action configured for position measurements
24  *  JSBuild: need to include OpenLayers/Handler/Point.js
25  */
26 GeoExt.ux.Measure.Position = Ext.extend(GeoExt.ux.Measure, {
27    
28     // FIXME: this depends on http://trac.openlayers.org/ticket/2511 for point measurements
29     
30     /** private: method[constructor]
31      */
32     constructor: function(config) {
33         var scope = {decimals: config.decimals || 2};
34        
35         Ext.applyIf(config, {
36             iconCls: 'gx-map-measureposition',
37             tooltip: "Position measurement"
38         });
39        
40         arguments.callee.superclass.constructor.call(this,
41             OpenLayers.Handler.Point, config);
42        
43         if (this.control.map.units == 'degrees' || this.control.map.units == 'dd') {
44             this.template = new Ext.XTemplate(
45                 '<p>{["lon: "+values.geometry.x.toFixed(this.decimals) + "&deg;"]}</p>'+
46                 '<p>{["lat: "+values.geometry.y.toFixed(this.decimals) + "&deg;"]}</p>',
47             scope);
48         } else {
49             this.template = new Ext.XTemplate(
50                 '<p>{["X: "+values.geometry.x.toFixed(this.decimals) '+
51                 '+ " " + values.units]}</p>'+
52                 '<p>{["Y: "+values.geometry.y.toFixed(this.decimals) '+
53                 '+ " " + values.units]}</p>',
54             scope);
55         }
56         this.template.compile();
57     }
58 });
Note: See TracBrowser for help on using the browser.