diff --git a/lib/OpenLayers/Control/MouseToolbar.js b/lib/OpenLayers/Control/MouseToolbar.js index 309660a871..712e59c3d5 100644 --- a/lib/OpenLayers/Control/MouseToolbar.js +++ b/lib/OpenLayers/Control/MouseToolbar.js @@ -180,7 +180,7 @@ OpenLayers.Control.MouseToolbar.prototype = switchModeTo: function(mode) { if (mode != this.mode) { - if (this.mode) { + if (this.mode && this.buttons[this.mode]) { OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation); } if (this.mode == "measure" && mode != "measure") { @@ -193,7 +193,9 @@ OpenLayers.Control.MouseToolbar.prototype = this.measureStart = null; } this.mode = mode; - OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation); + if (this.buttons[mode]) { + OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation); + } } },