[Commits] r1945 - in extensions/geoext.ux: examples tests ux ux/Measure ux/Measure/examples ux/Measure/lib ux/Measure/lib/GeoExt.ux ux/Measure/resources ux/Measure/resources/css ux/Measure/resources/images ux/Measure/tests ux/Measure/tests/lib ux/Measure/tests/lib/GeoExt.ux

commits at geoext.org commits at geoext.org
Wed Mar 10 13:48:56 CET 2010


Author: elemoine
Date: 2010-03-10 13:48:56 +0100 (Wed, 10 Mar 2010)
New Revision: 1945

Added:
   extensions/geoext.ux/ux/Measure/
   extensions/geoext.ux/ux/Measure/examples/
   extensions/geoext.ux/ux/Measure/examples/measure.html
   extensions/geoext.ux/ux/Measure/examples/measure.js
   extensions/geoext.ux/ux/Measure/lib/
   extensions/geoext.ux/ux/Measure/lib/GeoExt.ux/
   extensions/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.js
   extensions/geoext.ux/ux/Measure/lib/GeoExt.ux/MeasureArea.js
   extensions/geoext.ux/ux/Measure/lib/GeoExt.ux/MeasureLength.js
   extensions/geoext.ux/ux/Measure/resources/
   extensions/geoext.ux/ux/Measure/resources/css/
   extensions/geoext.ux/ux/Measure/resources/css/measure.css
   extensions/geoext.ux/ux/Measure/resources/images/
   extensions/geoext.ux/ux/Measure/resources/images/ruler.png
   extensions/geoext.ux/ux/Measure/resources/images/ruler_square.png
   extensions/geoext.ux/ux/Measure/tests/
   extensions/geoext.ux/ux/Measure/tests/index.html
   extensions/geoext.ux/ux/Measure/tests/lib/
   extensions/geoext.ux/ux/Measure/tests/lib/GeoExt.ux/
   extensions/geoext.ux/ux/Measure/tests/lib/GeoExt.ux/Measure.html
   extensions/geoext.ux/ux/Measure/tests/lib/GeoExt.ux/MeasureArea.html
   extensions/geoext.ux/ux/Measure/tests/lib/GeoExt.ux/MeasureLength.html
Modified:
   extensions/geoext.ux/examples/index.html
   extensions/geoext.ux/tests/list-tests.html
Log:
add an ux with specific GeoExt.Action's for measuring areas and distances, p=fvanderbiest, r=me. fvanderbiest becomes the maintainer of this ux

Modified: extensions/geoext.ux/examples/index.html
===================================================================
--- extensions/geoext.ux/examples/index.html	2010-03-09 14:12:25 UTC (rev 1944)
+++ extensions/geoext.ux/examples/index.html	2010-03-10 12:48:56 UTC (rev 1945)
@@ -8,6 +8,7 @@
              <li><a href="../ux/GeoNamesSearchCombo/examples/GeoNamesSearchComboExample.html">GeoNames search combobox</a></li> 
              <li><a href="../ux/PrintPreview/examples/PrintPreview.html">PrintPreview using GeoExt.data.PrintProvider</a></li> 
              <li><a href="../ux/SimplePrint/examples/SimplePrint.html">SimplePrint Form using GeoExt.data.PrintProvider</a></li> 
+             <li><a href="../ux/Measure/examples/measure.html">Measure tools</a></li> 
          </ul>
     </body>
 </html>

Modified: extensions/geoext.ux/tests/list-tests.html
===================================================================
--- extensions/geoext.ux/tests/list-tests.html	2010-03-09 14:12:25 UTC (rev 1944)
+++ extensions/geoext.ux/tests/list-tests.html	2010-03-10 12:48:56 UTC (rev 1945)
@@ -2,4 +2,7 @@
   <li>../../geoext.ux/ux/GeoNamesSearchCombo/tests/lib/GeoExt.ux.geonames/GeoNamesSearchCombo.html</li>
   <li>../../geoext.ux/ux/PrintPreview/tests/lib/GeoExt.ux/PrintPreview.html</li>
   <li>../../geoext.ux/ux/SimplePrint/tests/lib/GeoExt.ux/SimplePrint.html</li>
+  <li>../../geoext.ux/ux/Measure/tests/lib/GeoExt.ux/Measure.html</li>
+  <li>../../geoext.ux/ux/Measure/tests/lib/GeoExt.ux/MeasureArea.html</li>
+  <li>../../geoext.ux/ux/Measure/tests/lib/GeoExt.ux/MeasureLength.html</li>
 </ul>

Added: extensions/geoext.ux/ux/Measure/examples/measure.html
===================================================================
--- extensions/geoext.ux/ux/Measure/examples/measure.html	                        (rev 0)
+++ extensions/geoext.ux/ux/Measure/examples/measure.html	2010-03-10 12:48:56 UTC (rev 1945)
@@ -0,0 +1,31 @@
+<html>
+    <head>
+        <title>Measure Actions Example</title>
+
+        <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-3.1.1/resources/css/ext-all.css" /> 
+        <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-3.1.1/examples/shared/examples.css" /> 
+        <link rel="stylesheet" type="text/css" href="../resources/css/measure.css" />
+        <style type="text/css">p {margin-bottom: 0px;}</style>
+        
+        <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.1.1/adapter/ext/ext-base.js"></script> 
+        <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.1.1/ext-all.js"></script>
+        <script src="http://www.openlayers.org/api/2.8/OpenLayers.js"></script>
+        <script type="text/javascript" src="../../../../geoext/lib/GeoExt.js"></script>
+        
+        <!-- script resources for this ux -->
+        <script type="text/javascript" src="../lib/GeoExt.ux/Measure.js"></script>
+        <script type="text/javascript" src="../lib/GeoExt.ux/MeasureArea.js"></script>
+        <script type="text/javascript" src="../lib/GeoExt.ux/MeasureLength.js"></script>
+        
+        <script type="text/javascript" src="measure.js"></script>
+    </head>
+    <body>
+        <h1>Toolbar with GeoExt.ux.Measure actions</h1>
+        
+        <p style="margin-bottom:15px;">This example shows how to use the GeoExt.ux.Measure actions in a toolbar</p>
+        
+        <p style="margin-bottom:15px;">See <a href="measure.js">measure.js</a> for the source code.</p>
+        
+        <div id="content"></div>
+    </body>
+</html>

Added: extensions/geoext.ux/ux/Measure/examples/measure.js
===================================================================
--- extensions/geoext.ux/ux/Measure/examples/measure.js	                        (rev 0)
+++ extensions/geoext.ux/ux/Measure/examples/measure.js	2010-03-10 12:48:56 UTC (rev 1945)
@@ -0,0 +1,34 @@
+Ext.onReady(function() {
+
+    // required for tooltips
+    Ext.QuickTips.init();
+
+    var map = new OpenLayers.Map();
+
+    var measureLength = new GeoExt.ux.MeasureLength({
+        map: map,
+        controlOptions: {
+            geodesic: true
+        },
+        toggleGroup: 'tools'
+    });
+
+    var measureArea = new GeoExt.ux.MeasureArea({
+        map: map,
+        decimals: 0,
+        toggleGroup: 'tools'
+    });
+        
+    var mapPanel = new GeoExt.MapPanel({
+        renderTo: "content",
+        width: 800,
+        height: 350,
+        map: map,
+        layers: [new OpenLayers.Layer.WMS("Global Imagery",
+            "http://labs.metacarta.com/wms/vmap0",
+            {layers: "basic"})],
+        center: [16, 48],
+        zoom: 5,
+        tbar: [measureLength, measureArea]
+    });
+});

Added: extensions/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.js
===================================================================
--- extensions/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.js	                        (rev 0)
+++ extensions/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.js	2010-03-10 12:48:56 UTC (rev 1945)
@@ -0,0 +1,203 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ * 
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
+Ext.namespace("GeoExt.ux")
+
+/*
+ * @requires GeoExt/widgets/Action.js
+ */
+
+/** api: (define)
+ *  module = GeoExt.ux
+ *  class = Measure
+ */
+
+/** api: constructor
+ *  .. class:: Measure(config)
+ *
+ *      Creates a GeoExt.Action for measurements.
+ * 
+ *  JSBuild: OpenLayers/Control/Measure.js, OpenLayers/StyleMap.js,
+ *  OpenLayers/Style.js, OpenLayers/Rule.js, OpenLayers/Handler.js
+ *  must be included.
+ */
+GeoExt.ux.Measure = Ext.extend(GeoExt.Action, {
+
+    /** api: config[handlerClass]
+     *  ``Function`` The handler class to pass to the measure control,
+     *  ``OpenLayers.Handler.Polygon`` for area measurements,
+     *  ``OpenLayers.Handler.Path`` for distance measurements, and
+     *  ``OpenLayers.Handler.Point`` for position measurements.
+     *  Required.
+     */
+
+    /** api: config[styleMap]
+     *  ``OpenLayers.StyleMap`` A style map for the sketch layer. Optional.
+     */
+
+    /** api: config[controlOptions]
+     *  ``Object`` Options to pass to the Measure control. Optional.
+     */
+    
+    /** private: property[tip]
+     *  ``Ext.Tip`` The displayed tip.
+     */
+    tip: null,
+
+    /** api: config[template]
+     *  ``String`` | ``Ext.XTemplate`` HTML template, or Ext.XTemplate used
+     *      to display the measure. Required.
+     */
+    /** private: property[template]
+     *  ``Ext.XTemplate`` The template used for the display of measures.
+     */
+    template: null,
+     
+    /** api: config[decimals]
+     *  ``Integer`` The number of decimals for the displayed values.
+     *    Defaults to 2.
+     */
+    decimals: 2,
+
+    /** private: method[constructor]
+     */
+    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);
+    },
+
+    /** private: method[createControl]
+     *  Creates the measure control.
+     *
+     *  :param handlerClass: ``Function`` The handler class the measure
+     *      control is configured with.
+     *  :param styleMap: ``OpenLayers.StyleMap`` The style map used for
+     *      the sketch layer.
+     *  :param controlOptions: ``Object`` Extra options to set in the
+     *      measure control.
+     *
+     *  :return: ``OpenLayers.Control.Measure`` The mesure control.
+     */
+    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);
+    },
+    
+    /** private: method[cleanup]
+     *  Destroys the tip.
+     */
+    cleanup: function() {
+        if(this.tip) {
+            this.tip.destroy();
+            this.tip = null;
+        }
+    },
+    
+    /** private: method[makeString]
+     *  Builds the HTML string for the tip.
+     *
+     *  :param event ``Object`` The event object.
+     *
+     *  :return: ``String`` The HTML string.
+     */
+    makeString: function(event) {
+        return this.template.apply(event);
+    },
+
+    /** private: method[display]
+     *  Creates and displays the tip.
+     *
+     *  :param event ``Object`` The event object.
+     */
+    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});
+    },
+
+    /** private: method[createStyleMap]
+     *  Creates the default style map.
+     *
+     *  :return: ``OpenLayers.StyleMap`` The style map.
+     */
+    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})]
+            })
+        });
+    }
+});

Added: extensions/geoext.ux/ux/Measure/lib/GeoExt.ux/MeasureArea.js
===================================================================
--- extensions/geoext.ux/ux/Measure/lib/GeoExt.ux/MeasureArea.js	                        (rev 0)
+++ extensions/geoext.ux/ux/Measure/lib/GeoExt.ux/MeasureArea.js	2010-03-10 12:48:56 UTC (rev 1945)
@@ -0,0 +1,41 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ * 
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
+Ext.namespace("GeoExt.ux")
+
+/*
+ * @requires GeoExt.ux/Measure.js
+ */
+
+/** api: (define)
+ *  module = GeoExt.ux.MeasureArea
+ *  class = MeasureArea
+ */
+
+/** api: constructor
+ *  .. class:: MeasureArea(config)
+ *
+ *      Creates a GeoExt.Action for area measurements.
+ * 
+ *  JSBuild: OpenLayers/Handler/Polygon.js must be included.
+ */
+GeoExt.ux.MeasureArea = Ext.extend(GeoExt.ux.Measure, {
+    
+    /** private: method[constructor]
+     */
+    constructor: function(config) {
+        config = Ext.apply({
+            handlerClass: OpenLayers.Handler.Polygon,
+            iconCls: 'gx-map-measurearea',
+            tooltip: "Area measurement",
+            template: '<p>{[values.measure.toFixed(this.decimals)]}&nbsp;'+
+                '{units}<sup>2</sup></p>'
+        }, config);
+        arguments.callee.superclass.constructor.call(this, config);
+    }
+});

Added: extensions/geoext.ux/ux/Measure/lib/GeoExt.ux/MeasureLength.js
===================================================================
--- extensions/geoext.ux/ux/Measure/lib/GeoExt.ux/MeasureLength.js	                        (rev 0)
+++ extensions/geoext.ux/ux/Measure/lib/GeoExt.ux/MeasureLength.js	2010-03-10 12:48:56 UTC (rev 1945)
@@ -0,0 +1,41 @@
+/**
+ * Copyright (c) 2008-2009 The Open Source Geospatial Foundation
+ * 
+ * Published under the BSD license.
+ * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text
+ * of the license.
+ */
+
+Ext.namespace("GeoExt.ux")
+
+/*
+ * @requires GeoExt.ux/Measure.js
+ */
+
+/** api: (define)
+ *  module = GeoExt.ux.MeasureLength
+ *  class = MeasureLength
+ */
+
+/** api: constructor
+ *  .. class:: MeasureLength
+ * 
+ *      Creates a GeoExt.Action for length measurements.
+ *
+ *  JSBuild: OpenLayers/Handler/Path.js must be included.
+ */
+GeoExt.ux.MeasureLength = Ext.extend(GeoExt.ux.Measure, {
+    
+    /** private: method[constructor]
+     */
+    constructor: function(config) {
+        config = Ext.apply({
+            handlerClass: OpenLayers.Handler.Path,
+            iconCls: 'gx-map-measurelength',
+            tooltip: "Length measurement",
+            template: '<p>{[values.measure.toFixed(this.decimals)]}&nbsp;'+
+                '{units}</p>'
+        }, config);
+        arguments.callee.superclass.constructor.call(this, config);
+    }
+});

Added: extensions/geoext.ux/ux/Measure/resources/css/measure.css
===================================================================
--- extensions/geoext.ux/ux/Measure/resources/css/measure.css	                        (rev 0)
+++ extensions/geoext.ux/ux/Measure/resources/css/measure.css	2010-03-10 12:48:56 UTC (rev 1945)
@@ -0,0 +1,6 @@
+.x-toolbar .gx-map-measurelength {
+    background: url('../images/ruler.png') top left no-repeat;
+}
+.x-toolbar .gx-map-measurearea {
+    background: url('../images/ruler_square.png') top left no-repeat;
+}

Added: extensions/geoext.ux/ux/Measure/resources/images/ruler.png
===================================================================
--- extensions/geoext.ux/ux/Measure/resources/images/ruler.png	                        (rev 0)
+++ extensions/geoext.ux/ux/Measure/resources/images/ruler.png	2010-03-10 12:48:56 UTC (rev 1945)
@@ -0,0 +1,8 @@
+‰PNG
+
+   
+IHDR         óÿa   tEXtSoftware Adobe ImageReadyqÉe<  îIDATxÚ¤SÏkQþÞîKb²›ßivÕR‚±ŠÒ»Ô¿ÁsÐCÅ£ *xÄâIñêÅ›(xÔ‹ 
+6P’¶Û„ 
+¥Kók³;Î&vÝ®‚òófvæã›÷íˆ×5	ˆÉ³ Š©­ð Û#SÛxâ"éWs³?sýÉU×qðfåâŠø'“r„jÛ¦ó›õ:f°¤îò·ïDø59ã乏¯Ô_>…97§ß‡yêìbuéÂb»ÙÄáJa~v~¯n×î+{i»Ö­m´
+x®‹žm£»µ…D,v ÷{ü^¹; ëÙ½kÏ)±`½T1ƒõOïšÞ¿ýø×ùXrìá–´ºô¨½±QË
+H¨xÁ©å¾C‘ ɘ€ÔâZœ#îŒibÈ\‚ZÖ:60GƒHëkP?aYÈær`Vy‹šÀ·=`"+F ¸(•ËSÔýd>)Ðí#7D~ÙôöÏêB«…t&Ã#úkQ6	ìôœyìHÀ@K%¦äï…é`ÿ‘ŸAB9ÍÚ꺎Ññ0º¬ƒxôDšFpÎü;¼öˆÒQ7Ÿ=$ò%T`ðCk~¯>¼sS›Ü¦ÀjØ.e¸q6«ð¶QþǾ0 Îìka”W    IEND®B`‚
\ No newline at end of file

Added: extensions/geoext.ux/ux/Measure/resources/images/ruler_square.png
===================================================================
--- extensions/geoext.ux/ux/Measure/resources/images/ruler_square.png	                        (rev 0)
+++ extensions/geoext.ux/ux/Measure/resources/images/ruler_square.png	2010-03-10 12:48:56 UTC (rev 1945)
@@ -0,0 +1,11 @@
+‰PNG
+
+   
+IHDR         óÿa   tEXtSoftware Adobe ImageReadyqÉe<  nIDATxÚŒR_HSQÿÝ?fÒ̶5›±±dà@Á
+!Vb£zzð!ª‡z
+‚ êA"è!JÈ¡£^
+¢+¨²(ë¥DeŽFܹÉfcaÕ–÷ÞsOßÙ¼¦?øñ>Î÷ûýÎ÷iì„
+@ÎP
+¡Õ†%Ô¾”UÔšaq´E/Ü;Çïoœ×ê^‚ ªLŒQ¦ëÐff09Ïuùk>0\%°•ÏG`Yü ÄzÛñ¾özÝ¡}–‰@ÊŒ1pÂ\*…I­£\†¯Ê6DAäªmìú©AÓâûwDtlóùà,}žþ0ôåÍxÚtuÔ‘…ÚÑÓçûZƒÁ*ÁÊÜbôZƒáŽÅXG.“Á‹	6ÙVÎrRhn”ñÊ·ƒá0ôJŒseù	:*&§"Ë4áñzÑÓ¡è5Ë…ÇÛ$kÑ	0ºC‚ŠP+†½Q" |Ïå0ú‰m…]aãq=]UÁÊöP¨æ€DAˆËôv,AÜn7b»ei©oq ùŸ¹"Çë)Ö4›L֐۲ü%çªùÛªpPÈçñô˜/îsH
+4ÃÑ„†½eO+­x‘ä~ð}-›ñ€į̂&[&hÿÀéráæÈ•¾l6¿ßÈÁZ~x÷2š†­";;C½ÇB£CËÇŸ0üÒy3'AR¦];ÎU9ì7á#"árQ7`Ðß=ª-ÿGGrd ßQï÷ͦy›7’ñ¸hFéo‰…‰©þ¯’„$홯ƒ‡¥W…—WyîÙe.Îv]Å:c:ùß×.}çT»þO€ Þu®ö
+¾    IEND®B`‚
\ No newline at end of file

Added: extensions/geoext.ux/ux/Measure/tests/index.html
===================================================================
--- extensions/geoext.ux/ux/Measure/tests/index.html	                        (rev 0)
+++ extensions/geoext.ux/ux/Measure/tests/index.html	2010-03-10 12:48:56 UTC (rev 1945)
@@ -0,0 +1,4 @@
+<html>
+    <head><meta http-equiv="refresh" content="0;url=../../../../geoext/tests/run-tests.html?testlist=../../geoext.ux/ux/Measure/tests/list-tests.html"></head>
+    <body></body>
+</html>

Added: extensions/geoext.ux/ux/Measure/tests/lib/GeoExt.ux/Measure.html
===================================================================
--- extensions/geoext.ux/ux/Measure/tests/lib/GeoExt.ux/Measure.html	                        (rev 0)
+++ extensions/geoext.ux/ux/Measure/tests/lib/GeoExt.ux/Measure.html	2010-03-10 12:48:56 UTC (rev 1945)
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html debug="true">
+  <head>
+    <script type="text/javascript" src="http://www.openlayers.org/api/2.8/OpenLayers.js"></script>
+    <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.1.1/adapter/ext/ext-base.js"></script> 
+    <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.1.1/ext-all.js"></script>
+    <script type="text/javascript" src="../../../../../../geoext/lib/GeoExt.js"></script>
+    <script type="text/javascript" src="../../../lib/GeoExt.ux/Measure.js"></script>
+
+    <script type="text/javascript">
+        function test_ctor(t) {
+            t.plan(9);
+
+            // set up
+
+            var action;
+
+            var map = new OpenLayers.Map("map");
+
+            // test
+
+            action = new GeoExt.ux.Measure({
+                handlerClass: OpenLayers.Handler.Polygon,
+                template: "a template string",
+                map: map
+            });
+            t.ok(action instanceof GeoExt.ux.Measure,
+                 "ctor returns a GeoExt.ux.Measure");
+            t.ok(action instanceof GeoExt.Action,
+                 "ctor returns a GeoExt.Action");
+            t.ok(action.template instanceof Ext.XTemplate,
+                 "ctor creates an XTemplate");
+            t.ok(action.control instanceof OpenLayers.Control.Measure,
+                 "ctor creates a measure control");
+            t.ok(action.control.handler instanceof OpenLayers.Handler.Polygon,
+                 "ctor creates a measure control with correct handler type");
+            t.eq(action.control.persist, true,
+                 "ctor creates measure control with persist set to true");
+
+            action.control.activate();
+            t.ok(action.control.handler.layer.styleMap instanceof OpenLayers.StyleMap,
+                 "ctor provides a default style map for the sketch layer");
+
+            var styleMap = new OpenLayers.StyleMap();
+            action = new GeoExt.ux.Measure({
+                handlerClass: OpenLayers.Handler.Polygon,
+                template: "a template string",
+                map: map,
+                styleMap: styleMap,
+                controlOptions: {foo: "foo"}
+            });
+            action.control.activate();
+            t.ok(action.control.handler.layer.styleMap == styleMap,
+                 "ctor passes user-provider style map to sketch layer");
+            t.eq(action.control.foo, "foo",
+                 "ctor sets user-provider control options");
+
+            // tear down
+        }
+    </script>
+  <body>
+    <div id="map" style="width:600px;height:400px;"></div>
+  </body>
+</html>

Added: extensions/geoext.ux/ux/Measure/tests/lib/GeoExt.ux/MeasureArea.html
===================================================================
--- extensions/geoext.ux/ux/Measure/tests/lib/GeoExt.ux/MeasureArea.html	                        (rev 0)
+++ extensions/geoext.ux/ux/Measure/tests/lib/GeoExt.ux/MeasureArea.html	2010-03-10 12:48:56 UTC (rev 1945)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html debug="true">
+  <head>
+    <script type="text/javascript" src="http://www.openlayers.org/api/2.8/OpenLayers.js"></script>
+    <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.1.1/adapter/ext/ext-base.js"></script> 
+    <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.1.1/ext-all.js"></script>
+    <script type="text/javascript" src="../../../../../../geoext/lib/GeoExt.js"></script>
+    <script type="text/javascript" src="../../../lib/GeoExt.ux/Measure.js"></script>
+    <script type="text/javascript" src="../../../lib/GeoExt.ux/MeasureArea.js"></script>
+
+    <script type="text/javascript">
+        function test_ctor(t) {
+            t.plan(4);
+
+            // set up
+
+            var action;
+
+            // test
+
+            action = new GeoExt.ux.MeasureArea();
+            t.ok(action instanceof GeoExt.ux.MeasureArea,
+                 "ctor returns a GeoExt.ux.MeasureArea");
+            t.ok(action instanceof GeoExt.ux.Measure,
+                 "ctor returns a GeoExt.ux.Measure");
+            t.ok(action.template instanceof Ext.XTemplate,
+                 "ctor creates an XTemplate");
+            t.ok(action.control.handler instanceof OpenLayers.Handler.Polygon,
+                 "ctor creates a measure control with a polygon handler");
+
+            // tear down
+        }
+    </script>
+  <body>
+  </body>
+</html>

Added: extensions/geoext.ux/ux/Measure/tests/lib/GeoExt.ux/MeasureLength.html
===================================================================
--- extensions/geoext.ux/ux/Measure/tests/lib/GeoExt.ux/MeasureLength.html	                        (rev 0)
+++ extensions/geoext.ux/ux/Measure/tests/lib/GeoExt.ux/MeasureLength.html	2010-03-10 12:48:56 UTC (rev 1945)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html debug="true">
+  <head>
+    <script type="text/javascript" src="http://www.openlayers.org/api/2.8/OpenLayers.js"></script>
+    <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.1.1/adapter/ext/ext-base.js"></script> 
+    <script type="text/javascript" src="http://extjs.cachefly.net/ext-3.1.1/ext-all.js"></script>
+    <script type="text/javascript" src="../../../../../../geoext/lib/GeoExt.js"></script>
+    <script type="text/javascript" src="../../../lib/GeoExt.ux/Measure.js"></script>
+    <script type="text/javascript" src="../../../lib/GeoExt.ux/MeasureLength.js"></script>
+
+    <script type="text/javascript">
+        function test_ctor(t) {
+            t.plan(4);
+
+            // set up
+
+            var action;
+
+            // test
+
+            action = new GeoExt.ux.MeasureLength();
+            t.ok(action instanceof GeoExt.ux.MeasureLength,
+                 "ctor returns a GeoExt.ux.MeasureLength");
+            t.ok(action instanceof GeoExt.ux.Measure,
+                 "ctor returns a GeoExt.ux.Measure");
+            t.ok(action.template instanceof Ext.XTemplate,
+                 "ctor creates an XTemplate");
+            t.ok(action.control.handler instanceof OpenLayers.Handler.Path,
+                 "ctor creates a measure control with a path handler");
+
+            // tear down
+        }
+    </script>
+  <body>
+  </body>
+</html>



More information about the Commits mailing list