Thanks Toby for your quick answer.  <div><br></div><div>obviously, I really have to do it on the mouse move (because I force the user to draw a regular polygon with only 4 sides by clicking and then dragging).  </div><div>
<br></div><div>I never wrote a custom listener in OL, do you have examples or links?</div><div><div><br></div><div>MartinO<br><br><div class="gmail_quote">On Tue, Nov 22, 2011 at 11:03 AM, Toby Reinicke <span dir="ltr">&lt;<a href="mailto:ramotswa@gmail.com">ramotswa@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Martin.<br>
Have a look at <a href="http://openlayers.org/dev/examples/measure.html" target="_blank">http://openlayers.org/dev/examples/measure.html</a> and look at the immediate option. It&#39;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,<br>

Toby<br>
<div><div class="h5"><br>
On 22 Nov 2011, at 15:51, Martin Ouellet &lt;<a href="mailto:geomartino@gmail.com">geomartino@gmail.com</a>&gt; wrote:<br>
<br>
&gt; Hi all,<br>
&gt;<br>
&gt; Currently I used this piece of code to allow the user to draw a region of interest on the map:<br>
&gt;<br>
&gt; drawControls = new OpenLayers.Control();<br>
&gt;  OpenLayers.Util.extend(drawControls, {<br>
&gt;           draw: function() {<br>
&gt;               this.box = new OpenLayers.Handler.RegularPolygon(drawControls,<br>
&gt;               {&quot;done&quot;: this.notice}, {sides:4, irregular:true, persist:true});<br>
&gt;             },<br>
&gt;            notice: function(geom) {<br>
&gt;             // whatever you want it to do after the box has been drawn<br>
&gt;             var feature = new OpenLayers.Feature.Vector(geom);<br>
&gt;             layer_zone_extraction.addFeatures(feature);<br>
&gt;             //afficher la superficie de la zone dessiné<br>
&gt;             var bounds = getExtractBounds();<br>
&gt;             var ll = new OpenLayers.LonLat(bounds.left, bounds.bottom);<br>
&gt;             var ur = new OpenLayers.LonLat(bounds.right, bounds.top);<br>
&gt;             var superficieKm = Math.abs(((bounds.left-bounds.right)/1000)*((bounds.top-bounds.bottom)/1000));<br>
&gt;             $(&#39;#message&#39;).jGrowl(superficieKm.toFixed(2) + &quot; km²&quot;);<br>
&gt;            }<br>
&gt;         });<br>
&gt;<br>
&gt; Is it&#39;s possible to display the area value on-the-fly while the user draw it instead of after he finished?<br>
&gt;<br>
&gt; Thanks you in advance!<br>
&gt;<br>
&gt; MartinO<br>
</div></div>&gt; _______________________________________________<br>
&gt; Users mailing list<br>
&gt; <a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>
&gt; <a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
</blockquote></div><br></div></div>