views:

624

answers:

1

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)

A: 

Check out: http://garmin.na1400.info/routable.php

It has a checkbox to set "Enable tile selection" set it.

Now when you drag a box on the map, it will select the underlying objects.

You can reuse the sourcecode. All the magic is in: http://garmin.na1400.info/routable.js

milovanderlinden