[OpenLayers-Commits] r7317 - sandbox/topp/almanac
commits at openlayers.org
commits at openlayers.org
Thu Jun 5 22:13:37 EDT 2008
Author: sbenthall
Date: 2008-06-05 22:13:37 -0400 (Thu, 05 Jun 2008)
New Revision: 7317
Modified:
sandbox/topp/almanac/StoryEditGeometry.js
Log:
Changing StoryEditGeometry control to inherit from ToolSwitch
Modified: sandbox/topp/almanac/StoryEditGeometry.js
===================================================================
--- sandbox/topp/almanac/StoryEditGeometry.js 2008-06-06 02:12:30 UTC (rev 7316)
+++ sandbox/topp/almanac/StoryEditGeometry.js 2008-06-06 02:13:37 UTC (rev 7317)
@@ -3,16 +3,8 @@
var Almanac = {};
Almanac.Control = {};
-Almanac.Control.StoryEditGeometry = new OpenLayers.Class(OpenLayers.Control, {
-
- /**
- * Property: layer
- * {<Almanac.Layer.Story>}
- */
- layer: null,
+Almanac.Control.StoryEditGeometry = new OpenLayers.Class(OpenLayers.Control.ToolSwitch, {
- tools: null,
-
selectControl: null,
/**
@@ -20,11 +12,8 @@
* Create a new control to modify stories.
*/
initialize: function(layer, options) {
- OpenLayers.Control.prototype.initialize.apply(this, [options]);
-
- this.layer = layer;
- this.tools = {
+ var tools = {
point: new OpenLayers.Control.DrawFeature(layer,
OpenLayers.Handler.Point),
line: new OpenLayers.Control.DrawFeature(layer,
@@ -33,8 +22,11 @@
OpenLayers.Handler.Polygon),
modify: new OpenLayers.Control.ModifyFeature(layer)
};
-
+ OpenLayers.Control.ToolSwitch.prototype.initialize.apply(this, [layer, tools, options]);
+
+ this.defaultTool = 'modify';
+
this.selectControl = this.tools['modify'].selectControl;
this.layer.events.on({
@@ -49,11 +41,7 @@
},
- activate: function(){
- OpenLayers.Control.prototype.activate.apply(this, arguments);
- this.toggleMode('modify');
- },
-
+
destroy: function(){
this.layer.events.un({
"featureadded": this.onFeatureAdded,
@@ -64,29 +52,12 @@
"activate": this.selectFeature,
scope: this
})
-
- this.layer = null;
- this.tools = null;
+
this.selectControl = null;
- OpenLayers.Control.prototype.destroy.apply(this, arguments);
+ OpenLayers.Control.ToolSwitch.prototype.destroy.apply(this, arguments);
},
-
- toggleMode: function(name) {
- if(!this.active){
- return;
- }
-
- for(var key in this.tools) {
- var tool = this.tools[key];
- if(name == key) {
- tool.activate();
- } else {
- tool.deactivate();
- }
- }
- },
-
+
selectFeature: function(){
//this control maintains a maximum of one feature on its layer
var feature = this.layer.features[0];
@@ -105,32 +76,8 @@
}
}
- this.toggleMode('modify');
+ this.switchTool('modify');
},
- /**
- * Method: setMap
- * Set the map property for the control and all controls it owns.
- *
- * Parameters:
- * map - {<OpenLayers.Map>} The control's map.
- */
- setMap: function(map) {
- for(var key in this.tools){
- this.tools[key].setMap(map);
- }
-
- //this.selectControl.setMap(map);
-
- OpenLayers.Control.prototype.setMap.apply(this, arguments);
- },
-
- onToolActivateBehavior: function(tool, scope, behavior){
- this.tools[tool].events.on({
- "activate" : behavior,
- scope : scope
- })
- },
-
CLASS_NAME: "Almanac.Control.StoryEditGeometry"
});
More information about the Commits
mailing list