Changeset 2254
- Timestamp:
- 02/21/07 08:47:43 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/oterral/ButtonBar/vector/examples/Buttonbar.html
r2253 r2254 86 86 var dragpan=new OpenLayers.MouseListener.DragPan("dragpan","panning-hand-off.png", "panning-hand-on.png","radioButton",optionsTools); 87 87 var measuredistance=new OpenLayers.MouseListener.MeasureDistance("measuredistance","MeasureEnable.png", "MeasureDisable.png","radioButton",optionsTools); 88 var measurearea=new OpenLayers.MouseListener.MeasureArea("measurearea","MeasureEnable.png", "MeasureDisable.png","radioButton",optionsTools); 89 88 90 var zoomworld=new OpenLayers.MouseListener.Reset("zoomworld","ResetExtentDisable.png", "button",optionsTools); 89 91 … … 95 97 var drawpointstring=new OpenLayers.MouseListener.EditingListener.DrawPoint("drawpoint","EditPointEnable.png", "EditPointDisable.png","radioButton",optionsTools); 96 98 97 toolbar.addTools([measuredistance, drawlinearring,drawlinestring,drawpointstring]);99 toolbar.addTools([measuredistance,measurearea,drawlinearring,drawlinestring,drawpointstring]); 98 100 99 101 /*Modify Geometry Tool*/ … … 126 128 <div id="map"></div> 127 129 <div id="ButtonBar" style="position:relative;"></div> 130 131 <div id="Area" style="position:relative;display:block;"></div> 128 132 </body> 129 133 </html> sandbox/oterral/ButtonBar/vector/lib/OpenLayers/MouseListener/MeasureArea.js
r2157 r2254 27 27 * @constructor 28 28 ***/ 29 initialize: function( options) {29 initialize: function(id , imageOn , imageOff , type , options) { 30 30 OpenLayers.MouseListener.EditingListener.prototype.initialize.apply(this, arguments); 31 this.turnOn(); 32 31 //this.turnOn(); 32 this.id=id; 33 this.imageOn=imageOn; 34 this.imageOff=imageOff; 35 this.type=type; 36 33 37 options = options || []; 34 38 OpenLayers.Util.extend(this, options); … … 39 43 */ 40 44 turnOn: function() { 41 OpenLayers.MouseListener.EditingListener.prototype.turnOn.apply(this, arguments);42 this.geometry = new OpenLayers.Geometry.LinearRing();45 this.map.addMouseListener(this); 46 this.geometry = new OpenLayers.Geometry.LinearRing(); 43 47 this.tmpLineSting = new OpenLayers.Geometry.LineString(); 44 48 }, … … 48 52 */ 49 53 turnOff: function() { 50 OpenLayers.MouseListener.EditingListener.prototype.turnOff.apply(this, arguments); 51 this.eraseTmpElements(); 54 this.eraseTmpElements(); 52 55 this.geometry = null; 56 this.map.removeMouseListener(this); 57 53 58 }, 54 59 … … 63 68 64 69 eraseTmpElements: function() { 65 for(var i = 0; i < this.geometry.path.length; i++) { 66 this.map.vectorLayer.renderer.eraseGeometry(this.geometry.path[i]); 67 } 68 this.map.vectorLayer.renderer.eraseGeometry(this.geometry); 70 71 this.map.vectorLayer.renderer.eraseGeometry(this.tmpLineSting); 72 73 74 this.map.vectorLayer.renderer.eraseGeometry(this.oldGeometry); 69 75 }, 70 76 … … 115 121 this.map.vectorLayer.renderer.drawGeometry(this.tmpLineSting, this.style); 116 122 117 if (this.element != null) {118 this.draw();119 }120 123 } 121 124 } 122 125 }, 123 126 mouseUp: function(evt) { 127 OpenLayers.MouseListener.EditingListener.prototype.mouseUp.apply(this, arguments); 128 this.draw(); 129 }, 124 130 keyDown: function(evt) { 125 131 … … 146 152 draw: function() { 147 153 var digits = parseInt(this.numdigits); 148 154 if(!this.div) 155 { this.div=document.createElement('div'); 156 this.div.id="MeasureArea";} 157 this.div.innerHTML=""; 158 //configure main div 159 this.div.style.position = "relative"; 160 this.div.style.top = "30px"; 161 this.div.style.right = "0px"; 162 this.div.style.left = ""; 163 this.div.style.fontFamily = "sans-serif"; 164 this.div.style.fontWeight = "bold"; 165 this.div.style.marginTop = "3px"; 166 this.div.style.marginLeft = "3px"; 167 this.div.style.marginBottom = "3px"; 168 this.div.style.fontSize = "smaller"; 169 this.div.style.color = "white"; 170 this.div.style.backgroundColor = "blue"; 149 171 var newHtml = this.prefix + 150 172 this.geometry.getLength().toFixed(digits) + 151 173 this.suffix; 174 175 if (newHtml != this.div.innerHTML) { 152 176 153 if (newHtml != this.element.innerHTML) { 154 this.element.innerHTML = newHtml; 177 this.div.innerHTML = newHtml; 155 178 } 179 document.lastChild.lastChild.appendChild(this.div); 156 180 }, 157 181 sandbox/oterral/ButtonBar/vector/lib/OpenLayers/MouseListener/MeasureDistance.js
r2248 r2254 13 13 14 14 /** @type DOMElement */ 15 element: null,15 div: null, 16 16 17 17 /** @type String */ … … 19 19 20 20 /** @type String */ 21 suffix: ' m',21 suffix: null, 22 22 23 23 /** @type int */ 24 24 numdigits: 2, 25 25 26 map:null, 26 27 /** 27 28 * @constructor … … 34 35 this.imageOff=imageOff; 35 36 this.type=type; 37 36 38 options = options || []; 37 39 OpenLayers.Util.extend(this, options); … … 43 45 turnOn: function() { 44 46 // OpenLayers.MouseListener.EditingListener.prototype.turnOn.apply(this, arguments); 45 this.map.events.register( "mousedown", this, this.mouseDown); 46 this.map.events.register( "mousemove", this, this.mouseMove); 47 this.map.events.register( "mouseup", this, this.mouseUp); 47 this.map.addMouseListener(this); 48 this.suffix=this.map.units; 48 49 this.geometry = new OpenLayers.Geometry.LineString(); 49 this.tmpSegment = new OpenLayers.Geometry.LineS egment();50 this.tmpSegment = new OpenLayers.Geometry.LineString(); 50 51 }, 51 52 … … 54 55 */ 55 56 turnOff: function() { 56 this.map.events.unregister( "mousedown", this, this.mouseDown);57 this. map.events.unregister( "mousemove", this, this.mouseMove);58 this.map.events.unregister( "mouseup", this, this.mouseUp);57 this.eraseTmpElements(); 58 this.geometry = null; 59 this.map.removeMouseListener(this); 59 60 //OpenLayers.MouseListener.EditingListener.prototype.turnOff.apply(this, arguments); 60 this.eraseTmpElements(); 61 this.geometry = null; 61 62 62 }, 63 63 … … 66 66 */ 67 67 finalizeGeometry: function() { 68 68 69 this.oldGeometry = this.geometry; 69 70 this.geometry = new OpenLayers.Geometry.LineString(); … … 72 73 73 74 eraseTmpElements: function() { 74 for(var i = 0; i < this.geometry.path.length; i++) {75 /*for(var i = 0; i < this.oldGeometry.path.length; i++) { 75 76 this.map.vectorLayer.renderer.eraseGeometry(this.geometry.path[i]); 76 } 77 this.map.vectorLayer.renderer.eraseGeometry(this.geometry); 77 78 }*/ 79 this.map.vectorLayer.renderer.eraseGeometry(this.tmpSegment); 80 81 // this.map.vectorLayer.renderer.eraseGeometry(this.oldGeometry); 82 this.map.vectorLayer.renderer.eraseGeometry(this.oldGeometry); 83 78 84 }, 79 85 … … 82 88 83 89 this.mouseDown(evt); 84 //this.eraseTmpElements();90 // this.eraseTmpElements(); 85 91 if(this.geometry.path.length > 2){ 86 92 this.finalizeGeometry(); … … 112 118 113 119 } else { 114 if (this.geometry.path.length > 0) { 120 if (this.geometry.path.length > 0) {//alert(this.tmpSegment.path[1]); 121 this.tmpSegment.path[1] = this.geometry.path[this.geometry.path.length-1]; 115 122 this.tmpSegment.path[0] = evt.point; 116 this.tmpSegment.path[1] = this.geometry.path[this.geometry.path.length-1];123 //this.tmpLineSting.path[2] = this.geometry.path[this.geometry.path.length-1]; 117 124 this.map.vectorLayer.renderer.drawGeometry(this.tmpSegment, this.style); 118 125 119 if (this.element != null) { 120 this.draw(); 121 } 126 127 122 128 } 123 129 } 124 130 }, 125 131 mouseUp: function(evt) { 132 OpenLayers.MouseListener.EditingListener.prototype.mouseUp.apply(this, arguments); 133 this.draw(); 134 }, 126 135 keyDown: function(evt) { 127 136 … … 148 157 draw: function() { 149 158 var digits = parseInt(this.numdigits); 150 159 if(!this.div) 160 { this.div=document.createElement('div'); 161 this.div.id="MeasureDistance"; 162 } 163 this.div.innerHTML=""; 164 //configure main div 165 this.div.style.position = "relative"; 166 this.div.style.top = "30px"; 167 this.div.style.right = "0px"; 168 this.div.style.left = ""; 169 this.div.style.fontFamily = "sans-serif"; 170 this.div.style.fontWeight = "bold"; 171 this.div.style.marginTop = "3px"; 172 this.div.style.marginLeft = "3px"; 173 this.div.style.marginBottom = "3px"; 174 this.div.style.fontSize = "smaller"; 175 this.div.style.color = "white"; 176 this.div.style.backgroundColor = "blue"; 151 177 var newHtml = this.prefix + 152 178 this.geometry.getLength().toFixed(digits) + 153 179 this.suffix; 180 181 if (newHtml != this.div.innerHTML) { 154 182 155 if (newHtml != this.element.innerHTML) { 156 this.element.innerHTML = newHtml; 183 this.div.innerHTML = newHtml; 157 184 } 185 document.lastChild.lastChild.appendChild(this.div); 158 186 }, 159 187
