add support for maxVertices in Hander.Path, p=me,r=erilem, thanks erilem for the updated patch and your great work on this (closes #2779)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11797 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
bartvde
2011-03-30 14:38:32 +00:00
parent 7a29b2d324
commit 56bca84cfe
2 changed files with 49 additions and 0 deletions

View File

@@ -524,6 +524,43 @@
map.destroy();
}
function test_maxVertices(t) {
t.plan(1);
var map = new OpenLayers.Map("map", {
resolutions: [1]
});
var layer = new OpenLayers.Layer.Vector("foo", {
maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
isBaseLayer: true
});
map.addLayer(layer);
var control = new OpenLayers.Control({});
var log = {};
var doneCallback = function(evt) {
t.ok(evt, 'When maxVertices is reached, the geometry is finalized automatically');
};
var handler = new OpenLayers.Handler.Path(control, {'done': doneCallback}, {maxVertices: 2});
control.handler = handler;
map.addControl(control);
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
// mock up feature drawing
handler.activate();
var evt = {xy: new OpenLayers.Pixel(0, 0)};
handler.mousemove(evt);
handler.mousedown(evt);
handler.mouseup(evt);
evt = {xy: new OpenLayers.Pixel(20, 20)};
handler.mousemove(evt);
handler.mousedown(evt);
handler.mouseup(evt);
evt = {xy: new OpenLayers.Pixel(40, 40)};
handler.mousemove(evt);
handler.mousedown(evt);
handler.mouseup(evt);
map.destroy();
}
//
// Sequence tests
//