I'm trying to draw a box on a map, have it persist until another box gets drawn, and submit the coordinates of the box to a form. I'm doing this to allow the user to search for objects within a given area.
I'm doing this by using an OpenLayers.Handler.Box tool in a custom OpenLayers.Control, which then uses to the "done" callback of the draw method to create (or recreate) an OpenLayers.Feature.Vector and populate (or repopulate) a search form. My immediate problem is that the persistent box is not in quite the same location as the box the user just drew. I suspect this has something to do with projections, but since I never explicitly set projections, I'm not sure where the error sneaked in. More generally, I'm not sure I'm taking the optimal route from the bounds passed to the callback to the Vector feature. Currently, I do the following: 1) Take the incoming OpenLayers.Bounds object, 2) Get an OpenLayers.Pixel from the the corners 3) Get the coordinates of each pixel using map.getLonLatFromPixel 4) Create a new OpenLayers.Bounds 5) Extend it to my new coordinates 6) Convert it to a geometry 7) Convert it to an OpenLayers.Feature.Vector Then I take the coordinates from step 3) and populate a form with them, which I then submit to my application server side. The code for this is pasted here: http://pastebin.com/m300c24a5 Any pointers on how to do this more cleanly would be much appreciated. Cheers, Cliff _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
