<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> </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>> Hi,<BR>> I'm using the OpenLayers.Control.Measure control.<BR>> From the many examples found, the handler declaration can either be :<BR>> 1) function handleMeasr(geometry, length, area, units) {}<BR>> 2) function handleMeasr(event) {}<BR>> Since I need the area & the perimeter, the first one should be the one<BR>> to use. BUT, it's not working : I get a "length is undefined" error<BR>> when I try to access the length value (or the area) with that definition.<BR>> On the other hand, if I use the second declaration, the<BR>> "event.measure.toFixed(3)" works fine but I can't get the area (there<BR>> is no event.area.xxx) ...<BR>> Anything special to do to make sure the first declaration gets called<BR>> so I can get the area ?<BR>> Thanks a lot.<BR>> *________________________________________________________________________*<BR>> *James Léveillé<BR>> DMR, une division de Fujitsu Conseil (Canada) inc.*<BR>> Bureau : 418.653.6882 #6911<BR>> Cellulaire : 418.265.5005<BR>> James_Leveille@dmr.ca <<A href="mailto:James_Leveille@dmr.ca">mailto:James_Leveille@dmr.ca</A>><BR>> Ce courriel et ses pièces jointes peuvent contenir des renseignements<BR>> confidentiels ouprivilégiés à l’intention du destinataire seulement.<BR>> Toute revue, utilisation, distribution ou divulgation de ces<BR>> renseignements par d’autres personnes est strictement interdite. Si<BR>> vous n’êtes pas le destinataire de ce courriel, ou si vous n’êtes pas<BR>> autorisé à recevoir ce courriel en son nom, vous n’avez pas le droit<BR>> de l’examiner, de le copier ou de le distribuer. Veuillez communiquer<BR>> avec l’expéditeur en lui répondant et supprimez toutes les copies de<BR>> son message.<BR>> P *Devez-vous vraiment imprimer ce courriel ? Pensons à l'environnement !*<BR>> ------------------------------------------------------------------------<BR>><BR>> _______________________________________________<BR>> Users mailing list<BR>> Users@openlayers.org<BR>> <A href="http://openlayers.org/mailman/listinfo/users">http://openlayers.org/mailman/listinfo/users</A><BR>> <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>