| | 142 | }, |
|---|
| | 143 | |
|---|
| | 144 | /** |
|---|
| | 145 | * Method: removeControl |
|---|
| | 146 | * Remove a control from the toolbar. |
|---|
| | 147 | * |
|---|
| | 148 | * Parameters: |
|---|
| | 149 | * control - {<OpenLayers.Control>} The control to remove from |
|---|
| | 150 | * the toolbar. |
|---|
| | 151 | */ |
|---|
| | 152 | removeControl: function (control) { |
|---|
| | 153 | var button = this.getButtonForControl(control); |
|---|
| | 154 | |
|---|
| | 155 | button.destroy(); |
|---|
| | 156 | OpenLayers.Util.removeItem(this._buttons, button); |
|---|
| | 157 | |
|---|
| | 158 | control.events.un({ |
|---|
| | 159 | "activate": this.onControlActivate, |
|---|
| | 160 | "deactivate": this.onControlDeactivate, |
|---|
| | 161 | scope: this |
|---|
| | 162 | }); |
|---|
| | 163 | this.map.removeControl(control); |
|---|
| | 164 | OpenLayers.Util.removeItem(this.controls, control); |
|---|
| | 165 | }, |
|---|
| | 166 | |
|---|
| | 167 | /** |
|---|
| | 168 | * onControlActivate |
|---|
| | 169 | * Called when a control is activated. |
|---|
| | 170 | * |
|---|
| | 171 | * Parameters: |
|---|
| | 172 | * evt - {Object} An object with an object property referencing |
|---|
| | 173 | * the control. |
|---|
| | 174 | */ |
|---|
| | 175 | onControlActivate: function(evt) { |
|---|
| | 176 | var control = evt.object; |
|---|
| | 177 | var button = this.getButtonForControl(control); |
|---|
| | 178 | button.toggle(true); |
|---|
| | 179 | }, |
|---|
| | 180 | |
|---|
| | 181 | /** |
|---|
| | 182 | * onControlDeactivate |
|---|
| | 183 | * Called when a control is deactivated. |
|---|
| | 184 | * |
|---|
| | 185 | * Parameters: |
|---|
| | 186 | * evt - {Object} An object with an object property referencing |
|---|
| | 187 | * the control. |
|---|
| | 188 | */ |
|---|
| | 189 | onControlDeactivate: function(evt) { |
|---|
| | 190 | var control = evt.object; |
|---|
| | 191 | var button = this.getButtonForControl(control); |
|---|
| | 192 | button.toggle(false); |
|---|
| | 193 | this.checkDefaultControl(button); |
|---|