Add support for irregular transformations to TransformFeature
Give the TransformFeature control an irregular mode where dragging a handle just extends that side rather than growing the shape symmetrically about the centre.
This commit is contained in:
@@ -165,7 +165,13 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* {<OpenLayers.Control.DragFeature>}
|
||||
*/
|
||||
dragControl: null,
|
||||
|
||||
|
||||
/**
|
||||
* APIProperty: irregular
|
||||
* {Boolean}
|
||||
*/
|
||||
irregular: false,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.TransformFeature
|
||||
* Create a new transform feature control.
|
||||
@@ -390,6 +396,14 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
var dy1 = this.y - centerGeometry.y;
|
||||
var dx0 = dx1 - (this.x - oldGeom.x);
|
||||
var dy0 = dy1 - (this.y - oldGeom.y);
|
||||
if (control.irregular && !control._setfeature) {
|
||||
dx1 -= (this.x - oldGeom.x) / 2;
|
||||
dy1 -= (this.y - oldGeom.y) / 2;
|
||||
var newCenter = centerGeometry.clone();
|
||||
newCenter.x += Math.abs(dx0) < 0.00001 ? 0 : (this.x - oldGeom.x) / 2;
|
||||
newCenter.y += Math.abs(dy0) < 0.00001 ? 0 : (this.y - oldGeom.y) / 2;
|
||||
control.transformFeature({center: newCenter});
|
||||
}
|
||||
this.x = oldX;
|
||||
this.y = oldY;
|
||||
var scale, ratio = 1;
|
||||
@@ -410,6 +424,7 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
control.box.geometry.resize(scale, centerGeometry, ratio);
|
||||
control.box.geometry.rotate(control.rotation, centerGeometry);
|
||||
control.box.move(control.feature.geometry.getBounds().getCenterLonLat());
|
||||
control.transformFeature({scale: scale, ratio: ratio});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user