Hi all,

Currently I used this piece of code to allow the user to draw a region of
interest on the map:

drawControls = new OpenLayers.Control();
 OpenLayers.Util.extend(drawControls, {
          draw: function() {
              this.box = new OpenLayers.Handler.RegularPolygon(drawControls,
              {"done": this.notice}, {sides:4, irregular:true,
persist:true});
            },
           notice: function(geom) {
            // whatever you want it to do after the box has been drawn
            var feature = new OpenLayers.Feature.Vector(geom);
            layer_zone_extraction.addFeatures(feature);
            //afficher la superficie de la zone dessiné
            var bounds = getExtractBounds();
            var ll = new OpenLayers.LonLat(bounds.left, bounds.bottom);
            var ur = new OpenLayers.LonLat(bounds.right, bounds.top);
            var superficieKm =
Math.abs(((bounds.left-bounds.right)/1000)*((bounds.top-bounds.bottom)/1000));
            $('#message').jGrowl(superficieKm.toFixed(2) + " km²");
           }
        });

Is it's possible to display the area value on-the-fly while the user draw
it instead of after he finished?

Thanks you in advance!

MartinO
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to