Creating a Box Control over an area of the map with OpenLayers

Posted by Bernie Perez on Stack Overflow See other posts from Stack Overflow or by Bernie Perez
Published on 2009-05-01T22:48:36Z Indexed on 2010/05/01 12:07 UTC
Read the original article Hit count: 353

Filed under:
|
|

I am using OpenLayers to create a box of interest with my program. I am using this code:

var control = new OpenLayers.Control();
OpenLayers.Util.extend(control, {
    draw: function () {
        this.box = new OpenLayers.Handler.Box( control,
            {"done": this.notice},
            {keyMask: OpenLayers.Handler.MOD_SHIFT});
        this.box.activate();
    },
    notice: function (bounds) {
        areaSelected(bounds);
    }
});
map.addControl(control);

to capture the "Shift Create a Box" control and use the area selected as my area of interest. However the values come back as pixels. But I want Longitude and Latitude, not pixels. The Mouse Position control does show the correct long & lat. I really don't care how to box is created, I just want an easy way for the user to select a area of the map and I need to get the lat & longs of the area. (Box, Circle, doesn't matter)

© Stack Overflow or respective owner

Related posts about openlayers

Related posts about map