[Commits] r1930 - in sandbox/fvanderbiest: . geoext.ux geoext.ux/ux geoext.ux/ux/Measure geoext.ux/ux/Measure/examples geoext.ux/ux/Measure/lib geoext.ux/ux/Measure/lib/GeoExt.ux geoext.ux/ux/Measure/resources geoext.ux/ux/Measure/resources/css geoext.ux/ux/Measure/resources/images
commits at geoext.org
commits at geoext.org
Mon Mar 8 18:12:34 CET 2010
Author: fvanderbiest
Date: 2010-03-08 18:12:34 +0100 (Mon, 08 Mar 2010)
New Revision: 1930
Added:
sandbox/fvanderbiest/geoext.ux/
sandbox/fvanderbiest/geoext.ux/ux/
sandbox/fvanderbiest/geoext.ux/ux/Measure/
sandbox/fvanderbiest/geoext.ux/ux/Measure/examples/
sandbox/fvanderbiest/geoext.ux/ux/Measure/examples/Measure.html
sandbox/fvanderbiest/geoext.ux/ux/Measure/examples/Measure.js
sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/
sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/
sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.Area.js
sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.Length.js
sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.Position.js
sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.js
sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/
sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/css/
sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/css/measure.css
sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/images/
sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/images/bullet_orange.gif
sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/images/ruler.png
sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/images/ruler_square.png
sandbox/fvanderbiest/geoext.ux/ux/Measure/tests/
Log:
GeoExt.ux.Measure on stage
Added: sandbox/fvanderbiest/geoext.ux/ux/Measure/examples/Measure.html
===================================================================
--- sandbox/fvanderbiest/geoext.ux/ux/Measure/examples/Measure.html (rev 0)
+++ sandbox/fvanderbiest/geoext.ux/ux/Measure/examples/Measure.html 2010-03-08 17:12:34 UTC (rev 1930)
@@ -0,0 +1,30 @@
+<html>
+ <head>
+ <title>Measure Actions Example</title>
+
+ <script type="text/javascript" src="http://extjs.cachefly.net/ext-2.2.1/adapter/ext/ext-base.js"></script>
+ <script type="text/javascript" src="http://extjs.cachefly.net/ext-2.2.1/ext-all.js"></script>
+ <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/resources/css/ext-all.css" />
+ <link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-2.2.1/examples/shared/examples.css" />
+ <link rel="stylesheet" type="text/css" src="../resources/css/measure.css" />
+ <script src="http://dev.openlayers.org/nightly/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/Measure.Area.js"></script>
+ <script type="text/javascript" src="../lib/GeoExt.ux/Measure.Length.js"></script>
+ <script type="text/javascript" src="../lib/GeoExt.ux/Measure.Position.js"></script>
+
+ <script type="text/javascript" src="Measure.js"></script>
+ </head>
+ <body>
+ <h1>Toolbar with GeoExt.ux.Measure actions</h1>
+
+ <p>This example shows how to use the GeoExt.ux.Measure actions in a toolbar</p>
+
+ <p>See <a href="Measure.js">Measure.js</a> for the source code.</p>
+
+ <div id="content"></div>
+ </body>
+</html>
Added: sandbox/fvanderbiest/geoext.ux/ux/Measure/examples/Measure.js
===================================================================
--- sandbox/fvanderbiest/geoext.ux/ux/Measure/examples/Measure.js (rev 0)
+++ sandbox/fvanderbiest/geoext.ux/ux/Measure/examples/Measure.js 2010-03-08 17:12:34 UTC (rev 1930)
@@ -0,0 +1,37 @@
+Ext.onReady(function() {
+ // required for tooltips:
+ Ext.QuickTips.init();
+
+ var map = new OpenLayers.Map();
+
+ var measureLength = new GeoExt.ux.Measure.Length({
+ map: map,
+ toggleGroup: 'tools'
+ });
+
+ var measureArea = new GeoExt.ux.Measure.Area({
+ map: map,
+ decimals: 0,
+ toggleGroup: 'tools'
+ });
+
+ var measurePosition = new GeoExt.ux.Measure.Position({
+ map: map,
+ decimals: 6,
+ 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, measurePosition]
+ });
+
+});
Added: sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.Area.js
===================================================================
--- sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.Area.js (rev 0)
+++ sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.Area.js 2010-03-08 17:12:34 UTC (rev 1930)
@@ -0,0 +1,40 @@
+/**
+ * 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
+ * @include OpenLayers/Handler/Polygon.js
+ */
+
+/** api: (define)
+ * module = GeoExt.ux.Measure
+ * class = Area
+ */
+
+/** api: constructor
+ * .. class:: Area
+ *
+ * A GeoExt.Action configured for area measurements
+ */
+GeoExt.ux.Measure.Area = Ext.extend(GeoExt.ux.Measure, {
+
+ /** private: method[constructor]
+ */
+ constructor: function(config) {
+ Ext.applyIf(config, {
+ iconCls: 'gx-map-measurearea',
+ tooltip: "Area measurement",
+ template: '<p>{[values.measure.toFixed(this.decimals) + " "'
+ +'+ values.units + "<sup>2</sup>"]}</p>'
+ });
+ arguments.callee.superclass.constructor.call(this,
+ OpenLayers.Handler.Polygon, config);
+ }
+});
Added: sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.Length.js
===================================================================
--- sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.Length.js (rev 0)
+++ sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.Length.js 2010-03-08 17:12:34 UTC (rev 1930)
@@ -0,0 +1,40 @@
+/**
+ * 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
+ * @include OpenLayers/Handler/Path.js
+ */
+
+/** api: (define)
+ * module = GeoExt.ux.Measure
+ * class = Area
+ */
+
+/** api: constructor
+ * .. class:: Length
+ *
+ * A GeoExt.Action configured for length measurements
+ */
+GeoExt.ux.Measure.Length = Ext.extend(GeoExt.ux.Measure, {
+
+ /** private: method[constructor]
+ */
+ constructor: function(config) {
+ Ext.applyIf(config, {
+ iconCls: 'gx-map-measurelength',
+ tooltip: "Length measurement",
+ template: '<p>{[values.measure.toFixed(this.decimals) + " "'+
+ '+ values.units]}</p>'
+ });
+ arguments.callee.superclass.constructor.call(this,
+ OpenLayers.Handler.Path, config);
+ }
+});
Added: sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.Position.js
===================================================================
--- sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.Position.js (rev 0)
+++ sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.Position.js 2010-03-08 17:12:34 UTC (rev 1930)
@@ -0,0 +1,58 @@
+/**
+ * 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
+ * @include OpenLayers/Handler/Point.js
+ */
+
+/** api: (define)
+ * module = GeoExt.ux.Measure
+ * class = Position
+ */
+
+/** api: constructor
+ * .. class:: Position
+ *
+ * A GeoExt.Action configured for position measurements
+ */
+GeoExt.ux.Measure.Position = Ext.extend(GeoExt.ux.Measure, {
+
+ // FIXME: this depends on http://trac.openlayers.org/ticket/2511 for point measurements
+
+ /** private: method[constructor]
+ */
+ constructor: function(config) {
+ var scope = {decimals: config.decimals || 2};
+
+ Ext.applyIf(config, {
+ iconCls: 'gx-map-measureposition',
+ tooltip: "Position measurement"
+ });
+
+ arguments.callee.superclass.constructor.call(this,
+ OpenLayers.Handler.Point, config);
+
+ if (this.control.map.units == 'degrees' || this.control.map.units == 'dd') {
+ this.template = new Ext.XTemplate(
+ '<p>{["lon: "+values.geometry.x.toFixed(this.decimals) + "°"]}</p>'+
+ '<p>{["lat: "+values.geometry.y.toFixed(this.decimals) + "°"]}</p>',
+ scope);
+ } else {
+ this.template = new Ext.XTemplate(
+ '<p>{["X: "+values.geometry.x.toFixed(this.decimals) '+
+ '+ " " + values.units]}</p>'+
+ '<p>{["Y: "+values.geometry.y.toFixed(this.decimals) '+
+ '+ " " + values.units]}</p>',
+ scope);
+ }
+ this.template.compile();
+ }
+});
Added: sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.js
===================================================================
--- sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.js (rev 0)
+++ sandbox/fvanderbiest/geoext.ux/ux/Measure/lib/GeoExt.ux/Measure.js 2010-03-08 17:12:34 UTC (rev 1930)
@@ -0,0 +1,186 @@
+/**
+ * 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
+ * @include OpenLayers/Control/Measure.js
+ * @include OpenLayers/StyleMap.js
+ * @include OpenLayers/Style.js
+ * @include OpenLayers/Rule.js
+ * @include OpenLayers/Handler.js
+ */
+
+/** api: (define)
+ * module = GeoExt.ux
+ * class = Measure
+ */
+
+/** api: constructor
+ * .. class:: Measure
+ *
+ * A GeoExt.Action configured with an OpenLayers.Control.Measure
+ */
+GeoExt.ux.Measure = Ext.extend(GeoExt.Action, {
+
+ /** api: config[styleMap]
+ * ``OpenLayers.StyleMap`` Optional StyleMap for the sketches
+ */
+
+ /** 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.
+ */
+ /** api: property[template]
+ * ``Ext.XTemplate`` The template to display the measure.
+ */
+ template: null,
+
+ /** api: config[decimals]
+ * ``Integer`` The number of decimals for the displayed values.
+ * Defaults to 2.
+ */
+
+ /** private: method[constructor]
+ */
+ constructor: function(handler, config) {
+ config.control = this.buildControl({
+ handler: handler,
+ styleMap: config.styleMap || this.styleMap()
+ });
+ delete config.styleMap;
+ if (typeof(config.template) == "string") {
+ this.template = new Ext.XTemplate(config.template, {
+ decimals: config.decimals || 2,
+ 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[buildControl]
+ * Private method to build the Measure control.
+ *
+ * :param options ``Object`` A hash with keys:
+ * - handler: a reference to the OpenLayers.Handler class.
+ * - styleMap: an OpenLayers.StyleMap for sketches.
+ *
+ * :return: ``OpenLayers.Control.Measure`` The configured control.
+ */
+ buildControl: function(options) {
+ var listeners = {
+ "measure": OpenLayers.Function.bind(this.display, this),
+ "deactivate": OpenLayers.Function.bind(this.cleanup, this),
+ "measurepartial": OpenLayers.Function.bind(this.cleanup, this)
+ };
+ return new OpenLayers.Control.Measure(
+ options.handler, {
+ persist: true,
+ eventListeners: listeners,
+ handlerOptions: {
+ layerOptions: {
+ styleMap: options.styleMap
+ }
+ }
+ }
+ );
+ },
+
+ /** private: method[cleanup]
+ * Private method to destroy the tip.
+ */
+ cleanup: function() {
+ if (this.tip) {
+ this.tip.destroy();
+ this.tip = null;
+ }
+ },
+
+ /** private: method[makeString]
+ * Private method to build the HTML string.
+ *
+ * :param event ``Object`` The event object.
+ *
+ * :return: ``String`` The HTML string.
+ */
+ makeString: function(event) {
+ return this.template.apply(event);
+ },
+
+ /** private: method[display]
+ * Private method to create and display 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[styleMap]
+ * Private method to build the OpenLayers StyleMap.
+ *
+ * :return: ``OpenLayers.StyleMap`` The StyleMap.
+ */
+ styleMap: 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})]
+ })
+ });
+ }
+});
\ No newline at end of file
Added: sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/css/measure.css
===================================================================
--- sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/css/measure.css (rev 0)
+++ sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/css/measure.css 2010-03-08 17:12:34 UTC (rev 1930)
@@ -0,0 +1,9 @@
+.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;
+}
+.x-toolbar .gx-map-measureposition {
+ background: url('../images/bullet_orange.gif') top left no-repeat;
+}
\ No newline at end of file
Added: sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/images/bullet_orange.gif
===================================================================
(Binary files differ)
Property changes on: sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/images/bullet_orange.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/images/ruler.png
===================================================================
(Binary files differ)
Property changes on: sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/images/ruler.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/images/ruler_square.png
===================================================================
(Binary files differ)
Property changes on: sandbox/fvanderbiest/geoext.ux/ux/Measure/resources/images/ruler_square.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
More information about the Commits
mailing list