<HTML dir=ltr><HEAD><TITLE>Re: [OpenLayers-Users] measure control</TITLE>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.2900.5726" name=GENERATOR></HEAD>
<BODY>
<DIV id=idOWAReplyText52342 dir=ltr>
<DIV dir=ltr><FONT face=Verdana color=#000000 size=2>Great ! Thanks a lot Bart.</FONT></DIV>
<DIV dir=ltr><FONT face=Verdana color=#000000 size=2></FONT>&nbsp;</DIV></DIV>
<DIV id=idSignature51211 dir=ltr>
<DIV><FONT color=#000000 size=2><FONT face=Verdana><STRONG>________________________________________________________________________</STRONG></FONT></FONT></DIV>
<DIV><FONT color=#000000 size=2><FONT face=Verdana><STRONG>James Léveillé<BR>DMR, une division de Fujitsu Conseil (Canada) inc.</STRONG><BR></FONT></FONT><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>De:</B> Bart van den Eijnden (OSGIS) [mailto:bartvde@osgis.nl]<BR><B>Date:</B> mer. 25-02-09 12:53<BR><B>À:</B> James Leveille<BR><B>Cc:</B> users@openlayers.org<BR><B>Objet :</B> Re: [OpenLayers-Users] measure control<BR></FONT><BR></DIV></DIV>
<DIV>
<P><FONT size=2>Hi James,<BR><BR>the first syntax is OL 2.6, the second is OL 2.7.<BR><BR>I assume you are using a Polygon handler and want to retrieve both the<BR>area and the length?<BR><BR>The event thrown by the Measure control only contains the area in the<BR>evt.measure property in this case, so you have to calculate the length<BR>using something like (untested):<BR><BR>var a = map.getControlsByClass('OpenLayers.Control.Measure');<BR>var ctrl = a[0];<BR>var length = ctrl.getBestLength(evt.geometry)[0];<BR><BR>Hope this helps.<BR><BR>Best regards,<BR>Bart<BR><BR>James Leveille wrote:<BR>&gt; Hi,<BR>&gt; I'm using the OpenLayers.Control.Measure control.<BR>&gt; From the many examples found, the handler declaration can either be :<BR>&gt; 1) function handleMeasr(geometry, length, area, units) {}<BR>&gt; 2) function handleMeasr(event) {}<BR>&gt; Since I need the area &amp; the perimeter, the first one should be the one<BR>&gt; to use. BUT, it's not working : I get a "length is undefined" error<BR>&gt; when I try to access the length value (or the area) with that definition.<BR>&gt; On the other hand, if I use the second declaration, the<BR>&gt; "event.measure.toFixed(3)" works fine but I can't get the area (there<BR>&gt; is no event.area.xxx) ...<BR>&gt; Anything special to do to make sure the first declaration gets called<BR>&gt; so I can get the area ?<BR>&gt; Thanks a lot.<BR>&gt; *________________________________________________________________________*<BR>&gt; *James Léveillé<BR>&gt; DMR, une division de Fujitsu Conseil (Canada) inc.*<BR>&gt; Bureau : 418.653.6882 #6911<BR>&gt; Cellulaire : 418.265.5005<BR>&gt; James_Leveille@dmr.ca &lt;<A href="mailto:James_Leveille@dmr.ca">mailto:James_Leveille@dmr.ca</A>&gt;<BR>&gt; Ce courriel et ses pièces jointes peuvent contenir des renseignements<BR>&gt; confidentiels ouprivilégiés à l&#8217;intention du destinataire seulement.<BR>&gt; Toute revue, utilisation, distribution ou divulgation de ces<BR>&gt; renseignements par d&#8217;autres personnes est strictement interdite. Si<BR>&gt; vous n&#8217;êtes pas le destinataire de ce courriel, ou si vous n&#8217;êtes pas<BR>&gt; autorisé à recevoir ce courriel en son nom, vous n&#8217;avez pas le droit<BR>&gt; de l&#8217;examiner, de le copier ou de le distribuer. Veuillez communiquer<BR>&gt; avec l&#8217;expéditeur en lui répondant et supprimez toutes les copies de<BR>&gt; son message.<BR>&gt; P *Devez-vous vraiment imprimer ce courriel ? Pensons à l'environnement !*<BR>&gt; ------------------------------------------------------------------------<BR>&gt;<BR>&gt; _______________________________________________<BR>&gt; Users mailing list<BR>&gt; Users@openlayers.org<BR>&gt; <A href="http://openlayers.org/mailman/listinfo/users">http://openlayers.org/mailman/listinfo/users</A><BR>&gt;&nbsp;&nbsp;<BR><BR><BR>--<BR>Bart van den Eijnden<BR>OSGIS, Open Source GIS<BR>bartvde@osgis.nl<BR><A href="http://www.osgis.nl/">http://www.osgis.nl</A><BR><BR></FONT></P></DIV></BODY></HTML>