Support for moving vector features a given number of pixels, or to a given lon/lat, using a move() method. Patch from sbenthall. (Closes #1326)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@7593 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2008-07-29 23:30:32 +00:00
parent 2ed6483121
commit 7736e12d33
2 changed files with 70 additions and 0 deletions

View File

@@ -86,7 +86,47 @@
"clone can clone geometry-less features");
}
function test_Feature_Vector_move(t) {
t.plan(3);
var oldx = 26;
var oldy = 14;
var newx = 6;
var newy = 4;
var res = 10;
var geometry = new OpenLayers.Geometry.Point(oldx,
oldy);
var drawn = false;
feature = new OpenLayers.Feature.Vector(geometry);
feature.layer = {
getViewPortPxFromLonLat : function(lonlat){
return new OpenLayers.Pixel(lonlat.lon,lonlat.lat);
},
map: {
getResolution: function(){
return res;
}
},
drawFeature: function(){
drawn = true;
}
}
var pixel = new OpenLayers.Pixel(newx,newy)
feature.move(pixel);
geometry = feature.geometry;
t.ok(drawn, "The feature is redrawn after the move");
t.eq(geometry.x, res * (newx - oldx) + oldx, "New geometry has proper x coordinate");
t.eq(geometry.y, res * (oldy - newy) + oldy, "New geometry has proper y coordinate");
}
</script>
</head>