Hi Martin. Have a look at http://openlayers.org/dev/examples/measure.html and look at the immediate option. It'll work on each click, doing it on mouse move youd have to write a mouse move listener into the draw tool and do appropriate stuff there, Toby
On 22 Nov 2011, at 15:51, Martin Ouellet <[email protected]> wrote: > 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 _______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
