fix OverviewMap regression. r=elemoine (closes #2137)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10434 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Frédéric Junod
2010-06-30 09:06:27 +00:00
parent 0bc3e3c8b3
commit e643531a0a
2 changed files with 37 additions and 4 deletions

View File

@@ -91,7 +91,8 @@ OpenLayers.Handler = OpenLayers.Class({
* Parameters:
* control - {<OpenLayers.Control>} The control that initialized this
* handler. The control is assumed to have a valid map property; that
* map is used in the handler's own setMap method.
* map is used in the handler's own setMap method. If a map property
* is present in the options argument it will be used instead.
* callbacks - {Object} An object whose properties correspond to abstracted
* events or sequences of browser events. The values for these
* properties are functions defined by the control that get called by
@@ -103,8 +104,10 @@ OpenLayers.Handler = OpenLayers.Class({
OpenLayers.Util.extend(this, options);
this.control = control;
this.callbacks = callbacks;
if (control.map) {
this.setMap(control.map);
var map = this.map || control.map;
if (map) {
this.setMap(map);
}
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");

View File

@@ -2,7 +2,7 @@
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map;
var map, control;
function test_initialize(t) {
t.plan( 2 );
@@ -10,6 +10,36 @@
t.ok( control instanceof OpenLayers.Control.OverviewMap, "new OpenLayers.Control.OverviewMap returns object" );
t.eq( control.displayClass, "olControlOverviewMap", "displayClass is correct" );
}
function test_setMap(t) {
t.plan(4);
var setMapTest = function(map) {
t.ok(true, "Handler.setMap called for " + this.CLASS_NAME);
this.map = map;
};
var drag_setMap = OpenLayers.Handler.Drag.prototype.setMap;
OpenLayers.Handler.Drag.prototype.setMap = setMapTest;
var click_setMap = OpenLayers.Handler.Click.prototype.setMap;
OpenLayers.Handler.Click.prototype.setMap = setMapTest;
map = new OpenLayers.Map('map', {
layers : [new OpenLayers.Layer("layer", {isBaseLayer: true})],
controls: []
});
control = new OpenLayers.Control.OverviewMap();
map.addControl(control);
map.zoomToMaxExtent();
t.eq(control.handlers.drag.map.id, control.ovmap.id, "drag.map is correct");
t.eq(control.handlers.click.map.id, control.ovmap.id, "click.map is correct");
map.destroy();
OpenLayers.Handler.Drag.prototype.setMap = drag_setMap;
OpenLayers.Handler.Click.prototype.setMap = click_setMap;
}
function test_destroy(t) {
t.plan(6);