ModifyFeature: enable dragging without enabling vertex modifications. Special thanks to tschaub for the collaboration on all the changes to the modify feature control. And thanks to crschmidt for the review. (closes #1188)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@5467 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -88,16 +88,18 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
virtualStyle: null,
|
||||
|
||||
/**
|
||||
* APIProperty: rotate
|
||||
* {Boolean} Allow rotation of feature instead of vertex modification.
|
||||
* APIProperty: mode
|
||||
* {Integer} Bitfields specifying the modification mode. Defaults to
|
||||
* OpenLayers.Control.ModifyFeature.RESHAPE. To set the mode to a
|
||||
* combination of options, use the | operator. or example, to allow
|
||||
* the control to both resize and rotate features, use the following
|
||||
* syntax
|
||||
* (code)
|
||||
* control.mode = OpenLayers.Control.ModifyFeature.RESIZE |
|
||||
* OpenLayers.Control.ModifyFeature.ROTATE;
|
||||
* (end)
|
||||
*/
|
||||
rotate: false,
|
||||
|
||||
/**
|
||||
* APIProperty: resize
|
||||
* {Boolean} Allow resizing of feature instead of vertex modification.
|
||||
*/
|
||||
resize: false,
|
||||
mode: null,
|
||||
|
||||
/**
|
||||
* Property: radiusHandle
|
||||
@@ -105,12 +107,6 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
radiusHandle: null,
|
||||
|
||||
/**
|
||||
* APIProperty: drag
|
||||
* {Boolean} Allow dragging of feature with a drag handle.
|
||||
*/
|
||||
drag: false,
|
||||
|
||||
/**
|
||||
* Property: dragHandle
|
||||
* {<OpenLayers.Feature.Vector>} A handle for dragging a feature.
|
||||
@@ -159,6 +155,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.styleVirtual.fillOpacity = 0.3;
|
||||
this.styleVirtual.strokeOpacity = 0.3;
|
||||
this.deleteCodes = [46, 100];
|
||||
this.mode = OpenLayers.Control.ModifyFeature.RESHAPE;
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
if(!(this.deleteCodes instanceof Array)) {
|
||||
this.deleteCodes = [this.deleteCodes];
|
||||
@@ -427,12 +424,14 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
}
|
||||
if(this.feature &&
|
||||
this.feature.geometry.CLASS_NAME != "OpenLayers.Geometry.Point") {
|
||||
if(this.drag) {
|
||||
if((this.mode & OpenLayers.Control.ModifyFeature.DRAG)) {
|
||||
this.collectDragHandle();
|
||||
}
|
||||
if(this.rotate || this.resize) {
|
||||
if((this.mode & (OpenLayers.Control.ModifyFeature.ROTATE |
|
||||
OpenLayers.Control.ModifyFeature.RESIZE))) {
|
||||
this.collectRadiusHandle();
|
||||
} else {
|
||||
}
|
||||
if((this.mode & OpenLayers.Control.ModifyFeature.RESHAPE)) {
|
||||
this.collectVertices();
|
||||
}
|
||||
}
|
||||
@@ -553,8 +552,8 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
bounds.right, bounds.bottom
|
||||
);
|
||||
var radius = new OpenLayers.Feature.Vector(radiusGeometry);
|
||||
var resize = this.resize;
|
||||
var rotate = this.rotate;
|
||||
var resize = (this.mode & OpenLayers.Control.ModifyFeature.RESIZE);
|
||||
var rotate = (this.mode & OpenLayers.Control.ModifyFeature.ROTATE);
|
||||
radiusGeometry.move = function(x, y) {
|
||||
OpenLayers.Geometry.Point.prototype.move.call(this, x, y);
|
||||
var dx1 = this.x - originGeometry.x;
|
||||
@@ -593,3 +592,24 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.ModifyFeature"
|
||||
});
|
||||
|
||||
/**
|
||||
* Constant: RESHAPE
|
||||
* {Integer} Constant used to make the control work in reshape mode
|
||||
*/
|
||||
OpenLayers.Control.ModifyFeature.RESHAPE = 1;
|
||||
/**
|
||||
* Constant: RESIZE
|
||||
* {Integer} Constant used to make the control work in resize mode
|
||||
*/
|
||||
OpenLayers.Control.ModifyFeature.RESIZE = 2;
|
||||
/**
|
||||
* Constant: ROTATE
|
||||
* {Integer} Constant used to make the control work in rotate mode
|
||||
*/
|
||||
OpenLayers.Control.ModifyFeature.ROTATE = 4;
|
||||
/**
|
||||
* Constant: DRAG
|
||||
* {Integer} Constant used to make the control work in drag mode
|
||||
*/
|
||||
OpenLayers.Control.ModifyFeature.DRAG = 8;
|
||||
|
||||
Reference in New Issue
Block a user