[OpenLayers-Commits] r2304 - in sandbox/oterral/ButtonBar/vector/lib/OpenLayers: . Button Button/EditingButton

commits at openlayers.org commits at openlayers.org
Mon Mar 5 05:04:05 EST 2007


Author: oterral
Date: 2007-03-05 05:04:02 -0500 (Mon, 05 Mar 2007)
New Revision: 2304

Added:
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/DragPan.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingAttributes.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/AddPathPoint.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawLineString.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawLinearRing.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawMultiLineString.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawMultiPolygon.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawPoint.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawPolygon.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/MovePathPoint.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/RemovePathPoint.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/Selection.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/MeasureArea.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/MeasureDistance.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/Reset.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/ZoomIn.js
   sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/ZoomOut.js
Log:
add Button/EditingButton folder

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/DragPan.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/DragPan.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/DragPan.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,189 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
+ * for the full text of the license. */
+
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Button.js
+ */
+OpenLayers.Button.DragPan = OpenLayers.Class.create();
+OpenLayers.Button.DragPan.prototype =
+OpenLayers.Class.inherit( OpenLayers.Button, {
+
+	 /** @type String */
+	id: "dragpan",
+    imageOn:"PanEnable.png",
+    imageOff:"PanDisable.png",
+    type:"RadioButton",
+    cursor:"move",
+    
+    /*
+     * @constructor
+     */
+    initialize: function( options ) {
+        OpenLayers.Button.prototype.initialize.apply(this, arguments);  
+    },
+    
+    /**
+    * @param {Event} evt
+    */
+    mouseDown: function(evt) {
+    	this.map.div.style.cursor = "move";
+        if (!OpenLayers.Event.isLeftClick(evt))
+            return;
+
+        this.mouseDragStart = evt.xy.clone();
+        this.performedDrag  = false;
+        document.onselectstart = function() { return false; }
+        OpenLayers.Event.stop(evt);
+    },
+
+    /**
+    * @param {Event} evt
+    */
+    mouseMove: function(evt) {
+        // record the mouse position, used in onWheelEvent
+        this.mousePosition = evt.xy.clone();
+        //this.map.div.style.cursor = "move";
+        if (this.mouseDragStart != null) {
+           
+                var deltaX = this.mouseDragStart.x - evt.xy.x;
+                var deltaY = this.mouseDragStart.y - evt.xy.y;
+                var size = this.map.getSize();
+                var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
+                                                 size.h / 2 + deltaY);
+                var newCenter = this.map.getLonLatFromViewPortPx(newXY);
+                this.map.setCenter(newCenter, null, true);
+                this.mouseDragStart = evt.xy.clone();
+                
+            }
+            this.performedDrag = true;
+        
+    },
+	 /**
+    * @param {Event} evt
+    */
+    mouseUp: function(evt) {
+        if (!OpenLayers.Event.isLeftClick(evt)) 
+            return;
+
+            if (this.performedDrag) {
+                this.map.setCenter(this.map.center);
+            }
+        
+        document.onselectstart = null;
+        this.mouseDragStart = null;
+        this.map.div.style.cursor = this.cursor;
+    },
+    /**
+    * @param {Event} evt
+    */
+    mouseOut: function(evt) {
+        if (this.mouseDragStart != null &&
+            OpenLayers.Util.mouseLeft(evt, this.map.div)) {
+                this.mouseDragStart = null;
+            }
+    },
+
+	/**
+	 *  Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/
+	 */
+
+    /** Catch the wheel event and handle it xbrowserly
+     *
+     * @param {Event} e
+     */
+    mouseWheel: function(evt) {
+        // first determine whether or not the wheeling was inside the map
+        var inMap = false;
+        var elem = OpenLayers.Event.element(evt);
+
+        while(elem != null) {
+            if (this.map && elem == this.map.div) {
+                inMap = true;
+                break;
+            }
+            elem = elem.parentNode;
+        }
+
+        if (inMap) {
+
+            var delta = 0;
+            if (!evt) {
+                evt = window.event;
+            }
+            if (evt.wheelDelta) {
+                delta = evt.wheelDelta/120;
+                if (window.opera) {
+                    delta = -delta;
+                }
+            } else if (evt.detail) {
+                delta = -evt.detail / 3;
+            }
+            if (delta) {
+                // add the mouse position to the event because mozilla has a bug
+                // with clientX and clientY (see https://bugzilla.mozilla.org/show_bug.cgi?id=352179)
+                // getLonLatFromViewPortPx(e) returns wrong values
+                evt.xy = this.mousePosition;
+
+                if (delta < 0) {
+                    this.mouseWheelDown(evt);
+                } else {
+                    this.mouseWheelUp(evt);
+                }
+            }
+
+            //only wheel the map, not the window
+            OpenLayers.Event.stop(evt);
+        }
+    },
+
+    /** User spun scroll wheel up
+     *
+     */
+    mouseWheelUp: function(evt) {
+
+        if (this.map.getZoom() <= this.map.getNumZoomLevels()) {
+            var mouse = this.map.getLonLatFromPixel(evt.xy);
+            var center = this.map.getCenter();
+            var resolution = this.map.getResolution();
+            var mouseToCenter = new OpenLayers.Pixel((mouse.lon - center.lon) / resolution,
+                                                     (mouse.lat - center.lat) / resolution);
+
+            var nextResolution = this.map.getResolution(this.map.getZoom() + 1);
+
+            this.map.setCenter(new OpenLayers.LonLat(center.lon + (mouseToCenter.x * nextResolution),
+                                                     center.lat + (mouseToCenter.y * nextResolution)),
+                               this.map.getZoom() + 1);
+        }
+
+    },
+
+    /** User spun scroll wheel down
+     *
+     */
+    mouseWheelDown: function(evt) {
+        if (this.map.getZoom() > 0) {
+            var mouse = this.map.getLonLatFromPixel(evt.xy);
+            var center = this.map.getCenter();
+            var resolution = this.map.getResolution();
+            var mouseToCenter = new OpenLayers.Pixel((mouse.lon - center.lon) / resolution,
+                                                     (mouse.lat - center.lat) / resolution);
+
+            var prevResolution = this.map.getResolution(this.map.getZoom() - 1);
+
+
+            this.map.setCenter(new OpenLayers.LonLat(mouse.lon - (mouseToCenter.x * prevResolution),
+                                                     mouse.lat - (mouseToCenter.y * prevResolution)),
+                               this.map.getZoom() - 1);
+        }
+
+    },
+
+   
+
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Button.DragPan"
+});

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingAttributes.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingAttributes.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingAttributes.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,250 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+ 
+ /**
+ * @class
+ *
+ * @requires OpenLayers/Button/EditingButton.js
+ */
+OpenLayers.Button.EditingAttributes = OpenLayers.Class.create();
+OpenLayers.Button.EditingAttributes.prototype = OpenLayers.Class.inherit( OpenLayers.Button.EditingButton, {
+
+    /** @type String */
+    activeColor:"blue",
+    
+     /** @type String */
+	id: "editingattributes",
+	
+	/** @type String */
+    imageOn:"QueryEnable.png",
+    
+    /** @type String */
+    imageOff:"QueryDisable.png",
+    
+    /** @type String */
+    type:"RadioButton",
+
+//"editingattributes","QueryEnable.png", "QueryDisable.png","radioButton",optionsTools
+    /*
+     * 
+     */
+    initialize: function(options) {
+   		OpenLayers.Button.EditingButton.prototype.initialize.apply(this,arguments);
+        this.position = new OpenLayers.Pixel(100, 200);
+             
+    },
+    /* draw: function() {
+        OpenLayers.Control.prototype.draw.apply(this, arguments); 
+        return this.outputDiv;
+    },*/
+    /*   moveTo: function (px) {
+        OpenLayers.Button.prototype.moveTo.apply(this, arguments);
+    },*/
+   
+    
+    /**
+     * Render an array of attributes into a popup.
+     * @param attributes Attributes array to render
+     */
+    draw: function(attributes) {
+        // Clear previous popup
+        if (this.outputDiv == null) {
+            this.outputDiv = OpenLayers.Util.createDiv();
+            this.outputDiv.id = this.id+"test";
+            this.outputDiv.className = 'olControl';
+        }
+        
+        this.outputDiv.innerHTML="";
+        
+        //configure main div
+        this.outputDiv.style.position = "absolute";
+        this.outputDiv.style.top = "30px";
+        this.outputDiv.style.right = "0px";
+        this.outputDiv.style.left = "";
+        this.outputDiv.style.fontFamily = "sans-serif";
+        this.outputDiv.style.fontWeight = "bold";
+        this.outputDiv.style.marginTop = "3px";
+        this.outputDiv.style.marginLeft = "3px";
+        this.outputDiv.style.marginBottom = "3px";
+        this.outputDiv.style.fontSize = "smaller";   
+        this.outputDiv.style.color = "white";   
+        this.outputDiv.style.backgroundColor = "transparent";
+
+        this.innerDiv = document.createElement("div");
+        this.innerDiv.innerHTML="<b>Attribute List</b><br/>"
+        this.innerDiv.id = "layersDiv";
+        this.innerDiv.style.paddingTop = "2px";
+        this.innerDiv.style.paddingLeft = "2px";
+        this.innerDiv.style.paddingBottom = "2px";
+        this.innerDiv.style.paddingRight = "2px";
+        this.innerDiv.style.backgroundColor = this.activeColor;
+		this.innerDiv.style.height = "450";
+		this.innerDiv.style.overflow = "auto";
+        this.outputDiv.appendChild(this.innerDiv);    
+
+        OpenLayers.Rico.Corner.round(this.outputDiv, {corners: "tl bl",
+                                      bgColor: "transparent",
+                                      color: this.activeColor,
+                                      blend: false});
+
+        OpenLayers.Rico.Corner.changeOpacity(this.innerDiv, 0.75);
+        
+        attribs=attributes.getAttributes();
+        for (var i = 0; i < attribs.length; i++) {
+            var attributeDiv = document.createElement("div");
+            var attributeValue = document.createElement("div");
+            
+            var attributeLabel = document.createElement("label");
+            attributeLabel.setAttribute("for", attribs[i].label);
+            attributeLabel.appendChild(document.createTextNode(attribs[i].label));
+          
+            var attributeValue = document.createElement("input");
+            attributeValue.setAttribute("type", "text");
+            attributeValue.setAttribute("id", attribs[i].label);
+            attributeValue.setAttribute("value", attribs[i].value);
+            
+            attributeDiv.appendChild(attributeLabel);
+            attributeDiv.appendChild(attributeValue);
+
+            this.innerDiv.appendChild(attributeDiv);
+        }
+        
+        // minimize button div
+        var imgLocation = OpenLayers.Util.getImagesLocation();
+        var img = imgLocation + 'layer-switcher-minimize.png';
+        var sz = new OpenLayers.Size(18,18);        
+        this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv(
+                                    "OpenLayers_Control_MinimizeDiv", 
+                                    null, 
+                                    sz, 
+                                    img, 
+                                    "absolute");
+        this.minimizeDiv.style.top = "5px";
+        this.minimizeDiv.style.right = "0px";
+        this.minimizeDiv.style.left = "";
+        this.minimizeDiv.style.display = "";
+        OpenLayers.Event.observe(this.minimizeDiv, 
+                      "click", 
+                      this.minimizeControl.bindAsEventListener(this));
+        this.outputDiv.appendChild(this.minimizeDiv);
+
+        // Stop MouseEvents from propogating through this popup
+        OpenLayers.Event.observe(this.outputDiv, "mouseup", this.ignoreEvent);
+        OpenLayers.Event.observe(this.outputDiv, "mousedown", this.ignoreEvent);
+        OpenLayers.Event.observe(this.outputDiv, "click", this.ignoreEvent);
+        OpenLayers.Event.observe(this.outputDiv, "dblclick", this.ignoreEvent);
+        OpenLayers.Event.observe(this.outputDiv, "mousemove", this.ignoreEvent);
+        this.outputDiv.style.zIndex = this.map.Z_INDEX_BASE['Control'] +
+                                    this.map.controls.length;
+        this.map.viewPortDiv.appendChild( this.outputDiv );
+    },
+    
+    mouseDown: function(evt) {
+        
+        
+        // Double click manager
+        if (this.lastDown && this.lastDown.x  == evt.xy.x && this.lastDown.y == evt.xy.y) {
+            return;
+        }
+        this.lastDown = evt.xy;
+        
+        OpenLayers.Button.EditingButton.prototype.mouseDown.apply(this, arguments);
+        
+        // Display Feature attributes
+        if(evt.targetGeometry && evt.targetGeometry.feature && evt.targetGeometry.feature.attributes) {
+            this.draw(evt.targetGeometry.feature.attributes);
+        }
+    },
+	/*mouseUp: function(evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseUp.apply(this, arguments);
+         //this.draw();
+    },
+   */
+    /**
+     * Add the Geometry that has been selected to the Event.
+     * The top geometry layer is selected first, this is done using
+     * SVG/VML feature selection and is accurate. If a feature is not
+     * found, features in layers below are progressively queried using
+     * the BoundingBox of the feature. (Ie, it is not very accurate).
+     * See http://trac.openlayers.org/ticket/434 for more info.
+     *
+     * @param {Event} evt
+     */
+    _setEventContext: function(evt) {
+        // calculate the mouse position
+        var lonlat = this.map.getLonLatFromLayerPx(evt.xy);
+        evt.point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
+
+		// Set tolerance for point layers
+		// Currently tolerence is hard coded to +/- 2
+		// TBD, use the radius from Style for tollerance instead
+		var size=this.map.getSize();
+		var extent=this.map.getExtent();
+		var tolerance=2; // +/- 2 pixels
+		var toleranceLon=(extent.right-extent.left)*tolerance/size.w;
+		var toleranceLat=(extent.top-extent.bottom)*tolerance/size.h;
+		var toleranceLon1,toleranceLat1;
+
+        // For the top layer, query the SVG/VML feature
+        if(this.map.layers.length>0){
+            evt.targetGeometry = this.map.layers[this.map.layers.length-1].renderer.getGeometryFromEvent(evt);
+        }
+        // For remaining layers, query features based on feature bounds.
+        // Exit loop when a feature is found.
+        for(var i=this.map.layers.length-1;(!evt.targetGeometry&&(i>=0));i--){
+            if(this.map.layers[i].getVisibility()&&this.map.layers[i].isVector){
+// TBD: CLASS_TYPE is set to "Feature" instead of "Point". This doesn't seem right.
+//				if((this.map.layers[i].features.length>0)&&(this.map.layers[i].features[0].CLASS_NAME=="OpenLayers.Geometry.Point")){
+					toleranceLon1=toleranceLon;
+					toleranceLat1=toleranceLat;
+//				}
+//				else{
+//					toleranceLon1=0;
+//					toleranceLat1=0;
+//				}
+                for(var f=0;!evt.targetGeometry&&(f<this.map.layers[i].features.length);f++){
+                    if(this.map.layers[i].features[f].atPoint(lonlat,toleranceLon1,toleranceLat1)){
+                        evt.targetGeometry=this.map.layers[i].features[f].geometry;
+                    }
+                    
+                }
+            }
+        }
+        
+        // reset evt.point if modes are activated.
+        if (this.editingModes) {
+            for (var i = 0; i < this.editingModes.length; i++) {
+                var snappingCoordinates = 
+                    this.editingModes[i].calculatePoint(evt.point, evt.targetGeometry, this.geometry, this.layer);
+
+                if (snappingCoordinates) {
+                    evt.point = snappingCoordinates;                    
+                    break;
+                }
+            }
+        }
+    },
+
+    /** Hide all the contents of the control, shrink the size, 
+     *   add the maximize icon
+     * 
+     * @param {Event} e
+     */
+    minimizeControl: function(e) {
+
+        this.outputDiv.innerHTML = "";
+    },
+
+    /** 
+     * @private
+     *
+     * @param {Event} evt
+     */
+    ignoreEvent: function(evt) {
+        OpenLayers.Event.stop(evt);
+    },
+
+    CLASS_NAME: "OpenLayers.Button.EditingAttributes"
+    
+});

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/AddPathPoint.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/AddPathPoint.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/AddPathPoint.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,96 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Button/EditingButton.js
+ */
+
+OpenLayers.Button.EditingButton.AddPathPoint = OpenLayers.Class.create();
+OpenLayers.Button.EditingButton.AddPathPoint.prototype = OpenLayers.Class.inherit( OpenLayers.Button.EditingButton, {
+
+	/** @type String */
+	id: "addpathpoint",
+	
+	/** @type String */
+    imageOn:"AddPointEnable.png",
+    
+    /** @type String */
+    imageOff:"AddPointDisable.png",
+    
+    /** @type String */
+    type:"RadioButton",
+
+    /**
+     * @constructor
+     */
+    initialize: function(options) {
+        OpenLayers.Button.EditingButton.prototype.initialize.apply(this, arguments); 
+        this.geometry = null;
+        this.editingModes = [];
+    },
+
+    /**
+     * @param {Event} evt
+     */    
+    mouseDown: function(evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseDown.apply(this, arguments);
+
+        // reset position to resolve the snapping position conflict
+        var lonlat = this.map.getLonLatFromPixel(evt.xy);
+        evt.point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
+        
+        // add a new path point
+        if (this.editingSelection) {
+            
+            var snappingData = OpenLayers.Util.getSegmentSnappingPoint(evt.point, this.editingSelection);
+            
+            console.log(this.map.snappingTolerance);
+            
+            if (snappingData && snappingData.distance < this.map.snappingTolerance * this.map.getResolution()) {
+                snappingData.geometry.addPoint(snappingData.point, snappingData.index);
+                this.map.vectorLayer.renderer.drawGeometry(this.editingSelection, this.map.vectorLayer.style);
+                this._drawVertices(this.editingSelection);
+                OpenLayers.Button.EditingButton.MovePathPoint.prototype.mouseOver.apply(this, arguments);
+            }
+        }
+    },
+
+    /**
+     * @param {Event} evt
+     */     
+    mouseUp: function (evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseUp.apply(this, arguments);
+        
+        if (this.editingSelection.feature) {
+            this.map.vectorLayer.updateFeatures([this.editingSelection.feature]);
+        }
+    },
+
+    /**
+     * @param {Event} evt
+     */     
+    mouseOver: function(evt) {
+        OpenLayers.Button.EditingButton.MovePathPoint.prototype.mouseOver.apply(this, arguments);
+    },
+
+    /**
+     * @param {OpenLayers.Geometry} geometry
+     */     
+    _drawVertices: function(geometry) {
+        OpenLayers.Button.EditingButton.MovePathPoint.prototype._drawVertices.apply(this, arguments);
+    },
+
+    /**
+     * @param {OpenLayers.Geometry} geometry
+     */     
+    _eraseVertices: function(geometry) {
+        OpenLayers.Button.EditingButton.MovePathPoint.prototype._eraseVertices.apply(this, arguments);
+    },
+    
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Button.EditingButton.AddPathPoint"
+    
+});

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawLineString.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawLineString.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawLineString.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,134 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Button/EditingButton.js
+ */
+OpenLayers.Button.EditingButton.DrawLineString = OpenLayers.Class.create();
+OpenLayers.Button.EditingButton.DrawLineString.prototype = OpenLayers.Class.inherit( OpenLayers.Button.EditingButton, {
+
+	/** @type String */
+	id: "drawlinestring",
+	
+	/** @type String */
+    imageOn:"EditLineEnable.png",
+    
+    /** @type String */
+    imageOff:"EditLineDisable.png",
+    
+    /** @type String */
+    type:"RadioButton",
+    
+    /**
+     * @constructor
+    ***/
+    initialize: function(options) {
+    
+        OpenLayers.Button.EditingButton.prototype.initialize.apply(this, arguments);
+        this.geometry = new OpenLayers.Geometry.LineString();
+        this.tmpPoint = new OpenLayers.Geometry.Point();
+        this.tmpLineSting = new OpenLayers.Geometry.LineString();
+    },
+   
+    /** 
+     * Finalize the geometry from the current tool
+     */
+    _finalizeGeometry: function(){
+        var feature = new OpenLayers.Feature();
+        feature.setGeometry(this.geometry);
+        this.geometry = new OpenLayers.Geometry.LineString();
+        this.map.vectorLayer.addFeatures(feature);
+    },
+
+
+    eraseTmpElements: function(){
+        for(var i = 0; i < this.geometry.path.length; i++) {
+            this.map.vectorLayer.renderer.eraseGeometry(this.geometry.path[i]);
+        }
+        if(this.geometry)
+        this.map.vectorLayer.renderer.eraseGeometry(this.geometry);
+        if(this.tmpPoint)
+        this.map.vectorLayer.renderer.eraseGeometry(this.tmpPoint);
+        if (this.tmpLineString)
+        this.map.vectorLayer.renderer.eraseGeometry(this.tmpLineString);
+    },
+
+    mouseDblClick: function (evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseDblClick.apply(this, arguments);
+        
+        this.mouseDown(evt);
+        this.eraseTmpElements();
+        if(this.geometry.path.length > 1){
+            this._finalizeGeometry();
+        }
+    },
+
+    mouseDown: function (evt) {
+        // Double click manager
+        if (this.lastDown && this.lastDown.x  == evt.xy.x && this.lastDown.y == evt.xy.y) {
+            return;
+        }
+        this.lastDown = evt.xy;
+        
+        OpenLayers.Button.EditingButton.prototype.mouseDown.apply(this, arguments);
+        
+        if (evt.point == this.geometry.path[0]) {
+            this.eraseTmpElements();
+            this._finalizeGeometry();
+        } else {
+            this.geometry.addPoint(evt.point);
+            this.map.vectorLayer.renderer.drawGeometry(evt.point, this.map.vectorLayer.style);
+            this.map.vectorLayer.renderer.drawGeometry(this.geometry, this.map.vectorLayer.style);
+        }
+    },
+
+    mouseMove: function (evt) {
+        // Double click manager
+        if (this.lastDown && this.lastDown.x  == evt.xy.x && this.lastDown.y == evt.xy.y) {
+            return;
+        }
+        
+        OpenLayers.Button.EditingButton.prototype.mouseMove.apply(this, arguments);
+        
+        if (this.isMouseDown) {
+            this.mouseDown(evt);
+            
+        } else {
+            if (this.geometry.path.length > 0) {
+                this.tmpPoint.x = evt.point.x;
+                this.tmpPoint.y = evt.point.y;
+                this.map.vectorLayer.renderer.drawGeometry(this.tmpPoint, this.style);
+                this.tmpLineSting.path[0] = evt.point;
+                this.tmpLineSting.path[1] = this.geometry.path[this.geometry.path.length-1];
+                this.map.vectorLayer.renderer.drawGeometry(this.tmpLineSting, this.style);
+            }
+        }
+    },
+
+    keyDown: function(evt){
+        OpenLayers.Button.EditingButton.prototype.keyDown.apply(this, arguments);               
+        switch (evt.keyCode){
+            case OpenLayers.Event.KEY_RETURN:
+                this.eraseTmpElements();
+                if(this.geometry.path.length > 1){
+                    this._finalizeGeometry();
+                }           
+                OpenLayers.Util.clearArray(this.geometry.path);
+                break;
+            case OpenLayers.Event.KEY_BACKSPACE:
+            case OpenLayers.Event.KEY_DELETE:
+            case OpenLayers.Event.KEY_ESC:
+                this.eraseTmpElements();
+                OpenLayers.Util.clearArray(this.geometry.path);
+                OpenLayers.Event.stop(evt);
+                break;
+        }
+    },
+
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Button.EditingButton.DrawLineString"
+    
+});

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawLinearRing.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawLinearRing.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawLinearRing.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,139 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Button/EditingButton.js
+ */
+OpenLayers.Button.EditingButton.DrawLinearRing = OpenLayers.Class.create();
+OpenLayers.Button.EditingButton.DrawLinearRing.prototype = OpenLayers.Class.inherit( OpenLayers.Button.EditingButton, {
+	/** @type String */
+	id: "drawlinearring",
+	
+	/** @type String */
+    imageOn:"EditPolygonEnable.png",
+    
+    /** @type String */
+    imageOff:"EditPolygonDisable.png",
+    
+    /** @type String */
+    type:"RadioButton",
+
+    /**
+     * @constructor
+    ***/
+    initialize: function(options) {
+        OpenLayers.Button.EditingButton.prototype.initialize.apply(this, arguments);
+        this.geometry = new OpenLayers.Geometry.LinearRing();
+        this.tmpPoint = new OpenLayers.Geometry.Point();
+        this.tmpLineString = new OpenLayers.Geometry.LineString();
+    },
+
+    /**
+     * @param {Event} evt
+     */    
+    mouseDblClick: function (evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseDblClick.apply(this, arguments);
+        this.mouseDown(evt);
+        this._eraseTmpElements();
+        if(this.geometry.path.length > 1){
+            this._finalizeGeometry();
+        }
+    },
+
+    /**
+     * @param {Event} evt
+     */    
+    mouseDown: function (evt) {
+        // Double click manager
+        if (this.lastDown && this.lastDown.x  == evt.xy.x && this.lastDown.y == evt.xy.y) {
+            return;
+        }
+        this.lastDown = evt.xy;
+        
+        OpenLayers.Button.EditingButton.prototype.mouseDown.apply(this, arguments);
+        
+        if (evt.point == this.geometry.path[0]) {
+            this._eraseTmpElements();
+            this._finalizeGeometry();
+        } else {
+            this.geometry.addPoint(evt.point);
+            this.map.vectorLayer.renderer.drawGeometry(evt.point, this.map.vectorLayer.style);
+            this.map.vectorLayer.renderer.drawGeometry(this.geometry, this.map.vectorLayer.style);
+        }
+    },
+
+    /**
+     * @param {Event} evt
+     */    
+    mouseMove: function (evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseMove.apply(this, arguments);
+        
+        if (this.isMouseDown) {
+            this.mouseDown(evt);
+            
+        } else {
+            if (this.geometry.path.length > 0) {
+                this.tmpPoint.x = evt.point.x;
+                this.tmpPoint.y = evt.point.y;
+                this.map.vectorLayer.renderer.drawGeometry(this.tmpPoint, this.style);
+                this.tmpLineString.path[0] = this.geometry.path[this.geometry.path.length-2];
+                this.tmpLineString.path[1] = evt.point;
+                this.tmpLineString.path[2] = this.geometry.path[this.geometry.path.length-1];
+                this.map.vectorLayer.renderer.drawGeometry(this.tmpLineString, this.style);
+            }
+        }
+    },
+
+    /**
+     * @param {Event} evt
+     */    
+    keyDown: function(evt){
+        OpenLayers.Button.EditingButton.prototype.keyDown.apply(this, arguments);               
+        switch (evt.keyCode){
+            case OpenLayers.Event.KEY_RETURN:
+                this._eraseTmpElements();
+                if(this.geometry.path.length > 1){
+                    this._finalizeGeometry();
+                }           
+                OpenLayers.Util.clearArray(this.geometry.path);
+                break;
+            case OpenLayers.Event.KEY_BACKSPACE:
+            case OpenLayers.Event.KEY_DELETE:
+            case OpenLayers.Event.KEY_ESC:
+                this._eraseTmpElements();
+                OpenLayers.Util.clearArray(this.geometry.path);
+                OpenLayers.Event.stop(evt);
+                break;
+        }
+    },
+    
+    /** 
+     * Finalize the geometry from the current tool
+     */
+    _finalizeGeometry: function(){
+        var feature = new OpenLayers.Feature();
+        feature.setGeometry(this.geometry);
+        this.geometry = new OpenLayers.Geometry.LinearRing();
+        this.map.vectorLayer.addFeatures(feature);
+    },
+
+
+    _eraseTmpElements: function(){
+        for(var i = 0; i < this.geometry.path.length; i++) {
+            this.map.vectorLayer.renderer.eraseGeometry(this.geometry.path[i]);
+        }
+        if(this.geometry)
+        this.map.vectorLayer.renderer.eraseGeometry(this.geometry);
+        if(this.tmpPoint)
+        this.map.vectorLayer.renderer.eraseGeometry(this.tmpPoint);
+        if (this.tmpLineString)
+        this.map.vectorLayer.renderer.eraseGeometry(this.tmpLineString);
+    },
+
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Button.EditingButton.DrawLinearRing"
+    
+});

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawMultiLineString.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawMultiLineString.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawMultiLineString.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,28 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Button/.js
+ */
+OpenLayers.Button.EditingButton.DrawMultiLineString = OpenLayers.Class.create();
+OpenLayers.Button.EditingButton.DrawMultiLineString.prototype = OpenLayers.Class.inherit( OpenLayers.Button.EditingButton.DrawLineString, {
+   
+    /** 
+     * Finalize the geometry from the current tool
+     */
+    _finalizeGeometry: function(){
+        var feature = new OpenLayers.Feature();
+        var multiLineString = new OpenLayers.Geometry.MultiLineString();
+        multiLineString.addComponents([this.geometry]);
+        feature.setGeometry(multiLineString);
+        this.geometry = new OpenLayers.Geometry.LineString();
+        this.map.vectorLayer.addFeatures(feature);
+    },
+
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Button.EditingButton.DrawMultiLineString"
+    
+});
\ No newline at end of file

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawMultiPolygon.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawMultiPolygon.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawMultiPolygon.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,30 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Button/EditingButton.js
+ */
+OpenLayers.Button.EditingButton.DrawMultiPolygon = OpenLayers.Class.create();
+OpenLayers.Button.EditingButton.DrawMultiPolygon.prototype = OpenLayers.Class.inherit( OpenLayers.Button.EditingButton.DrawLinearRing, {
+   
+    /** 
+     * Finalize the geometry from the current tool
+     */
+    _finalizeGeometry: function(){
+        var feature = new OpenLayers.Feature();
+        var multiPolygon = new OpenLayers.Geometry.MultiPolygon();
+        var polygon = new OpenLayers.Geometry.Polygon();
+        polygon.addComponents([this.geometry]);
+        multiPolygon.addComponents([polygon]);
+        feature.setGeometry(multiPolygon);        
+        this.geometry = new OpenLayers.Geometry.LinearRing();
+        this.map.vectorLayer.addFeatures(feature);
+    },
+
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Button.EditingButton.DrawMultiPolygon"
+    
+});
\ No newline at end of file

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawPoint.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawPoint.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawPoint.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,116 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Button/EditingButton.js
+ */
+OpenLayers.Button.EditingButton.DrawPoint = OpenLayers.Class.create();
+OpenLayers.Button.EditingButton.DrawPoint.prototype = OpenLayers.Class.inherit( OpenLayers.Button.EditingButton, {
+	/** @type String */
+	id: "drawpoint",
+	
+	/** @type String */
+    imageOn:"EditPointEnable.png",
+    
+    /** @type String */
+    imageOff:"EditPointDisable.png",
+    
+    /** @type String */
+    type:"RadioButton",
+
+    /**
+     * @constructor
+     */
+    initialize: function(options) {
+        OpenLayers.Button.EditingButton.prototype.initialize.apply(this, arguments);
+        this.geometry = new OpenLayers.Geometry.Point();
+    },
+	
+    /** 
+     * Function
+     * 
+     * Finalize the feature and add it to the vector layer.
+     */
+    _finalizeGeometry: function(){
+        var feature = new OpenLayers.Feature();
+        feature.setGeometry(this.geometry);
+        this.map.vectorLayer.addFeatures(feature);
+        
+    },
+    
+    /**
+     * Function
+     * 
+     * @param {Event} evt
+     */
+    mouseDown: function (evt) {
+        // Double click manager
+        if (this.lastDown && this.lastDown.x  == evt.xy.x && this.lastDown.y == evt.xy.y) {
+            return;
+        }
+        
+       OpenLayers.Button.EditingButton.prototype.mouseDown.apply(this, arguments);
+  
+        this.geometry = new OpenLayers.Geometry.Point();
+        this.geometry.x = evt.point.x;
+        this.geometry.y = evt.point.y;
+         
+        this.map.vectorLayer.renderer.drawGeometry(this.geometry, this.style);
+    },
+
+    /**
+     * Function
+     * 
+     * @param {Event} evt
+     */
+    mouseMove: function (evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseMove.apply(this, arguments);
+        if (this.isMouseDown) {
+            this.geometry.x = evt.point.x;
+            this.geometry.y = evt.point.y;
+            this.map.vectorLayer.renderer.drawGeometry(this.geometry, this.style);
+        }
+    },
+
+    /**
+     * Function
+     * 
+     * @param {Event} evt
+     */
+    mouseUp: function (evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseUp.apply(this, arguments);
+        this._finalizeGeometry();
+    },
+
+    /**
+     * Function
+     * 
+     * @param {Event} evt
+     */
+    keyDown: function(evt){
+        OpenLayers.Button.EditingButton.prototype.defaultKeyDown.apply(this, arguments);               
+        switch (evt.keyCode){
+            case OpenLayers.Event.KEY_RETURN:
+                this.eraseTmpElements();
+                if(this.geometry.path.length > 1){
+                    this.finalizeGeometry();
+                }           
+                OpenLayers.Util.clearArray(this.geometry.path);
+                break;
+            case OpenLayers.Event.KEY_BACKSPACE:
+            case OpenLayers.Event.KEY_DELETE:
+            case OpenLayers.Event.KEY_ESC:
+                this.eraseTmpElements();
+                OpenLayers.Util.clearArray(this.geometry.path);
+                OpenLayers.Event.stop(evt);
+                break;
+        }
+    },
+
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Button.EditingButton.DrawPoint"
+    
+});

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawPolygon.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawPolygon.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/DrawPolygon.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,28 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Button/EditingButton.js
+ */
+OpenLayers.Button.EditingButton.DrawPolygon = OpenLayers.Class.create();
+OpenLayers.Button.EditingButton.DrawPolygon.prototype = OpenLayers.Class.inherit( OpenLayers.Button.EditingButton.DrawLinearRing, {
+   
+    /** 
+     * Finalize the geometry from the current tool
+     */
+    _finalizeGeometry: function(){
+        var feature = new OpenLayers.Feature();
+        var polygon = new OpenLayers.Geometry.Polygon();
+        polygon.addComponents([this.geometry]);
+        feature.setGeometry(polygon);
+        this.geometry = new OpenLayers.Geometry.LinearRing();
+        this.map.vectorLayer.addFeatures(feature);
+    },
+
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Button.EditingButton.DrawPolygon"
+    
+});
\ No newline at end of file

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/MovePathPoint.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/MovePathPoint.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/MovePathPoint.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,140 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Button/EditingButton.js
+ */
+
+OpenLayers.Button.EditingButton.MovePathPoint = OpenLayers.Class.create();
+OpenLayers.Button.EditingButton.MovePathPoint.prototype = OpenLayers.Class.inherit( OpenLayers.Button.EditingButton, {
+
+	/** @type String */
+	id: "movepathpoint",
+	
+	/** @type String */
+    imageOn:"GetFeatureEnable.png",
+    
+    /** @type String */
+    imageOff:"GetFeatureDisable.png",
+    
+    /** @type String */
+    type:"RadioButton",
+
+    /**
+    * @constructor
+    *
+    * @param {array} points
+    */
+    initialize: function(options) {
+        OpenLayers.Button.EditingButton.prototype.initialize.apply(this, arguments);
+},
+    mouseOver: function(evt) {
+    	OpenLayers.Button.EditingButton.prototype.mouseOver.apply(this, arguments);
+		
+		// display verctice
+		if (!this.isMouseDown){
+			if (evt.targetGeometry) {
+			  	if(evt.targetGeometry.path || evt.targetGeometry.components) {
+			  		this._eraseVertices(this.editingSelection);
+					this.editingSelection = evt.targetGeometry;
+	    			this._drawVertices(this.editingSelection);
+	   			}
+	    	} else {
+	    		this._eraseVertices(this.editingSelection);
+	    	}
+    	}
+    },
+    
+    mouseMove: function(evt) {
+		OpenLayers.Button.EditingButton.prototype.mouseMove.apply(this, arguments);
+		if (this.isMouseDown) {
+			if (this.vertexSelection) {
+				this.vertexSelection.setX(this.vertexSelection.x + (evt.point.x - this.reference.x));
+				this.vertexSelection.setY(this.vertexSelection.y + (evt.point.y - this.reference.y));
+				this.reference = evt.point;
+				this.map.vectorLayer.renderer.drawGeometry(this.vertexSelection, this.style);
+				this.map.vectorLayer.renderer.drawGeometry(this.editingSelection, this.map.vectorLayer.style);
+			}
+		}
+    },
+
+    /**
+     * @param {Event} evt
+     */
+     
+    mouseDown: function(evt) {
+        // Double click manager
+        if (this.lastDown && this.lastDown.x  == evt.xy.x && this.lastDown.y == evt.xy.y) {
+            return;
+        }
+        this.lastDown = evt.xy;
+        
+        OpenLayers.Button.EditingButton.prototype.mouseDown.apply(this, arguments);
+        
+        if (evt.targetGeometry && evt.targetGeometry.isVertex) {
+        	this.vertexSelection = evt.targetGeometry;
+        	this.reference = evt.point;
+        } else {
+        	this.vertexSelection = null;
+        }
+    },
+
+    /**
+     * @param {Event} evt
+     */
+    mouseUp: function (evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseUp.apply(this, arguments);
+        
+        this.map.vectorLayer.renderer.drawGeometry(this.vertexSelection, this.map.vectorLayer.style);
+        
+        if (this.editingSelection.feature) {
+            this.map.vectorLayer.updateFeatures([this.editingSelection.feature]);
+        }
+    },
+
+    _drawVertices: function(geometry) {
+    	if (geometry) {
+	    	if (geometry.path) {
+            
+                var pathLength = geometry.path.length;
+                
+                // the last point of a linearRing is not draw
+                if ( geometry.path[0].x == geometry.path[pathLength-1].x 
+                  && geometry.path[0].y == geometry.path[pathLength-1].y ) {
+                    pathLength = pathLength - 1;
+                }
+                
+	    		for(var i = 0; i < pathLength; i++) {
+	    			this.map.vectorLayer.renderer.drawGeometry(geometry.path[i], this.map.vectorLayer.style);
+	   			}
+                
+	    	} else if (geometry.components) {
+                
+	    		for(var i = 0; i < geometry.components.length; i++) {
+	    			this._drawVertices(geometry.components[i]);
+	   			}
+	    	}
+    	}
+    },
+    
+    _eraseVertices: function(geometry) {
+    	if (geometry) {
+	    	if (geometry.path) {
+	    		for(var i = 0; i < geometry.path.length; i++) {
+	    			this.map.vectorLayer.renderer.eraseGeometry(geometry.path[i]);
+	   			}
+	    	} else if (geometry.components) {
+	    		for(var i = 0; i < geometry.components.length; i++) {
+	    			this._eraseVertices(geometry.components[i]);
+	   			}
+	    	}
+    	}
+    },
+
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Button.EditingButton.MovePathPoint"
+});
+

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/RemovePathPoint.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/RemovePathPoint.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/RemovePathPoint.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,81 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Button/EditingButton.js
+ */
+
+OpenLayers.Button.EditingButton.RemovePathPoint = OpenLayers.Class.create();
+OpenLayers.Button.EditingButton.RemovePathPoint.prototype = OpenLayers.Class.inherit( OpenLayers.Button.EditingButton, {
+
+   /** @type String */
+	id: "removepathpoint",
+	
+	/** @type String */
+    imageOn:"DelPointEnable.png",
+    
+    /** @type String */
+    imageOff:"DelPointDisable.png",
+    
+    /** @type String */
+    type:"RadioButton",
+	
+    /** @type Integer */
+    tolerance: 5,
+    
+    /**
+     * @constructor
+     */
+    initialize: function(options) {
+        OpenLayers.Button.EditingButton.prototype.initialize.apply(this, arguments); 
+        this.geometry = null;  
+    },
+
+    mouseOver: function(evt) {
+    	OpenLayers.Button.EditingButton.MovePathPoint.prototype.mouseOver.apply(this, arguments);
+    },
+
+    mouseDown: function(evt) {
+        // Double click manager
+        if (this.lastDown && this.lastDown.x  == evt.xy.x && this.lastDown.y == evt.xy.y) {
+            return;
+        }
+        this.lastDown = evt.xy;
+        
+        OpenLayers.Button.EditingButton.prototype.mouseDown.apply(this, arguments);
+
+        if (evt.targetGeometry && evt.targetGeometry.isVertex) {
+            if (this.editingSelection) {
+                this._eraseVertices(this.editingSelection);
+                this._removePathPoint(this.editingSelection, evt.targetGeometry);
+                this.map.vectorLayer.renderer.drawGeometry(this.editingSelection, this.map.vectorLayer.style);
+                this._drawVertices(this.editingSelection);
+            }
+        }
+    },
+    
+    _drawVertices: function(geometry) {
+        OpenLayers.Button.EditingButton.MovePathPoint.prototype._drawVertices.apply(this, arguments);
+    },
+    
+    _eraseVertices: function(geometry) {
+        OpenLayers.Button.EditingButton.MovePathPoint.prototype._eraseVertices.apply(this, arguments);
+    },
+    
+    _removePathPoint: function (geometry, point) {
+        if (geometry.path) {
+            geometry.removePoint(point);
+        } else if (geometry.components) {
+            for (var i = 0; i < geometry.components.length; i++) {
+                this._removePathPoint(geometry.components[i], point);
+            }
+        }
+    },
+
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Button.EditingButton.RemovePathPoint"
+    
+});

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/Selection.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/Selection.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton/Selection.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,203 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Button/EditingButton.js
+ */
+
+OpenLayers.Button.EditingButton.Selection = OpenLayers.Class.create();
+OpenLayers.Button.EditingButton.Selection.prototype = OpenLayers.Class.inherit( OpenLayers.Button.EditingButton, {
+
+    /** @type OpenLayers.Control.EditingAttributes */
+    attributesControl: null,
+    
+	 /** @type String */
+	id: "selection",
+	
+	/** @type String */
+    imageOn:"stock_draw-polygon-filled.png",
+    
+    /** @type String */
+    imageOff:"stock_draw-polygon.png",
+    
+    /** @type String */
+    type:"RadioButton",
+
+    /**
+    * @constructor
+    *
+    * @param {array} points
+    */
+    initialize: function(options) {
+        OpenLayers.Button.EditingButton.prototype.initialize.apply(this, arguments);
+        this.style = OpenLayers.Style.DefaultRendererSelectionStyle;
+        this.editingModes = [];
+    },
+
+    /**
+     * @param {Event} evt
+     */
+    mouseDown: function(evt) {
+        // Double click manager
+        if (this.lastDown && this.lastDown.x  == evt.xy.x && this.lastDown.y == evt.xy.y) {
+            return;
+        }
+        this.lastDown = evt.xy;
+        
+        OpenLayers.Button.EditingButton.prototype.mouseDown.apply(this, arguments);
+            
+        // Display Feature attributes
+        if(this.attributesControl && evt.targetGeometry && evt.targetGeometry.feature && evt.targetGeometry.feature.attributes) {
+            this.attributesControl.setContent(evt.targetGeometry.feature.attributes);
+        }
+        
+        // Geometry Selection
+        if (evt.targetGeometry && evt.targetGeometry.feature && !evt.targetGeometry.isSnappingSegment){
+            
+            // Multiple geometry Selection
+            if (this.shiftDown){
+                
+                // Verify if the geometry is selected
+                if (OpenLayers.Util.indexOf(this.map.featureSelection, evt.targetGeometry.feature) < 0){
+                    this.map.featureSelection.push(evt.targetGeometry.feature);
+                    this.map.vectorLayer.renderer.drawGeometry(evt.targetGeometry, this.style);
+                
+                // UnSelect the geometry
+                } else {
+                    this.map.featureSelection = OpenLayers.Util.removeItem(this.map.featureSelection, evt.targetGeometry.feature);
+                    this.map.vectorLayer.renderer.drawGeometry(evt.targetGeometry, this.map.vectorLayer.style);
+                }
+                
+            // Reset the geometry selection
+            } else {
+                for(var i=0; i<this.map.featureSelection.length; i++) {
+                	this.map.vectorLayer.renderer.drawGeometry(this.map.featureSelection[i].geometry, this.map.vectorLayer.style);
+                }
+                this.map.featureSelection = [];
+                this.map.featureSelection = [evt.targetGeometry.feature];
+                this.map.vectorLayer.renderer.drawGeometry(evt.targetGeometry.feature.geometry, this.style);
+            }
+        } else {
+            for(var i=0; i<this.map.featureSelection.length; i++) {
+            	this.map.vectorLayer.renderer.drawGeometry(this.map.featureSelection[i].geometry, this.map.vectorLayer.style);
+            }
+            this.map.featureSelection = [];
+        }
+        
+        // initialize lastPositionReference wich is use to translate an an array of points
+        var lonlat = this.map.getLonLatFromLayerPx(evt.xy);
+        this.lastPositionReference =  new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
+    },
+
+    /**
+     * @param {Event} evt
+     */
+    mouseMove: function (evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseMove.apply(this, arguments);
+        
+        if (this.isMouseDown){
+            this.selectionChange = true;
+            
+            // new coordinates values
+            var xTranslation = evt.point.x - this.lastPositionReference.x;
+            var yTranslation = evt.point.y - this.lastPositionReference.y;
+            
+            var lonlat = this.map.getLonLatFromLayerPx(evt.xy);
+            this.lastPositionReference =  new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
+            
+            // translate and draw the points
+            for(var i=0; i<this.map.featureSelection.length; i++) {
+                // Point Geometry
+            	if (this.map.featureSelection[i].geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
+            	    this.map.featureSelection[i].geometry.setX( this.map.featureSelection[i].geometry.x + xTranslation);
+                    this.map.featureSelection[i].geometry.setY( this.map.featureSelection[i].geometry.y + yTranslation);
+            	            	    
+            	// Path Geometry
+            	} else if (this.map.featureSelection[i].geometry.path) {
+            	    var path = this.map.featureSelection[i].geometry.path;
+                    for(var iPath = 0; iPath < path.length; iPath++) {
+                        if (this.map.featureSelection[i].geometry.CLASS_NAME != "OpenLayers.Geometry.LinearRing" || iPath != path.length-1) {
+                            path[iPath].setX(path[iPath].x + xTranslation);
+                            path[iPath].setY(path[iPath].y + yTranslation);
+                        }
+                    }
+                    this.map.featureSelection[i].geometry.path = path;       	    
+            	
+            	// Aggregate Geometry
+            	} else {
+            	    
+            	}
+            	
+            	this.map.vectorLayer.renderer.drawGeometry(this.map.featureSelection[i].geometry, this.style);
+            }
+        }
+    },
+
+    /**
+     * @param {Event} evt
+     */
+    mouseUp: function (evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseUp.apply(this, arguments);
+        
+        // TBD check if this is working
+        if (this.map.featureSelection.length > 0){
+            this.map.vectorLayer.updateFeatures(this.map.featureSelection);
+        }
+    },
+    
+    /**
+     * Copy the current featureSelection to the clipBoard
+     */
+    copyToClipBoard: function() {
+        this.map.clipBoard = [];
+        for (var i = 0; i < this.map.featureSelection.length; i++) {
+            this.map.clipBoard.push(this.map.featureSelection[i].clone());
+        }
+    },
+    
+    /**
+     * Paste features from the clipBoard
+     */
+    pasteFromClipBoard: function() {
+        // TBD check if features geometry match the needed type
+        for (var i = 0; i < this.map.clipBoard.length; i++) {
+            if (this.map.clipBoard[i] instanceof OpenLayers.Feature) {
+                this.map.vectorLayer.addFeatures(this.map.clipBoard[i]);
+            }
+        }
+        console.log(this.map.vectorLayer.features);
+    },
+
+    /**
+     * @param {Event} evt
+     */
+    keyDown: function(evt){
+        OpenLayers.Button.EditingButton.prototype.keyDown.apply(this, arguments);
+        
+        switch (evt.keyCode){
+        case OpenLayers.Event.KEY_BACKSPACE:
+        case OpenLayers.Event.KEY_DELETE:
+            this.map.vectorLayer.removeFeatures(this.map.featureSelection);
+            this.map.featureSelection = []
+            OpenLayers.Event.stop(evt);
+            break;
+        case OpenLayers.Event.KEY_C:
+            if (evt.ctrlKey) {
+                this.copyToClipBoard();
+            }
+            break;
+        case OpenLayers.Event.KEY_V:
+            if (evt.ctrlKey) {
+                this.pasteFromClipBoard();
+            }
+            break;
+        }
+    },
+
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Button.EditingButton.Selection"
+});
+

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/EditingButton.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,184 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Button.js
+ */
+OpenLayers.Button.EditingButton = OpenLayers.Class.create();
+OpenLayers.Button.EditingButton.prototype =
+    OpenLayers.Class.inherit( OpenLayers.Button, {
+
+    /**
+     * @constructor
+     */
+    initialize: function() {
+        OpenLayers.Button.prototype.initialize.apply(this, arguments);
+        this.style = OpenLayers.Style.DefaultRendererTemporaryElementStyle;
+        this.isMouseDown = false;
+    },
+
+    /**
+     * @param {Event} evt
+     */
+    defaultClick: function(evt) {
+        // set position
+        var lonlat = this.map.getLonLatFromPixel(evt.xy);
+        evt.point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
+
+        this._setEventContext(evt);
+    },
+
+    /**
+     * @param {Event} evt
+     */
+    mouseDblClick: function(evt) {
+        // set position
+        var lonlat = this.map.getLonLatFromPixel(evt.xy);
+        evt.point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
+
+        this._setEventContext(evt);
+    },
+
+    /**
+     * @param {Event} evt
+     */
+    mouseDown: function(evt) {
+        // set position
+        var lonlat = this.map.getLonLatFromPixel(evt.xy);
+        evt.point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
+
+        this._setEventContext(evt);
+
+        this.isMouseDown = true;
+    },
+
+    /**
+     * @param {Event} evt
+     */
+    mouseMove: function(evt) {
+        //OpenLayers.Button.AutoPan.prototype.mouseMove.apply(this, arguments);
+
+        // set position
+        var lonlat = this.map.getLonLatFromPixel(evt.xy);
+        evt.point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
+
+        this._setEventContext(evt);
+    },
+
+    /**
+     * @param {Event} evt
+     */
+    mouseUp: function(evt) {
+        // set position
+        var lonlat = this.map.getLonLatFromPixel(evt.xy);
+        evt.point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
+
+        this._setEventContext(evt);
+
+        this.isMouseDown = false;
+    },
+
+    /**
+     * @param {Event} evt
+     */
+    mouseOut: function(evt) {
+        //OpenLayers.Button.AutoPan.prototype.mouseOut.apply(this, arguments);
+
+        // set position
+        var lonlat = this.map.getLonLatFromPixel(evt.xy);
+        evt.point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
+
+        this._setEventContext(evt);
+    },
+
+    mouseOver: function(evt) {
+        // set position
+        var lonlat = this.map.getLonLatFromPixel(evt.xy);
+        evt.point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
+
+        this._setEventContext(evt);
+    },
+
+    /**
+     * @param {Event} evt
+     */
+    wheelEvent: function(evt) {
+        OpenLayers.Button.MouseDefaults.prototype.mouseWheel.apply(this, arguments);
+    },
+
+    /**
+     * @param {Event} evt
+     */
+    keyDown: function(evt) {
+        switch (evt.keyCode) {
+            case OpenLayers.Event.KEY_LEFT:
+            this.map.pan(-50, 0);
+            break;
+            case OpenLayers.Event.KEY_RIGHT:
+            this.map.pan(50, 0);
+            break;
+            case OpenLayers.Event.KEY_UP:
+            this.map.pan(0, -50);
+            break;
+            case OpenLayers.Event.KEY_DOWN:
+            this.map.pan(0, 50);
+            break;
+            case OpenLayers.Event.KEY_SHIFT:
+            this.shiftDown = true;
+            this.controlledMode = true;
+            break;
+            case OpenLayers.Event.KEY_CTRL:
+            this.snappingMode = true;
+            break;
+        }
+    },
+
+    /**
+     * @param {Event} evt
+     */
+    keyUp: function(evt) {
+        switch (evt.keyCode) {
+            case OpenLayers.Event.KEY_SHIFT:
+            this.shiftDown = false;
+            this.controlledMode = false;
+            break;
+            case OpenLayers.Event.KEY_CTRL:
+            this.capsLock = false;
+            this.snappingMode = false;
+            break;
+        }
+    },
+
+    /**
+     * @param {Event} evt
+     *
+     * add rich properties to an evt object for the edition
+     */
+    _setEventContext: function(evt) {
+        // the target Geometry is the shape under the mouse
+        evt.targetGeometry = this.map.vectorLayer.renderer.getGeometryFromEvent(evt);
+
+        // reset evt.point if modes are activated.
+        if (this.map.editingModes) {
+            for (var i = 0; i < this.map.editingModes.length; i++) {
+                if (this.map.editingModes[i].isSnappingTypeMode && this.snappingMode
+                    || this.map.editingModes[i].isControlledTypeMode && this.controlledMode
+                    || !this.map.editingModes[i].isSnappingTypeMode && !this.map.editingModes[i].isControlledTypeMode) {
+                    var snappingCoordinates =
+                        this.map.editingModes[i].calculatePoint(evt.point, evt.targetGeometry);
+
+                    if (snappingCoordinates) {
+                        evt.point = snappingCoordinates;
+                        break;
+                    }
+                }
+            }
+        }
+    },
+
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Button.EditingButton"
+});

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/MeasureArea.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/MeasureArea.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/MeasureArea.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,189 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Button/EditingButton.js
+ */
+OpenLayers.Button.MeasureArea = OpenLayers.Class.create();
+OpenLayers.Button.MeasureArea.prototype =
+    OpenLayers.Class.inherit(OpenLayers.Button.EditingButton, {
+    
+	/** @type String */
+	id: "measurearea",
+	
+	/** @type String */
+    imageOn:"MeasureEnable.png",
+    
+    /** @type String */
+    imageOff:"MeasureDisable.png",
+    
+    /** @type String */
+    type:"RadioButton",
+    
+    /** @type DOMElement */
+    element: null,
+
+    /** @type String */
+    prefix: 'area: ',
+
+    /** @type String */
+    suffix: ' m&sup2;',
+
+    /** @type int */
+    numdigits: 2,
+
+    /**
+     * @constructor
+    ***/
+    initialize: function(options) {
+        OpenLayers.Button.EditingButton.prototype.initialize.apply(this, arguments);
+    },
+
+    /**
+     * Turn on the current tool and catch all the concerned events.
+     */
+    turnOn: function() {
+         OpenLayers.Button.prototype.turnOn.apply(this, arguments);
+         this.geometry = new OpenLayers.Geometry.LinearRing();
+         this.tmpLineSting = new OpenLayers.Geometry.LineString();
+    },
+
+    /**
+     * Turn off the current tool and catch all the concerned events.
+     */
+    turnOff: function() {
+
+    	this.eraseTmpElements();
+        this.geometry = null;
+        OpenLayers.Button.prototype.turnOff.apply(this, arguments);
+      
+    },
+
+    /**
+     * Finalize the geometry from the current tool
+     */
+    finalizeGeometry: function() {
+        this.oldGeometry = this.geometry;
+        this.geometry = new OpenLayers.Geometry.LinearRing();
+    },
+
+
+    eraseTmpElements: function() {
+  			if(this.tmpLineSting)
+            	this.map.vectorLayer.renderer.eraseGeometry(this.tmpLineSting);
+            if(this.oldGeometry)
+            	this.map.vectorLayer.renderer.eraseGeometry(this.oldGeometry);
+    },
+
+    mouseDblClick: function(evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseDblClick.apply(this, arguments);
+
+        this.mouseDown(evt);
+        // this.eraseTmpElements();
+        if (this.geometry.path.length > 2) {
+            this.finalizeGeometry();
+        }
+    },
+
+    mouseDown: function(evt) {
+        // Double click manager
+        if (this.lastDown && this.lastDown.x  == evt.xy.x && this.lastDown.y == evt.xy.y) {
+            return;
+        }
+        this.lastDown = evt.xy;
+
+        if (this.geometry.path.length == 0 && this.oldGeometry) {
+            this.map.vectorLayer.renderer.eraseGeometry(this.oldGeometry);
+        }
+
+        OpenLayers.Button.EditingButton.prototype.mouseDown.apply(this, arguments);
+
+        if (evt.point == this.geometry.path[0]) {
+            this.eraseTmpElements();
+            this.finalizeGeometry();
+        } else {
+            this.geometry.addPoint(evt.point);
+            this.map.vectorLayer.renderer.drawGeometry(this.geometry, this.map.vectorLayer.style);
+        }
+
+    },
+
+    mouseMove: function(evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseMove.apply(this, arguments);
+
+        if (this.isMouseDown) {
+            this.mouseDown(evt);
+
+        } else {
+            if (this.geometry.path.length > 0) {
+                this.tmpLineSting.path[0] = this.geometry.path[this.geometry.path.length-2];
+                this.tmpLineSting.path[1] = evt.point;
+                this.tmpLineSting.path[2] = this.geometry.path[this.geometry.path.length-1];
+                this.map.vectorLayer.renderer.drawGeometry(this.tmpLineSting, this.style);
+
+            }
+        }
+    },
+   mouseUp: function(evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseUp.apply(this, arguments);
+         this.draw();
+    },
+    keyDown: function(evt) {
+
+        OpenLayers.Button.EditingButton.prototype.keyDown.apply(this, arguments);
+
+        switch (evt.keyCode){
+            case OpenLayers.Event.KEY_RETURN:
+                this.eraseTmpElements();
+                if(this.geometry.path.length > 1){
+                    this.finalizeGeometry();
+                }
+                OpenLayers.Util.clearArray(this.geometry.path);
+                break;
+            case OpenLayers.Event.KEY_BACKSPACE:
+            case OpenLayers.Event.KEY_DELETE:
+            case OpenLayers.Event.KEY_ESC:
+                this.eraseTmpElements();
+                OpenLayers.Util.clearArray(this.geometry.path);
+                OpenLayers.Event.stop(evt);
+                break;
+        }
+    },
+
+    draw: function() {
+        var digits = parseInt(this.numdigits);
+        if(!this.outputDiv)
+        {	this.outputDiv=document.createElement('div');
+       		this.outputDiv.id="MeasureArea";}
+		this.outputDiv.innerHTML="";
+        //configure main div
+        this.outputDiv.style.position = "relative";
+        this.outputDiv.style.top = "30px";
+        this.outputDiv.style.right = "0px";
+        this.outputDiv.style.left = "";
+        this.outputDiv.style.fontFamily = "sans-serif";
+        this.outputDiv.style.fontWeight = "bold";
+        this.outputDiv.style.marginTop = "3px";
+        this.outputDiv.style.marginLeft = "3px";
+        this.outputDiv.style.marginBottom = "3px";
+        this.outputDiv.style.fontSize = "smaller";   
+        this.outputDiv.style.color = "white";   
+        this.outputDiv.style.backgroundColor = "blue";
+        var newHtml = this.prefix +
+                      this.geometry.getLength().toFixed(digits) +
+                      this.suffix;
+	
+        if (newHtml != this.outputDiv.innerHTML) {
+
+            this.outputDiv.innerHTML = newHtml;
+        }
+        document.lastChild.lastChild.appendChild(this.outputDiv);
+    },
+
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Button.MeasureArea"
+
+});

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/MeasureDistance.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/MeasureDistance.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/MeasureDistance.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,193 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
+ * for the full text of the license. */
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Button/EditingButton.js
+ */
+OpenLayers.Button.MeasureDistance = OpenLayers.Class.create();
+OpenLayers.Button.MeasureDistance.prototype =
+    OpenLayers.Class.inherit(OpenLayers.Button.EditingButton, {
+
+	/** @type String */
+	id: "measuredistance",
+	
+	/** @type String */
+    imageOn:"MeasureEnable.png",
+    
+    /** @type String */
+    imageOff:"MeasureDisable.png",
+    
+    /** @type String */
+    type:"RadioButton",
+    
+    /** @type DOMElement */
+    div: null,
+
+    /** @type String */
+    prefix: 'dist: ',
+
+    /** @type String */
+    suffix: null,
+
+    /** @type int */
+    numdigits: 2,
+
+	map:null,
+    /**
+     * @constructor
+    ***/
+    initialize: function(options) {
+        OpenLayers.Button.EditingButton.prototype.initialize.apply(this, arguments);
+    },
+
+    /**
+     * Turn on the current tool and catch all the concerned events.
+     */
+    turnOn: function() {
+       OpenLayers.Button.prototype.turnOn.apply(this, arguments);
+       this.suffix=this.map.units;
+        this.geometry = new OpenLayers.Geometry.LineString();
+        this.tmpSegment = new OpenLayers.Geometry.LineString();
+    },
+
+    /**
+     * Turn off the current tool and catch all the concerned events.
+     */
+    turnOff: function() {
+        this.eraseTmpElements();
+        this.geometry = null;
+        this.map.removeMouseListener(this);
+        OpenLayers.Button.prototype.turnOff.apply(this, arguments);
+        
+    },
+
+    /**
+     * Finalize the geometry from the current tool
+     */
+    finalizeGeometry: function() {
+    
+        this.oldGeometry = this.geometry;
+        this.geometry = new OpenLayers.Geometry.LineString();
+    },
+
+
+    eraseTmpElements: function() {
+        /*for(var i = 0; i < this.oldGeometry.path.length; i++) {
+            this.map.vectorLayer.renderer.eraseGeometry(this.geometry.path[i]);
+           
+        }*/
+        if(this.tmpSegment)
+         	this.map.vectorLayer.renderer.eraseGeometry(this.tmpSegment);
+        if(this.oldGeometry)
+             this.map.vectorLayer.renderer.eraseGeometry(this.oldGeometry);
+        
+    },
+
+    mouseDblClick: function(evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseDblClick.apply(this, arguments);
+
+        this.mouseDown(evt);
+       // this.eraseTmpElements();
+        if(this.geometry.path.length > 2){
+            this.finalizeGeometry();
+        }
+    },
+
+    mouseDown: function(evt) {
+        // Double click manager
+        if (this.lastDown && this.lastDown.x  == evt.xy.x && this.lastDown.y == evt.xy.y) {
+            return;
+        }
+        this.lastDown = evt.xy;
+
+        if (this.geometry.path.length == 0 && this.oldGeometry) {
+            this.map.vectorLayer.renderer.eraseGeometry(this.oldGeometry);
+        }
+
+        OpenLayers.Button.EditingButton.prototype.mouseDown.apply(this, arguments);
+
+        this.geometry.addPoint(evt.point);
+        this.map.vectorLayer.renderer.drawGeometry(this.geometry, this.map.vectorLayer.style);
+    },
+
+    mouseMove: function(evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseMove.apply(this, arguments);
+
+        if (this.isMouseDown) {
+            this.mouseDown(evt);
+
+        } else {
+            if (this.geometry.path.length > 0) {//alert(this.tmpSegment.path[1]);
+               this.tmpSegment.path[1] = this.geometry.path[this.geometry.path.length-1];
+                this.tmpSegment.path[0] = evt.point;
+                //this.tmpLineSting.path[2] = this.geometry.path[this.geometry.path.length-1];
+                this.map.vectorLayer.renderer.drawGeometry(this.tmpSegment, this.style);
+
+
+             
+            }
+        }
+    },
+   mouseUp: function(evt) {
+        OpenLayers.Button.EditingButton.prototype.mouseUp.apply(this, arguments);
+         this.draw();
+    },
+    keyDown: function(evt) {
+
+        OpenLayers.Button.EditingButton.prototype.keyDown.apply(this, arguments);
+
+        switch (evt.keyCode) {
+            case OpenLayers.Event.KEY_RETURN:
+                this.eraseTmpElements();
+                if (this.geometry.path.length > 1) {
+                    this.finalizeGeometry();
+                }
+                OpenLayers.Util.clearArray(this.geometry.path);
+                break;
+            case OpenLayers.Event.KEY_BACKSPACE:
+            case OpenLayers.Event.KEY_DELETE:
+            case OpenLayers.Event.KEY_ESC:
+                this.eraseTmpElements();
+                OpenLayers.Util.clearArray(this.geometry.path);
+                OpenLayers.Event.stop(evt);
+                break;
+        }
+    },
+
+    draw: function() {
+        var digits = parseInt(this.numdigits);
+        if(!this.outputDiv)
+        {	this.outputDiv=document.createElement('div');
+       		this.outputDiv.id="MeasureDistance";
+       	}
+		this.outputDiv.innerHTML="";
+        //configure main div
+        this.outputDiv.style.position = "relative";
+        this.outputDiv.style.top = "30px";
+        this.outputDiv.style.right = "0px";
+        this.outputDiv.style.left = "";
+        this.outputDiv.style.fontFamily = "sans-serif";
+        this.outputDiv.style.fontWeight = "bold";
+        this.outputDiv.style.marginTop = "3px";
+        this.outputDiv.style.marginLeft = "3px";
+        this.outputDiv.style.marginBottom = "3px";
+        this.outputDiv.style.fontSize = "smaller";   
+        this.outputDiv.style.color = "white";   
+        this.outputDiv.style.backgroundColor = "blue";
+        var newHtml = this.prefix +
+                      this.geometry.getLength().toFixed(digits) +
+                      this.suffix;
+	
+        if (newHtml != this.outputDiv.innerHTML) {
+
+            this.outputDiv.innerHTML = newHtml;
+        }
+        document.lastChild.lastChild.appendChild(this.outputDiv);
+    },
+
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Button.MeasureDistance"
+});

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/Reset.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/Reset.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/Reset.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,43 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+ 
+ /**
+ * @class
+ *
+ * @requires OpenLayers/Button.js
+ */
+OpenLayers.Button.Reset = OpenLayers.Class.create();
+OpenLayers.Button.Reset.prototype = OpenLayers.Class.inherit( OpenLayers.Button, {
+//this._addButton("zoombox", "drag-rectangle-off.png", "drag-rectangle-on.png", centered, sz, "Shift->Drag to zoom to area");
+       
+   /** @type String */
+	id: "zoomworld",
+	
+	/** @type String */
+    imageOff:"ResetExtentDisable.png",
+
+    /** @type String */
+    type:"Button",
+    
+	map:null,
+    /*
+     * 
+     */
+    initialize: function(options) {
+        OpenLayers.Button.prototype.initialize.apply(this, arguments);
+        
+    },
+    
+    /**
+     * Register for mousedown events
+     */
+    doSelect: function() {
+	
+		this.map.zoomToMaxExtent(); 
+
+    },
+  
+    CLASS_NAME: "OpenLayers.Button.Reset"
+    
+});

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/ZoomIn.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/ZoomIn.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/ZoomIn.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,168 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt 
+ * for the full text of the license. */
+ 
+ /**
+ * @class
+ *
+ * @requires OpenLayers/Button.js
+ */
+OpenLayers.Button.ZoomIn = OpenLayers.Class.create();
+OpenLayers.Button.ZoomIn.prototype = OpenLayers.Class.inherit( OpenLayers.Button, {
+      
+    /** @type String */
+	id: "zoomin",
+	/** @type String */
+    imageOn:"ZoomInEnable.png",
+    /** @type String */
+    imageOff:"ZoomInDisable.png",
+    /** @type String */
+    type:"RadioButton",
+    /** @type String */
+    cursor: "crosshair",
+    /** @type OpenLayers.Map */
+	map:null,
+	
+	/** @type Boolean */
+	selected:null,
+    /*
+     *@constructor 
+     */
+    initialize: function(options) {
+        OpenLayers.Button.prototype.initialize.apply(this, arguments);
+    },
+    
+   /**
+    * @param {Event} evt
+    */
+    mouseDown: function(evt) {
+        if (!OpenLayers.Event.isLeftClick(evt))
+            return;
+
+        this.mouseDragStart = evt.xy.clone();
+        this.performedDrag  = false;
+        this.map.div.style.cursor = this.cursor;
+        this.zoomBox = OpenLayers.Util.createDiv('zoomBox',
+                                                     this.mouseDragStart,
+                                                     null,
+                                                     null,
+                                                     "absolute",
+                                                     "2px solid red");
+        this.zoomBox.initialCoords = evt.xy;
+        this.zoomBox.style.backgroundColor = "white";
+        this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
+        this.zoomBox.style.opacity = "0.50";
+        this.zoomBox.style.fontSize = "1px";
+        this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
+        this.map.viewPortDiv.appendChild(this.zoomBox);
+     
+        document.onselectstart = function() { return false; }
+        OpenLayers.Event.stop(evt);
+    },
+
+    /**
+    * @param {Event} evt
+    */
+    mouseMove: function(evt) {
+        // record the mouse position, used in onWheelEvent
+        this.mousePosition = evt.xy.clone();
+
+        if (this.mouseDragStart != null) {
+            if (this.zoomBox) {
+                var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);
+                var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);
+                this.zoomBox.style.width = Math.max(1, deltaX) + "px";
+                this.zoomBox.style.height = Math.max(1, deltaY) + "px";
+                if (evt.xy.x < this.mouseDragStart.x) {
+                    this.zoomBox.style.left = evt.xy.x + "px";
+                } else {
+                    this.zoomBox.style.left = this.zoomBox.initialCoords.x + "px";
+                }
+                if (evt.xy.y < this.mouseDragStart.y) {
+                    this.zoomBox.style.top = evt.xy.y+ "px";
+                } else {
+                    this.zoomBox.style.top = this.zoomBox.initialCoords.y + "px";
+                }
+            } else {
+                var deltaX = this.mouseDragStart.x - evt.xy.x;
+                var deltaY = this.mouseDragStart.y - evt.xy.y;
+                var size = this.map.getSize();
+                var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
+                                                 size.h / 2 + deltaY);
+                var newCenter = this.map.getLonLatFromViewPortPx(newXY);
+                this.map.setCenter(newCenter, null, true);
+                this.mouseDragStart = evt.xy.clone();
+                this.map.div.style.cursor = this.cursor;
+            }
+            this.performedDrag = true;
+        }
+    },
+
+    /**
+    * @param {Event} evt
+    */
+    mouseUp: function(evt) {
+        if (!OpenLayers.Event.isLeftClick(evt)) 
+            return;
+        
+        if (this.zoomBox) {
+            this.zoomBoxEnd(evt);
+        } else {
+            if (this.performedDrag) {
+                this.map.setCenter(this.map.center);
+            }
+        }
+        document.onselectstart = null;
+        this.mouseDragStart = null;
+        this.map.div.style.cursor = this.cursor;
+    },
+ 
+   /**
+    * @param {Event} evt
+    */
+    mouseOut: function(evt) {
+        if (this.mouseDragStart != null &&
+            OpenLayers.Util.mouseLeft(evt, this.map.div)) {
+                if (this.zoomBox) {
+                    this.removeZoomBox();
+                }
+                this.mouseDragStart = null;
+            }
+    },
+ /** Zoombox function.
+     *
+     */
+    zoomBoxEnd: function(evt) {
+        if (this.mouseDragStart != null) {
+            if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 ||
+                Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) {
+                    var start = this.map.getLonLatFromViewPortPx(this.mouseDragStart);
+                    var end = this.map.getLonLatFromViewPortPx(evt.xy);
+                    var top = Math.max(start.lat, end.lat);
+                    var bottom = Math.min(start.lat, end.lat);
+                    var left = Math.min(start.lon, end.lon);
+                    var right = Math.max(start.lon, end.lon);
+                    var bounds = new OpenLayers.Bounds(left, bottom, right, top);
+                    this.map.zoomToExtent(bounds);
+                } else {
+                    var end = this.map.getLonLatFromViewPortPx( evt.xy );
+                    this.map.setCenter(new OpenLayers.LonLat((end.lon),
+                                                             (end.lat)), 
+                                       this.map.getZoom() + 1);
+                }
+            this.removeZoomBox();
+        }
+    },
+
+    /**
+     * Remove the zoombox from the screen and nullify our reference to it.
+     */
+    removeZoomBox: function() {
+        this.zoomBox.initialCoords = null;
+        this.map.viewPortDiv.removeChild(this.zoomBox);
+        this.zoomBox = null;
+    },
+
+    CLASS_NAME: "OpenLayers.Button.ZoomIn"
+    
+});

Added: sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/ZoomOut.js
===================================================================
--- sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/ZoomOut.js	                        (rev 0)
+++ sandbox/oterral/ButtonBar/vector/lib/OpenLayers/Button/ZoomOut.js	2007-03-05 10:04:02 UTC (rev 2304)
@@ -0,0 +1,272 @@
+/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
+ * for the full text of the license. */
+
+
+/**
+ * @class
+ *
+ * @requires OpenLayers/Button.js
+ */
+OpenLayers.Button.ZoomOut = OpenLayers.Class.create();
+OpenLayers.Button.ZoomOut.prototype =
+OpenLayers.Class.inherit( OpenLayers.Button, {
+
+    /** @type Boolean */
+    performedDrag: false,
+    
+	/** @type String */
+	id: "zoomout",
+	
+	/** @type String */
+    imageOn:"ZoomOutEnable.png",
+    
+    /** @type String */
+    imageOff:"ZoomOutDisable.png",
+    
+    /** @type String */
+    type:"RadioButton",
+    
+    cursor:"crosshair",
+    /**
+     * @constructor
+     */
+    initialize: function(options) {
+        OpenLayers.Button.prototype.initialize.apply(this, arguments);
+    },
+    /**
+    * @param {Event} evt
+    */
+    mouseDown: function(evt) {
+        if (!OpenLayers.Event.isLeftClick(evt))
+            return;
+
+        this.mouseDragStart = evt.xy.clone();
+        this.performedDrag  = false;
+        /*if (evt.shiftKey) {*/
+            this.map.div.style.cursor = "crosshair";
+            this.zoomBox = OpenLayers.Util.createDiv('zoomBox',
+                                                     this.mouseDragStart,
+                                                     null,
+                                                     null,
+                                                     "absolute",
+                                                     "2px solid red");
+            this.zoomBox.initialCoords = evt.xy;
+            this.zoomBox.style.backgroundColor = "white";
+            this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
+            this.zoomBox.style.opacity = "0.50";
+            this.zoomBox.style.fontSize = "1px";
+            this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
+            this.map.viewPortDiv.appendChild(this.zoomBox);
+        /*}*/
+        document.onselectstart = function() { return false; }
+        OpenLayers.Event.stop(evt);
+    },
+
+    /**
+    * @param {Event} evt
+    */
+    mouseMove: function(evt) {
+        // record the mouse position, used in onWheelEvent
+        this.mousePosition = evt.xy.clone();
+
+        if (this.mouseDragStart != null) {
+            if (this.zoomBox) {
+                var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);
+                var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);
+                this.zoomBox.style.width = Math.max(1, deltaX) + "px";
+                this.zoomBox.style.height = Math.max(1, deltaY) + "px";
+                if (evt.xy.x < this.mouseDragStart.x) {
+                    this.zoomBox.style.left = evt.xy.x + "px";
+                } else {
+                    this.zoomBox.style.left = this.zoomBox.initialCoords.x + "px";
+                }
+                if (evt.xy.y < this.mouseDragStart.y) {
+                    this.zoomBox.style.top = evt.xy.y+ "px";
+                } else {
+                    this.zoomBox.style.top = this.zoomBox.initialCoords.y + "px";
+                }
+            } else {
+                var deltaX = this.mouseDragStart.x - evt.xy.x;
+                var deltaY = this.mouseDragStart.y - evt.xy.y;
+                var size = this.map.getSize();
+                var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
+                                                 size.h / 2 + deltaY);
+                var newCenter = this.map.getLonLatFromViewPortPx(newXY);
+                this.map.setCenter(newCenter, null, true);
+                this.mouseDragStart = evt.xy.clone();
+                this.map.div.style.cursor = "move";
+            }
+            this.performedDrag = true;
+        }
+    },
+
+    /**
+    * @param {Event} evt
+    */
+    mouseUp: function(evt) {
+        if (!OpenLayers.Event.isLeftClick(evt)) 
+            return;
+        
+        if (this.zoomBox) {
+            this.zoomBoxEnd(evt);
+        } else {
+            if (this.performedDrag) {
+                this.map.setCenter(this.map.center,this.map.getZoom()-1);
+            }
+        }
+        document.onselectstart = null;
+        this.mouseDragStart = null;
+        this.map.div.style.cursor = "default";
+    },
+
+    /**
+    * @param {Event} evt
+    */
+    mouseOut: function(evt) {
+        if (this.mouseDragStart != null &&
+            OpenLayers.Util.mouseLeft(evt, this.map.div)) {
+                if (this.zoomBox) {
+                    this.removeZoomBox();
+                }
+                this.mouseDragStart = null;
+            }
+    },
+
+	/**
+	 *  Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/
+	 */
+
+    /** Catch the wheel event and handle it xbrowserly
+     *
+     * @param {Event} e
+     */
+    mouseWheel: function(evt) {
+        // first determine whether or not the wheeling was inside the map
+        var inMap = false;
+        var elem = OpenLayers.Event.element(evt);
+
+        while(elem != null) {
+            if (this.map && elem == this.map.div) {
+                inMap = true;
+                break;
+            }
+            elem = elem.parentNode;
+        }
+
+        if (inMap) {
+
+            var delta = 0;
+            if (!evt) {
+                evt = window.event;
+            }
+            if (evt.wheelDelta) {
+                delta = evt.wheelDelta/120;
+                if (window.opera) {
+                    delta = -delta;
+                }
+            } else if (evt.detail) {
+                delta = -evt.detail / 3;
+            }
+            if (delta) {
+                // add the mouse position to the event because mozilla has a bug
+                // with clientX and clientY (see https://bugzilla.mozilla.org/show_bug.cgi?id=352179)
+                // getLonLatFromViewPortPx(e) returns wrong values
+                evt.xy = this.mousePosition;
+
+                if (delta < 0) {
+                    this.mouseWheelDown(evt);
+                } else {
+                    this.mouseWheelUp(evt);
+                }
+            }
+
+            //only wheel the map, not the window
+            OpenLayers.Event.stop(evt);
+        }
+    },
+
+    /** User spun scroll wheel up
+     *
+     */
+    mouseWheelUp: function(evt) {
+
+        if (this.map.getZoom() <= this.map.getNumZoomLevels()) {
+            var mouse = this.map.getLonLatFromPixel(evt.xy);
+            var center = this.map.getCenter();
+            var resolution = this.map.getResolution();
+            var mouseToCenter = new OpenLayers.Pixel((mouse.lon - center.lon) / resolution,
+                                                     (mouse.lat - center.lat) / resolution);
+
+            var nextResolution = this.map.getResolution(this.map.getZoom() + 1);
+
+            this.map.setCenter(new OpenLayers.LonLat(center.lon + (mouseToCenter.x * nextResolution),
+                                                     center.lat + (mouseToCenter.y * nextResolution)),
+                               this.map.getZoom() + 1);
+        }
+
+    },
+
+    /** User spun scroll wheel down
+     *
+     */
+    mouseWheelDown: function(evt) {
+        if (this.map.getZoom() > 0) {
+            var mouse = this.map.getLonLatFromPixel(evt.xy);
+            var center = this.map.getCenter();
+            var resolution = this.map.getResolution();
+            var mouseToCenter = new OpenLayers.Pixel((mouse.lon - center.lon) / resolution,
+                                                     (mouse.lat - center.lat) / resolution);
+
+            var prevResolution = this.map.getResolution(this.map.getZoom() - 1);
+
+
+            this.map.setCenter(new OpenLayers.LonLat(mouse.lon - (mouseToCenter.x * prevResolution),
+                                                     mouse.lat - (mouseToCenter.y * prevResolution)),
+                               this.map.getZoom() - 1);
+        }
+
+    },
+
+    /** Zoombox function.
+     *
+     */
+    zoomBoxEnd: function(evt) {
+        if (this.mouseDragStart != null) {
+            if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 ||
+                Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) {
+                    var start = this.map.getLonLatFromViewPortPx(this.mouseDragStart);
+                    var end = this.map.getLonLatFromViewPortPx(evt.xy);
+                    var top = Math.max(start.lat, end.lat);
+                    var bottom = Math.min(start.lat, end.lat);
+                    var centerLat=((top+bottom)/2);
+                    var left = Math.min(start.lon, end.lon);
+                    var right = Math.max(start.lon, end.lon);
+                    var centerLon=((left+right)/2);
+                    this.map.setCenter(new OpenLayers.LonLat((centerLon),
+                                                             (centerLat)), 
+                                       this.map.getZoom() - 1);
+                    //var bounds = new OpenLayers.Bounds(left, bottom, right, top);
+                    //this.map.zoomToExtent(bounds);
+                } else {
+                    var end = this.map.getLonLatFromViewPortPx( evt.xy );
+                    this.map.setCenter(new OpenLayers.LonLat((end.lon),
+                                                             (end.lat)), 
+                                       this.map.getZoom() - 1);
+                }
+            this.removeZoomBox();
+        }
+    },
+
+    /**
+     * Remove the zoombox from the screen and nullify our reference to it.
+     */
+    removeZoomBox: function() {
+        this.zoomBox.initialCoords = null;
+        this.map.viewPortDiv.removeChild(this.zoomBox);
+        this.zoomBox = null;
+    },
+
+    /** @final @type String */
+    CLASS_NAME: "OpenLayers.Button.ZoomOut"
+});



More information about the Commits mailing list