[OpenLayers-Users] How to draw a BoundingBox Vector feature?

Heidt, Christopher M. CHRISTOPHER.M.HEIDT at saic.com
Mon Nov 17 11:37:49 EST 2008


I need a way to allow the user to draw a bounding box on the map but
there doesnt seem to be a builtin way of doing this.
polygon and regularPolygon are no good because you cant force them to be
straight.
 
I'm attempting to use the Box Handler to allow the user to draw a
bounding box on the map. (code below)
The problem im having is that the feature that ends up being created is
suppose to be a polygon with the same bounds produced by the box, 
but what i end up with is an extreamly tiny polygon at 0,0. 
I'm using a google base so i thought maybe the projection was the
culprit, 
but i've tried transforming the bounds and nothing good seems to come
from it. 
Any ideas? 
 
var control = new OpenLayers.Control({
    draw: function () {
        this.box = new OpenLayers.Handler.Box( control,
            {done: this.notice},
            {keyMask: OpenLayers.Handler.MOD_SHIFT});
        this.box.activate();
    },
    notice: function (bounds){
        var geom = bounds.toGeometry();
        var feature = new OpenLayers.Feature.Vector(geom);
        _bboxLayer.addFeatures(feature);
        _map.zoomToExtent(bounds,true);
    }
});
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20081117/21e16644/attachment.html


More information about the Users mailing list