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