measure control - wrong measure when moving fast, r=fredj (closes #2691)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10407 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -180,6 +180,7 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
*/
|
*/
|
||||||
measurePartial: function(point, geometry) {
|
measurePartial: function(point, geometry) {
|
||||||
if (geometry.getLength() > 0) {
|
if (geometry.getLength() > 0) {
|
||||||
|
geometry = geometry.clone();
|
||||||
this.delayedTrigger = window.setTimeout(
|
this.delayedTrigger = window.setTimeout(
|
||||||
OpenLayers.Function.bind(function() {
|
OpenLayers.Function.bind(function() {
|
||||||
this.measure(geometry, "measurepartial");
|
this.measure(geometry, "measurepartial");
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test for <http://trac.openlayers.org/ticket/2691>
|
||||||
function test_cancel(t) {
|
function test_cancel(t) {
|
||||||
|
|
||||||
t.plan(4);
|
t.plan(4);
|
||||||
@@ -67,6 +68,52 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_partial(t) {
|
||||||
|
t.plan(1);
|
||||||
|
|
||||||
|
// set up
|
||||||
|
|
||||||
|
var map, layer, control, geometry, log;
|
||||||
|
|
||||||
|
map = new OpenLayers.Map("map", {units: "m"});
|
||||||
|
|
||||||
|
layer = new OpenLayers.Layer(null, {isBaseLayer: true});
|
||||||
|
map.addLayer(layer);
|
||||||
|
|
||||||
|
map.zoomToMaxExtent();
|
||||||
|
|
||||||
|
control = new OpenLayers.Control.Measure(OpenLayers.Handler.Path, {
|
||||||
|
partialDelay: null
|
||||||
|
});
|
||||||
|
|
||||||
|
map.addControl(control);
|
||||||
|
control.activate();
|
||||||
|
|
||||||
|
control.events.on({
|
||||||
|
"measurepartial": function(e) {
|
||||||
|
log.measure = e.measure;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// test
|
||||||
|
|
||||||
|
geometry = new OpenLayers.Geometry.LineString([
|
||||||
|
new OpenLayers.Geometry.Point(1, 1),
|
||||||
|
new OpenLayers.Geometry.Point(2, 1)
|
||||||
|
]);
|
||||||
|
|
||||||
|
log = {};
|
||||||
|
control.measurePartial(null, geometry);
|
||||||
|
geometry.components[1].x = 3;
|
||||||
|
t.delay_call(0.2, function() {
|
||||||
|
|
||||||
|
t.eq(log.measure, 1, "partial measure is correct");
|
||||||
|
|
||||||
|
// tear down
|
||||||
|
map.destroy
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in New Issue
Block a user