I'm using the DragZoom control in conjunction with a Silveright app.
During the map creation I switch a few times the control on and off.
It turns out that it may happen that I call the disableKeyDragZoom method while
the control was enabled but wasn't yet added to the map.
What steps will reproduce the problem?
1. enable the KeyDragZoom feature
2. disable it straight away without leaving the map a change to add the feature
to itself
3. exception is thrown
I'm using IE8.
What I suggest that solved the issue for me is to add a flag to check that the
feature was added to the map.
Replacethe disableKeyDragZoom method with this one:
google.maps.Map.prototype.disableKeyDragZoom = function () {
var i;
var d = this.dragZoom_;
if (d) {
if (d.initDone_) { // <-------- this is the bit that I added
for (i = 0; i < d.listeners_.length; ++i) {
google.maps.event.removeListener(d.listeners_[i]);
}
this.getDiv().removeChild(d.boxDiv_);
for (i = 0; i < d.veilDiv_.length; i++) {
this.getDiv().removeChild(d.veilDiv_[i]);
}
if (d.visualEnabled_) {
// Remove the custom control:
this.controls[d.visualPosition_].removeAt(d.controlIndex_);
}
}
d.prjov_.setMap(null);
}
this.dragZoom_ = null;
};
and replace the constructor with this one:
function DragZoom(map, opt_zoomOpts) {
var me = this;
var ov = new google.maps.OverlayView();
ov.onAdd = function () {
me.init_(map, opt_zoomOpts);
me.initDone_ = true; // <------------- this is the bit I added
};
ov.draw = function () {
};
ov.onRemove = function () {
};
ov.setMap(map);
this.prjov_ = ov;
}
The changes I described fixed the issue for me.
Original issue reported on code.google.com by arnaud.t...@gmail.com on 4 Mar 2011 at 8:03
Original issue reported on code.google.com by
arnaud.t...@gmail.com
on 4 Mar 2011 at 8:03