[OpenLayers-Dev] How to modify regular polygon - ModifyFeature vs TransformFeature

mikeluz paweluz at o2.pl
Wed Oct 31 08:28:22 PDT 2012

Hi everyone

I want to create a combination of transformFeature anf ModifyFeature. I am
thinking about extending one of those classes... My functionality should
work like that:
- user draws regular polygon (4 sides - actually rectangle, option
irregular=true in modifyFeature example page in here:
http://www.openlayers.org/dev/examples/modify-feature.html )
- user can edit rectangle that he draws. Editing should look like that:
 - drag handler in the middle of rectangle
 - rotation handler is in bottom right corner. But not exactly in there, a
bit in right and a bit down (so it does not cover edit node)
 - 8 edit/resize vertex - in each corners, and in the middle of each sides
of the rectangle.
 - creating additional vertex is not allowed - so actually this is just
resize functionality. But I want it to be allowed from each corner, and each
middle of side of the rectangle.

 I think I can not use transformControl because:
 - drag is allowed in any place of rectangle (you can just simply drag it)
 - rotation handler is sicked to its place (I want to be always in the
bottom-right of bounds)
 - the worst thing. If the rectangle is already rotated, and I select it to
transfrom, the transform box is like a bounds of the rectangle. so it is
always at the beginning a box without any rotation.
... ro maybe I am wrong.

I have decided to go on with modifyFeature. I have drag handler, rotate
handler in correct places. Now problem is with this resizing. If I choose
RESIZE option the I can resize rectangle just from one corner. If I choose
RESHAPE I got all my vertex but I am actually editing the sides, vertex....
and I want to resize them, so at the end it is always a regular rectangle (4
* 90 angles). 

1. I find it strange that Modify and Transform inherits from
OpenLayers.Control. Their functionality is really similar. Maybe one should
inherid from the other. They both actually allow to: modify, rotate and drag
2. I think modify feature should have an option that allow to: edit vertex
or resize them (for geometries that are actually drew with

Thanks in advance for any help!


View this message in context: http://osgeo-org.1560.n6.nabble.com/How-to-modify-regular-polygon-ModifyFeature-vs-TransformFeature-tp5012585.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.

More information about the Dev mailing list