Changeset 7541
- Timestamp:
- 07/18/08 01:28:25 (1 month ago)
- Files:
-
- sandbox/topp/trimet/examples/measure.html (added)
- sandbox/topp/trimet/lib/OpenLayers.js (modified) (1 diff)
- sandbox/topp/trimet/lib/OpenLayers/Control/Measure.js (added)
- sandbox/topp/trimet/lib/OpenLayers/Handler/Path.js (modified) (5 diffs)
- sandbox/topp/trimet/lib/OpenLayers/Handler/Point.js (modified) (7 diffs)
- sandbox/topp/trimet/lib/OpenLayers/Handler/Polygon.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/topp/trimet/lib/OpenLayers.js
r7496 r7541 151 151 "OpenLayers/Control/Navigation.js", 152 152 "OpenLayers/Control/MouseDefaults.js", 153 "OpenLayers/Control/Measure.js", 153 154 "OpenLayers/Control/MousePosition.js", 154 155 "OpenLayers/Control/OverviewMap.js", sandbox/topp/trimet/lib/OpenLayers/Handler/Path.js
r7496 r7541 74 74 this.point = new OpenLayers.Feature.Vector( 75 75 new OpenLayers.Geometry.Point()); 76 this.layer.addFeatures([this.line, this.point]); 76 77 }, 77 78 … … 82 83 destroyFeature: function() { 83 84 OpenLayers.Handler.Point.prototype.destroyFeature.apply(this); 84 if(this.line) {85 this.line.destroy();86 }87 85 this.line = null; 86 }, 87 88 /** 89 * Method: destroyPoint 90 * Destroy the temporary point. 91 */ 92 destroyPoint: function() { 93 if(this.point) { 94 this.layer.destroyFeatures([this.point]); 95 } 88 96 }, 89 97 … … 163 171 } 164 172 if(this.lastDown == null) { 173 if(this.persist) { 174 this.destroyFeature(); 175 } 165 176 this.createFeature(); 166 177 } … … 219 230 if(this.drawing) { 220 231 if(this.freehandMode(evt)) { 232 if(this.persist) { 233 this.destroyPoint(); 234 } 221 235 this.finalize(); 222 236 } else { … … 246 260 var index = this.line.geometry.components.length - 1; 247 261 this.line.geometry.removeComponent(this.line.geometry.components[index]); 262 if(this.persist) { 263 this.destroyPoint(); 264 } 248 265 this.finalize(); 249 266 } sandbox/topp/trimet/lib/OpenLayers/Handler/Point.js
r7496 r7541 63 63 */ 64 64 lastUp: null, 65 66 /** 67 * APIProperty: persist 68 * {Boolean} Leave the feature rendered until destroyFeature is called. 69 * Default is false. If set to true, the feature remains rendered until 70 * destroyFeature is called, typically by deactivating the handler or 71 * starting another drawing. 72 */ 73 persist: false, 65 74 66 75 /** … … 116 125 createFeature: function() { 117 126 this.point = new OpenLayers.Feature.Vector( 118 new OpenLayers.Geometry.Point()); 127 new OpenLayers.Geometry.Point() 128 ); 129 this.layer.addFeatures([this.point]); 119 130 }, 120 131 … … 131 142 this.cancel(); 132 143 } 144 this.destroyFeature(); 133 145 // If a layer's map property is set to null, it means that that layer 134 146 // isn't added to the map. Since we ourself added the layer to the map … … 148 160 */ 149 161 destroyFeature: function() { 150 if(this.point) { 151 this.point.destroy(); 152 } 162 this.layer.destroyFeatures(); 153 163 this.point = null; 154 164 }, … … 164 174 finalize: function(cancel) { 165 175 var key = cancel ? "cancel" : "done"; 166 this.layer.renderer.clear();167 176 this.drawing = false; 168 177 this.mouseDown = false; … … 170 179 this.lastUp = null; 171 180 this.callback(key, [this.geometryClone()]); 172 this.destroyFeature(); 181 if(cancel || !this.persist) { 182 this.destroyFeature(); 183 } 173 184 }, 174 185 … … 257 268 } 258 269 if(this.lastDown == null) { 270 if(this.persist) { 271 this.destroyFeature(); 272 } 259 273 this.createFeature(); 260 274 } sandbox/topp/trimet/lib/OpenLayers/Handler/Polygon.js
r7496 r7541 60 60 this.point = new OpenLayers.Feature.Vector( 61 61 new OpenLayers.Geometry.Point()); 62 this.layer.addFeatures([this.polygon, this.point]); 62 63 }, 63 64 … … 68 69 destroyFeature: function() { 69 70 OpenLayers.Handler.Path.prototype.destroyFeature.apply(this); 70 if(this.polygon) {71 this.polygon.destroy();72 }73 71 this.polygon = null; 74 72 }, … … 123 121 var index = this.line.geometry.components.length - 2; 124 122 this.line.geometry.removeComponent(this.line.geometry.components[index]); 123 if(this.persist) { 124 this.destroyPoint(); 125 } 125 126 this.finalize(); 126 127 }
