I thought I had figured this out.  All I needed to do was to create a 
DrawFeature control, passing to its constructor the layer I wanted the box 
features added to, and a Box handler.

Unfortunately, this doesn't work.  Handler.Box is very different in structure 
and behavior than Handler.Point and Handler.Polygon.   I get an error in 
Renderer.drawFeature().

If I use Handler.Polygon, Renderer.drawFeature() is passed a feature whose 
feature.geometry is a Geometry.Polygon, and feature.geometry.getBounds() is 
defined.

If I use Handler.Box, Renderer.drawFeature() is passed a feature whose 
feature.geometry is a OpenLayers.Bounds, and feature.geometry.getBounds() is 
undefined.

It seems odd, to me, that the Point, Line, and Polygon handlers behave one way, 
and the Box handler behaves another.

Still, I feel like I'm making progress.

Anyone have any ideas on how to most easily modify or extend Handler.Box to 
return a Geometry, instead of a Bounds?

From: [email protected] 
[mailto:[email protected]] On Behalf Of Jeff Dege
Sent: Thursday, September 23, 2010 5:25 PM
To: [email protected]
Subject: [OpenLayers-Users] Simple draw-box control?

I need a control for drawing simple boxes on a vector layer.

It needs to sit in a Panel.
It needs to activate when clicked, and deactivate when any other control in the 
panel is clicked.

When it's active, it should record the location of a mousedown on the map, and 
the next mouseup, and fire an event to a listener, passing the coordinates of 
the two locations (perhaps as a Bounds object).

Seems simple enough, but I'm not sure where to start.   The examples I have 
found are far more complicated than I need.


_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to