fisrt of all thanks to Matti Tahvonen for this great add-on! I’m new of this add-on, and I have the following problem.
I’d like to allow the user to draw a rectangular region (a “bounding box”
) over the map; then I need to get the box bounds in order to retrieve the correspondent coordinates in lat/lon.
As far a I know, something like this is possible by default with Openlayers by clicking the “shift” key and dragging the mouse; this is exactly what I need, but when the mouse button is released, then a “zoom in” is performed. Is there a way to change this behaviour in order to avoid the zoom? And if it’s possible, how should I get the box bounds?
Maybe a better way should be to use a VectorLayer added to the map because in this way should be very easy to get the drawed vector bound (and to delete or modify the vector). Unfortunately the available DrawingMode (AREA,LINE,POINT,NONE,MODIFIED) does not allow to draw a rectangular vector.
You’d need “Box” handler for the vector drawing as you guessed. Please fill a ticket about this feature to the project page. Feel free to implement it by yourself or try to lob the task for somebody else. I’d guess this this will be implemented soon (simple task and rather good value).
In the mean time (if your app is not in production) you could just use simple line drawing instead. There wouldn’t be visual hints about the final area, but drawing a simple line is basically the same action as drawing a rectangle. You would just get two points on the server side instead of four points where every other coordinate is duplicated.
Thank you very much for your quick response!
I’ve added a new ticket in the project page with this email sghibbione@gmail.com and title “Drawing rectangular region”; it’s not a defect but I didn’t find the way to change the issue type. In the mean time I’m using a solution very similar to the one you’re proposing; I’m using two points, the first as as anchor point and the second causes the creation of the resulting Area.