[OpenLayers-Users] Rectangle (box-like) drawing tool?

Christopher Schmidt crschmidt at metacarta.com
Wed Apr 4 15:50:26 EDT 2007


On Wed, Apr 04, 2007 at 12:46:36PM -0700, Mike Quentel wrote:
> Has anyone implemented a rectangle drawing tool?  As in something that draws polygons like the sandbox examples, but restricts mouse movements so that only rectangles are drawn?  I see there is an OpenLayers.Handler.Box class and an OpenLayers.Handler.Polygon class.  I want to have a rectangle drawing tool, so I'm thinking I'd want to inherit from Polygon and/or Box.  Has anyone already implemented such a class?  Would be nice to not "re-invent the wheel".  I searched the API and the Nabble archives (thank you so much for this very useful resource).  Any advice on how to make a rectangle drawing tool appreciated.  Thank you.

Handler.Box will allow you to draw a div (like the zoombox does):

http://openlayers.org/dev/examples/custom-control.html

Hold shift and drag.

Right now, it doesn't stick. You could take the points from the
Handler.Box (in a custom control) and cause it to create a vector
feature, or a Marker.Box, depending on what you're looking for.

I think that's the closest you'll get to what you're looking for --
beyond that you'll have to build on your own.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list