[OpenLayers-Dev] Question: Vector layer with draw & modify feature

Moiz Bhukhiya moiz.bhukhiya at gmail.com
Wed Sep 15 15:11:25 EDT 2010


Thank you so much Alexandre for your response. You are absolutely right, it
is working now as it should. But I have one more question. Is there a way to
resize it from all four corners, I don't need to keep the aspect ratio. I
would like to resize the box like a cropping tool(
http://odyniec.net/projects/imgareaselect/ ). I am also having another
problem. When I assign {displayClass: "olControlDrawFeaturePoint"} to
modifyFeature, it doesn't give strictly horizontally aligned rectangles. I
can draw rectangles in that case but they form an angle.

I'd really appreciate any of your help.

Thanks,
Moiz
On Wed, Sep 15, 2010 at 7:24 AM, Alexandre Dube <adube at mapgears.com> wrote:

>  Hi Moiz,
>
>   The constructor of the control only takes 2 parameters [1] and you give
> it 3.  This might be why it doesn't work.
>
> Regards,
>
> Alexandre
>
>
> [1]
> http://dev.openlayers.org/releases/OpenLayers-2.10/doc/apidocs/files/OpenLayers/Control/ModifyFeature-js.html#OpenLayers.Control.ModifyFeature.OpenLayers.Control.ModifyFeature
>
>
> On 10-09-15 05:32 AM, Moiz Bhukhiya wrote:
>
> Hi,
>
> I am using vector (polygon) layer with draw feature and modify feature. Let
> me explain first what I am trying to achieve. I want to draw
> rectangles(strict horizontally aligned) and after drawing it might require a
> little bit of modification but again it shouldn't lose its shape.
>
> Here is what I tried doing:
>
> polygonLayer = new OpenLayers.Layer.Vector("Capture Region",
> {displayInLayerSwitcher: true, reproject: true});
>         polyOptions = {sides: 4, snapAngle: 180, irregular: true}; //To
> draw only rectangles
>         var pan = new OpenLayers.Control.Navigation({title: "Navigate"})
>         polygonControl = new OpenLayers.Control.DrawFeature(polygonLayer,
> OpenLayers.Handler.RegularPolygon,
>             {handlerOptions: polyOptions});
>         modify = new OpenLayers.Control.ModifyFeature(
>                 polygonLayer, {displayClass: "olControlModifyFeature",
> title: "Modify Features"},
>                 {mode: ~OpenLayers.Control.ModifyFeature.RESHAPE |
> OpenLayers.Control.ModifyFeature.RESIZE
>                 | OpenLayers.Control.ModifyFeature.DRAG }
>             );
>         var panel = new OpenLayers.Control.Panel({
>              displayClass: "olControlEditingToolbar"
>         });
>         panel.addControls([pan, polygonControl, modify]);
>         map.addControl(panel);
>
> The problem is it doesn't follow the modify feature modes I have defined.
> It allows reshaping and doesn't allow dragging and resizing. Another problem
> I have is when I define the displayClass for draw feature, it wouldn't let
> me draw rectangles that are horizontally aligned. To point your attention
> towards where I might be making a mistake, I am using
> OpenLayers.Handler.RegularPolygon to draw feature. Is that a problem?
>
> Thanks a lot for taking time to read my problem and I'd really appreciate
> if you could help me with any suggestions and ideas.
>
> Thanks!
> Moiz
>
>
> _______________________________________________
> Dev mailing listDev at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/openlayers-dev
>
>
>
> --
> Alexandre Dubé
> Mapgearswww.mapgears.com
>
>
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20100915/f437e755/attachment.html


More information about the Dev mailing list