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:
@@ -216,6 +216,36 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
|
||||
destroyPopup: function() {
|
||||
// pass
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: move
|
||||
* Moves the feature and redraws it at its new location
|
||||
*
|
||||
* Parameters:
|
||||
* state - {OpenLayers.LonLat or OpenLayers.Pixel} the
|
||||
* location to which to move the feature.
|
||||
*/
|
||||
move: function(location) {
|
||||
|
||||
if(!this.layer || !this.geometry.move){
|
||||
//do nothing if no layer or immoveable geometry
|
||||
return;
|
||||
}
|
||||
|
||||
var pixel;
|
||||
if (location.CLASS_NAME == "OpenLayers.LonLat") {
|
||||
pixel = this.layer.getViewPortPxFromLonLat(location);
|
||||
} else {
|
||||
pixel = location;
|
||||
}
|
||||
|
||||
var lastPixel = this.layer.getViewPortPxFromLonLat(this.geometry.getBounds().getCenterLonLat());
|
||||
var res = this.layer.map.getResolution();
|
||||
this.geometry.move(res * (pixel.x - lastPixel.x),
|
||||
res * (lastPixel.y - pixel.y));
|
||||
this.layer.drawFeature(this);
|
||||
return lastPixel;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: toState
|
||||
|
||||
Reference in New Issue
Block a user