Properly destroy features in the point, path, and polygon handlers. Patch with tests from fredj - thank you for the catch and the great patch. (Closes #931)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@4063 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -66,6 +66,33 @@
|
||||
t.ok(!handler.line.geometry.getBounds().equals(new OpenLayers.Bounds(0,-35.15625,35.15625,0)), "Correct bounds after dragging without letting go. (Came out as "+handler.line.geometry.getBounds().toBBOX() + ".)");
|
||||
}
|
||||
|
||||
function test_Handler_Path_destroy(t) {
|
||||
t.plan(6);
|
||||
var map = new OpenLayers.Map('map');
|
||||
map.addLayer(new OpenLayers.Layer.WMS("", "", {}));
|
||||
map.zoomToMaxExtent();
|
||||
var control = new OpenLayers.Control();
|
||||
map.addControl(control);
|
||||
var handler = new OpenLayers.Handler.Path(control, {foo: 'bar'});
|
||||
|
||||
handler.activate();
|
||||
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
||||
handler.mousedown(evt);
|
||||
|
||||
t.ok(handler.layer,
|
||||
"handler has a layer prior to destroy");
|
||||
t.ok(handler.point,
|
||||
"handler has a point prior to destroy");
|
||||
t.ok(handler.line,
|
||||
"handler has a line prior to destroy");
|
||||
handler.destroy();
|
||||
t.eq(handler.layer, null,
|
||||
"handler.layer is null after destroy");
|
||||
t.eq(handler.point, null,
|
||||
"handler.point is null after destroy");
|
||||
t.eq(handler.line, null,
|
||||
"handler.line is null after destroy");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -62,6 +62,29 @@
|
||||
t.ok(!handler.point.geometry.getBounds().equals(new OpenLayers.Bounds(0,0,0,0)), "Bounds changed after moving mouse");
|
||||
}
|
||||
|
||||
function test_Handler_Point_destroy(t) {
|
||||
t.plan(4);
|
||||
var map = new OpenLayers.Map('map');
|
||||
map.addLayer(new OpenLayers.Layer.WMS("", "", {}));
|
||||
map.zoomToMaxExtent();
|
||||
var control = new OpenLayers.Control();
|
||||
map.addControl(control);
|
||||
var handler = new OpenLayers.Handler.Point(control, {foo: 'bar'});
|
||||
|
||||
handler.activate();
|
||||
var evt = {xy: new OpenLayers.Pixel(150, 75), which: 1};
|
||||
handler.mousedown(evt);
|
||||
|
||||
t.ok(handler.layer,
|
||||
"handler has a layer prior to destroy");
|
||||
t.ok(handler.point,
|
||||
"handler has a point prior to destroy");
|
||||
handler.destroy();
|
||||
t.eq(handler.layer, null,
|
||||
"handler.layer is null after destroy");
|
||||
t.eq(handler.point, null,
|
||||
"handler.point is null after destroy");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user